# Using QUIP potentials with Atomic Simulation Environment

• quippy Potential objects can be used as ASE calculators

• Communicate with other packages using ASE as lingua franca

## Example: vacancy formation energy

• Generate structure with ASE lattice tools

• Stillinger-Weber potential implementation from QUIP

• Elastic constant fitting routine from matscipy, internal relaxations with ASE FIRE minimiser

[5]:

from ase.build import bulk
from ase.optimize import LBFGS
from quippy.potential import Potential

si = bulk('Si', a=5.44, cubic=True)
sw_pot = Potential('IP SW', param_str="""
<SW_params n_types="3" label="PRB_31_plus_H_Ge">
<per_type_data type="1" atomic_num="14" />
<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" />
<per_triplet_data atnum_c="14" atnum_j="14" atnum_k="14"
lambda="21.0" gamma="1.20" eps="2.1675" />
</SW_params>
""") # call into Fortran code
si.set_calculator(sw_pot)
e_bulk_per_atom = si.get_potential_energy()/len(si)

# call general purpose elastic constants calculator
#   using ASE Atoms and QUIP Potential
from matscipy.elasticity import fit_elastic_constants
Cij = fit_elastic_constants(si, optimizer=LBFGS,
symmetry='cubic', logfile='-')
vac1 = si.copy()
vac1 *= (3, 3, 3)
half_cell = np.diag(vac1.cell)/2.
vac_atom = ((vac1.positions - half_cell)**2).sum(axis=1).argmin()
del vac1[vac_atom]

vac1.set_calculator(sw_pot)
vac1.rattle(0.01)

opt = LBFGS(vac1)
opt.run(fmax=1e-6)
e_vac = vac1.get_potential_energy() - e_bulk_per_atom*len(vac1)
print('SW vacancy formation energy', e_vac, 'eV')

       Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25      -34.635777*       0.3247
LBFGS:    1 16:55:25      -34.644590*       0.1504
LBFGS:    2 16:55:25      -34.646997*       0.0001
Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25      -34.670667*       0.1584
LBFGS:    1 16:55:25      -34.672777*       0.0749
LBFGS:    2 16:55:25      -34.673385*       0.0000
Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25      -34.678737*       0.0000
Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25      -34.660845*       0.1508
LBFGS:    1 16:55:25      -34.662784*       0.0742
LBFGS:    2 16:55:25      -34.663403*       0.0000
Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25      -34.617822*       0.2945
LBFGS:    1 16:55:25      -34.625262*       0.1477
LBFGS:    2 16:55:25      -34.627763*       0.0001
Fitting C_11
Strain array([-0.02, -0.01,  0.  ,  0.01,  0.02])
Stress array([-2.56044687, -1.01247671,  0.5027424 ,  1.98366491,  3.42893711]) GPa
Cij (gradient) / GPa    :     149.74909575669915
Error in Cij / GPa      :     1.1696996170085603
Correlation coefficient :     0.9999084935045536
Setting C11 (1) to 0.934660 +/- 0.007301

Fitting C_21
Strain array([-0.02, -0.01,  0.  ,  0.01,  0.02])
Stress array([-1.07663577, -0.26643655,  0.5027424 ,  1.23345414,  1.92818198]) GPa
Cij (gradient) / GPa    :     75.0952617697293
Error in Cij / GPa      :     1.3149075235415504
Correlation coefficient :     0.9995404242109733
Setting C21 (7) to 0.468708 +/- 0.008207

Fitting C_31
Strain array([-0.02, -0.01,  0.  ,  0.01,  0.02])
Stress array([-1.07663577, -0.26643655,  0.5027424 ,  1.23345414,  1.92818198]) GPa
Cij (gradient) / GPa    :     75.09526176972929
Error in Cij / GPa      :     1.31490752354155
Correlation coefficient :     0.9995404242109733
Updating C31 (7) with value 0.468708 +/- 0.008207

Fitting C_44
Strain array([-0.02, -0.01,  0.  ,  0.01,  0.02])
Stress array([-1.13572340e+00, -5.65842409e-01, -9.46072689e-15,  5.60142655e-01,
1.11304586e+00]) GPa
Cij (gradient) / GPa    :     56.23523568430934
Error in Cij / GPa      :     0.19437884854805132
Correlation coefficient :     0.9999820790695022
Setting C44 (4) to 0.350993 +/- 0.001213

[[b C11 b C12 b C12 b     b     b    ]
[b C12 b C11 b C12 b     b     b    ]
[b C12 b C12 b C11 b     b     b    ]
[b     b     b     b C44 b     b    ]
[b     b     b     b     b C44 b    ]
[b     b     b     b     b     b C44]]

=

[[149.75  75.1   75.1    0.     0.     0.  ]
[ 75.1  149.75  75.1    0.     0.     0.  ]
[ 75.1   75.1  149.75   0.     0.     0.  ]
[  0.     0.     0.    56.24   0.     0.  ]
[  0.     0.     0.     0.    56.24   0.  ]
[  0.     0.     0.     0.     0.    56.24]]
C_11 = 149.75 +/- 1.17 GPa
C_12 = 75.10 +/- 1.31 GPa
C_44 = 56.24 +/- 0.19 GPa
Step     Time          Energy         fmax
*Force-consistent energies used in optimization.
LBFGS:    0 16:55:25     -927.087471*       0.8332
LBFGS:    1 16:55:25     -927.431001*       0.4667
LBFGS:    2 16:55:25     -927.618490*       0.1404
LBFGS:    3 16:55:25     -927.627345*       0.1185
LBFGS:    4 16:55:25     -927.645023*       0.0525
LBFGS:    5 16:55:25     -927.647485*       0.0567
LBFGS:    6 16:55:25     -927.652217*       0.0421
LBFGS:    7 16:55:25     -927.653638*       0.0372
LBFGS:    8 16:55:25     -927.654968*       0.0298
LBFGS:    9 16:55:25     -927.655716*       0.0221
LBFGS:   10 16:55:25     -927.656230*       0.0185
LBFGS:   11 16:55:25     -927.656496*       0.0136
LBFGS:   12 16:55:25     -927.656686*       0.0109
LBFGS:   13 16:55:25     -927.656814*       0.0104
LBFGS:   14 16:55:25     -927.656908*       0.0091
LBFGS:   15 16:55:25     -927.656982*       0.0072
LBFGS:   16 16:55:25     -927.657045*       0.0061
LBFGS:   17 16:55:25     -927.657090*       0.0049
LBFGS:   18 16:55:25     -927.657121*       0.0045
LBFGS:   19 16:55:25     -927.657144*       0.0046
LBFGS:   20 16:55:25     -927.657163*       0.0033
LBFGS:   21 16:55:25     -927.657178*       0.0029
LBFGS:   22 16:55:25     -927.657189*       0.0027
LBFGS:   23 16:55:25     -927.657199*       0.0024
LBFGS:   24 16:55:25     -927.657207*       0.0025
LBFGS:   25 16:55:25     -927.657212*       0.0021
LBFGS:   26 16:55:25     -927.657216*       0.0016
LBFGS:   27 16:55:25     -927.657218*       0.0012
LBFGS:   28 16:55:25     -927.657220*       0.0013
LBFGS:   29 16:55:25     -927.657221*       0.0010
LBFGS:   30 16:55:25     -927.657222*       0.0012
LBFGS:   31 16:55:25     -927.657223*       0.0010
LBFGS:   32 16:55:25     -927.657224*       0.0008
LBFGS:   33 16:55:25     -927.657225*       0.0006
LBFGS:   34 16:55:25     -927.657225*       0.0006
LBFGS:   35 16:55:25     -927.657225*       0.0005
LBFGS:   36 16:55:25     -927.657226*       0.0004
LBFGS:   37 16:55:25     -927.657226*       0.0004
LBFGS:   38 16:55:25     -927.657226*       0.0003
LBFGS:   39 16:55:25     -927.657226*       0.0002
LBFGS:   40 16:55:25     -927.657226*       0.0002
LBFGS:   41 16:55:25     -927.657226*       0.0002
LBFGS:   42 16:55:25     -927.657226*       0.0001
LBFGS:   43 16:55:25     -927.657226*       0.0001
LBFGS:   44 16:55:25     -927.657226*       0.0001
LBFGS:   45 16:55:25     -927.657226*       0.0001
LBFGS:   46 16:55:25     -927.657226*       0.0001
LBFGS:   47 16:55:25     -927.657226*       0.0001
LBFGS:   48 16:55:25     -927.657226*       0.0001
LBFGS:   49 16:55:25     -927.657226*       0.0001
LBFGS:   50 16:55:25     -927.657226*       0.0000
LBFGS:   51 16:55:25     -927.657226*       0.0000
LBFGS:   52 16:55:25     -927.657226*       0.0000
LBFGS:   53 16:55:25     -927.657226*       0.0000
LBFGS:   54 16:55:25     -927.657226*       0.0000
LBFGS:   55 16:55:25     -927.657226*       0.0000
LBFGS:   56 16:55:25     -927.657226*       0.0000
LBFGS:   57 16:55:26     -927.657226*       0.0000
LBFGS:   58 16:55:26     -927.657226*       0.0000
LBFGS:   59 16:55:26     -927.657226*       0.0000
LBFGS:   60 16:55:26     -927.657226*       0.0000
LBFGS:   61 16:55:26     -927.657226*       0.0000
LBFGS:   62 16:55:26     -927.657226*       0.0000
LBFGS:   63 16:55:26     -927.657226*       0.0000
LBFGS:   64 16:55:26     -927.657226*       0.0000
LBFGS:   65 16:55:26     -927.657226*       0.0000
LBFGS:   66 16:55:26     -927.657226*       0.0000
LBFGS:   67 16:55:26     -927.657226*       0.0000
LBFGS:   68 16:55:26     -927.657226*       0.0000
LBFGS:   69 16:55:26     -927.657226*       0.0000
LBFGS:   70 16:55:26     -927.657226*       0.0000
LBFGS:   71 16:55:26     -927.657226*       0.0000
LBFGS:   72 16:55:26     -927.657226*       0.0000
LBFGS:   73 16:55:26     -927.657226*       0.0000
LBFGS:   74 16:55:26     -927.657226*       0.0000
LBFGS:   75 16:55:26     -927.657226*       0.0000
LBFGS:   76 16:55:26     -927.657226*       0.0000
LBFGS:   77 16:55:26     -927.657226*       0.0000
SW vacancy formation energy 4.333840201785051 eV

[ ]: