Exemplo n.º 1
0
def test_generator_glycine_fixq():
    system = get_system_glycine()
    fn_pars = pkg_resources.resource_filename(__name__, '../../data/test/parameters_glycine_fixq.txt')
    ff = ForceField.generate(system, fn_pars)
    assert len(ff.parts) == 1 #Non-periodic, so only one part
    part_pair_ei = ff.part_pair_ei
    # check part settings
    assert part_pair_ei.pair_pot.alpha == 0.0
    # check charges and atomic radii
    ac = {1:0.2, 6:0.5, 7:-1.0, 8:-0.5 } #Charges
    ar = {1:1.2*angstrom, 6: 1.7*angstrom, 7: 1.55*angstrom, 8: 1.50*angstrom} #Radii
    for i in range(system.natom):
        assert abs(system.charges[i] - ac[system.numbers[i]]) < 1e-5
        assert abs(system.radii[i] - ar[system.numbers[i]]) < 1e-5

    system = get_system_glycine()
    log.set_level(log.silent)
    fn_pars = pkg_resources.resource_filename(__name__, '../../data/test/parameters_glycine_fixq.txt')
    ff2 = ForceField.generate(system, fn_pars)
    log.set_level(log.debug)
    # check charges and atomic radii
    ac = {1:0.2, 6:0.5, 7:-1.0, 8:-0.5 } #Charges
    ar = {1:1.2*angstrom, 6: 1.7*angstrom, 7: 1.55*angstrom, 8: 1.50*angstrom} #Radii
    for i in range(system.natom):
        assert abs(system.charges[i] - ac[system.numbers[i]]) < 1e-5
        assert abs(system.radii[i] - ar[system.numbers[i]]) < 1e-5
    energy = ff.compute()
    energy2 = ff2.compute()
    assert abs(energy - energy2) < 1e-3
Exemplo n.º 2
0
def test_generator_water32_fixq():
    system = get_system_water32()
    fn_pars = pkg_resources.resource_filename(
        __name__, '../../data/test/parameters_water_fixq.txt')
    ff = ForceField.generate(system, fn_pars)
    assert len(ff.parts) == 4
    part_pair_ei = ff.part_pair_ei
    part_ewald_reci = ff.part_ewald_reci
    part_ewald_cor = ff.part_ewald_cor
    part_ewald_neut = ff.part_ewald_neut
    # check part settings
    assert part_pair_ei.pair_pot.alpha > 0
    assert part_pair_ei.pair_pot.alpha == part_ewald_reci.alpha
    assert part_pair_ei.pair_pot.alpha == part_ewald_cor.alpha
    assert part_pair_ei.pair_pot.alpha == part_ewald_neut.alpha
    # check charges and atomic radii
    for i in range(system.natom):
        if system.numbers[i] == 1:
            assert abs(system.charges[i] - 0.417) < 1e-5
            assert abs(system.radii[i] - 1.2 * angstrom) < 1e-5
        else:
            assert abs(system.charges[i] + 2 * 0.417) < 1e-5
            assert abs(system.radii[i] - 1.5 * angstrom) < 1e-5

    system = get_system_water32()
    log.set_level(log.silent)
    fn_pars = pkg_resources.resource_filename(
        __name__, '../../data/test/parameters_water_fixq.txt')
    ff2 = ForceField.generate(system, fn_pars)
    log.set_level(log.debug)
    # check charges
    for i in range(system.natom):
        if system.numbers[i] == 1:
            assert abs(system.charges[i] - 0.417) < 1e-5
            assert abs(system.radii[i] - 1.2 * angstrom) < 1e-5
        else:
            assert abs(system.charges[i] + 2 * 0.417) < 1e-5
            assert abs(system.radii[i] - 1.5 * angstrom) < 1e-5
    energy = ff.compute()
    energy2 = ff2.compute()
    assert abs(energy - energy2) < 1e-3
Exemplo n.º 3
0
def test_generator_water32_fixq():
    system = get_system_water32()
    fn_pars = pkg_resources.resource_filename(__name__, '../../data/test/parameters_water_fixq.txt')
    ff = ForceField.generate(system, fn_pars)
    assert len(ff.parts) == 4
    part_pair_ei = ff.part_pair_ei
    part_ewald_reci = ff.part_ewald_reci
    part_ewald_cor = ff.part_ewald_cor
    part_ewald_neut = ff.part_ewald_neut
    # check part settings
    assert part_pair_ei.pair_pot.alpha > 0
    assert part_pair_ei.pair_pot.alpha == part_ewald_reci.alpha
    assert part_pair_ei.pair_pot.alpha == part_ewald_cor.alpha
    assert part_pair_ei.pair_pot.alpha == part_ewald_neut.alpha
    # check charges and atomic radii
    for i in range(system.natom):
        if system.numbers[i] == 1:
            assert abs(system.charges[i] - 0.417) < 1e-5
            assert abs(system.radii[i] - 1.2*angstrom) < 1e-5
        else:
            assert abs(system.charges[i] + 2*0.417) < 1e-5
            assert abs(system.radii[i] - 1.5*angstrom) < 1e-5

    system = get_system_water32()
    log.set_level(log.silent)
    fn_pars = pkg_resources.resource_filename(__name__, '../../data/test/parameters_water_fixq.txt')
    ff2 = ForceField.generate(system, fn_pars)
    log.set_level(log.debug)
    # check charges
    for i in range(system.natom):
        if system.numbers[i] == 1:
            assert abs(system.charges[i] - 0.417) < 1e-5
            assert abs(system.radii[i] - 1.2*angstrom) < 1e-5
        else:
            assert abs(system.charges[i] + 2*0.417) < 1e-5
            assert abs(system.radii[i] - 1.5*angstrom) < 1e-5
    energy = ff.compute()
    energy2 = ff2.compute()
    assert abs(energy - energy2) < 1e-3
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
# YAFF is yet another force-field code
# Copyright (C) 2011 - 2013 Toon Verstraelen <*****@*****.**>,
# Louis Vanduyfhuys <*****@*****.**>, Center for Molecular Modeling
# (CMM), Ghent University, Ghent, Belgium; all rights reserved unless otherwise
# stated.
#
# This file is part of YAFF.
#
# YAFF is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# YAFF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
#--

from yaff.log import log

log.set_level(log.debug)
Exemplo n.º 5
0
# --

from __future__ import division
from __future__ import print_function

import numpy as np
np.random.seed(3)
import h5py as h5

from yaff.sampling import VerletScreenLog, HDF5Writer, NHCThermostat, MTDHook,\
    VerletIntegrator
from yaff.external import ForcePartPlumed
from yaff.pes import CVInternalCoordinate, DihedAngle
from yaff.test.common import get_alaninedipeptide_amber99ff
from yaff.log import log
log.set_level(log.medium)
from molmod.units import *

plumed = False

T = 300 * kelvin

if __name__ == '__main__':
    ff = get_alaninedipeptide_amber99ff()
    vsl = VerletScreenLog(step=1000)
    fh5 = h5.File('traj.h5', 'w')
    h5writer = HDF5Writer(fh5, step=1000)
    thermo = NHCThermostat(T, timecon=100 * femtosecond)
    hooks = [thermo, vsl, h5writer]
    if plumed:
        plumed = ForcePartPlumed(ff.system, fn='plumed.dat')