当前位置: 首页>>代码示例>>Python>>正文


Python FaceCenteredCubic.set_cell方法代码示例

本文整理汇总了Python中ase.lattice.cubic.FaceCenteredCubic.set_cell方法的典型用法代码示例。如果您正苦于以下问题:Python FaceCenteredCubic.set_cell方法的具体用法?Python FaceCenteredCubic.set_cell怎么用?Python FaceCenteredCubic.set_cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ase.lattice.cubic.FaceCenteredCubic的用法示例。


在下文中一共展示了FaceCenteredCubic.set_cell方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: relax

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
def relax(input_atoms, ref_db):
    atoms_string = input_atoms.get_chemical_symbols()

    # Open connection to the database with reference data
    db = connect(ref_db)

    # Load our model structure which is just FCC
    atoms = FaceCenteredCubic('X', latticeconstant=1.)
    atoms.set_chemical_symbols(atoms_string)

    # Compute the average lattice constant of the metals in this individual
    # and the sum of energies of the constituent metals in the fcc lattice
    # we will need this for calculating the heat of formation
    a = 0
    ei = 0
    for m in set(atoms_string):
        dct = db.get(metal=m)
        count = atoms_string.count(m)
        a += count * dct.latticeconstant
        ei += count * dct.energy_per_atom
    a /= len(atoms_string)
    atoms.set_cell([a, a, a], scale_atoms=True)

    # Since calculations are extremely fast with EMT we can also do a volume
    # relaxation
    atoms.set_calculator(EMT())
    eps = 0.05
    volumes = (a * np.linspace(1 - eps, 1 + eps, 9))**3
    energies = []
    for v in volumes:
        atoms.set_cell([v**(1. / 3)] * 3, scale_atoms=True)
        energies.append(atoms.get_potential_energy())

    eos = EquationOfState(volumes, energies)
    v1, ef, B = eos.fit()
    latticeconstant = v1**(1. / 3)

    # Calculate the heat of formation by subtracting ef with ei
    hof = (ef - ei) / len(atoms)

    # Place the calculated parameters in the info dictionary of the
    # input_atoms object
    input_atoms.info['key_value_pairs']['hof'] = hof
    
    # Raw score must always be set
    # Use one of the following two; they are equivalent
    input_atoms.info['key_value_pairs']['raw_score'] = -hof
    # set_raw_score(input_atoms, -hof)
    
    input_atoms.info['key_value_pairs']['latticeconstant'] = latticeconstant

    # Setting the atoms_string directly for easier analysis
    atoms_string = ''.join(input_atoms.get_chemical_symbols())
    input_atoms.info['key_value_pairs']['atoms_string'] = atoms_string
开发者ID:rosswhitfield,项目名称:ase,代码行数:56,代码来源:ga_fcc_alloys_relax.py

示例2: test_stress

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
    def test_stress(self):
        a = FaceCenteredCubic('Au', size=[2,2,2])
        calc = EAM('Au-Grochola-JCP05.eam.alloy')
        a.set_calculator(calc)
        self.assertArrayAlmostEqual(a.get_stress(), calc.calculate_numerical_stress(a), tol=self.tol)

        sx, sy, sz = a.cell.diagonal()
        a.set_cell([sx, 0.9*sy, 1.2*sz], scale_atoms=True)
        self.assertArrayAlmostEqual(a.get_stress(), calc.calculate_numerical_stress(a), tol=self.tol)

        a.set_cell([[sx, 0.1*sx, 0], [0, 0.9*sy, 0], [0, -0.1*sy, 1.2*sz]], scale_atoms=True)
        self.assertArrayAlmostEqual(a.get_stress(), calc.calculate_numerical_stress(a), tol=self.tol)
开发者ID:libAtoms,项目名称:matscipy,代码行数:14,代码来源:eam_calculator.py

示例3: MakeAtoms

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
def MakeAtoms(elem1, elem2=None):
    if elem2 is None:
        elem2 = elem1
    a1 = reference_states[elem1]['a']
    a2 = reference_states[elem2]['a']
    a0 = (0.5 * a1**3 + 0.5 * a2**3)**(1.0/3.0) * 1.03
    if ismaster:
        print "Z1 = %i,  Z2 = %i,  a0 = %.5f" % (elem1, elem2, a0)
    # 50*50*50 would be big enough, but some vacancies are nice.
    atoms = FaceCenteredCubic(symbol='Cu', size=(51,51,51))
    nremove = len(atoms) - 500000
    assert nremove > 0
    remove = np.random.choice(len(atoms), nremove, replace=False)
    del atoms[remove]
    if elem1 != elem2:
        z = atoms.get_atomic_numbers()
        z[np.random.choice(len(atoms), len(atoms)/2, replace=False)] = elem2
        atoms.set_atomic_numbers(z)
    if isparallel:
        # Move this contribution into position
        uc = atoms.get_cell()
        x = mpi.world.rank % cpuLayout[0]
        y = (mpi.world.rank // cpuLayout[0]) % cpuLayout[1]
        z = mpi.world.rank // (cpuLayout[0] * cpuLayout[1])
        assert(0 <= x < cpuLayout[0])
        assert(0 <= y < cpuLayout[1])
        assert(0 <= z < cpuLayout[2])
        offset = x * uc[0] + y * uc[1] + z * uc[2]
        new_uc = cpuLayout[0] * uc[0] + cpuLayout[1] * uc[1] + cpuLayout[2] * uc[2]
        atoms.set_cell(new_uc, scale_atoms=False)
        atoms.set_positions(atoms.get_positions() + offset)
        # Distribute atoms. Maybe they are all on the wrong cpu, but that will
        # be taken care of.
        atoms = MakeParallelAtoms(atoms, cpuLayout)
    MaxwellBoltzmannDistribution(atoms, T * units.kB)
    return atoms
开发者ID:auag92,项目名称:n2dm,代码行数:38,代码来源:OpenKIM_ParTiming.py

示例4: connect

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
from ase.lattice.cubic import FaceCenteredCubic
from ase.calculators.emt import EMT
from ase.utils.eos import EquationOfState
from ase.db import connect

db = connect('refs.db')

metals = ['Al', 'Au', 'Cu', 'Ag', 'Pd', 'Pt', 'Ni']
for m in metals:
    atoms = FaceCenteredCubic(m)
    atoms.set_calculator(EMT())
    e0 = atoms.get_potential_energy()
    a = atoms.cell[0][0]

    eps = 0.05
    volumes = (a * np.linspace(1 - eps, 1 + eps, 9))**3
    energies = []
    for v in volumes:
        atoms.set_cell([v**(1. / 3)] * 3, scale_atoms=True)
        energies.append(atoms.get_potential_energy())

    eos = EquationOfState(volumes, energies)
    v1, e1, B = eos.fit()

    atoms.set_cell([v1**(1. / 3)] * 3, scale_atoms=True)
    ef = atoms.get_potential_energy()

    db.write(atoms, metal=m,
             latticeconstant=v1**(1. / 3),
             energy_per_atom=ef / len(atoms))
开发者ID:PHOTOX,项目名称:fuase,代码行数:32,代码来源:ga_fcc_references.py

示例5: range

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
        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
        cell = atoms.get_cell()
        atoms.set_cell(cell * (1.0 + dv/3.0))

    T = atoms.get_kinetic_energy() / (1.5 * atoms.get_number_of_atoms() * units.kB)
    print "Temperature is now %.2f K" % (T,)

    stressstate = array([-2, -1, 0, 0, 0, 0])*p_goal*units.GPa
    dyn = NPT(atoms, 5 * units.fs, T_goal*units.kB, stressstate,
              ttime*units.fs, (ptime*units.fs)**2 * bulk * units.GPa)
    traj = PickleTrajectory("NPT-atoms.traj", "w", atoms)
    #dyntraj = ParallelHooverNPTTrajectory("NPT-dyn-traj.nc", dyn, interval = 50)
    dyn.attach(traj, interval=50)
    #dyn.Attach(dyntraj)

    out = open(out1, "w")

    temp = []
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:parallelNPT.py

示例6: set_verbose

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
from asap3 import *
from ase.lattice.cubic import FaceCenteredCubic
import numpy as np

set_verbose(1)

#AsapThreads()

n = 100

atoms = FaceCenteredCubic(symbol='Cu', size=(10,10,10))
atoms.set_calculator(EMT())
uc = atoms.get_cell()
for i in range(n+1):
    factor = float(n - i) / n
    print "Squeeze factor", factor
    uc2 = np.array(uc)
    uc2[2,2] *= factor
    atoms.set_cell(uc2, scale_atoms=True)
    #nbl = NeighborList(10.0, atoms)
    print atoms.get_potential_energy()
    
    
开发者ID:auag92,项目名称:n2dm,代码行数:23,代码来源:Squeeze.py

示例7: print

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
a1=np.array([0,1,1])
d1=np.cross(a1,d3)
a2=np.array([0,-1,1])
d2=np.cross(a2,d3)

#create your slab
slab  =FaceCenteredCubic(directions=[d1,d2,d3],
                         size=(2,1,2),
                         symbol=('Pt'),
                         latticeconstant=3.9)

#add some vacuum to your slab
uc = slab.get_cell()
print(uc)
uc[2] += [0,0,10]  #there are ten layers of vacuum
uc = slab.set_cell(uc,scale_atoms=False)
#view the slab to make sure it is how you expect
view(slab)

#some positions needed to place the atom in the correct place
x1 = 1.379
x2 = 4.137
x3 = 2.759
y1 = 0.0
y2 = 2.238
z1 = 7.165
z2 = 6.439


#Add the adatom to the list of atoms and set constraints of surface atoms.
slab += Atoms('N', [ ((x2+x1)/2,y1,z1+1.5)])
开发者ID:rosswhitfield,项目名称:ase,代码行数:33,代码来源:idpp3.py

示例8: in

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
from asap3 import *
from ase.lattice.cubic import FaceCenteredCubic
from asap3.testtools import ReportTest

print __doc__

for pbc in (True, False, (1,1,0)):
    for scale in (True, False):
        print "Running test with pbc=%s and scale_atoms=%s" % (pbc, scale)
        
        atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]],
                                  size=(6,6,6), symbol="Cu", pbc=pbc)
        atoms.set_calculator(EMT())
        uc = atoms.get_cell()
        atoms.get_potential_energy()
        for factor in (1.0, 1.01, 1.02, 1.1, 1.5, 1.49, 1.4, 1.4, 1.0, 0.9):
            atoms.set_cell(uc * factor, scale_atoms=scale)
            f = atoms.get_forces()
            e = atoms.get_potential_energy()
            atoms2 = Atoms(atoms)
            atoms2.set_calculator(EMT())
            e2 = atoms2.get_potential_energy()
            f2 = atoms2.get_forces()
            name = "(factor = %.3f  PBC = %s  scale_atoms = %s)" % (factor,
                                                                    pbc, scale)
            ReportTest("Energy "+name, e, e2, 1e-6)
            maxf = max(abs(f.flat[:] - f2.flat[:]))
            ReportTest("Forces "+name, maxf, 0.0, 1e-6)

ReportTest.Summary()
开发者ID:auag92,项目名称:n2dm,代码行数:32,代码来源:ChangeUnitCell2.py

示例9: len

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
    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
    cell = atoms.get_cell()
    atoms.set_cell(cell * (1.0 + dv/3.0), scale_atoms=True)
    
T = atoms.get_kinetic_energy() / (1.5 * len(atoms) * units.kB)
print "Temperature is now %.2f K" % (T,)

dyn = NPT(atoms, 5 * units.fs, T_goal * units.kB, p_goal * units.GPa,
          ttime * units.fs, (ptime*units.fs)**2 * bulk * units.GPa)
traj = BundleTrajectory(trajfile, "w", atoms)
dyn.attach(traj, interval=50)

out = open(out1, "w")

temp = []
pres = []
vol = []
for i in xrange(step1):
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:HooverNPT.py

示例10: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
from vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
import numpy as np
import matplotlib.pyplot as plt
DELTAS = np.linspace(-0.05, 0.05, 5)
calcs = []
volumes = []
for delta in DELTAS:
    atoms = FaceCenteredCubic(symbol='Al')
    cell = atoms.cell
    T = np.array([[1 + delta, 0, 0],
                  [0,1, 0],
                  [0, 0, 1]])
    newcell = np.dot(cell, T)
    atoms.set_cell(newcell, scale_atoms=True)
    volumes += [atoms.get_volume()]
    calcs += [Vasp('bulk/Al-c11-{}'.format(delta),
                xc='pbe',
                kpts=[12, 12, 12],
                encut=350,
                atoms=atoms)]
Vasp.run()
energies =  [calc.potential_energy for calc in calcs]
# fit a parabola
eos = np.polyfit(DELTAS, energies, 2)
# first derivative
d_eos = np.polyder(eos)
print(np.roots(d_eos))
xfit = np.linspace(min(DELTAS), max(DELTAS))
yfit = np.polyval(eos, xfit)
plt.plot(DELTAS, energies, 'bo', xfit, yfit, 'b-')
开发者ID:beeruyue,项目名称:dft-book,代码行数:33,代码来源:script-130.py

示例11: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_cell [as 别名]
print "Test for Ticket #11: https://trac.fysik.dtu.dk/projects/Asap/ticket/11"

atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]], size=(6,6,6),
                          symbol="Cu")
atoms.set_calculator(EMT())
r = atoms.get_positions()
print "Orig position", r[-1]

uc = atoms.get_cell()
print uc
r[-1] = 1.51*uc[2]
atoms.set_positions(r)
print atoms.get_potential_energy()

p1 = atoms.get_positions()[-1]
print "p1:", p1

atoms.set_cell(uc, scale_atoms=True)
print atoms.get_potential_energy()
p2  = atoms.get_positions()[-1]
print "p2:", p2

atoms.set_cell(uc, scale_atoms=False)
print atoms.get_potential_energy()
p3 = atoms.get_positions()[-1]
print "p3:", p3

ReportTest("p2 equals p1", p2[2], p1[2], 1e-6)
ReportTest("p3 equals p1", p3[2], p1[2], 1e-6)
ReportTest.Summary()
开发者ID:auag92,项目名称:n2dm,代码行数:32,代码来源:ChangeUnitCell.py


注:本文中的ase.lattice.cubic.FaceCenteredCubic.set_cell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。