示例#1
0
    def __init__(self,
                 init_file,
                 args_str,
                 param_file,
                 latency=1.0e-3,
                 name="",
                 pars=None,
                 dopbc=True,
                 threaded=False):
        """Initialises QUIP.

        Args:
        pars: Mandatory dictionary, giving the parameters needed by QUIP.
        """
        if quippy is None:
            info("QUIPPY import failed", verbosity.low)
            raise quippy_exc

        # a socket to the communication library is created or linked
        super(FFQUIP, self).__init__(latency,
                                     name,
                                     pars,
                                     dopbc,
                                     threaded=threaded)
        self.init_file = init_file
        self.args_str = args_str
        self.param_file = param_file

        # Initializes an atoms object and the interaction potential
        self.atoms = quippy.Atoms(self.init_file)
        self.pot = quippy.Potential(self.args_str,
                                    param_filename=self.param_file)

        # Initializes the conversion factors from i-pi to QUIP
        self.len_conv = unit_to_user("length", "angstrom", 1)
        self.energy_conv = unit_to_user("energy", "electronvolt", 1)
        self.force_conv = unit_to_user("force", "ev/ang", 1)
示例#2
0
文件: convert.py 项目: casv2/MDLearn
import quippy
from ase.io import read, write
import sys

i = sys.argv[1]

calculator = quippy.Potential(
    "TB NRL-TB",
    param_filename=
    "/Users/Cas/.julia/dev/MDLearn/exampleTB_com_surf/quip_params.xml")

at = read(
    "/Users/Cas/.julia/dev/MDLearn/exampleTB_com_surf/crash_{}.xyz".format(i))
at.set_calculator(calculator)

at.arrays["force"] = at.get_forces()
at.info["energy"] = at.get_potential_energy()
at.info["config_type"] = "HMD_iter{}".format(i)

write(
    "/Users/Cas/.julia/dev/MDLearn/exampleTB_com_surf/crash_conv_{}.xyz".
    format(i), at)

i0 = int(i) - 1

al = read(
    "/Users/Cas/.julia/dev/MDLearn/exampleTB_com_surf/DB_{}.xyz".format(i0),
    ":")
al.append(at)
write("/Users/Cas/.julia/dev/MDLearn/exampleTB_com_surf/DB_{}.xyz".format(i),
      al)
示例#3
0
def center_atoms(atoms, vacuum=None, axis=(0, 1, 2)):
    """                                               
    (1) Removes existing vacuum, (2) adds specified vacuum and (3) centers system along specified directions.
    Substitute for the screwed up quippy Atoms.center()
    """

    if vacuum is not None:
        shrink_cell(atoms)
        atoms.cell += np.eye(3) * vacuum

    axis_mask = [True if ax in axis else False for ax in range(3)]
    atoms.positions -= atoms.positions.mean(axis=0) * axis_mask
    return


calc = quippy.Potential('IP TS', param_filename="ts_params.xml")

# Load atomic configuration
fld = sys.argv[1].strip()
params.os.chdir(fld)

crack_slab = quippy.Atoms('slab.xyz')
print('Unit slab with %d atoms per unit cell:' % len(crack_slab))
print(crack_slab.cell)
print('')

in_put = raw_input('Perform dry system generation (guess configuration)?')
GUESS_RUN = (in_put in ['y', 'Y', 'yes'])
if GUESS_RUN:
    print("Performing dry run...")
else:
示例#4
0
        def setUp(self):
            self.pot = quippy.Potential('IP SW',
                                        param_str="""
            <SW_params n_types="2" label="PRB_31_plus_H">
            <comment> Stillinger and Weber, Phys. Rev. B  31 p 5262 (1984), extended for other elements </comment>
            <per_type_data type="1" atomic_num="1" />
            <per_type_data type="2" atomic_num="14" />
            <per_pair_data atnum_i="1" atnum_j="1" AA="0.0" BB="0.0"
                  p="0" q="0" a="1.0" sigma="1.0" eps="0.0" />
            <per_pair_data atnum_i="1" atnum_j="14" AA="8.581214" BB="0.0327827"
                  p="4" q="0" a="1.25" sigma="2.537884" eps="2.1672" />
            <per_pair_data atnum_i="14" atnum_j="14" AA="7.049556277" BB="0.6022245584"
                  p="4" q="0" a="1.80" sigma="2.0951" eps="2.1675" />

            <!-- triplet terms: atnum_c is the center atom, neighbours j and k -->
            <per_triplet_data atnum_c="1"  atnum_j="1"  atnum_k="1"
                  lambda="21.0" gamma="1.20" eps="2.1675" />
            <per_triplet_data atnum_c="1"  atnum_j="1"  atnum_k="14"
                  lambda="21.0" gamma="1.20" eps="2.1675" />
            <per_triplet_data atnum_c="1"  atnum_j="14" atnum_k="14"
                  lambda="21.0" gamma="1.20" eps="2.1675" />

            <per_triplet_data atnum_c="14" atnum_j="1"  atnum_k="1"
                  lambda="21.0" gamma="1.20" eps="2.1675" />
            <per_triplet_data atnum_c="14" atnum_j="1"  atnum_k="14"
                  lambda="21.0" gamma="1.20" eps="2.1675" />
            <per_triplet_data atnum_c="14" atnum_j="14" atnum_k="14"
                  lambda="21.0" gamma="1.20" eps="2.1675" />
            </SW_params>
            """)

            self.fmax = 1e-4
            self.at0 = Diamond('Si', latticeconstant=5.43)
            self.at0.set_calculator(self.pot)
            # relax initial positions and unit cell
            FIRE(StrainFilter(self.at0, mask=[1, 1, 1, 0, 0, 0]),
                 logfile=None).run(fmax=self.fmax)

            self.C_ref = np.array(
                [[151.4276439, 76.57244456, 76.57244456, 0., 0., 0.],
                 [76.57244456, 151.4276439, 76.57244456, 0., 0., 0.],
                 [76.57244456, 76.57244456, 151.4276439, 0., 0., 0.],
                 [0., 0., 0., 109.85498798, 0., 0.],
                 [0., 0., 0., 0., 109.85498798, 0.],
                 [0., 0., 0., 0., 0., 109.85498798]])

            self.C_err_ref = np.array(
                [[1.73091718, 1.63682097, 1.63682097, 0., 0., 0.],
                 [1.63682097, 1.73091718, 1.63682097, 0., 0., 0.],
                 [1.63682097, 1.63682097, 1.73091718, 0., 0., 0.],
                 [0., 0., 0., 1.65751232, 0., 0.],
                 [0., 0., 0., 0., 1.65751232, 0.],
                 [0., 0., 0., 0., 0., 1.65751232]])

            self.C_ref_relaxed = np.array(
                [[151.28712587, 76.5394162, 76.5394162, 0., 0., 0.],
                 [76.5394162, 151.28712587, 76.5394162, 0., 0., 0.],
                 [76.5394162, 76.5394162, 151.28712587, 0., 0., 0.],
                 [0., 0., 0., 56.32421772, 0., 0.],
                 [0., 0., 0., 0., 56.32421772, 0.],
                 [0., 0., 0., 0., 0., 56.32421772]])

            self.C_err_ref_relaxed = np.array(
                [[1.17748661, 1.33333615, 1.33333615, 0., 0., 0.],
                 [1.33333615, 1.17748661, 1.33333615, 0., 0., 0.],
                 [1.33333615, 1.33333615, 1.17748661, 0., 0., 0.],
                 [0., 0., 0., 0.18959684, 0., 0.],
                 [0., 0., 0., 0., 0.18959684, 0.],
                 [0., 0., 0., 0., 0., 0.18959684]])
#!/usr/local/bin/python
from __future__ import print_function
import numpy as np
import ase
import ase.lattice
from ase.optimize.precon import PreconLBFGS, Exp

# Initialise the atomistic energy model

#
# if your matscipy installation was successful use its fast model, if not, fall back on the slow one

import quippy

calc = quippy.Potential('IP SW', param_filename='ip.parms.SW.xml')
calc.set_calc_args({'local_energy': True})

# Create the structure of the bar. The directions in the function below
# orient the crystal such that the dislocations are easer to see in this
# quasi 2-dimensional geometry. "pbc" refers to "Periodic Boundary Conditions"
# and are set to be active in the Z direction, but not in X and Y
unitcell = ase.lattice.cubic.Diamond(directions=[[1, 1, 1], [1, 1, -2],
                                                 [1, -1, 0]],
                                     size=(1, 1, 1),
                                     symbol='Si',
                                     pbc=(1, 1, 1))

# the unit cell is replicated in the X and Y directions, but kept minimal in Z
atoms = unitcell * (10, 30, 1)

# assign the energy model to the atoms object
示例#6
0
文件: convert.py 项目: casv2/MDLearn
import quippy
from ase.io import read, write
import sys

i = sys.argv[1]
config_type = sys.argv[2]

calculator = quippy.Potential("TB NRL-TB", param_filename="/Users/Cas/.julia/dev/MDLearn/HMD_surf_vac/quip_params.xml")

at = read("/Users/Cas/.julia/dev/MDLearn/HMD_surf_vac/crash_{}.xyz".format(i))
at.set_calculator(calculator)

at.arrays["force"] = at.get_forces()
at.info["energy"] = at.get_potential_energy()
#at.info["virial"] = -1.0 * at.get_volume() * at.get_stress(voigt=False)
at.info["config_type"] = "HMD_{}".format(config_type)

write("/Users/Cas/.julia/dev/MDLearn/HMD_surf_vac/crash_conv_{}.xyz".format(i), at)

i0 = int(i) - 1

al = read("/Users/Cas/.julia/dev/MDLearn/HMD_surf_vac/DB_{}.xyz".format(i0), ":")
al.append(at)
write("/Users/Cas/.julia/dev/MDLearn/HMD_surf_vac/DB_{}.xyz".format(i), al)
示例#7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Module for comparing enthalpies between different stacking sequences. 
"""
#from __future__ import print_function
import quippy
import numpy as np
from numpy import sqrt
from math import tan, pi
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

LJ = quippy.Potential("IP LJ", param_filename="LJ.xml")
# Use sig=1, (atom #14, type 1)


def aparray(sqnc):
    """Returns atom numpy array.
   
    Args:
        sqnc (string): polytype stacking sequence to be made into an array
          For example, 'abc' or 'abcabcacbacb'.

    Returns:
        numpy array
    """
    z = sqrt(2. / 3)
    b = sqrt(3) / 6
    c = 1 - b