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


Python FaceCenteredCubic.set_calculator方法代码示例

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


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

示例1: relax

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [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_calculator [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: MakeCu

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
def MakeCu(T=300, size=(29,29,30)):
    print "Preparing", T, "K Copper system."
    atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]],
                              symbol='Cu', size=size)
    atoms.set_calculator(EMT())
    MaxwellBoltzmannDistribution(atoms, 2*T * units.kB)
    #dyn = VelocityVerlet(atoms, 5*units.fs)
    dyn = Langevin(atoms, 5*units.fs, T*units.kB, 0.05)
    dyn.run(50)
    print "Done.  Temperature =", temperature(atoms), \
          "K.  Number of atoms: ", len(atoms)
    return atoms
开发者ID:auag92,项目名称:n2dm,代码行数:14,代码来源:OfficialTiming.py

示例4: test_Grochola

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
 def test_Grochola(self):
     a = FaceCenteredCubic('Au', size=[2,2,2])
     calc = EAM('Au-Grochola-JCP05.eam.alloy')
     a.set_calculator(calc)
     FIRE(StrainFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
     a0 = a.cell.diagonal().mean()/2
     self.assertTrue(abs(a0-4.0701)<2e-5)
     self.assertTrue(abs(a.get_potential_energy()/len(a)+3.924)<0.0003)
     C, C_err = fit_elastic_constants(a, symmetry='cubic', verbose=False)
     C11, C12, C44 = Voigt_6x6_to_cubic(C)
     self.assertTrue(abs((C11-C12)/GPa-32.07)<0.7)
     self.assertTrue(abs(C44/GPa-45.94)<0.5)
开发者ID:libAtoms,项目名称:matscipy,代码行数:14,代码来源:eam_calculator.py

示例5: test_CuZr

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
    def test_CuZr(self):
        # This is a test for the potential published in:
        # Mendelev, Sordelet, Kramer, J. Appl. Phys. 102, 043501 (2007)
        a = FaceCenteredCubic('Cu', size=[2,2,2])
        calc = EAM('CuZr_mm.eam.fs', kind='eam/fs')
        a.set_calculator(calc)
        FIRE(StrainFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
        a_Cu = a.cell.diagonal().mean()/2
        #print('a_Cu (3.639) = ', a_Cu)
        self.assertAlmostEqual(a_Cu, 3.639, 3)

        a = HexagonalClosedPacked('Zr', size=[2,2,2])
        a.set_calculator(calc)
        FIRE(StrainFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
        a, b, c = a.cell/2
        #print('a_Zr (3.220) = ', norm(a), norm(b))
        #print('c_Zr (5.215) = ', norm(c))
        self.assertAlmostEqual(norm(a), 3.220, 3)
        self.assertAlmostEqual(norm(b), 3.220, 3)
        self.assertAlmostEqual(norm(c), 5.215, 3)

        # CuZr3
        a = L1_2(['Cu', 'Zr'], size=[2,2,2], latticeconstant=4.0)
        a.set_calculator(calc)
        FIRE(UnitCellFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
        self.assertAlmostEqual(a.cell.diagonal().mean()/2, 4.324, 3)

        # Cu3Zr
        a = L1_2(['Zr', 'Cu'], size=[2,2,2], latticeconstant=4.0)
        a.set_calculator(calc)
        FIRE(UnitCellFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
        self.assertAlmostEqual(a.cell.diagonal().mean()/2, 3.936, 3)

        # CuZr
        a = B2(['Zr', 'Cu'], size=[2,2,2], latticeconstant=3.3)
        a.set_calculator(calc)
        FIRE(UnitCellFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.001)
        self.assertAlmostEqual(a.cell.diagonal().mean()/2, 3.237, 3)
开发者ID:libAtoms,项目名称:matscipy,代码行数:40,代码来源:eam_calculator.py

示例6: range

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
            for j in range(3):
                if i != j and np.abs(uc[i,j]) > 1e-15:
                    diagonal = False  
        if not (self.allow_mi_opbc and atoms.get_pbc().all() and diagonal):
            # Minimum Image Orthogonal Periodic Boundary Conditions
            # are not allowed
            remove.extend(["MI_OPBC_H", "MI_OPBC_F"])
        if  atoms.get_pbc().any():
            # Cluster method is not allowed
            remove.append("CLUSTER")
        for rem in remove:
            if rem in allowed:
                allowed.remove(rem)
        if self.verbose:
            print "Allowed PBC:", allowed
        return allowed
    
if __name__ == '__main__':
    from ase.lattice.cubic import FaceCenteredCubic
    atoms = FaceCenteredCubic(size=(10,10,10), symbol='Cu')
    print "Creating calculator"
    pot = OpenKIMcalculator('EMT_Asap_Standard_AlAgAuCuNiPdPt__MO_118428466217_000')
    print "Setting atoms"
    atoms.set_calculator(pot)
    print "Calculating energy"
    print atoms.get_potential_energy()
    print atoms.get_forces()[10:]
    print atoms.get_stress()
    
    
    
开发者ID:auag92,项目名称:n2dm,代码行数:30,代码来源:OpenKIMcalculator.py

示例7: AsapThreads

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
lasttime = targettime
results = {}
for nthreads in threads:
    try:
        AsapThreads(nthreads)
    except ValueError:
        break
    maxthread = nthreads
    for natoms in sizes:
        print "Timing with %i atoms (%i threads)" % (natoms, nthreads)
        blocksize = int(np.ceil((natoms/4)**(1./3.)))
        atoms = FaceCenteredCubic(symbol='Cu', size=(blocksize,blocksize,blocksize), pbc=False)
        print "Creating block with %i atoms, cutting to %i atoms" % (len(atoms), natoms)
        atoms = atoms[:natoms]
        assert len(atoms) == natoms
        atoms.set_calculator(EMT())
        MaxwellBoltzmannDistribution(atoms, 2 * T * units.kB)
        dyn = VelocityVerlet(atoms, 5*units.fs)
        ptsteps = int(laststeps * (0.1 * targettime / lasttime) * lastsize / natoms)
        if ptsteps < 100:
            ptsteps = 100
        print "Running pre-timing (%i steps)..." % (ptsteps,)
        t1 = time.time()
        dyn.run(ptsteps - 50)
        MaxwellBoltzmannDistribution(atoms, (2 * T - atoms.get_temperature()) * units.kB)
        dyn.run(50)
        t1 = time.time() - t1
        steps = int(ptsteps * targettime / t1)
        if steps < 200:
            steps = 200 
        print "Temperature is %.1f K" % (atoms.get_temperature(),)
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:TimingMatrix.py

示例8: FaceCenteredCubic

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

from ase.constraints import UnitCellFilter
from ase.lattice.cubic import FaceCenteredCubic
from ase.optimize import FIRE
from ase.utils.eos import EquationOfState

from atomistica import TabulatedAlloyEAM

###

n = 2
a = FaceCenteredCubic('Au', size=[n, n, n])
x0 = a.cell[0, 0]/n
c = TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy')
a.set_calculator(c)

# Vary volume and fit minimum
def en(a, x):
	a.set_cell([x, x, x], scale_atoms=True)
	return a.get_potential_energy()
x = np.linspace(0.9*x0, 1.1*x0, 101)
e = [ en(a, n*_x)/(n**3) for _x in x ]
eos = EquationOfState(x**3, e)
v0, e0, B = eos.fit()

print 'lattice constant (from equation of state) =', v0**(1./3)

# Keep cell rectangular during optimization
FIRE(UnitCellFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.0001)
开发者ID:Atomistica,项目名称:atomistica,代码行数:32,代码来源:fcc.py

示例9: print_version

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
elif world.size == 3:
    cpulayout = [1,3,1]
elif world.size == 4:
    cpulayout = [1,2,2]

print_version(1)

if ismaster:
    atoms = FaceCenteredCubic(size=(2,10,10), symbol="Cu", pbc=False,
                              latticeconstant = 3.5)
else:
    atoms = None

if isparallel:
    atoms = MakeParallelAtoms(atoms, cpulayout)
atoms.set_calculator(asap3.EMT())
natoms = atoms.get_number_of_atoms()
    
ReportTest("Number of atoms", natoms, 800, 0)

# Make a small perturbation of the momenta
atoms.set_momenta(1e-6 * random.random([len(atoms), 3]))
print "Initializing ..."
predyn = VelocityVerlet(atoms, 0.5)
try:
    predyn.run(2500)
except:
    print atoms.arrays['positions']
    print atoms.arrays['momenta']
    print atoms.arrays['momenta'].shape
    print atoms.get_masses()
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:parallelLangevin.py

示例10: Vasp

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
from ase.calculators.vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
from ase.io import write
calc = Vasp(xc='PBE', kpts=(3,3,3), ismear=0, sigma=0.1, ediff=1e-10, lcharg=False, lwave=False, encut=400,
            nelmin=4, nelmdl=6, ispin=1,lvdw=True, vdw_version=3,isif=3,ibrion=1,nsw=500)

#a = 5.0
#c = 3.5
#iro2 = crystal(['Ir', 'O'], basis=[(0,0,0), (0.3,0.3,0)], cellpar=[a, a, c, 90, 90, 90], spacegroup=136)
#FCC

Cell = FaceCenteredCubic(symbol='Ag') 
Cell.set_calculator(calc)

calc.initialize(Cell)
calc.write_incar(Cell)
calc.write_potcar()
calc.write_kpoints()
write('POSCAR', calc.atoms_sorted)  # this will write a "sorted" POSCAR


#sf = StrainFilter(Cell)

#opt = LBFGS(sf, trajectory=traj('atom-cell.traj', 'w', Cell))
#opt.run(fmax=0.01)

#opt = LBFGS(Cell, trajectory=traj('atom.traj', 'w', Cell))
#opt.run(fmax=0.01)

开发者ID:JLans,项目名称:ASE_Scripts,代码行数:30,代码来源:lattice.py

示例11: test_mask_decomposition_tabulated_alloy_eam

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
 def test_mask_decomposition_tabulated_alloy_eam(self):
     a = FaceCenteredCubic('Au', size=[2,2,2])
     c = TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy')
     a.set_calculator(c)
     self.random_mask_test(a)
开发者ID:Atomistica,项目名称:atomistica,代码行数:7,代码来源:mask.py

示例12: test_mask_decomposition_lj_cut

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
 def test_mask_decomposition_lj_cut(self):
     a = FaceCenteredCubic('Au', size=[2,2,2])
     c = LJCut(el1='Au', el2='Au', epsilon=1.0, sigma=1.0, cutoff=6.0)
     a.set_calculator(c)
     self.random_mask_test(a)
开发者ID:Atomistica,项目名称:atomistica,代码行数:7,代码来源:mask.py

示例13: len

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
        a.set_cell(newcell, scale_atoms=True)
        #if len(v) > 1:
        #    print "fmin: %.4f  %7.4f  %8.4f  %8.4f" % (v[0], v[1], a.get_positions()[1792,2], a.get_potential_energy())
        return a.get_potential_energy()
    xopt, fopt, iter, calls, flag = fmin(energy, var, delta=0.01, full_output=True, disp=False)
    #print "Minimize unit cell:", xopt, fopt, iter, calls

if __name__ == '__main__':
    from asap3 import EMT, units, EMThcpParameters
    from ase.lattice.cubic import FaceCenteredCubic
    from ase.lattice.hexagonal import HexagonalClosedPacked
    
    print "Calculating cubic constants for Cu"
    atoms = FaceCenteredCubic(size=(5,5,5), symbol='Cu', 
                              latticeconstant=3.59495722231)
    atoms.set_calculator(EMT())
    e = ElasticConstants(atoms, 'cubic')
    print np.array(e) / units.GPa
    
    print "Pretending that Cu is hexagonal"
    e = ElasticConstants(atoms, 'hexagonal', sanity=False)
    print np.array(e) / units.GPa
    
    print "Calculating elastic constants for Ru"
    atoms = HexagonalClosedPacked(size=(5,5,5), symbol='Ru',
                                  directions=[[1,-2,1,0], 
                                              [1,0,-1,0],
                                              [0,0,0,1]])
    atoms.set_calculator(EMT(EMThcpParameters()))
    e = ElasticConstants(atoms, 'hexagonal', minimize=True)
    print np.array(e) / units.GPa
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:ElasticConstants.py

示例14: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
"""Check that energy is correct even after wrapping through periodic boundary conditions.
"""

from ase.lattice.cubic import FaceCenteredCubic
from asap3 import *
from asap3.testtools import *
import random

ref_atoms = FaceCenteredCubic(size=(7,7,7), symbol="Cu", pbc=(True, False, True))
ref_atoms.set_calculator(EMT())

ref_energy = ref_atoms.get_potential_energy()
ref_energies = ref_atoms.get_potential_energies()
ref_forces = ref_atoms.get_forces()

passes = 5
for ps in range(passes):
    print "Pass", ps, "of", passes

    atoms = ref_atoms.copy()
    atoms.set_calculator(EMT())
    nat = random.randint(0, len(atoms))
    assert nat < len(atoms)
    pos0 = atoms[nat].position
    cell = atoms.get_cell()
    for d in range(1,4):
        for dx in (-d, 0, d):
            #for dy in (-d, 0, d):
            for dy in (0,):
                for dz in (-d, 0 ,d):
                    deltar = dx * cell[0] + dy * cell[1] + dz * cell[2]
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:PBCwrap.py

示例15: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import set_calculator [as 别名]
#nsteps = 5000
nprint = 50000
nequil = 100000
nminor = 25
nequilprint = 200
tolerance = 0.01
timestep = 5 # fs
frict = 0.001
temp = 100 # K
repeats = 5

# Set up atoms in a regular simple-cubic lattice.
initial = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]],
                            size = (1,5,5), symbol="Cu", latticeconstant=3.5,
                            pbc=False, debug=0)
initial.set_calculator(EMT())
    
ReportTest("Number of atoms", len(initial), 100, 0)

# Make a small perturbation of the momenta
initial.set_momenta(1e-6 * np.random.normal(size=[len(initial), 3]))
print "Initializing (1) ..."
predyn = VelocityVerlet(initial, 0.5)
predyn.run(2500)

initial2 = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]],
                             size = (4,4,4), symbol="Cu", debug=0)
initial2.set_calculator(EMT())
# Make a small perturbation of the momenta
initial2.set_momenta(1e-6 * np.random.normal(size=[len(initial2), 3]))
print "Initializing (2) ..."
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:LongLangevin.py


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