@@ -16,12 +16,6 @@ simulation resemble the Monte Carlo move from :ref:`chapter6-label`:
1616- 4) We then decide to keep or reject the move by calculating
1717 the difference in energy between the trial and the initial configurations:
1818 :math: `\Delta E = E_\text {pot}^\text {trial} - E_\text {pot}^\text {initial}`.
19-
20- - If :math: `\Delta E < 0 `, then the move is automatically accepted.
21- - If :math: `\Delta E > 0 `, then the move is accepted with a probability given
22- by the Boltzmann factor :math: `\exp {- \beta \Delta E}`, where
23- :math: `\beta = 1 / k_\text {B} T` and :math: `T` is the imposed temperature.
24-
2519- 5) Steps 1-4 are repeated a large number of times, generating a broad range of
2620 possible configurations.
2721
@@ -38,7 +32,7 @@ Let us add the following method called *monte_carlo_exchange* to the *MonteCarlo
3832 # The first step is to make a copy of the previous state
3933 # Since atoms numbers are evolving, its also important to store the
4034 # neighbor, sigma, and epsilon lists
41- self .Epot = self .compute_potential()
35+ self .Epot = self .compute_potential() # TOFIX: not necessary every time
4236 initial_positions = copy.deepcopy(self .atoms_positions)
4337 initial_number_atoms = copy.deepcopy(self .number_atoms)
4438 initial_neighbor_lists = copy.deepcopy(self .neighbor_lists)
@@ -72,15 +66,15 @@ Let us add the following method called *monte_carlo_exchange* to the *MonteCarlo
7266 .. label :: end_MonteCarlo_class
7367
7468First, the potential energy is calculated, and the current state of the
75- simulations , such as positions and atom numbers, are saved. Then, an insertion
76- try or a deletion trial is made, each with a probability of 0.5. The
77- *monte_carlo_insert * and *monte_carlo_delete *, that are implemented here below,
78- are both calculting the *acceptation_probability *. A random number is again selected,
79- and if that number is larger than the acceptation probability, then the system
80- revert to its previous position. If the random number is lower than the acceptation
81- probability, nothing appends, which means that the last trial is accepted.
69+ simulation , such as positions and atom numbers, is saved. Then, an insertion
70+ trial or a deletion trial is made, each with a probability of 0.5. The
71+ *monte_carlo_insert * and *monte_carlo_delete * methods, which are implemented
72+ below, both calculate the *acceptance_probability *. A random number is selected,
73+ and if that number is larger than the acceptance probability, the system reverts
74+ to its previous position. If the random number is lower than the acceptance
75+ probability, nothing happens, meaning that the last trial is accepted.
8276
83- Then, let us write the *monte_carlo_insert * method:
77+ Then, let us write the *monte_carlo_insert() * method:
8478
8579.. label :: start_MonteCarlo_class
8680
@@ -96,7 +90,6 @@ Then, let us write the *monte_carlo_insert* method:
9690 self .atoms_positions = np.vstack([self .atoms_positions[:shift_id],
9791 new_atom_position,
9892 self .atoms_positions[shift_id:]])
99- self .total_number_atoms = np.sum(self .number_atoms)
10093 self .update_neighbor_lists()
10194 self .identify_atom_properties()
10295 self .update_cross_coefficients()
@@ -111,7 +104,10 @@ Then, let us write the *monte_carlo_insert* method:
111104
112105 .. label :: end_MonteCarlo_class
113106
114- as well as the *monte_carlo_delete * method:
107+ After trying to insert a new particle, neighbor lists and cross coefficients
108+ must be re-evaluated. Then, the acceptance probability is calculated.
109+
110+ Let us add the very similar *monte_carlo_delete() * method:
115111
116112.. label :: start_MonteCarlo_class
117113
@@ -192,7 +188,7 @@ Let us also normalised the "desired_mu":
192188
193189 .. label :: end_MonteCarlo_class
194190
195- Finally, the *monte_carlo_insert_delete () * method must be included in the run:
191+ Finally, the *monte_carlo_exchange () * method must be included in the run:
196192
197193.. label :: start_MonteCarlo_class
198194
@@ -207,7 +203,7 @@ Finally, the *monte_carlo_insert_delete()* method must be included in the run:
207203
208204 .. label :: end_MonteCarlo_class
209205
210- We need to calculate Lambda:
206+ We need to calculate :math: ` \ Lambda` :
211207
212208.. label :: start_MonteCarlo_class
213209
@@ -228,6 +224,7 @@ To output the density, let us add the following method to the *Measurements* cla
228224
229225 def calculate_density (self ):
230226 """ Calculate the mass density."""
227+ # TOFIX: not used yet
231228 volume = np.prod(self .box_size[:3 ]) # Unitless
232229 total_mass = np.sum(self .atoms_mass) # Unitless
233230 return total_mass/ volume # Unitless
@@ -237,8 +234,8 @@ To output the density, let us add the following method to the *Measurements* cla
237234Test the code
238235-------------
239236
240- One can use a similar test as previously. Let us use a displace distance of
241- 0.5 Angstrom, and make 1000 steps.
237+ One can use a similar test as previously, but with an imposed chemical
238+ potential * desired_mu *:
242239
243240.. label :: start_test_8a_class
244241
@@ -287,8 +284,10 @@ One can use a similar test as previously. Let us use a displace distance of
287284
288285 # Test function using pytest
289286 def test_output_files ():
290- assert os.path.exists(" Outputs/dump.mc.lammpstrj" ), " Test failed: dump file was not created"
291- assert os.path.exists(" Outputs/simulation.log" ), " Test failed: log file was not created"
287+ assert os.path.exists(" Outputs/dump.mc.lammpstrj" ), \
288+ " Test failed: dump file was not created"
289+ assert os.path.exists(" Outputs/simulation.log" ), \
290+ " Test failed: log file was not created"
292291 print (" Test passed" )
293292
294293 # If the script is run directly, execute the tests
@@ -300,5 +299,4 @@ One can use a similar test as previously. Let us use a displace distance of
300299 .. label :: end_test_8a_class
301300
302301The evolution of the potential energy as a function of the
303- number of steps are written in the *Outputs/Epot.dat * file
304- and can be plotted.
302+ number of steps are written in the *Outputs/Epot.dat *.
0 commit comments