Пример #1
0
disl = Dislocation(center, atoms.MillerToDirection((1, 1, 0)),
                   atoms.MillerToDirection((1, 1, 0)) / 2.0)

#atoms = ListOfAtoms(slab)
disl.ApplyTo(atoms)

atoms.SetCalculator(EMT(EMTRasmussenParameters()))

# Constant temperatur dynamics
dyn = Langevin(atoms, 5 * femtosecond, 300 * kB, 0.002)

# Run Common Neighbor Analysis on each n_output timestep, using the
# positions averaged over the last n_avg timesteps, and writing the
# result to the output file.
avg = TimeAveragedPositions(atoms, n_avg, n_output)
dyn.Attach(avg)
cna = RestrictedCNA(avg, verbose=1)
avg.Attach(cna)

# We output and plot the instantaneous positions.  Replace atoms with
# avg to output and plot the averaged positions instead.
plotlog = open("plot.log", "w")
plotter = PrimiPlotter(atoms, verbose=1)
plotter.SetOutput(PostScriptFile("cna_plot"))
plotter.SetOutput(GifFile("cna_plot"))
plotter.SetLog(plotlog)

# Only plot atoms in the dislocation.


def invis(a):
Пример #2
0
                            silent=True)
        ReportTest.BoolTest("Overflow (%d)" % (self.n, ),
                            max(rs) <= 1.0,
                            silent=True)
        print "Ekin =", atoms.GetKineticEnergy() / len(atoms), min(rs), max(rs)


PrintVersion(1)

atoms = FaceCenteredCubic(directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                          size=(20, 10, 4),
                          element='Cu',
                          periodic=(1, 1, 1))
atoms.SetCalculator(EMT())
dyn = Langevin(atoms, 5 * femtosecond, 3000 * kB, 0.05)
dyn.Attach(Check(atoms))
dyn.Run(100)

r = matrixmultiply(atoms.GetCartesianPositions(),
                   inverse(atoms.GetUnitCell())).flat
print min(r), max(r)
atoms2 = ListOfAtoms(atoms)
atoms2.SetCartesianPositions(2 * atoms2.GetCartesianPositions() - 4.0)
atoms2.SetCalculator(EMT())
r = matrixmultiply(atoms2.GetCartesianPositions(),
                   inverse(atoms2.GetUnitCell())).flat
print min(r), max(r)
Check(atoms2).Update()

ReportTest.Summary()
Пример #3
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))
Пример #4
0
# 1-Angstrom-cube unit cell.

atoms = ListOfAtoms(positions=positions, cell=[max(positions[:,0]),
                                               max(positions[:,1]),
                                               max(positions[:,2])])
atoms.SetAtomicNumbers(element)

# Now the standard EMT Calculator is attached
atoms.SetCalculator(EMT())

# Make an object doing Langevin dynamics at a temperature of 800 K
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)