Skip to content

Commit 277678f

Browse files
committed
more typo correction
1 parent 694644b commit 277678f

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

docs/source/chapters/chapter2.rst

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Here, *number_atoms* :math:`N`, *epsilon* :math:`\epsilon`,
111111
*sigma* :math:`\sigma`, and *atom_mass* :math:`m` must be provided as lists
112112
where the elements have no units, kcal/mol, angstrom, and g/mol units,
113113
respectively. The units will be enforced with the |Pint| unit registry, *ureg*,
114-
which must also be provided as a parameter.
114+
which must also be provided as a parameter (more details later).
115115

116116
.. |Pint| raw:: html
117117

@@ -124,17 +124,17 @@ of positional and keyword arguments, respectively.
124124
Calculate LJ units prefactors
125125
-----------------------------
126126

127-
Within the *Prepare* class, let us create a method called *calculate_LJunits_prefactors*
128-
that will be used to calculate the prefactors necessary to convert units from the *real*
129-
unit system to the *LJ* unit system:
127+
Within the *Prepare* class, create a method called *calculate_LJunits_prefactors*
128+
that will be used to calculate the prefactors necessary to convert units from the
129+
*real* unit system to the *LJ* unit system:
130130

131131
.. label:: start_Prepare_class
132132

133133
.. code-block:: python
134134
135135
def calculate_LJunits_prefactors(self):
136136
"""Calculate the Lennard-Jones units prefactors."""
137-
# First define constants
137+
# First define Boltzmann and Avogadro constants
138138
kB = cst.Boltzmann*cst.Avogadro/cst.calorie/cst.kilo # kcal/mol/K
139139
kB *= self.ureg.kcal/self.ureg.mol/self.ureg.kelvin
140140
Na = cst.Avogadro/self.ureg.mol
@@ -157,22 +157,24 @@ unit system to the *LJ* unit system:
157157
# Calculate the prefactor for the pressure (in Atmosphere)
158158
self.ref_pressure = (self.ref_energy \
159159
/self.ref_length**3/Na).to(self.ureg.atmosphere)
160-
# Regroup all the reference quantities in list, for practicality
160+
# Group all the reference quantities into a list for practicality
161161
self.ref_quantities = [self.ref_length, self.ref_energy,
162162
self.ref_mass, self.ref_time, self.ref_pressure, self.ref_temperature]
163163
self.ref_units = [ref.units for ref in self.ref_quantities]
164164
165165
.. label:: end_Prepare_class
166166

167-
This method defines the reference distance as the first element in the
168-
*sigma* list, i.e., :math:`\sigma_{11}`. Therefore, atoms of type one will
169-
always be used for the normalization. Similarly, the first element
170-
in the *epsilon* list (:math:`\epsilon_{11}`) is used as the reference energy,
171-
and the first element in the *atom_mass* list (:math:`m_1`) is used as the
172-
reference mass. Then, the reference_time in femtoseconds is calculated
173-
as :math:`\sqrt{m_1 \sigma_{11}^2 / \epsilon_{11}}`, the reference temperature
174-
in Kelvin as :math:`\epsilon_{11} / k_\text{B}`, and the reference_pressure
175-
in atmospheres is calculated as :math:`\epsilon_{11}/\sigma_{11}^3`.
167+
This method defines the reference length as the first element in the
168+
*sigma* list, i.e., :math:`\sigma_{11}`. Therefore, atoms of type 1 will
169+
always be used for normalization. Similarly, the first element in the
170+
*epsilon* list (:math:`\epsilon_{11}`) is used as the reference energy, and
171+
the first element in the *atom_mass* list (:math:`m_1`) is used as the
172+
reference mass.
173+
174+
The reference time in femtoseconds is then calculated as
175+
:math:`\sqrt{m_1 \sigma_{11}^2 / \epsilon_{11}}`, the reference
176+
temperature in Kelvin as :math:`\epsilon_{11} / k_\text{B}`, and the
177+
reference pressure in atmospheres as :math:`\epsilon_{11} / \sigma_{11}^3`.
176178

177179
Finally, let us ensure that the *calculate_LJunits_prefactors* method is
178180
called systematically by adding the following line to the *__init__()* method:
@@ -233,11 +235,11 @@ class:
233235
234236
.. label:: end_Prepare_class
235237

236-
The index *0* is used to differentiate this method from other methods that
237-
will be used to nondimensionalize units in future classes. We anticipate that
238-
*epsilon*, *sigma*, and *atom_mass* may contain more than one element, so
239-
each element is normalized with the corresponding reference value. The
240-
*zip()* function allows us to loop over all three lists at once.
238+
When a *quantities_to_normalise* list containing parameter names is provided
239+
to the *nondimensionalize_units* method, a loop is performed over all the
240+
quantities. The value of each quantity is extracted using *getattr*. The units
241+
of the quantity of interest are then detected and normalized by the appropriate
242+
reference quantities defined by *calculate_LJunits_prefactors*.
241243

242244
Let us also call the *nondimensionalize_units* from the *__init__()* method
243245
of the *Prepare* class:
@@ -253,22 +255,25 @@ of the *Prepare* class:
253255
254256
.. label:: end_Prepare_class
255257

256-
Identify atom properties
258+
Here, the *epsilon*, *sigma*, and *atom_mass* parameters will be
259+
nondimensionalized.
260+
261+
Identify Atom Properties
257262
------------------------
258263

259264
Anticipating the future use of multiple atom types, where each type will be
260265
associated with its own :math:`\sigma`, :math:`\epsilon`, and :math:`m`, let
261266
us create arrays containing the properties of each atom in the simulation. For
262-
instance, in the case of a simulation with two atoms of type 1 and three atoms
263-
of type 2, the corresponding *atoms_sigma* array will be:
267+
instance, in a simulation with two atoms of type 1 and three atoms of type 2,
268+
the corresponding *atoms_sigma* array will be:
264269

265270
.. math::
266271
267272
\text{atoms_sigma} = [\sigma_{11}, \sigma_{11}, \sigma_{22}, \sigma_{22}, \sigma_{22}]
268273
269274
where :math:`\sigma_{11}` and :math:`\sigma_{22}` are the sigma values for
270-
atoms of type 1 and 2, respectively. The *atoms_sigma* array will allow for
271-
future calculations of force.
275+
atoms of type 1 and 2, respectively. The *atoms_sigma* array will facilitate
276+
future calculations of forces.
272277

273278
Create a new method called *identify_atom_properties*, and place it
274279
within the *Prepare* class:
@@ -318,7 +323,8 @@ Test the code
318323

319324
Let's test the *Prepare* class to make sure that it does what is expected.
320325
Here, a system containing 2 atoms of type 1, and 3 atoms of type 2 is
321-
prepared. LJs parameters and masses for each groups are also defined.
326+
prepared. LJs parameters and masses for each groups are also defined, and given
327+
physical units thanks to the *UnitRegistry* of Pint.
322328

323329
.. label:: start_test_2a_class
324330

@@ -351,7 +357,8 @@ prepared. LJs parameters and masses for each groups are also defined.
351357
def test_atoms_epsilon():
352358
expected = np.array([1., 1., 2., 2., 2.])
353359
result = prep.atoms_epsilon
354-
assert np.array_equal(result, expected), f"Test failed: {result} != {expected}"
360+
assert np.array_equal(result, expected), \
361+
f"Test failed: {result} != {expected}"
355362
print("Test passed")
356363
357364
# In the script is launched with Python, call Pytest
@@ -361,5 +368,6 @@ prepared. LJs parameters and masses for each groups are also defined.
361368
362369
.. label:: end_test_2a_class
363370

364-
This test assert that the generated *atoms_epsilon* array is consistent with
365-
its expected value (see the previous paragraphs).
371+
This test asserts that the generated *atoms_epsilon* array is consistent
372+
with its expected value (see the previous paragraphs). Note that the expected
373+
values are in LJ units, i.e., they have been nondimensionalized by :math:`\epsilon_1`.

0 commit comments

Comments
 (0)