Skip to content

Commit ce13f9f

Browse files
authored
Merge pull request #4 from KennethQNgo/fix-typos
Fix typos
2 parents fb58f23 + 3555424 commit ce13f9f

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

docs/source/chapters/chapter8.rst

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,40 @@ Let us add the following method called *monte_carlo_exchange* to the *MonteCarlo
2929
.. code-block:: python
3030
3131
def monte_carlo_exchange(self):
32-
# The first step is to make a copy of the previous state
33-
# Since atoms numbers are evolving, it's also important to store the
34-
# neighbor, sigma, and epsilon lists
35-
self.Epot = self.compute_potential() # TOFIX: not necessary every time
36-
initial_positions = copy.deepcopy(self.atoms_positions)
37-
initial_number_atoms = copy.deepcopy(self.number_atoms)
38-
initial_neighbor_lists = copy.deepcopy(self.neighbor_lists)
39-
initial_sigma_lists = copy.deepcopy(self.sigma_ij_list)
40-
initial_epsilon_lists = copy.deepcopy(self.epsilon_ij_list)
41-
# Apply a 50-50 probability to insert or delete
42-
insert_or_delete = np.random.random()
43-
if np.random.random() < insert_or_delete:
44-
self.monte_carlo_insert()
45-
else:
46-
self.monte_carlo_delete()
47-
if np.random.random() < self.acceptation_probability: # accepted move
48-
# Update the success counters
32+
if self.desired_mu is not None:
33+
# The first step is to make a copy of the previous state
34+
# Since atoms numbers are evolving, its also important to store the
35+
# neighbor, sigma, and epsilon lists
36+
self.Epot = self.compute_potential() # TOFIX: not necessary every time
37+
initial_positions = copy.deepcopy(self.atoms_positions)
38+
initial_number_atoms = copy.deepcopy(self.number_atoms)
39+
initial_neighbor_lists = copy.deepcopy(self.neighbor_lists)
40+
initial_sigma_lists = copy.deepcopy(self.sigma_ij_list)
41+
initial_epsilon_lists = copy.deepcopy(self.epsilon_ij_list)
42+
# Apply a 50-50 probability to insert or delete
43+
insert_or_delete = np.random.random()
4944
if np.random.random() < insert_or_delete:
50-
self.successful_insert += 1
45+
self.monte_carlo_insert()
5146
else:
52-
self.successful_delete += 1
53-
else:
54-
# Reject the new position, revert to inital position
55-
self.neighbor_lists = initial_neighbor_lists
56-
self.sigma_ij_list = initial_sigma_lists
57-
self.epsilon_ij_list = initial_epsilon_lists
58-
self.atoms_positions = initial_positions
59-
self.number_atoms = initial_number_atoms
60-
# Update the failed counters
61-
if np.random.random() < insert_or_delete:
62-
self.failed_insert += 1
47+
self.monte_carlo_delete()
48+
if np.random.random() < self.acceptation_probability: # accepted move
49+
# Update the success counters
50+
if np.random.random() < insert_or_delete:
51+
self.successful_insert += 1
52+
else:
53+
self.successful_delete += 1
6354
else:
64-
self.failed_delete += 1
55+
# Reject the new position, revert to inital position
56+
self.neighbor_lists = initial_neighbor_lists
57+
self.sigma_ij_list = initial_sigma_lists
58+
self.epsilon_ij_list = initial_epsilon_lists
59+
self.atoms_positions = initial_positions
60+
self.number_atoms = initial_number_atoms
61+
# Update the failed counters
62+
if np.random.random() < insert_or_delete:
63+
self.failed_insert += 1
64+
else:
65+
self.failed_delete += 1
6566
6667
.. label:: end_MonteCarlo_class
6768

docs/source/projects/project1.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Within the Python script, write:
9898

9999
.. code-block:: python
100100
101-
epsilon = (119.76*ureg.kelvin*cst.Boltzmann*cst.N_A).to(ureg.kcal/ureg.mol)
101+
epsilon = (119.76*ureg.kelvin*kB*Na).to(ureg.kcal/ureg.mol)
102102
r_star = 3.822*ureg.angstrom
103103
sigma = r_star / 2**(1/6)
104104
m_argon = 39.948*ureg.gram/ureg.mol
@@ -161,17 +161,17 @@ statistical mechanics that describes how the state variables of a system, such a
161161
pressure :math:`p`, volume :math:`V`, and temperature :math:`T`, are interrelated.
162162
Here, let us extract the pressure of the fluid for different density values.
163163

164-
To easily launch multiple simulation in parallel, let us create a
164+
To easily launch multiple simulations in parallel, let us create a
165165
function called *launch_MC_code* that will be used to call
166166
our Monte Carlo script with a chosen value of :math:`\tau = v / v^*`.
167167

168-
Create a new function, so that the current script ressemble the following:
168+
Create a new function so that the current script resembles the following:
169169

170170
.. code-block:: python
171171
172172
def launch_MC_code(tau):
173173
174-
epsilon = (119.76*ureg.kelvin*cst.Boltzmann*cst.N_A).to(ureg.kcal/ureg.mol)
174+
epsilon = (119.76*ureg.kelvin*kB*Na).to(ureg.kcal/ureg.mol)
175175
r_star = 3.822*ureg.angstrom
176176
sigma = r_star / 2**(1/6)
177177
m_argon = 39.948*ureg.gram/ureg.mol
@@ -217,7 +217,7 @@ simulation with too much overlap between the atoms:
217217
)
218218
em.run()
219219
220-
Then, let us start the Monte carlo simulation. As initial positions for the atoms,
220+
Then, let us start the Monte Carlo simulation. For the initial positions of the atoms,
221221
let us use the last positions from the *em* run,
222222
i.e. *initial_positions = em.atoms_positions*em.reference_distance*:
223223

@@ -256,12 +256,12 @@ i.e. *initial_positions = em.atoms_positions*em.reference_distance*:
256256
mc.run()
257257
258258
Finally, it is possible to call the *launch_MC_code* function using
259-
*multiprocessing*, and perform the simulation for multiple value of :math:`\tau`
259+
*multiprocessing*, and perform the simulation for multiple values of :math:`\tau`
260260
at the same time (if your computer has enough CPU core, if not, perform these
261261
calculations in serial):
262262

263263
.. code-block:: python
264-
264+
A
265265
if __name__ == "__main__":
266266
tau_values = np.round(np.logspace(-0.126, 0.882, 10),2)
267267
pool = multiprocessing.Pool()
@@ -287,7 +287,7 @@ with those of Ref. :cite:`woodMonteCarloEquation1957`:
287287
:class: only-dark
288288

289289
Figure: Equation of state of the argon fluid as calculated using the Monte
290-
carlo code (disks), and compared with the results from Ref. :cite:`woodMonteCarloEquation1957`.
291-
Normalised pressure, :math:`p V / RT` as a function of the normalised volume,
290+
Carlo code (disks), and compared with the results from Ref. :cite:`woodMonteCarloEquation1957`.
291+
Normalized pressure, :math:`p V / RT` as a function of the normalized volume,
292292
:math:`V / V^*`, where :math:`V^*` is the molar volume. For benchmark purposes,
293293
the data obtained using LAMMPS were also added.

0 commit comments

Comments
 (0)