Esempio n. 1
0
def generate_muairss_collection(struct, params):

    if params["mu_symbol"] in struct.get_chemical_symbols():
        print(
            "WARNING: chosen muon symbol conflicts with existing elements in"
            " the starting unit cell. This could cause mistakes"
        )

    # Make a supercell
    sm = make_3x3(params["supercell"])
    # ASE's make_supercell is weird, avoid if not necessary...
    smdiag = np.diag(sm).astype(int)
    if np.all(np.diag(smdiag) == sm):
        scell0 = struct.repeat(smdiag)
    else:
        scell0 = make_supercell(struct, sm)

    reduced_struct = find_primitive_structure(struct)

    print("Generating defect configurations...")
    # Seed the random generator
    Random.reseed(params["random_seed"])
    # Now generate the defect configurations
    defect_gen = defectGen(
        reduced_struct,
        "H",
        poisson_r=params["poisson_r"],
        vdw_scale=params["vdw_scale"],
    )
    defect_collection = AtomsCollection(defect_gen)
    print("{0} configurations generated".format(len(defect_collection)))

    collection = []
    for atoms in defect_collection:
        # Where's the muon?
        # We rely on the fact that it's always put at the first place
        mupos = atoms.get_positions()[0]
        scell = scell0.copy() + Atoms(
            "H", positions=[mupos], masses=[constants.m_mu_amu]
        )
        # Add castep custom species
        csp = scell0.get_chemical_symbols() + [params["mu_symbol"]]
        scell.set_array("castep_custom_species", np.array(csp))
        scell.set_pbc(params["dftb_pbc"])
        collection.append(scell)

    return AtomsCollection(collection)
Esempio n. 2
0
def generate_muairss_collection(struct, params):

    if params['mu_symbol'] in struct.get_chemical_symbols():
        print('WARNING: chosen muon symbol conflicts with existing elements in'
              ' the starting unit cell. This could cause mistakes')

    # Make a supercell
    sm = make_3x3(params['supercell'])
    # ASE's make_supercell is weird, avoid if not necessary...
    smdiag = np.diag(sm).astype(int)
    if np.all(np.diag(smdiag) == sm):
        scell0 = struct.repeat(smdiag)
    else:
        scell0 = make_supercell(struct, sm)

    reduced_struct = find_primitive_structure(struct)

    print('Generating defect configurations...')
    # Now generate the defect configurations
    defect_gen = defectGen(reduced_struct,
                           'H',
                           poisson_r=params['poisson_r'],
                           vdw_scale=params['vdw_scale'])
    defect_collection = AtomsCollection(defect_gen)
    print('{0} configurations generated'.format(len(defect_collection)))

    collection = []
    for atoms in defect_collection:
        # Where's the muon?
        # We rely on the fact that it's always put at the first place
        mupos = atoms.get_positions()[0]
        scell = scell0.copy() + Atoms('H', positions=[mupos])
        # Add castep custom species
        csp = scell0.get_chemical_symbols() + [params['mu_symbol']]
        scell.set_array('castep_custom_species', np.array(csp))
        scell.set_pbc(params['dftb_pbc'])
        collection.append(scell)

    return AtomsCollection(collection)
import sys
import glob
from ase import io, Atoms
from ase.build import make_supercell

from pymuonsuite.utils import make_3x3
from pymuonsuite.schemas import load_input_file, MuAirssSchema

atoms = io.read(sys.argv[1])
if len(sys.argv) > 2:
    params = load_input_file(sys.argv[2], MuAirssSchema)
    scell = make_3x3(params["supercell"])
    atoms = make_supercell(atoms, scell)

for f in glob.glob("muon-airss-out/dftb+/*/geo_end.xyz"):
    a = io.read(f)
    atoms += Atoms("H", positions=a.get_positions()[-1, None, :])

io.write("merged.cif", atoms)
Esempio n. 4
0
import sys
import glob
import numpy as np
from ase import io, Atoms
from ase.build import make_supercell

from pymuonsuite.utils import make_3x3
from pymuonsuite.schemas import load_input_file, MuAirssSchema

atoms = io.read(sys.argv[1])
if len(sys.argv) > 2:
    params = load_input_file(sys.argv[2], MuAirssSchema)
    scell = make_3x3(params['supercell'])
    atoms = make_supercell(atoms, scell)

for f in glob.glob('muon-airss-out/dftb+/*/geo_end.xyz'):
    a = io.read(f)
    atoms += Atoms('H', positions=a.get_positions()[-1, None, :])

io.write('merged.cif', atoms)