Skip to content

Latest commit

 

History

History
106 lines (84 loc) · 3.49 KB

File metadata and controls

106 lines (84 loc) · 3.49 KB
CurrentModule = ASEconvert

ASEconvert

Light-weight module to install the atomistic simulation environment (ASE) and provide routines for cross-converting between ASE datastructures and the respective ones of the JuliaMolSim ecosystem. E.g. it allows to convert between the ASE Atoms and exposing them using an AtomsBase compatible interface or it allows to employ calculators from ASE as AtomsCalculators.

Automatic ASE installation

Using the mechanism provided by PythonCall and CondaPkg ASEconvert will automatically take care of installing ASE and exporting a useful subset of its modules under the ase variable. For example one may easily create bulk systems

using ASEconvert
ase.build.bulk("Mg")

or surfaces

using ASEconvert
ase.build.surface(ase.build.bulk("Mg"), (1, 1, 0), 4, 0, periodic=true)

Conversion from ASE to AtomsBase

using ASEconvert

# Construct bulk magnesium using ASE and convert to atomsbase
mg_ase = ase.build.bulk("Mg")
mg_atb = pyconvert(AbstractSystem, mg_ase)
using DFTK
using PseudoPotentialData

# Attach pseudopotentials, construct LDA DFT model and solve for DFT ground state
pseudopotentials = PseudoFamily("dojo.nc.sr.lda.v0_4_1.oncvpsp3.standard.upf")
model  = model_DFT(mg_atb; temperature=1e-3, smearing=Smearing.MarzariVanderbilt(),
                   pseudopotentials, functionals=LDA())
basis  = PlaneWaveBasis(model; Ecut=20, kgrid=(4, 4, 4))
scfres = self_consistent_field(basis)

scfres.energies

Conversion from AtomsBase to ASE

using ASEconvert
using ExtXYZ

# Read an extxyz file using AtomsIO.jl.
system = ExtXYZ.Atoms(ExtXYZ.read_frame("Mn3Si.extxyz"))

This example uses ExtXYZ to read the extended XYZ file file Mn3Si.extxyz. The data is returned as a subtype of AtomsBase.AbstractSystem (in this case an ExtXYZ.Atoms from ExtXYZ). We can thus directly convert this system to an ase.Atoms using convert_ase and write it again as an ASE json file

ase.io.write("out.json", convert_ase(system));

For a more convenient and feature-rich way of reading and writing atomic structures in julia see AtomsIO.

Employing ASE calculators in Julia

using PythonCall
using ASEconvert

ase_emt = pyimport("ase.calculators.emt")
calculator = ASEcalculator(ase_emt.EMT())

The above codeblock employs PythonCall to setup an EMT calculator in ASE. Using the ASEcalculator wrapper this calculator is wrapped and now exposes a standard AtomsCalculators-compatible interface. For example one can use it to compute energy and forces of a copper supercell.

First we make the supercell:

using AtomsBuilder
system = bulk(:Cu) * (4, 3, 2)  # Make copper supercell

Next we use the energy_forces function from AtomsCalculators:

using AtomsCalculators
AtomsCalculators.energy_forces(system, calculator)