本文整理汇总了Python中ase.lattice.cubic.FaceCenteredCubic.get_kinetic_energy方法的典型用法代码示例。如果您正苦于以下问题:Python FaceCenteredCubic.get_kinetic_energy方法的具体用法?Python FaceCenteredCubic.get_kinetic_energy怎么用?Python FaceCenteredCubic.get_kinetic_energy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.lattice.cubic.FaceCenteredCubic
的用法示例。
在下文中一共展示了FaceCenteredCubic.get_kinetic_energy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: targetfunc
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
raise
initr = atoms.get_positions()
initp = atoms.get_momenta()
def targetfunc(params, x):
return params[0] * exp(-params[1] * x) + params[2]
output = file("Langevin.dat", "w")
for temp, frict in ((0.01, 0.001),):
dyn = Langevin(atoms, timestep, temp, frict)
print ""
print "Testing Langevin dynamics with T = %f eV and lambda = %f" % (temp, frict)
ekin = atoms.get_kinetic_energy()/natoms
print ekin
output.write("%.8f\n" % ekin)
temperatures = [(0, 2.0 / 3.0 * ekin)]
a = 0.1
b = frict
c = temp
print "Equilibrating ..."
tstart = time.time()
for i in xrange(1,nequil+1):
dyn.run(nminor)
ekin = atoms.get_kinetic_energy() / natoms
if i % nequilprint == 0:
print "%.6f T = %.6f (goal: %f)" % \
(ekin, 2./3. * ekin, temp)
output.write("%.8f\n" % ekin)
示例2: FaceCenteredCubic
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
from asap3 import Atoms, EMT, units
from ase.lattice.cubic import FaceCenteredCubic
from asap3.md.verlet import VelocityVerlet
# Create the atoms
atoms = FaceCenteredCubic(size=(3,3,3), symbol="Cu", pbc=False)
# Give the first atom a non-zero momentum
atoms[0].set_momentum(array([0, -11.3, 0]))
print "Kinetic energies of all atoms:"
p = atoms.get_momenta()
kinenergies = 0.5 * (p * p).sum(1) / atoms.get_masses()
print kinenergies
# Associate the EMT potential with the atoms
atoms.set_calculator(EMT())
# Now do molecular dynamics, printing kinetic, potential and total
# energy every ten timesteps.
dyn = VelocityVerlet(atoms, 5.0*units.fs)
print ""
print "Energy per atom:"
print " %15s %15s %15s" % ("Pot. energy", "Kin. energy", "Total energy")
for i in range(25):
dyn.run(10)
epot = atoms.get_potential_energy()/len(atoms)
ekin = atoms.get_kinetic_energy()/len(atoms)
print "%15.5f %15.5f %15.5f" % (epot, ekin, epot+ekin)
示例3: hasattr
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
if not hasattr(NPT, '_npt_version'):
print "Skipping test: NP dynamics does not work in parallel with this old version of ASE."
else:
if ismaster:
atoms = FaceCenteredCubic(size=(30,15,15), symbol="Cu", pbc=True)
else:
atoms = None
atoms = MakeParallelAtoms(atoms, cpulayout)
atoms.set_calculator(EMT())
print "Number of atoms:", atoms.get_number_of_atoms()
print "Heating to %d K using Langevin" % T_goal
lgv = Langevin(atoms, 5 * units.fs, temperature=2*T_goal*units.kB, friction=0.05)
while atoms.get_kinetic_energy() < 1.5 * atoms.get_number_of_atoms() * T_goal * units.kB:
lgv.run(5)
T = atoms.get_kinetic_energy() / (1.5 * atoms.get_number_of_atoms() * units.kB)
print "Temperature is now %.2f K" % (T,)
print "Desired temperature reached!"
lgv.set_temperature(T_goal*units.kB)
for i in range(2):
lgv.run(20)
s = atoms.get_stress()
p = -(s[0] + s[1] + s[2])/3.0 / units.GPa
T = atoms.get_kinetic_energy() / (1.5 * atoms.get_number_of_atoms() * units.kB)
print "Pressure is %f GPa, desired pressure is %f GPa (T = %.2f K)" % (p, p_goal, T)
dv = (p - p_goal) / bulk
print "Adjusting volume by", dv
示例4: FaceCenteredCubic
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from ase.lattice.cubic import FaceCenteredCubic
atoms = FaceCenteredCubic(size=(50,50,50), symbol="Cu", pbc=False)
print "Number of atoms:", len(atoms)
MaxwellBoltzmannDistribution(atoms, 0.1)
temp = atoms.get_kinetic_energy() / (1.5 * len(atoms))
print "Temperature", temp, " (should be 0.1)"
assert abs(temp - 0.1) < 1e-3
示例5: MaxwellBoltzmannDistribution
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
atoms.set_calculator(EMT())
MaxwellBoltzmannDistribution(atoms, 3000*units.kB)
if ismaster:
print "Initializing"
e_st_pot = atoms.get_potential_energy()/natoms
try:
e_start_pot = e_start_dict[boundary]
except KeyError:
e_start_pot = e_start_dict[boundary] = e_st_pot
else:
ReportTest("Initial energy ", e_st_pot, e_start_pot, 1e-4,
silent=True)
dyn = VelocityVerlet(atoms, logfile="-", dt=3*units.fs, loginterval=1)
dyn.run(50)
e_start = (atoms.get_potential_energy()
+ atoms.get_kinetic_energy())/natoms
if ismaster:
print "Running"
dyn = VelocityVerlet(atoms, dt=5*units.fs)
logger = MDLogger(dyn, atoms, '-', peratom=True)
logger()
dyn.attach(logger, interval=25)
if writetraj:
if cpulayout is None:
tname = "longVerlet-serial-%d-%d-%d.traj" % tuple(boundary)
else:
tname = ("longVerlet-%d-%d-%d--%d-%d-%d.traj" %
(tuple(cpulayout) + tuple(boundary)))
traj = PickleTrajectory(tname, "w", atoms)
traj.write()
dyn.attach(traj, interval=1000)
示例6: FaceCenteredCubic
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_kinetic_energy [as 别名]
else:
raise RuntimeError, "Expected zero or two parameter to the script!"
#ReportTest.Verbose()
atoms = FaceCenteredCubic(directions=((1,0,0), (0,1,0), (0,0,1)),
size=(15,15,15), symbol="Cu", pbc=True)
atoms.set_calculator(EMT())
print "Number of atoms:", len(atoms)
print "Heating to %d K using Langevin" % T_goal
lgv = Langevin(atoms, 5 * units.fs, temperature=2*T_goal*units.kB,
friction=0.01)
MaxwellBoltzmannDistribution(atoms, 0.9*T_goal*units.kB)
while atoms.get_kinetic_energy() < 1.5 * len(atoms) * T_goal * units.kB:
lgv.run(10)
T = atoms.get_kinetic_energy() / (1.5 * len(atoms) * units.kB)
print "Temperature is now %.2f K" % (T,)
print "Desired temperature reached!"
lgv.set_temperature(T_goal*units.kB)
for i in range(4):
lgv.run(100)
s = atoms.get_stress()
p = -(s[0] + s[1] + s[2])/3.0 / units.GPa
T = atoms.get_kinetic_energy() / (1.5 * len(atoms) * units.kB)
print "Pressure is %f GPa, desired pressure is %f GPa (T = %.2f K)" % (p, p_goal, T)
dv = (p - p_goal) / bulk
print "Adjusting volume by", dv