示例#1
0
    def test(self):
        rho = 1e-3  # number density
        nMol = 500  # number of particles
        space = feasst.makeSpace(
            feasst.args({
                "dimen": "3",
                "boxLength": str((float(nMol) / rho)**(1. / 3.))
            }))
        pair = feasst.makePairLJ(
            space,
            feasst.args({
                "rCut": "3",  # potential truncation at 3
                "cutType": "lrc",
                "molTypeInForcefield": "data.lj"
            }))
        criteria = feasst.makeCriteriaMetropolis(
            feasst.args({"beta": str(1. / 0.9)}))
        mc = feasst.MC(pair, criteria)
        feasst.addTrialTransform(
            mc,
            feasst.args({
                "transType": "translate",
                "maxMoveParam": str(0.1)
            }))
        mc.nMolSeek(nMol)
        mc.initLog("log", int(1e4))
        mc.initMovie("movie", int(1e4))
        mc.initRestart("tmp/rst", int(1e4))
        mc.setNFreqTune(int(1e4))
        mc.setNFreqCheckE(int(1e4), 1e-6)
        mc.runNumTrials(int(1e7))  # run equilibration

        # Run the production simulation and compute statistics on potential energy
        mc.setNFreqTune(0)  # do not tune during production
        pe = feasst.Accumulator()
        from itertools import islice, count
        for itrial in islice(count(1), int(1e7) - 1):
            mc.runNumTrials(1)
            pe.accumulate(pair.peTot() / float(space.nMol()))

        # Check average energy against the NIST SRSW
        # https:#mmlapps.nist.gov/srs/LJ_PURE/mc.htm
        # https:#www.nist.gov/programs-projects/nist-standard-reference-simulation-website
        peAv = pe.average()
        peStd = pe.blockStdev()
        peSRSW = -9.9165E-03
        peSRSWstd = 1.89E-05
        self.assertAlmostEqual(peAv, peSRSW, delta=2.576 * (peSRSWstd + peStd))
示例#2
0
文件: test.py 项目: yangxi1209/feasst
    def test(self):
        feasst.ranInitByDate()
        space = feasst.makeSpace(
            feasst.args({
                "dimen": "3",
                "boxLength": "24.8586887"
            }))

        pair = feasst.makePairLJCoulEwald(
            space,
            feasst.args({
                "rCut": str(space.minl() / 2.),
                "molTypeInForcefield": "data.spce",
                "alphaL": "5.6",
                "k2max": "38"
            }))

        # acceptance criteria
        temperature = 298  # Kelvin
        beta = 1. / (temperature * feasst.idealGasConstant / 1e3)  # mol/KJ
        criteria = feasst.CriteriaMetropolis(beta, 1.)
        mc = feasst.MC(space, pair, criteria)
        feasst.transformTrial(mc, "translate", 0.1)
        feasst.transformTrial(mc, "rotate", 0.1)
        mc.initLog("log", int(1e4))
        mc.initMovie("movie", int(1e4))
        mc.initRestart("tmp/rst", int(1e4))
        mc.setNFreqTune(int(1e4))
        mc.setNFreqCheckE(int(1e4), 1e-6)
        mc.nMolSeek(512)
        mc.runNumTrials(int(1e6))  # run equilibration

        # Run the production simulation
        mc.initProduction()
        mc.zeroStat()
        mc.setNFreqTune(0)
        mc.runNumTrials(int(1e6))

        # Check average energy against Gerhard Hummer
        # https:#doi.org/10.1063/1.476834
        peAv = mc.peAccumulator().average() / float(space.nMol())
        peStd = mc.peAccumulator().blockStdev() / float(space.nMol())
        pePublish = -46.82  # published value
        pePublishStd = 0.02
        self.assertAlmostEqual(peAv,
                               pePublish,
                               delta=2.576 * (pePublishStd + peStd))
示例#3
0
文件: test.py 项目: ishan111/feasst
    def test(self):
        space = feasst.Space(3)
        space.initBoxLength(24.8586887)  # molecule-center based cut-off

        pair = feasst.PairLJCoulEwald(space, space.minl() / 2.)
        pair.initData(space.install_dir() + "/forcefield/data.spce")
        pair.initKSpace(
            5.6,  # alpha*L
            38)  # k^2 < k2max cutoff

        # Read the pre-equilibrated configuration of 512 water molecules
        conf_file = feasst.make_ifstream(space.install_dir() + \
            "/testcase/3_spce/2_nvt-mc/test.xyz")
        pair.readxyz(conf_file)
        pair.initEnergy()

        # acceptance criteria
        temperature = 298  # Kelvin
        beta = 1. / (temperature * feasst.idealGasConstant / 1e3)  # mol/KJ
        criteria = feasst.CriteriaMetropolis(beta, 1.)
        mc = feasst.MC(space, pair, criteria)
        feasst.transformTrial(mc, "translate", 0.1)
        mc.initLog("log", int(1e4))
        mc.initMovie("movie", int(1e4))
        mc.initRestart("tmp/rst", int(1e4))
        mc.setNFreqTune(int(1e4))
        mc.runNumTrials(int(1e6))  # run equilibration

        # Run the production simulation
        mc.zeroStat()
        mc.runNumTrials(int(1e6))

        # Check average energy against Gerhard Hummer
        # https:#doi.org/10.1063/1.476834
        peAv = mc.peAccumulator().average() / float(space.nMol())
        peStd = mc.peAccumulator().blockStdev() / float(space.nMol())
        pePublish = -46.
        # pePublish = -46.82  # published value
        pePublishStd = 0.02
        self.assertAlmostEqual(peAv,
                               pePublish,
                               delta=2.576 * (pePublishStd + peStd))
示例#4
0
文件: test.py 项目: yangxi1209/feasst
    def test(self):
        space = feasst.Space(3)
        rho = 1e-3  # number density
        nMol = 500  # number of particles
        space.initBoxLength(
            (float(nMol) / rho)**(1. / 3.))  # set the cubic PBCs
        pair = feasst.PairHardSphere(space)
        pair.initData(space.install_dir() + "/forcefield/data.atom")
        pair.initEnergy()
        criteria = feasst.CriteriaMetropolis(1., 1.)
        mc = feasst.MC(space, pair, criteria)
        feasst.transformTrial(mc, "translate", 0.1)
        mc.nMolSeek(nMol)
        mc.initLog("log", int(1e4))
        mc.initMovie("movie", int(1e4))
        mc.initRestart("tmp/rst", int(1e4))
        mc.setNFreqTune(int(1e4))
        mc.runNumTrials(int(1e7))  # run equilibration

        # Run the production simulation
        mc.runNumTrials(int(1e7))
示例#5
0
    def test(self):
        space = feasst.Space(3)
        rho = 1e-3  # number density
        nMol = 500  # number of particles
        space.initBoxLength(
            (float(nMol) / rho)**(1. / 3.))  # set the cubic PBCs
        molNameSS = space.install_dir() + "/forcefield/data.lj"
        space.addMolInit(molNameSS)
        pair = feasst.PairLJ(space, 3)  # potential truncation at 3
        pair.initEnergy()
        temperature = 0.9
        criteria = feasst.CriteriaMetropolis(1. / temperature, 1.)
        mc = feasst.MC(space, pair, criteria)
        feasst.transformTrial(mc, "translate", 0.1)
        mc.nMolSeek(nMol)
        mc.initLog("log", int(1e4))
        mc.initMovie("movie", int(1e4))
        mc.initRestart("tmp/rst", int(1e4))
        mc.setNFreqTune(int(1e4))
        mc.runNumTrials(int(1e7))  # run equilibration

        # Run the production simulation and compute statistics on potential energy
        mc.setNFreqTune(0)  # do not tune during production
        pe = feasst.Accumulator()
        from itertools import islice, count
        for itrial in islice(count(1), int(1e7) - 1):
            mc.runNumTrials(1)
            pe.accumulate(pair.peTot() / float(space.nMol()))

        # Check average energy against the NIST SRSW
        # https:#mmlapps.nist.gov/srs/LJ_PURE/mc.htm
        # https:#www.nist.gov/programs-projects/nist-standard-reference-simulation-website
        peAv = pe.average()
        peStd = pe.blockStdev()
        peSRSW = -9.9165E-03
        peSRSWstd = 1.89E-05
        self.assertAlmostEqual(peAv, peSRSW, delta=2.576 * (peSRSWstd + peStd))
示例#6
0
import feasst
space = feasst.makeSpace(feasst.args(
    {"dimen" : "3",                 # 3D space
     "boxLength" : "8"}))           # cubic periodic boundaries
pair = feasst.makePairLJ(space, feasst.args(
    {"rCut" : "3",                  # potential truncation
     "cutType" : "lrc"}))           # long range corrections
criteria = feasst.makeCriteriaMetropolis(feasst.args(
    {"beta" : "1.2"}))              # beta = 1/k_B/T
mc = feasst.MC(pair, criteria)
feasst.addTrialTransform(mc, feasst.args(
    {"transType" : "translate",          # attempt particle translations
     "maxMoveParam" : "0.1"}))   # maximum displacement for each dimension
mc.nMolSeek(50)                     # add particles
mc.initLog("log", int(1e4))         # output instantaneous values
mc.initMovie("movie", int(1e4))     # output xyz trajectory
mc.runNumTrials(int(1e6))           # perform MC trials
示例#7
0
文件: lj.py 项目: ishan111/feasst
 * Harold W. Hatch, [email protected]
 *
 * Permission to use this data/software is contingent upon your acceptance of
 * the terms of LICENSE.txt and upon your providing
 * appropriate acknowledgments of NIST's creation of the data/software.
"""

# # The following three lines are an alternative method to link _feasst.so
# import os, sys
# feasstdir = os.getenv("FEASST_INSTALL_DIR_") + "/build"
# sys.path.append(feasstdir)

import feasst
feasst.ranInitByDate()
space = feasst.makeSpace(3)
space.initBoxLength(8)
space.addMolInit("../forcefield/data.lj")
pair = feasst.PairLJ(space, 3)  # potential truncation at 3
pair.initEnergy()
criteria = feasst.CriteriaMetropolis(1.2, 1.)
# 1/kT = 1.2
mc = feasst.MC(space, pair, criteria)
maxMoveParam = 0.1
feasst.transformTrial(mc, "translate", maxMoveParam)
mc.nMolSeek(50)  # add 50 particles
mc.initLog("log", int(1e4))
mc.initMovie("movie", int(1e4))
mc.runNumTrials(int(1e6))
# mc.initWindows(1)       # initialize parallel windows
# mc.runNumSweeps(1, -1)  # run until all windows sweep once