@@ -337,16 +337,42 @@ def run(
337337 traj = Trajectory (traj_file , "w" , atoms )
338338
339339 if not np .isnan (t_schedule ).any ():
340- MaxwellBoltzmannDistribution (
341- atoms = atoms ,
342- temperature_K = t_schedule [last_step ],
343- rng = np .random .default_rng (seed = velocity_seed ),
344- )
340+ if atoms .get_temperature () == 0.0 :
341+ MaxwellBoltzmannDistribution (
342+ atoms = atoms ,
343+ temperature_K = t_schedule [0 ],
344+ rng = np .random .default_rng (seed = velocity_seed ),
345+ )
346+ else :
347+ atoms .set_momenta (
348+ atoms .get_momenta () * np .sqrt (
349+ t_schedule [0 ] / atoms .get_temperature ()
350+ )
351+ )
345352
346353 if zero_linear_momentum :
347354 Stationary (atoms )
348355 if zero_angular_momentum :
349356 ZeroRotation (atoms )
357+ else :
358+ if not np .isnan (t_schedule ).any ():
359+ if atoms .get_temperature () == 0.0 :
360+ MaxwellBoltzmannDistribution (
361+ atoms = atoms ,
362+ temperature_K = t_schedule [0 ],
363+ rng = np .random .default_rng (seed = velocity_seed ),
364+ )
365+ else :
366+ atoms .set_momenta (
367+ atoms .get_momenta () * np .sqrt (
368+ t_schedule [0 ] / atoms .get_temperature ()
369+ )
370+ )
371+
372+ if zero_linear_momentum :
373+ Stationary (atoms )
374+ if zero_angular_momentum :
375+ ZeroRotation (atoms )
350376
351377 fraction_traceless = dynamics_kwargs .pop ("fraction_traceless" , 1.0 )
352378
0 commit comments