本文整理汇总了Python中Sire.System.mustNowRecalculateFromScratch方法的典型用法代码示例。如果您正苦于以下问题:Python System.mustNowRecalculateFromScratch方法的具体用法?Python System.mustNowRecalculateFromScratch怎么用?Python System.mustNowRecalculateFromScratch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sire.System
的用法示例。
在下文中一共展示了System.mustNowRecalculateFromScratch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_protein_moves
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_protein_moves(verbose = False):
mols = MoleculeGroup("mols")
for residue in protein.residues():
mols.add(residue)
oldsys = System()
newsys = System()
parsys = System()
oldsys.add(oldff)
oldsys.add(mols)
newsys.add(newff)
newsys.add(mols)
parsys.add(parff)
parsys.add(mols)
moves = RigidBodyMC(mols)
moves.setMaximumTranslation(0.25 * angstrom)
moves.setMaximumRotation(1 * degrees)
moves.enableOptimisedMoves()
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
parsys.mustNowRecalculateFromScratch()
if verbose:
print("\nChecking total system energies...")
_checkEnergies(oldsys, newsys, parsys, verbose)
if verbose:
print("\nChecking system simulation...")
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(oldsys, nmoves, False)
oldns = t.nsecsElapsed()
old_naccept = moves.nAccepted()
old_nreject = moves.nRejected()
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(newsys, nmoves, False)
newns = t.nsecsElapsed()
new_naccept = moves.nAccepted()
new_nreject = moves.nRejected()
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(parsys, nmoves, False)
parns = t.nsecsElapsed()
par_naccept = moves.nAccepted()
par_nreject = moves.nRejected()
if verbose:
print("OLD: accept = %s, reject = %s, time = %s ms" % \
(old_naccept, old_nreject, oldns*0.000001))
print("NEW: accept = %s, reject = %s, time = %s ms" % \
(new_naccept, new_nreject, newns*0.000001))
print("PAR: accept = %s, reject = %s, time = %s ms" % \
(par_naccept, par_nreject, parns*0.000001))
print("\nChecking final total energies...")
_checkEnergies(oldsys, newsys, parsys, verbose)
if verbose:
print("\nRechecking total energies...")
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
parsys.mustNowRecalculateFromScratch()
_checkEnergies(oldsys, newsys, parsys, verbose)
示例2: test_system
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_system(verbose=False):
cljff = InterCLJFF()
mincoords = Vector(-18.3854, -18.66855, -18.4445)
maxcoords = Vector( 18.3854, 18.66855, 18.4445)
vol = PeriodicBox(mincoords, maxcoords)
cljff.setSpace(vol)
mols = PDB().read("../io/water.pdb")
if verbose:
print("Read in %d molecules!" % mols.nMolecules())
i = 0
mol = mols.moleculeAt(0).molecule()
mol = mol.edit().atom( AtomName("O00") ) \
.setProperty("LJ", LJParameter(3.15363*angstrom, \
0.1550*kcal_per_mol)).molecule() \
.atom( AtomName("H01") ) \
.setProperty("charge", 0.520 * mod_electron).molecule() \
.atom( AtomName("H02") ) \
.setProperty("charge", 0.520 * mod_electron).molecule() \
.atom( AtomName("M03") ) \
.setProperty("charge", -1.04 * mod_electron).molecule() \
.commit()
charges = mol.property("charge")
ljs = mol.property("LJ")
cljff.add(mol)
for i in range(1, mols.nMolecules()):
mol = mols.moleculeAt(i).molecule()
mol = mol.edit().setProperty("charge", charges) \
.setProperty("LJ", ljs) \
.commit()
cljff.add(mol)
system = System()
system.add(cljff)
nrg = system.energy()
if verbose:
print("System energy = %s" % (nrg))
copy_system = System(system)
nrg2 = copy_system.energy()
if verbose:
print("Copy energy: %s (should be %s)" % (nrg2,nrg))
assert_almost_equal(nrg.value(), nrg2.value(), 5)
copy_system.mustNowRecalculateFromScratch()
nrg3 = copy_system.energy()
if verbose:
print("Copy energy: %s (should be %s)" % (nrg2,nrg))
assert_almost_equal(nrg.value(), nrg3.value(), 5)
示例3: test_grid_sim
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_grid_sim(verbose = False):
oldsys = System()
newsys = System()
oldsys.add(cluster)
oldsys.add(old_clusterff)
oldsys.add(old_fixedff)
newsys.add(cluster)
newsys.add(new_clusterff)
t = QElapsedTimer()
t.start()
old_total = oldsys.energy().value()
oldns = t.nsecsElapsed()
t.start()
new_total = newsys.energy().value()
newns = t.nsecsElapsed()
ff = newsys[FFName("new_clusterff")]
print(ff.grid())
old_cnrg = oldsys.energy( old_clusterff.components().coulomb() ).value() + \
oldsys.energy( old_fixedff.components().coulomb() ).value()
old_ljnrg = oldsys.energy( old_clusterff.components().lj() ).value() + \
oldsys.energy( old_fixedff.components().lj() ).value()
new_cnrg = newsys.energy( new_clusterff.components().coulomb() ).value()
new_ljnrg = newsys.energy( new_clusterff.components().lj() ).value()
if verbose:
print("OLD: %s %s %s %s : %s ms" % (old_total,old_cnrg+old_ljnrg,old_cnrg,old_ljnrg,
0.000001*oldns))
print("NEW: %s %s %s %s : %s ms" % (new_total,new_cnrg+new_ljnrg,new_cnrg,new_ljnrg,
0.000001*newns))
moves = RigidBodyMC(cluster)
moves.enableOptimisedMoves()
moves.setReflectionSphere( reflect_sphere_center, reflect_sphere_radius )
moves.setGenerator( RanGenerator( 42 ) )
t.start()
moves.move(oldsys, 1000, False)
move_oldns = t.nsecsElapsed()
moves.setGenerator( RanGenerator( 42 ) )
t.start()
moves.move(newsys, 1000, False)
move_newns = t.nsecsElapsed()
t.start()
old_total = oldsys.energy().value()
old_ns = t.nsecsElapsed()
t.start()
new_total = newsys.energy().value()
new_ns = t.nsecsElapsed()
old_cnrg = oldsys.energy( old_clusterff.components().coulomb() ).value() + \
oldsys.energy( old_fixedff.components().coulomb() ).value()
old_ljnrg = oldsys.energy( old_clusterff.components().lj() ).value() + \
oldsys.energy( old_fixedff.components().lj() ).value()
new_cnrg = newsys.energy( new_clusterff.components().coulomb() ).value()
new_ljnrg = newsys.energy( new_clusterff.components().lj() ).value()
if verbose:
print("\nMoves: %s ms vs. %s ms" % (0.000001*move_oldns, 0.000001*move_newns))
print("OLD SYS: %s %s %s %s : %s ms" % (old_total,old_cnrg+old_ljnrg,old_cnrg,old_ljnrg,
0.000001*old_ns))
print("NEW SYS: %s %s %s %s : %s ms" % (new_total,new_cnrg+new_ljnrg,new_cnrg,new_ljnrg,
0.000001*new_ns))
newsys.mustNowRecalculateFromScratch()
oldsys.mustNowRecalculateFromScratch()
t.start()
old_total = oldsys.energy().value()
old_ns = t.nsecsElapsed()
t.start()
new_total = newsys.energy().value()
new_ns = t.nsecsElapsed()
old_cnrg = oldsys.energy( old_clusterff.components().coulomb() ).value() + \
oldsys.energy( old_fixedff.components().coulomb() ).value()
old_ljnrg = oldsys.energy( old_clusterff.components().lj() ).value() + \
oldsys.energy( old_fixedff.components().lj() ).value()
new_cnrg = newsys.energy( new_clusterff.components().coulomb() ).value()
new_ljnrg = newsys.energy( new_clusterff.components().lj() ).value()
if verbose:
print("\nRecalculate energy")
print("OLD SYS: %s %s %s %s : %s ms" % (old_total,old_cnrg+old_ljnrg,old_cnrg,old_ljnrg,
0.000001*old_ns))
print("NEW SYS: %s %s %s %s : %s ms" % (new_total,new_cnrg+new_ljnrg,new_cnrg,new_ljnrg,
0.000001*new_ns))
示例4: test_ligand_moves
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_ligand_moves(verbose = False):
mols = MoleculeGroup("mols")
mols.add(ligand)
oldsys = System()
newsys = System()
parsys = System()
oldsys.add(oldff)
oldsys.add(mols)
newsys.add(newff)
newsys.add(mols)
parsys.add(parff)
parsys.add(mols)
moves = InternalMove(mols)
moves.enableOptimisedMoves()
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
parsys.mustNowRecalculateFromScratch()
if verbose:
print("\nChecking total system energies...")
_checkEnergies(oldsys, newsys, parsys, verbose)
if verbose:
print("\nChecking system simulation...")
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(oldsys, nmoves, False)
oldns = t.nsecsElapsed()
old_naccept = moves.nAccepted()
old_nreject = moves.nRejected()
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(newsys, nmoves, False)
newns = t.nsecsElapsed()
new_naccept = moves.nAccepted()
new_nreject = moves.nRejected()
moves.setGenerator( RanGenerator(42) )
moves.clearStatistics()
t.start()
moves.move(parsys, nmoves, False)
parns = t.nsecsElapsed()
par_naccept = moves.nAccepted()
par_nreject = moves.nRejected()
if verbose:
print("OLD: accept = %s, reject = %s, time = %s ms" % \
(old_naccept, old_nreject, oldns*0.000001))
print("NEW: accept = %s, reject = %s, time = %s ms" % \
(new_naccept, new_nreject, newns*0.000001))
print("PAR: accept = %s, reject = %s, time = %s ms" % \
(par_naccept, par_nreject, parns*0.000001))
print("\nChecking final total energies...")
_checkEnergies(oldsys, newsys, parsys, verbose)
if verbose:
print("\nRechecking total energies...")
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
parsys.mustNowRecalculateFromScratch()
_checkEnergies(oldsys, newsys, parsys, verbose)
示例5: test_sim
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_sim(verbose = False):
oldsys = System()
newsys = System()
oldsys.add(mols)
newsys.add(mols)
oldsys.add(oldff)
newsys.add(newff)
t = QElapsedTimer()
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
t.start()
nrgs = oldsys.energies()
oldns = t.nsecsElapsed()
t.start()
nrgs = newsys.energies()
newns = t.nsecsElapsed()
oldcnrg = oldsys.energy( oldff.components().coulomb() ).value()
oldljnrg = oldsys.energy( oldff.components().lj() ).value()
newcnrg = newsys.energy( newff.components().coulomb() ).value()
newljnrg = newsys.energy( newff.components().lj() ).value()
if verbose:
print("\nStarting energy")
print("OLD SYS: %s %s %s : %s ms" % (oldcnrg+oldljnrg,oldcnrg,oldljnrg,
0.000001*oldns))
print("NEW SYS: %s %s %s : %s ms" % (newcnrg+newljnrg,newcnrg,newljnrg,
0.000001*newns))
moves = RigidBodyMC(mols)
moves.setGenerator( RanGenerator( 42 ) )
moves.enableOptimisedMoves()
t.start()
moves.move(oldsys, nmoves, False)
move_oldns = t.nsecsElapsed()
old_naccepted = moves.nAccepted()
old_nrejected = moves.nRejected()
moves.setGenerator( RanGenerator( 42 ) )
moves.clearStatistics()
t.start()
moves.move(newsys, nmoves, False)
move_newns = t.nsecsElapsed()
new_naccepted = moves.nAccepted()
new_nrejected = moves.nRejected()
t.start()
nrgs = oldsys.energies()
oldns = t.nsecsElapsed()
t.start()
nrgs = newsys.energies()
newns = t.nsecsElapsed()
oldcnrg = oldsys.energy( oldff.components().coulomb() ).value()
oldljnrg = oldsys.energy( oldff.components().lj() ).value()
newcnrg = newsys.energy( newff.components().coulomb() ).value()
newljnrg = newsys.energy( newff.components().lj() ).value()
if verbose:
print("\nMoves: old %s ms vs. new %s ms" % (0.000001*move_oldns, 0.000001*move_newns))
print("OLD SYS: %s %s %s : %s ms" % (oldcnrg+oldljnrg,oldcnrg,oldljnrg,
0.000001*oldns))
print("nAccepted() = %s, nRejected() = %s" % (old_naccepted, old_nrejected))
print("NEW SYS: %s %s %s : %s ms" % (newcnrg+newljnrg,newcnrg,newljnrg,
0.000001*newns))
print("nAccepted() = %s, nRejected() = %s" % (new_naccepted, new_nrejected))
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
t.start()
nrgs = oldsys.energies()
oldns = t.nsecsElapsed()
t.start()
nrgs = newsys.energies()
newns = t.nsecsElapsed()
r_oldcnrg = oldsys.energy( oldff.components().coulomb() ).value()
r_oldljnrg = oldsys.energy( oldff.components().lj() ).value()
r_newcnrg = newsys.energy( newff.components().coulomb() ).value()
r_newljnrg = newsys.energy( newff.components().lj() ).value()
if verbose:
print("\nRecalculated energy")
#.........这里部分代码省略.........
示例6: print
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
system = moves.move(system, 10000, True)
ms = t.elapsed()
print("Done! (took %d ms)" % ms)
system.add( "trajectory", TrajectoryMonitor(solvent), 1000 )
print("Running 10000 moves with saving the trajectory...")
t.start()
system = moves.move(system, 10000, True)
ms = t.elapsed()
print("Done! (took %d ms)" % ms)
print("Writing the trajectory to disk...")
t.start()
system[ MonitorName("trajectory") ].writeToDisk("tempXXXXXX.pdb")
ms = t.elapsed()
print("Took %d ms" % ms)
print("Final energy = %s" % system.energy())
system.mustNowRecalculateFromScratch();
print("Are we sure? = %s" % system.energy())
mc = moves.moves()[0]
print("nAccepted() == %d, nRejected() == %d (%f %%)" % (mc.nAccepted(), \
mc.nRejected(), 100 * mc.acceptanceRatio()))
示例7: test_sim
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_sim(verbose = False):
oldsys = System()
newsys = System()
parsys = System()
oldsys.add(mols)
newsys.add(mols)
parsys.add(mols)
oldsys.add(newff)
newsys.add(newff)
parsys.add(parff)
t = QElapsedTimer()
oldsys.mustNowRecalculateFromScratch()
newsys.mustNowRecalculateFromScratch()
parsys.mustNowRecalculateFromScratch()
t.start()
nrgs = oldsys.energies()
oldns = t.nsecsElapsed()
t.start()
nrgs = newsys.energies()
newns = t.nsecsElapsed()
t.start()
nrgs = parsys.energies()
parns = t.nsecsElapsed()
oldcnrg = oldsys.energy( newff.components().coulomb() ).value()
oldljnrg = oldsys.energy( newff.components().lj() ).value()
newcnrg = newsys.energy( newff.components().coulomb() ).value()
newljnrg = newsys.energy( newff.components().lj() ).value()
parcnrg = parsys.energy( parff.components().coulomb() ).value()
parljnrg = parsys.energy( parff.components().lj() ).value()
if verbose:
print("\nStarting energy")
print("OLD SYS: %s %s %s : %s ms" % (oldcnrg+oldljnrg,oldcnrg,oldljnrg,
0.000001*oldns))
print("NEW SYS: %s %s %s : %s ms" % (newcnrg+newljnrg,newcnrg,newljnrg,
0.000001*newns))
print("PAR SYS: %s %s %s : %s ms" % (parcnrg+parljnrg,parcnrg,parljnrg,
0.000001*parns))
assert_almost_equal( oldcnrg, newcnrg )
assert_almost_equal( oldljnrg, newljnrg )
assert_almost_equal( parcnrg, newcnrg )
assert_almost_equal( parljnrg, newljnrg )
moves = RigidBodyMC(mols)
moves.disableOptimisedMoves()
moves.setGenerator( RanGenerator( 42 ) )
optmoves = RigidBodyMC(mols)
optmoves.enableOptimisedMoves()
optmoves.setGenerator( RanGenerator( 42 ) )
parmoves = RigidBodyMC(mols)
parmoves.enableOptimisedMoves()
parmoves.setGenerator( RanGenerator( 42 ) )
t.start()
moves.move(oldsys, nmoves, False)
move_oldns = t.nsecsElapsed()
old_naccepted = moves.nAccepted()
old_nrejected = moves.nRejected()
t.start()
optmoves.move(newsys, nmoves, False)
move_newns = t.nsecsElapsed()
new_naccepted = optmoves.nAccepted()
new_nrejected = optmoves.nRejected()
t.start()
parmoves.move(parsys, nmoves, False)
move_parns = t.nsecsElapsed()
par_naccepted = parmoves.nAccepted()
par_nrejected = parmoves.nRejected()
t.start()
nrgs = oldsys.energies()
oldns = t.nsecsElapsed()
t.start()
nrgs = newsys.energies()
newns = t.nsecsElapsed()
t.start()
nrgs = parsys.energies()
parns = t.nsecsElapsed()
#.........这里部分代码省略.........
示例8: test_moves
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
def test_moves(verbose = False):
newsys = System()
oldsys = System()
optsys = System()
parsys = System()
res = MoleculeGroup("residues")
protein = mols[ MolWithResID("ALA") ].molecule()
for residue in protein.residues():
res.add(residue)
newsys.add(newff)
oldsys.add(oldff)
optsys.add(newff)
parsys.add(parff)
newsys.add(res)
oldsys.add(res)
optsys.add(res)
parsys.add(res)
moves = RigidBodyMC(res)
moves.disableOptimisedMoves()
moves.setMaximumTranslation( 0.2 * angstrom )
moves.setMaximumRotation( 0.5 * degrees )
opt_moves = RigidBodyMC(res)
opt_moves.enableOptimisedMoves()
opt_moves.setMaximumTranslation( 0.2 * angstrom )
opt_moves.setMaximumRotation( 0.5 * degrees )
t = QElapsedTimer()
if verbose:
print("Calculating initial energy...")
t.start()
oldnrg = oldsys.energy().value()
oldns = t.nsecsElapsed()
t.start()
newnrg = newsys.energy().value()
newns = t.nsecsElapsed()
t.start()
optnrg = optsys.energy().value()
optns = t.nsecsElapsed()
t.start()
parnrg = parsys.energy().value()
parns = t.nsecsElapsed()
if verbose:
print("\nTIMES: old = %s ms, new = %s ms, opt = %s ms, par = %s ms" % \
(oldns*0.000001,newns*0.000001,optns*0.000001,parns*0.000001))
print("\nENERGIES: old = %s, new = %s, opt = %s, par = %s" % \
(oldnrg,newnrg,optnrg,parnrg))
assert_almost_equal( oldnrg, newnrg, 0.5 )
assert_almost_equal( optnrg, newnrg, 0.1 )
assert_almost_equal( parnrg, newnrg, 0.1 )
if verbose:
print("\nPerforming simulation...")
moves.clearStatistics()
moves.setGenerator( RanGenerator(42) )
t.start()
moves.move(oldsys, nmoves, False)
oldns = t.nsecsElapsed()
old_naccept = moves.nAccepted()
old_nreject = moves.nRejected()
oldcnrg = oldsys.energy( oldff.components().coulomb() ).value()
oldljnrg = oldsys.energy( oldff.components().lj() ).value()
oldsys.mustNowRecalculateFromScratch()
check_oldcnrg = oldsys.energy( oldff.components().coulomb() ).value()
check_oldljnrg = oldsys.energy( oldff.components().lj() ).value()
moves.clearStatistics()
moves.setGenerator( RanGenerator(42) )
t.start()
moves.move(newsys, nmoves, False)
newns = t.nsecsElapsed()
new_naccept = moves.nAccepted()
new_nreject = moves.nRejected()
newcnrg = newsys.energy( newff.components().coulomb() ).value()
newljnrg = newsys.energy( newff.components().lj() ).value()
newsys.mustNowRecalculateFromScratch()
check_newcnrg = newsys.energy( newff.components().coulomb() ).value()
check_newljnrg = newsys.energy( newff.components().lj() ).value()
#.........这里部分代码省略.........
示例9: print
# 需要导入模块: from Sire import System [as 别名]
# 或者: from Sire.System import mustNowRecalculateFromScratch [as 别名]
ms = t.elapsed()
print(("Moves complete! Took %d ms" % ms))
print(("GRID: ",grid_system.energies()))
exp_system.update( grid_system.molecules() )
print(("EXPT: ",exp_system.energies()))
print(("\nGrid energy equals: %s. Explicit energy equals: %s." % \
(grid_system.energy(), exp_system.energy())))
diff = grid_system.energy() - exp_system.energy()
print(("The difference is %s\n" % diff))
PDB().write(grid_system.molecules(), "test%0004d.pdb" % (i+10))
print("\nTriggering recalculation from scratch...")
grid_system.mustNowRecalculateFromScratch()
exp_system.mustNowRecalculateFromScratch()
print((grid_system.energies()))
print((exp_system.energies()))
print(("\nGrid energy equals: %s. Explicit energy equals: %s." % \
(grid_system.energy(), exp_system.energy())))
diff = grid_system.energy() - exp_system.energy()
print(("The difference is %s\n" % diff))
for i in range(1,11):
print("Moving the system...")
t.start()
grid_system = moves.move(grid_system, 1000, False)
ms = t.elapsed()