Orbitales Atomiques - Visualisation par nuages de points

De Physix.

Il s'agit ici de visualiser des orbitales atomiques simples modélisées sous forme d'un nuage de points. La distribution des points suit la densité de probabilité associée à la fonction d'onde de l'orbitale atomique considérée. Le code correspondant est publié avec chacune des orbitales.


Sommaire

Visualisation de quelques orbitales

Orbitale 1sAlgoMethodeRejet.jpg Orbitale 2sAlgoMethodeRejet.jpg

Orbitale 2pxAlgoMethodeRejet.jpg Orbitale 3pxAlgoMethodeRejet.jpg

Orbitale 3dxyAlgoMethodeRejet.jpg Orbitale 3dx²AlgoMethodeRejet.jpg

Code Orbitale 1s

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. /**
  5.  * simulation of a 1s orbital with the Rejection Sampling Method
  6.  * 
  7.  * @author Cécile POT
  8.  * @version PhysiX - January 2009
  9.  */
  10.  
  11. public class Orbitale_1s extends Applet {
  12.     static final long serialVersionUID = 1L;
  13.  
  14.     int n = 50000;	// number of points
  15.  
  16.     Point tab[];	// array of points
  17.  
  18.     // --------------------------------------------------
  19.     // wave function
  20.     double f(double r, double theta) {
  21. 	return 1. / Math.sqrt(Math.PI) * Math.exp(-r);
  22.     }
  23.  
  24.     // --------------------------------------------------
  25.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  26.     double g(double x, double y) {
  27. 	return 1. / 25;
  28.     }
  29.  
  30.     // f(x)<=a*g(x)
  31.     double a = 25. * d(0, 1 / 2.);
  32.  
  33.     // probability density function associated with f
  34.     double d(double x, double y) {
  35. 	double r = Math.sqrt(x * x + y * y);
  36. 	double theta = Math.atan2(y, x);
  37. 	return r * f(r, theta) * f(r, theta);
  38.     }
  39.  
  40.     // --------------------------------------------------
  41.     // The applet is initialised
  42.     public void init() {
  43. 	// resizing
  44. 	this.setSize(500, 500);
  45. 	// array is initialised
  46. 	tab = new Point[n];
  47. 	// array is filled with n samplings
  48. 	int k = 0;
  49. 	while (k < n) {
  50. 	    double x, y, U;
  51. 	    //  x is sampled from the g-distribution
  52. 	    x = 10. * Math.random() - 5.;
  53. 	    y = 10. * Math.random() - 5.;
  54. 	    // uniform variable is simulated
  55. 	    U = Math.random();
  56. 	    // acceptance or rejection
  57. 	    if (d(x, y) > U * a * g(x, y)) {
  58. 		tab[k] = new Point(x, y);
  59. 		k++;
  60. 	    }
  61. 	}
  62.     } // init()
  63.  
  64.     // --------------------------------------------------
  65.     public void start() {
  66.     } // start()
  67.  
  68.     // --------------------------------------------------
  69.     // The applet is displayed
  70.     public void paint(Graphics g) {
  71. 	int k;
  72. 	for (k = 0; k < n; k++) {
  73. 	    int x, y;
  74. 	    x = (int) (50. * (5. + tab[k].x));
  75. 	    y = (int) (50. * (5. - tab[k].y));
  76. 	    g.drawLine(x, y, x, y);
  77. 	}
  78. 	g.setColor(Color.BLACK);
  79.     } // paint()
  80.  
  81.     // --------------------------------------------------
  82. } // class Orbitale_1s

Code Orbitale 2s

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. /**
  5.  * simulation of a 2s Orbital with the Rejection Sampling Method
  6.  * 
  7.  * @author Cécile POT
  8.  * @version PhysiX - January 2009
  9.  */
  10.  
  11. public class Orbitale_2s extends Applet {
  12.     static final long serialVersionUID = 1L;
  13.  
  14.     int n = 100000;	// number of points
  15.  
  16.     Point tab[];	// array of points
  17.  
  18.     // --------------------------------------------------
  19.     // wave function
  20.     public double f(double x, double y) {
  21. 	double r = Math.sqrt(x * x + y * y);
  22. 	double theta = Math.atan2(y, x);
  23. 	return 2. / Math.sqrt(3 * Math.PI) * (2 - r) * Math.exp(-r);
  24.     }
  25.  
  26.     // --------------------------------------------------
  27.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  28.     double g(double x, double y) {
  29. 	return 1. / 25;
  30.     }
  31.  
  32.     // f(x)<=a*g(x)
  33.     double a = 25. * 0.5;
  34.  
  35.     // probability density function associated with f
  36.     double d(double x, double y) {
  37. 	double r = Math.sqrt(x * x + y * y);
  38. 	return r * f(x, y) * f(x, y);
  39.     }
  40.  
  41.     // --------------------------------------------------
  42.     // The applet is initialised
  43.     public void init() {
  44. 	// resizing
  45. 	this.setSize(500, 500);
  46. 	// array is initialised
  47. 	tab = new Point[n];
  48. 	// array is filled with n samplings
  49. 	int k = 0;
  50. 	while (k < n) {
  51. 	    double x, y, U;
  52. 	    // x is sampled from the g-distribution
  53. 	    x = 10. * Math.random() - 5.;
  54. 	    y = 10. * Math.random() - 5.;
  55. 	    // uniform variable is simulated
  56. 	    U = Math.random();
  57. 	    // acceptance or rejection
  58. 	    if (d(x, y) > U * a * g(x, y)) {
  59. 		tab[k] = new Point(x, y);
  60. 		k++;
  61. 	    }
  62. 	}
  63.     } // init()
  64.  
  65.     // --------------------------------------------------
  66.     public void start() {
  67.     } // start()
  68.  
  69.     // --------------------------------------------------
  70.     // The applet is displayed
  71.     public void paint(Graphics g) {
  72. 	int k;
  73. 	for (k = 0; k < n; k++) {
  74. 	    int x, y;
  75. 	    x = (int) (50. * (5. + tab[k].x));
  76. 	    y = (int) (50. * (5. - tab[k].y));
  77. 	    // f(x)<0 in blue and f(x)>0 in red
  78. 	    g.setColor(f(tab[k].x, tab[k].y) >= 0. ? Color.RED : Color.BLUE);
  79. 	    g.drawLine(x, y, x, y);
  80. 	}
  81. 	g.setColor(Color.BLACK);
  82.     } // paint()
  83.  
  84.     // --------------------------------------------------
  85. } // class Orbitale_2s
  86.  
  87.  
  88.  
  89. <source lang="java" line="1">
  90.  
  91. import java.awt.*;
  92. import java.applet.*;
  93.  
  94. /**
  95.  * simulation of a 2px Orbital with the Rejection Sampling Method
  96.  * 
  97.  * @author Cécile POT
  98.  * @version PhysiX - January 2009
  99.  */
  100.  
  101. public class Orbitale_2px extends Applet {
  102.  
  103.     static final long serialVersionUID = 1L;
  104.  
  105.     int n = 100000;	// number of points
  106.  
  107.     Point tab[];	// array of points
  108.  
  109.     // --------------------------------------------------
  110.     // wave function
  111.     public double f(double x, double y) {
  112. 	double r = Math.sqrt(x * x + y * y);
  113. 	double theta = Math.atan2(y, x);
  114. 	return  x * Math.exp(-3*r/2);
  115.     }
  116.  
  117.     // --------------------------------------------------
  118.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  119.     double g(double x, double y) {
  120. 	return 1. / 25;
  121.     }
  122.  
  123.     // f(x)<=a*g(x)
  124.     double a = 5;
  125.  
  126.     // probability density function associated with f
  127.     double d(double x, double y) {
  128. 	double r = Math.sqrt(x * x + y * y);
  129. 	return r * f(x, y) * f(x, y);
  130.     }
  131.  
  132.     // --------------------------------------------------
  133.     // The applet is initialised
  134.     public void init() {
  135. 	// resizing
  136. 	this.setSize(500, 500);
  137. 	// array is initialised
  138. 	tab = new Point[n];
  139. 	// array is filled with n samplings
  140. 	int k = 0;
  141. 	while (k < n) {
  142. 	    double x, y, U;
  143. 	    // x is sampled from the g-distribution
  144. 	    x = 10. * Math.random() - 5.;
  145. 	    y = 10. * Math.random() - 5.;
  146. 	    // uniform variable is simulated
  147. 	    U = Math.random();
  148. 	    // acceptance or rejection
  149. 	    if (d(x, y) > U * a * g(x, y)) {
  150. 		tab[k] = new Point(x, y);
  151. 		k++;
  152. 		System.out.println(k);
  153. 	    }
  154. 	}
  155.     } // init()
  156.  
  157.     // --------------------------------------------------
  158.     public void start() {
  159.     } // start()
  160.  
  161.     // --------------------------------------------------
  162.     // The applet is displayed
  163.     public void paint(Graphics g) {
  164. 	int k;
  165. 	for (k = 0; k < n; k++) {
  166. 	    int x, y;
  167. 	    x = (int) (50. * (5. + tab[k].x));
  168. 	    y = (int) (50. * (5. - tab[k].y));
  169. 	    // f(x)<0 in blue and f(x)>0 in red
  170. 	    g.setColor(f(tab[k].x, tab[k].y) >= 0. ? Color.RED : Color.BLUE);
  171. 	    g.drawLine(x, y, x, y);
  172. 	}
  173. 	g.setColor(Color.BLACK);
  174.     } // paint()
  175.  
  176.     // --------------------------------------------------
  177. } // class Orbitale_2px

Code Orbitale 3px

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. /**
  5.  * simulation of a 3px Orbital with the Rejection Sampling Method
  6.  * 
  7.  * @author Cécile POT
  8.  * @version PhysiX - January 2009
  9.  */
  10.  
  11. public class Orbitale_3dxy extends Applet {
  12.  
  13.     static final long serialVersionUID = 1L;
  14.  
  15.     int n = 100000;	// number of points
  16.  
  17.     Point tab[];	// array of points
  18.  
  19.     // --------------------------------------------------
  20.     // wave function
  21.     public double f(double x, double y) {
  22. 	double r = Math.sqrt(x * x + y * y);
  23. 	double theta = Math.atan2(y, x);
  24. 	return  x * r * (1-r) * Math.exp(-3*r/2);
  25.     }
  26.  
  27.     // --------------------------------------------------
  28.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  29.     double g(double x, double y) {
  30. 	return 1. / 25;
  31.     }
  32.  
  33.     // f(x)<=a*g(x)
  34.     double a = 5;
  35.  
  36.     // probability density function associated with f
  37.     double d(double x, double y) {
  38. 	double r = Math.sqrt(x * x + y * y);
  39. 	return r * f(x, y) * f(x, y);
  40.     }
  41.  
  42.     // --------------------------------------------------
  43.     // The applet is initialised
  44.     public void init() {
  45. 	// resizing
  46. 	this.setSize(500, 500);
  47. 	// array is initialised
  48. 	tab = new Point[n];
  49. 	// array is filled with n samplings
  50. 	int k = 0;
  51. 	while (k < n) {
  52. 	    double x, y, U;
  53. 	    // x is sampled from the g-distribution
  54. 	    x = 10. * Math.random() - 5.;
  55. 	    y = 10. * Math.random() - 5.;
  56. 	    // a uniform variable is simulated
  57. 	    U = Math.random();
  58. 	    // acceptance or rejection
  59. 	    if (d(x, y) > U * a * g(x, y)) {
  60. 		tab[k] = new Point(x, y);
  61. 		k++;
  62. 	    }
  63. 	}
  64.     } // init()
  65.  
  66.     // --------------------------------------------------
  67.     public void start() {
  68.     } // start()
  69.  
  70.     // --------------------------------------------------
  71.     // The applet is displayed
  72.     public void paint(Graphics g) {
  73. 	int k;
  74. 	for (k = 0; k < n; k++) {
  75. 	    int x, y;
  76. 	    x = (int) (50. * (5. + tab[k].x));
  77. 	    y = (int) (50. * (5. - tab[k].y));
  78. 	    // f(x)<0 in blue and f(x)>0 in red
  79. 	    g.setColor(f(tab[k].x, tab[k].y) >= 0. ? Color.RED : Color.BLUE);
  80. 	    g.drawLine(x, y, x, y);
  81. 	}
  82. 	g.setColor(Color.BLACK);
  83.     } // paint()
  84.  
  85.     // --------------------------------------------------
  86. } // class Orbitale_3dxy
  87.  
  88.  
  89. public class Orbitale_3dxy {
  90.  
  91. }

Code Orbitale 3dxy

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. /**
  5.  * simulation of a 3dxy Orbital with the Rejection Sampling Method
  6.  * 
  7.  * @author Cécile POT
  8.  * @version PhysiX - January 2009
  9.  */
  10.  
  11. public class Orbitale_3dxy extends Applet {
  12.  
  13.     static final long serialVersionUID = 1L;
  14.  
  15.     int n = 100000;	// number of points
  16.  
  17.     Point tab[];	// array of points
  18.  
  19.     // --------------------------------------------------
  20.     // wave function
  21.     public double f(double x, double y) {
  22. 	double r = Math.sqrt(x * x + y * y);
  23. 	double theta = Math.atan2(y, x);
  24. 	return  x * y * Math.exp(-3*r/2);
  25.     }
  26.  
  27.     // --------------------------------------------------
  28.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  29.     double g(double x, double y) {
  30. 	return 1. / 25;
  31.     }
  32.  
  33.     // f(x)<=a*g(x)
  34.     double a = 5;
  35.  
  36.     // probability density function associated with f
  37.     double d(double x, double y) {
  38. 	double r = Math.sqrt(x * x + y * y);
  39. 	return r * f(x, y) * f(x, y);
  40.     }
  41.  
  42.     // --------------------------------------------------
  43.     // The applet is initialised
  44.     public void init() {
  45. 	// resizing
  46. 	this.setSize(500, 500);
  47. 	// array is initialised
  48. 	tab = new Point[n];
  49. 	// array is filled with n samplings
  50. 	int k = 0;
  51. 	while (k < n) {
  52. 	    double x, y, U;
  53. 	    // x is sampled from the g-distribution
  54. 	    x = 10. * Math.random() - 5.;
  55. 	    y = 10. * Math.random() - 5.;
  56. 	    // a uniform variable is simulated
  57. 	    U = Math.random();
  58. 	    // acceptance or rejection
  59. 	    if (d(x, y) > U * a * g(x, y)) {
  60. 		tab[k] = new Point(x, y);
  61. 		k++;
  62. 	    }
  63. 	}
  64.     } // init()
  65.  
  66.     // --------------------------------------------------
  67.     public void start() {
  68.     } // start()
  69.  
  70.     // --------------------------------------------------
  71.     // The applet is displayed
  72.     public void paint(Graphics g) {
  73. 	int k;
  74. 	for (k = 0; k < n; k++) {
  75. 	    int x, y;
  76. 	    x = (int) (50. * (5. + tab[k].x));
  77. 	    y = (int) (50. * (5. - tab[k].y));
  78. 	    // f(x)<0 in blue and f(x)>0 in red
  79. 	    g.setColor(f(tab[k].x, tab[k].y) >= 0. ? Color.RED : Color.BLUE);
  80. 	    g.drawLine(x, y, x, y);
  81. 	}
  82. 	g.setColor(Color.BLACK);
  83.     } // paint()
  84.  
  85.     // --------------------------------------------------
  86. } // class Orbitale_3dxy

Code Orbitale 3dx²

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. /**
  5.  * simulation of a 3dx² Orbital with the Rejection Sampling Method
  6.  * 
  7.  * @author Cécile POT
  8.  * @version PhysiX - January 2009
  9.  */
  10.  
  11. public class Orbitale_3dx2 extends Applet {
  12.  
  13.     static final long serialVersionUID = 1L;
  14.  
  15.     int n = 100000;	// number of points
  16.  
  17.     Point tab[];	// array of points
  18.  
  19.     // --------------------------------------------------
  20.     // wave function
  21.     public double f(double x, double y) {
  22. 	double r = Math.sqrt(x * x + y * y);
  23. 	double theta = Math.atan2(y, x);
  24. 	return  (3*x*x - r*r) * Math.exp(-3*r/2);
  25.     }
  26.  
  27.     // --------------------------------------------------
  28.     // uniform probability distribution across the interval [-5,5] (easily simulated)
  29.     double g(double x, double y) {
  30. 	return 1. / 25;
  31.     }
  32.  
  33.     // f(x)<=a*g(x)
  34.     double a = 5;
  35.  
  36.     // probability density function associated with f
  37.     double d(double x, double y) {
  38. 	double r = Math.sqrt(x * x + y * y);
  39. 	return r * f(x, y) * f(x, y);
  40.     }
  41.  
  42.     // --------------------------------------------------
  43.     // The applet is initialised
  44.     public void init() {
  45. 	// resizing
  46. 	this.setSize(500, 500);
  47. 	// array is initialised
  48. 	tab = new Point[n];
  49. 	// array is filled with n samplings
  50. 	int k = 0;
  51. 	while (k < n) {
  52. 	    double x, y, U;
  53. 	    // x is sampled from the g-distribution
  54. 	    x = 10. * Math.random() - 5.;
  55. 	    y = 10. * Math.random() - 5.;
  56. 	    // a uniform variable is simulated
  57. 	    U = Math.random();
  58. 	    // acceptance or rejection
  59. 	    if (d(x, y) > U * a * g(x, y)) {
  60. 		tab[k] = new Point(x, y);
  61. 		k++;
  62. 	    }
  63. 	}
  64.     } // init()
  65.  
  66.     // --------------------------------------------------
  67.     public void start() {
  68.     } // start()
  69.  
  70.     // --------------------------------------------------
  71.     // The applet is displayed
  72.     public void paint(Graphics g) {
  73. 	int k;
  74. 	for (k = 0; k < n; k++) {
  75. 	    int x, y;
  76. 	    x = (int) (50. * (5. + tab[k].x));
  77. 	    y = (int) (50. * (5. - tab[k].y));
  78. 	    // f(x)<0 in blue and f(x)>0 in red
  79. 	    g.setColor(f(tab[k].x, tab[k].y) >= 0. ? Color.RED : Color.BLUE);
  80. 	    g.drawLine(x, y, x, y);
  81. 	}
  82. 	g.setColor(Color.BLACK);
  83.     } // paint()
  84.  
  85.     // --------------------------------------------------
  86. } // class Orbitale_3dx2


Voir aussi

Projet Orbitale

Orbitales Atomiques

Orbitales Atomiques - Visualisation par surfaces d'isodensité

Anglais Chinois
L'article que vous demandez n'existe pas en Chinois.
Outils personnels