ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
atoms.set_calculator(EMT())<br />
# Set the momenta corresponding to T=300K<br />
MaxwellBoltzmannDistribution(atoms, 300*units.kB)<br />
<strong>ASE</strong> <strong>Manual</strong>, <strong>Release</strong> 3.6.1.2828<br />
# We want to run MD with constant energy using the VelocityVerlet algorithm.<br />
dyn = VelocityVerlet(atoms, 5*units.fs) # 5 fs time step.<br />
#Function to print the potential, kinetic and total energy<br />
def printenergy(a):<br />
epot = a.get_potential_energy() / len(a)<br />
ekin = a.get_kinetic_energy() / len(a)<br />
print ("Energy per atom: Epot = %.3feV Ekin = %.3feV (T=%3.0fK) Etot = %.3feV" %<br />
(epot, ekin, ekin/(1.5*units.kB), epot+ekin))<br />
# Now run the dynamics<br />
printenergy(atoms)<br />
for i in range(20):<br />
dyn.run(10)<br />
printenergy(atoms)<br />
Note how the total energy is conserved, but the kinetic energy quickly drops to half the expected value. Why?<br />
Instead of printing within a loop, it is possible to use an “observer” to observe the atoms and do the printing (or<br />
more sophisticated analysis).<br />
"Demonstrates molecular dynamics with constant energy."<br />
from ase.calculators.emt import EMT<br />
from ase.lattice.cubic import FaceCenteredCubic<br />
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution<br />
from ase.md.verlet import VelocityVerlet<br />
from ase import units<br />
# Use Asap for a huge performance increase if it is installed<br />
useAsap = True<br />
if useAsap:<br />
from asap3 import EMT<br />
size = 10<br />
else:<br />
size = 3<br />
# Set up a crystal<br />
atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]], symbol="Cu",<br />
size=(size,size,size), pbc=True)<br />
# Describe the interatomic interactions with the Effective Medium Theory<br />
atoms.set_calculator(EMT())<br />
# Set the momenta corresponding to T=300K<br />
MaxwellBoltzmannDistribution(atoms, 300*units.kB)<br />
# We want to run MD with constant energy using the VelocityVerlet algorithm.<br />
dyn = VelocityVerlet(atoms, 5*units.fs) # 5 fs time step.<br />
#Function to print the potential, kinetic and total energy.<br />
def printenergy(a=atoms): #store a reference to atoms in the definition.<br />
epot = a.get_potential_energy() / len(a)<br />
ekin = a.get_kinetic_energy() / len(a)<br />
print ("Energy per atom: Epot = %.3feV Ekin = %.3feV (T=%3.0fK) Etot = %.3feV" %<br />
(epot, ekin, ekin/(1.5*units.kB), epot+ekin))<br />
6.2. <strong>ASE</strong> 39