How to use the matscipy.pressurecoupling.SlideLogger function in matscipy

To help you get started, we’ve selected a few matscipy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libAtoms / matscipy / tests / test_pressurecoupling.py View on Github external
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()
github libAtoms / matscipy / examples / pressure_coupling / equilibrate_pressure.py View on Github external
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()
github libAtoms / matscipy / examples / pressure_coupling / slide.py View on Github external
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()
github libAtoms / matscipy / examples / pressure_coupling / restart_equilibrate_pressure.py View on Github external
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()
github libAtoms / matscipy / examples / pressure_coupling / restart_slide.py View on Github external
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()