Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
vdir,
v,
damping
)
atoms.set_constraint(slider)
MaxwellBoltzmannDistribution(atoms, 2 * kB * T)
atoms.arrays['momenta'][top_mask, :] = 0
atoms.arrays['momenta'][bottom_mask, :] = 0
handle = StringIO()
beginning = handle.tell()
temps = np.zeros((len(atoms), 3))
temps[slider.middle_mask, slider.Tdir] = kB * T
gammas = np.zeros((len(atoms), 3))
gammas[slider.middle_mask, slider.Tdir] = gamma_langevin
integrator = Langevin(atoms, dt, temps, gammas, fixcm=False)
logger = pc.SlideLogger(handle, atoms, slider, integrator)
logger.write_header()
logger()
images = []
integrator.attach(logger)
integrator.attach(lambda: images.append(atoms.copy()))
integrator.run(50)
handle.seek(beginning)
pc.SlideLog(handle)
handle.close()
atoms.arrays['momenta'][bottom_mask, :] = 0
calc = ASE_CALCULATOR_OBJECT # put a specific calculator here
atoms.set_calculator(calc)
# only thermalize middle region in one direction
temps = np.zeros((len(atoms), 3))
temps[slider.middle_mask, slider.Tdir] = kB * T
gammas = np.zeros((len(atoms), 3))
gammas[slider.middle_mask, slider.Tdir] = gamma_langevin
integrator = Langevin(atoms, dt, temps, gammas, fixcm=False)
trajectory = Trajectory('equilibrate_pressure.traj', 'w', atoms)
log_handle = open('log_equilibrate.txt', 'w', 1, encoding='utf-8') # 1 means line buffered
logger = pc.SlideLogger(log_handle, atoms, slider, integrator)
# log can be read using pc.SlideLog (see docstring there)
logger.write_header()
logger() # step 0
trajectory.write() # step 0
integrator.attach(logger)
integrator.attach(trajectory)
integrator.run(steps_integrate)
log_handle.close()
trajectory.close()
damp = pc.AutoDamping(C11, p_c)
slider = pc.SlideWithNormalPressureCuboidCell(top_mask, bottom_mask, Pdir, P, vdir, v, damp)
atoms.set_constraint(slider)
calc = ASE_CALCULATOR_OBJECT # put a specific calculator here
atoms.set_calculator(calc)
temps = np.zeros((len(atoms), 3))
temps[slider.middle_mask, slider.Tdir] = kB * T
gammas = np.zeros((len(atoms), 3))
gammas[slider.middle_mask, slider.Tdir] = gamma_langevin
integrator = Langevin(atoms, dt, temps, gammas, fixcm=False)
trajectory = Trajectory('slide.traj', 'w', atoms)
log_handle = open('log_slide.txt', 'w', 1, encoding='utf-8') # line buffered
logger = pc.SlideLogger(log_handle, atoms, slider, integrator)
# log can be read using pc.SlideLog (see docstring there)
logger.write_header()
logger() # step 0
trajectory.write() # step 0
integrator.attach(logger)
integrator.attach(trajectory)
integrator.run(steps_integrate)
log_handle.close()
trajectory.close()
slider = pc.SlideWithNormalPressureCuboidCell(top_mask, bottom_mask, Pdir, P, vdir, v, damp)
atoms.set_constraint(slider)
calc = ASE_CALCULATOR_OBJECT # put a specific calculator here
atoms.set_calculator(calc)
temps = np.zeros((len(atoms), 3))
temps[slider.middle_mask, slider.Tdir] = kB * T
gammas = np.zeros((len(atoms), 3))
gammas[slider.middle_mask, slider.Tdir] = gamma_langevin
integrator = Langevin(atoms, dt, temps, gammas, fixcm=False)
trajectory = Trajectory('equilibrate_pressure.traj', 'a', atoms) # append
with open('log_equilibrate.txt', 'r', encoding='utf-8') as log_handle:
step_offset = pc.SlideLog(log_handle).step[-1]
log_handle = open('log_equilibrate.txt', 'a', 1, encoding='utf-8') # line buffered append
logger = pc.SlideLogger(log_handle, atoms, slider, integrator, step_offset)
integrator.attach(logger)
integrator.attach(trajectory)
integrator.run(steps_integrate)
log_handle.close()
trajectory.close()
atoms.set_constraint(slider)
calc = ASE_CALCULATOR_OBJECT # put a specific calculator here
atoms.set_calculator(calc)
temps = np.zeros((len(atoms), 3))
temps[slider.middle_mask, slider.Tdir] = kB * T
gammas = np.zeros((len(atoms), 3))
gammas[slider.middle_mask, slider.Tdir] = gamma_langevin
integrator = Langevin(atoms, dt, temps, gammas, fixcm=False)
trajectory = Trajectory('slide.traj', 'a', atoms) # append
with open('log_slide.txt', 'r', encoding='utf-8') as log_handle:
step_offset = pc.SlideLog(log_handle).step[-1]
log_handle = open('log_slide.txt', 'a', 1, encoding='utf-8') # line buffered append
logger = pc.SlideLogger(log_handle, atoms, slider, integrator, step_offset)
integrator.attach(logger)
integrator.attach(trajectory)
integrator.run(steps_integrate)
log_handle.close()
trajectory.close()