def Compare(name, atoms, observer, ref, interval=4): dyn = VelocityVerlet(atoms, 5*units.fs) dyn.attach(observer, interval=interval) r = [] for i in range(50): dyn.run(5) epot = atoms.get_potential_energy() / len(atoms) ekin = atoms.get_kinetic_energy() / len(atoms) r.append([epot, ekin, epot+ekin]) r = array(r) diff = r - ref maxdiff = diff.max() print "Maximal difference is", maxdiff ReportTest(name, maxdiff, 0.0, 1e-6)
print "Number of atoms:", nTotalAtoms epot = atoms.get_potential_energy() / nTotalAtoms ekin = atoms.get_kinetic_energy() / nTotalAtoms etotallist = [epot+ekin] ekinlist = [ekin] #report() if ismaster: print "\nE_pot = %-12.5f E_kin = %-12.5f E_tot = %-12.5f" % (epot, ekin, epot+ekin) ReportTest("Initial potential energy", epot,-3.4669, 1e-4) ReportTest("Initial kinetic energy", ekin, 0.0, 1e-9) dyn.attach(MDLogger(dyn, atoms, "-", peratom=True), interval=10) for i in range(40): dyn.run(10) epot = atoms.get_potential_energy() / nTotalAtoms ekin = atoms.get_kinetic_energy() / nTotalAtoms etotallist.append(epot+ekin) ekinlist.append(ekin) if ismaster: print "Average total energy:", sum(etotallist)/len(etotallist) print "Average kinetic energy:", sum(ekinlist)/len(ekinlist) ReportTest("Agv. total energy", sum(etotallist)/len(etotallist), -3.4669, 0.0001) ReportTest("Agv. kinetic energy", sum(ekinlist)/len(ekinlist), 0.02165,
""" from numpy import * from asap3 import Atoms, EMT, units, Trajectory 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].momentum = array([0, -11.3, 0]) # 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) # Make a trajectory writing output trajectory = Trajectory("TrajectoryMD-output.traj", "w", atoms) # Attach it to the dynamics, so it is informed every fifth time a # timestep is made. dyn.attach(trajectory, interval=5) # Now do 1000 timesteps. dyn.run(1000) print "The output is in the ASE Trajectory file TrajectoryMD-output.traj"
from numpy import * from asap3 import Atoms, EMT, units from ase.visualize.primiplotter import * 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])) # 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) # Set up a plotter plotter = PrimiPlotter(atoms) plotter.set_output(X11Window()) # Attach it to the dynamics, so it is informed every 25'th time a # timestep is made. dyn.attach(plotter.plot, interval=25) # Now do 1000 timesteps. dyn.run(1000) print "The output is in the NetCDF file TrajectoryMD-output.traj"
from ase.visualize.primiplotter import * 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].momentum = array([0, -11.3, 0]) # 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) # Set up a plotter plotter = PrimiPlotter(atoms) plotter.set_output(X11Window()) # Plot in X11 window on the user's screen plotter.set_output(JpegFile("a")) # Save as GIF files # plotter.set_output(PostScriptFile("a")) # Save as PS files # Attach it to the dynamics, so it is informed every 25'th time a # timestep is made. dyn.attach(plotter.plot, interval=25) # Now do 1000 timesteps. dyn.run(1000) print "The output is in the NetCDF file TrajectoryMD-output.traj"
from numpy import * from asap3 import Atoms, EMT, units, PickleTrajectory 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])) # 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) # Make a trajectory writing output trajectory = PickleTrajectory("TrajectoryMD-output.traj", "w", atoms) # Attach it to the dynamics, so it is informed every fifth time a # timestep is made. dyn.attach(trajectory, interval=5) # Now do 1000 timesteps. dyn.run(1000) print "The output is in the NetCDF file TrajectoryMD-output.traj"