@@ -96,44 +96,17 @@ and the desired temperature (:math:`T`). Let us add these parameters to the
9696 class MonteCarlo (Measurements ):
9797 def __init__ (self ,
9898 maximum_steps ,
99- cut_off = 9 ,
99+ desired_temperature ,
100100 displace_mc = None ,
101- neighbor = 1 ,
102- desired_temperature = 300 ,
103101 thermo_outputs = " press" ,
104- data_folder = None ,
105102 * args ,
106103 ** kwargs ):
107104 self .maximum_steps = maximum_steps
108- self .cut_off = cut_off
109105 self .displace_mc = displace_mc
110- self .neighbor = neighbor
111106 self .desired_temperature = desired_temperature
112107 self .thermo_outputs = thermo_outputs
113- self .data_folder = data_folder
114- if self .data_folder is not None :
115- if os.path.exists(self .data_folder) is False :
116- os.mkdir(self .data_folder)
117108 super ().__init__ (* args, ** kwargs)
118- self .nondimensionalize_units_3()
119-
120- .. label :: end_MonteCarlo_class
121-
122- Here, we anticipate that some of the parameters have to be nondimensionalized, which
123- is done with the *nondimensionalize_units_3 * method that must also be added to
124- the *MonteCarlo * class:
125-
126- .. label :: start_MonteCarlo_class
127-
128- .. code-block :: python
129-
130- def nondimensionalize_units_3 (self ):
131- """ Use LJ prefactors to convert units into non-dimensional."""
132- self .cut_off = self .cut_off/ self .reference_distance
133- self .desired_temperature = self .desired_temperature \
134- / self .reference_temperature
135- if self .displace_mc is not None :
136- self .displace_mc /= self .reference_distance
109+ self .nondimensionalize_units([" desired_temperature" , " displace_mc" ])
137110
138111 .. label :: end_MonteCarlo_class
139112
@@ -201,21 +174,41 @@ One can use a similar test as previously. Let us use a displace distance of
201174
202175.. code-block :: python
203176
204- import os
205177 from MonteCarlo import MonteCarlo
178+ from pint import UnitRegistry
179+ ureg = UnitRegistry()
180+ import os
206181
207- mc = MonteCarlo(maximum_steps = 1000 ,
208- dumping_period = 100 ,
182+ # Define atom number of each group
183+ nmb_1= 50
184+ # Define LJ parameters (sigma)
185+ sig_1 = 3 * ureg.angstrom
186+ # Define LJ parameters (epsilon)
187+ eps_1 = 0.1 * ureg.kcal/ ureg.mol
188+ # Define atom mass
189+ mss_1 = 10 * ureg.gram/ ureg.mol
190+ # Define box size
191+ L = 20 * ureg.angstrom
192+ # Define a cut off
193+ rc = 2.5 * sig_1
194+ # Pick the desired temperature
195+ T = 300 * ureg.kelvin
196+
197+ # Initialize the prepare object
198+ mc = MonteCarlo(
199+ ureg = ureg,
200+ maximum_steps = 1000 ,
209201 thermo_period = 100 ,
210- thermo_outputs = " Epot" ,
211- displace_mc = 0.5 ,
212- number_atoms = [50 ],
213- epsilon = [0.1 ], # kcal/mol
214- sigma = [3 ], # A
215- atom_mass = [10 ], # g/mol
216- box_dimensions = [20 , 20 , 20 ], # A
217- data_folder = " Outputs/" ,
218- )
202+ dumping_period = 100 ,
203+ number_atoms = [nmb_1],
204+ epsilon = [eps_1], # kcal/mol
205+ sigma = [sig_1], # A
206+ atom_mass = [mss_1], # g/mol
207+ box_dimensions = [L, L, L], # A
208+ cut_off = rc,
209+ thermo_outputs = " Epot" ,
210+ desired_temperature = T, # K
211+ )
219212 mc.run()
220213
221214 .. label :: end_test_6a_class
0 commit comments