ASEconvert

Light-weight module to install ASE and provide routines for converting between the Atoms datastructure from ASE and atomistic data provided in the AtomsBase ecosystem.

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")
Python: Atoms(symbols='Mg2', pbc=True, cell=[[3.21, 0.0, 0.0], [-1.605, 2.7799415461480477, 0.0], [0.0, 0.0, 5.21304]])

or surfaces

using ASEconvert
ase.build.surface(ase.build.bulk("Mg"), (1, 1, 0), 4, 0, periodic=true)
Python: Atoms(symbols='Mg8', pbc=True, cell=[5.559883092296095, 5.21304, 4.8149999999999995])

Conversion from ASE to AtomsBase

using ASEconvert
using DFTK

# Construct bulk magnesium using ASE and convert to atomsbase
mg_ase = ase.build.bulk("Mg")
mg_atb = pyconvert(AbstractSystem, mg_ase)
FlexibleSystem(Mg₂, periodic = TTT):
    bounding_box      : [    3.21        0        0;
                           -1.605  2.77994        0;
                                0        0  5.21304]u"Å"

    Atom(Mg, [       0,        0,        0]u"Å")
    Atom(Mg, [-8.86328e-17,  1.85329,  2.60652]u"Å")

             
             
        Mg   
             
             
             
      Mg     
             
             
# Attach pseudopotentials, construct LDA DFT model and solve for DFT ground state
system = attach_psp(mg_atb; Mg="hgh/lda/mg-q2")
model  = model_LDA(system; temperature=1e-3, smearing=Smearing.MarzariVanderbilt())
basis  = PlaneWaveBasis(model; Ecut=20, kgrid=(4, 4, 4))
scfres = self_consistent_field(basis)

scfres.energies
Energy breakdown (in Ha):
    Kinetic             0.7125694 
    AtomicLocal         0.3212858 
    AtomicNonlocal      0.3386598 
    Ewald               -2.1416410
    PspCorrection       -0.1823028
    Hartree             0.0045839 
    Xc                  -0.8537690
    Entropy             0.0000048 

    total               -1.800609100652

Conversion from AtomsBase to ASE

using ASEconvert
using AtomsIO

# Read an extxyz file using AtomsIO.jl.
system = load_system("Mn3Si.extxyz")
Atoms(Mn₃Si, periodic = TTT):
    bounding_box      : [ 3.99987        0        0;
                          1.99993  3.46399        0;
                          1.99993  1.15466  3.26588]u"Å"
    spacegroup        : P 1
    occupancy         : _JSON {"0": {"Mn": 1}, "1": {"Mn": 1}, "2": {"Mn": 1}, "3": {"Si": 1}}
    unit_cell         : conventional

    AtomView(Mn, [ 1.99993,  1.15466,  0.81647]u"Å")
    AtomView(Mn, [  5.9998,  3.46399,  2.44941]u"Å")
    AtomView(Mn, [ 3.99987,  2.30933,  1.63294]u"Å")
    AtomView(Si, [       0,        0,        0]u"Å")

                              
                        Mn    
                              
                  Mn          
             Mn               
                              
       Si                     
                              

This example uses AtomsIO 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));
Python: None