Пример #1
0
freq = max(1, math.floor(cmd.ladder_num_steps / 10))
if cmd.hmr:
    # Time step is 5 fs
    xyz_freq = cmd.xyz_freq if cmd.xyz_freq is not None else freq
    log_freq = cmd.log_freq if cmd.log_freq is not None else freq
else:
    # Time step is 2 fs
    xyz_freq = cmd.xyz_freq if cmd.xyz_freq is not None else freq
    log_freq = cmd.log_freq if cmd.log_freq is not None else freq

# Calculate total simulation length in steps
n_stages = math.ceil(cmd.temperature / cmd.ladder_step_temperature)
n_total_steps = n_stages * cmd.ladder_num_steps

# Setup Reporters
dcd_fname = _utils.make_fname(rootname + '.dcd')
cpt_fname = _utils.make_fname(rootname + '.cpt')
log_fname = _utils.make_fname(rootname + '.log')
dcd = app.DCDReporter(dcd_fname, xyz_freq)
cpt = app.CheckpointReporter(cpt_fname, xyz_freq)
state = app.StateDataReporter(log_fname,
                              log_freq,
                              step=True,
                              potentialEnergy=True,
                              kineticEnergy=True,
                              temperature=True,
                              progress=True,
                              remainingTime=True,
                              totalSteps=n_total_steps,
                              speed=True,
                              separator='\t')
Пример #2
0
logging.info('Writing system without dummy (restraint) atoms')
system = forcefield.createSystem(model.topology,
                                 nonbondedMethod=app.PME,
                                 nonbondedCutoff=md_nbct,
                                 constraints=md_cstr,
                                 hydrogenMass=md_hamu,
                                 ewaldErrorTolerance=0.0005,
                                 rigidWater=True)

integrator = mm.LangevinIntegrator(md_temp, md_fric, md_step)
simulation = app.Simulation(model.topology, system, integrator)
simulation.context.setPositions(xyz[:n_ini_atoms])
simulation.context.setVelocities(vel[:n_ini_atoms])
simulation.context.setPeriodicBoxVectors(vx, vy, vz)

xml_fname = _utils.make_fname(rootname + '_noDUM' + '.xml')
logging.info(f'Writing dummy-less state to \'{xml_fname}\'')
simulation.saveState(xml_fname)

# Write last frame as mmCIF
cif_fname = _utils.make_fname(rootname + '_noDUM' + '.cif')
logging.info(f'Writing dummy-less structure to \'{cif_fname}\'')
with open(cif_fname, 'w') as handle:
    app.PDBxFile.writeFile(model.topology,
                           xyz[:n_ini_atoms],
                           handle,
                           keepIds=True)

logging.info('Finished')
Пример #3
0
# Minimize
simulation = app.Simulation(structure.topology, system, integrator, platform,
                            plat_properties)
simulation.context.setPositions(structure.positions)

state = simulation.context.getState(getEnergy=True)
energy = state.getPotentialEnergy().value_in_unit_system(units.md_unit_system)
logging.info('Initial Potential Energy: {:10.3f}'.format(energy))

logging.info('Running minimization ...')
simulation.minimizeEnergy(maxIterations=cmd.iterations)

state = simulation.context.getState(getEnergy=True, getPositions=True)
energy = state.getPotentialEnergy().value_in_unit_system(units.md_unit_system)
logging.info('Final Potential Energy: {:10.3f}'.format(energy))

# Write minimized structure
if cmd.output:
    if not cmd.output.endswith('.cif'):
        _fname = cmd.output + '.cif'
    else:
        _fname = cmd.output
else:
    _fname = fname + '_EM' + '.cif'

cif_fname = _utils.make_fname(_fname)
logging.info('Writing structure to \'{}\''.format(cif_fname))
with open(cif_fname, 'w') as handle:
    minimized_positions = state.getPositions()
    app.PDBxFile.writeFile(structure.topology, minimized_positions, handle)