Пример #1
0
        for k in range(N):
            pos.append((i, j, k))
            pos.append((i, j + 0.5, k + 0.5))
            pos.append((i + 0.5, j, k + 0.5))
            pos.append((i + 0.5, j + 0.5, k))
pos = array(pos) * latconst
supercell = [N * latconst, N * latconst, N * latconst]

# Create the atoms object
atoms = ListOfAtoms(positions=pos, cell=supercell)
atoms.SetAtomicNumbers(Z)

# The dynamics
atoms.SetCalculator(EMT())  # Use the EMT potential
dyn = Langevin(atoms, 5 * femtosecond, 800 * kB, 0.002)

# Output to NetCDF file
trajectory = NetCDFTrajectory("output.nc", atoms, interval=2000)
dyn.Attach(trajectory)

# Do the dynamics
for i in range(100):
    if i == 50:
        dyn.SetTemperature(2000 * kB)
        print "Setting temperature to 2000K"
    dyn.Run(100)
    print "Ekin = %.5f   Epot = %.5f  Etot = %.5f" % \
          (atoms.GetKineticEnergy()/len(atoms),
           atoms.GetPotentialEnergy()/len(atoms),
           (atoms.GetKineticEnergy()+atoms.GetPotentialEnergy())/len(atoms))
Пример #2
0
cna.Attach(plotter)

# We output and plot the instantaneous positions.  Replace atoms with
# avg to output and plot the averaged positions instead.
plotter = FieldPlotter(atoms, atoms.GetTags, verbose=1)
plotter.SetBlackWhiteColors(reverse=True)
plotter.SetDataRange('plot')
plotter.SetOutput(PostScriptFile("bwplot"))
plotter.SetOutput(GifFile("bwplot"))
plotter.SetLog(plotlog)

cna.Attach(plotter)

# Run the simulation
dyn.Run(n_total)

plotlog.close()

if cleanup:
    print "Removing output files"
    print "Deleting plot.log"
    os.unlink("plot.log")
    for name in ("cna_plot", "fieldplot", "bwplot"):
        for num in ("0000", "0001"):
            for ending in (".ps", ".gif"):
                fn = name + num + ending
                print "Deleting", fn
                os.unlink(fn)

print
Пример #3
0
dyn = Langevin(atoms, dt=5*femtosecond, temperature=800*kB, friction=0.005)

# Make a trajectory
traj = NetCDFTrajectory('MD_Cluster.nc', atoms, interval=500)
dyn.Attach(traj)

# Write the initial configuration
traj.Update()

# Print the energies
def printenergy(a, step=[0,]):
    n = len(a)
    ekin = a.GetKineticEnergy() / n
    epot = a.GetPotentialEnergy() / n
    print ("%4d: E_kin = %-9.5f  E_pot = %-9.5f  E_tot = %-9.5f  T = %.1f K" %
           (step[0], ekin, epot, ekin+epot, 2.0/3.0*ekin/kB))
    step[0] += 1
          
printenergy(atoms)

# Now do the dynamics, doing 5000 timesteps, writing energies every 50 steps
for major in range(100):
    dyn.Run(50)
    printenergy(atoms)

# Now increase the temperature to 2000 K and continue
dyn.SetTemperature(2000 * kB)
for major in range(100):
    dyn.Run(50)
    printenergy(atoms)