Пример #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)
Пример #2
0
    def test_defect(self):

        si2 = bulk('Si')

        poisson_r = 0.5

        dGen = defectGen(si2, 'H', poisson_r)
        dColl = AtomsCollection(dGen)

        dPos = dColl.all.get_positions()[:, 0]

        holds = True
        for i, p1 in enumerate(dPos[:-1]):
            vecs, _ = minimum_periodic(dPos[i + 1:] - p1, si2.get_cell())
            p_holds = (np.linalg.norm(vecs, axis=1) >= poisson_r).all()
            holds = holds and p_holds

        self.assertTrue(holds)
Пример #3
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)