示例#1
0
def test_pressure_with_exceptions():
    system, positions, topology = readSystem('emim_BCN4_Jiung2014')
    platform = openmm.Platform.getPlatformByName('Reference')
    computer = atomsmm.PressureComputer(system,
                                        topology,
                                        platform,
                                        temperature=300 * unit.kelvin)
    context = openmm.Context(system, openmm.CustomIntegrator(0), platform)
    context.setPositions(positions)
    state = context.getState(getPositions=True,
                             getVelocities=True,
                             getForces=True)
    computer.import_configuration(state)
    atomic_virial = computer.get_atomic_virial()
    assert atomic_virial / atomic_virial.unit == pytest.approx(
        -22827.477810819175)
    atomic_pressure = computer.get_atomic_pressure()
    assert atomic_pressure / atomic_pressure.unit == pytest.approx(
        -282.7243180164338)
    molecular_virial = computer.get_molecular_virial(state.getForces())
    assert molecular_virial / molecular_virial.unit == pytest.approx(
        -23272.958585794207)
    molecular_pressure = computer.get_molecular_pressure(state.getForces())
    assert molecular_pressure / molecular_pressure.unit == pytest.approx(
        -3283.563262288828)
示例#2
0
def test_pressure_with_bath_temperature():
    system, positions, topology = readSystem('q-SPC-FW')
    platform = openmm.Platform.getPlatformByName('Reference')
    computer = atomsmm.PressureComputer(system,
                                        topology,
                                        platform,
                                        temperature=300 * unit.kelvin)
    context = openmm.Context(system, openmm.CustomIntegrator(0), platform)
    context.setPositions(positions)
    state = context.getState(getPositions=True,
                             getVelocities=True,
                             getForces=True)
    computer.import_configuration(state)
    atomic_virial = computer.get_atomic_virial()
    assert atomic_virial / atomic_virial.unit == pytest.approx(
        -11661.677650154408)
    atomic_pressure = computer.get_atomic_pressure()
    assert atomic_pressure / atomic_pressure.unit == pytest.approx(
        -58.64837784125407)
    molecular_virial = computer.get_molecular_virial(state.getForces())
    assert molecular_virial / molecular_virial.unit == pytest.approx(
        -5418.629781093525)
    molecular_pressure = computer.get_molecular_pressure(state.getForces())
    assert molecular_pressure / molecular_pressure.unit == pytest.approx(
        -554.9525554206972)
示例#3
0
def test_pressure_with_kinetic_temperature():
    system, positions, topology = readSystem('q-SPC-FW')
    platform = openmm.Platform.getPlatformByName('Reference')
    computer = atomsmm.PressureComputer(system, topology, platform)
    context = openmm.Context(system, openmm.CustomIntegrator(0), platform)
    context.setPositions(positions)
    context.setVelocitiesToTemperature(300 * unit.kelvin, 1234)
    state = context.getState(getPositions=True,
                             getVelocities=True,
                             getForces=True)
    computer.import_configuration(state)
    atomic_virial = computer.get_atomic_virial()
    assert atomic_virial / atomic_virial.unit == pytest.approx(
        -11661.677650154408)
    atomic_pressure = computer.get_atomic_pressure()
    assert atomic_pressure / atomic_pressure.unit == pytest.approx(
        -86.95921953101447)
    molecular_virial = computer.get_molecular_virial(state.getForces())
    assert molecular_virial / molecular_virial.unit == pytest.approx(
        -5418.629781093525)
    molecular_pressure = computer.get_molecular_pressure(state.getForces())
    assert molecular_pressure / molecular_pressure.unit == pytest.approx(
        -539.0081647715243)
示例#4
0
def platform(name):
    return [
        openmm.Platform.getPlatformByName(name),
        dict(Precision='mixed') if name == 'CUDA' else dict()
    ]


integrator = openmm.LangevinIntegrator(temp, 0.1 / unit.femtoseconds,
                                       1.0 * unit.femtosecond)
system.addForce(openmm.MonteCarloBarostat(1 * unit.atmospheres, temp, 20))
simulation = app.Simulation(topology, system, integrator,
                            *platform(simulation_platform))
simulation.context.setPositions(modeller.getPositions())
simulation.context.setVelocitiesToTemperature(temp)

computer = atomsmm.PressureComputer(system, topology,
                                    *platform(pressure_computer_platform))
reporter = atomsmm.ExtendedStateDataReporter(stdout,
                                             100,
                                             step=True,
                                             speed=True,
                                             potentialEnergy=True,
                                             temperature=True,
                                             density=True,
                                             atomicPressure=(not rigid_water),
                                             molecularPressure=True,
                                             pressureComputer=computer,
                                             extraFile='properties.csv')

simulation.reporters.append(reporter)
simulation.minimizeEnergy()
simulation.step(100000)
示例#5
0
integrator = atomsmm.integrators.Langevin_R_Integrator(dt,
                                                       loops,
                                                       temp,
                                                       gamma,
                                                       has_memory=True)

simulation = openmm.app.Simulation(pdb.topology, respa_system, integrator,
                                   platform, properties)
simulation.context.setPositions(pdb.positions)
simulation.context.setVelocitiesToTemperature(temp, seed)

computer = atomsmm.PressureComputer(
    openmm_system,
    pdb.topology,
    #        openmm.Platform.getPlatformByName('CPU'),
    openmm.Platform.getPlatformByName('CUDA'),
    dict(Precision='mixed', DeviceIndex=args.secdev),
    temperature=temp)

dataReporter = atomsmm.ExtendedStateDataReporter(
    stdout,
    reportInterval,
    separator=',',
    step=True,
    potentialEnergy=True,
    kineticEnergy=True,
    #        totalEnergy=True,
    temperature=True,
    #        atomicVirial=True,
    atomicPressure=True,
示例#6
0
                                                  loops,
                                                  temp,
                                                  tau,
                                                  gamma,
                                                  L=args.L)

simulation = openmm.app.Simulation(pdb.topology, respa_system, integrator,
                                   platform, properties)
simulation.context.setPositions(pdb.positions)
simulation.context.setVelocitiesToTemperature(temp, seed)

computer = atomsmm.PressureComputer(
    openmm_system,
    pdb.topology,
    platform
    if args.secdev is None else openmm.Platform.getPlatformByName('CUDA'),
    properties if args.secdev is None else dict(Precision='mixed',
                                                DeviceIndex=args.secdev),
    temperature=temp,
)

dataReporter = atomsmm.ExtendedStateDataReporter(stdout,
                                                 reportInterval,
                                                 separator=',',
                                                 step=True,
                                                 potentialEnergy=True,
                                                 temperature=True,
                                                 atomicPressure=True,
                                                 molecularPressure=True,
                                                 pressureComputer=computer,
                                                 speed=True,