예제 #1
0
파일: _lammps.py 프로젝트: exalearn/maml
    def get_unit_cell(specie, lattice, alat):
        """
        Get the unit cell from specie, lattice type and lattice constant.

        Args
            specie (str): Name of specie.
            lattice (str): The lattice type of structure. e.g. bcc or diamond.
            alat (float): The lattice constant of specific lattice and specie.
        """
        if lattice == "fcc":
            unit_cell = Structure.from_spacegroup(sg="Fm-3m",
                                                  lattice=Lattice.cubic(alat),
                                                  species=[specie],
                                                  coords=[[0, 0, 0]])
        elif lattice == "bcc":
            unit_cell = Structure.from_spacegroup(sg="Im-3m",
                                                  lattice=Lattice.cubic(alat),
                                                  species=[specie],
                                                  coords=[[0, 0, 0]])
        elif lattice == "diamond":
            unit_cell = Structure.from_spacegroup(sg="Fd-3m",
                                                  lattice=Lattice.cubic(alat),
                                                  species=[specie],
                                                  coords=[[0, 0, 0]])
        else:
            raise ValueError("Lattice type is invalid.")

        return unit_cell
예제 #2
0
    def bi(self):
        """Return BCC Bi structure."""

        bcc_bi = Structure.from_spacegroup("Im-3m", Lattice.cubic(3.453),
                                           ["Bi"], [[0, 0, 0]])
        bcc_bi = bcc_bi.get_reduced_structure("niggli")
        return bcc_bi
예제 #3
0
 def test_get_vertex_indices(self):
     # Create a 2x2x2 NaCl supercell
     lattice = Lattice.from_parameters(a=5.0,
                                       b=5.0,
                                       c=5.0,
                                       alpha=90,
                                       beta=90,
                                       gamma=90)
     structure = Structure.from_spacegroup(
         sg='Fm-3m',
         lattice=lattice,
         species=['Na', 'Cl'],
         coords=[[0.0, 0.0, 0.0], [0.5, 0.0, 0.0]]) * [2, 2, 2]
     vertex_indices = get_vertex_indices(structure=structure,
                                         centre_species='Na',
                                         vertex_species='Cl',
                                         cutoff=3.0,
                                         n_vertices=6)
     c = Counter()
     for vi in vertex_indices:
         self.assertEqual(len(vi), 6)
         c += Counter(vi)
         for i in vi:
             self.assertEqual(structure[i].species_string, 'Cl')
     for i in range(33, 64):
         self.assertEqual(c[i], 6)
예제 #4
0
    def setUp(self):
        parser = CifParser(os.path.join(PymatgenTest.TEST_FILES_DIR, "Fe.cif"))
        self.Fe = parser.get_structures()[0]

        parser = CifParser(
            os.path.join(PymatgenTest.TEST_FILES_DIR, "LiFePO4.cif"))
        self.LiFePO4 = parser.get_structures()[0]

        parser = CifParser(
            os.path.join(PymatgenTest.TEST_FILES_DIR, "Fe3O4.cif"))
        self.Fe3O4 = parser.get_structures()[0]

        parser = CifParser(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "magnetic.ncl.example.GdB4.mcif"))
        self.GdB4 = parser.get_structures()[0]

        parser = CifParser(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "magnetic.example.NiO.mcif"))
        self.NiO_expt = parser.get_structures()[0]

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords)

        latt = Lattice([[2.085, 2.085, 0.0], [0.0, -2.085, -2.085],
                        [-2.085, 2.085, -4.17]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0, 0.5], [0, 0, 0], [0.25, 0.5, 0.25],
                  [0.75, 0.5, 0.75]]
        self.NiO_AFM_111 = Structure(latt,
                                     species,
                                     coords,
                                     site_properties={"magmom": [-5, 5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0], [0, 0, -4.17], [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5], [0, 0, 0], [0, 0.5, 0], [0.5, 0, 0.5]]
        self.NiO_AFM_001 = Structure(latt,
                                     species,
                                     coords,
                                     site_properties={"magmom": [-5, 5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0], [0, 0, -4.17], [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5], [0, 0, 0], [0, 0.5, 0], [0.5, 0, 0.5]]
        self.NiO_AFM_001_opposite = Structure(
            latt, species, coords, site_properties={"magmom": [5, -5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0], [0, 0, -4.17], [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5], [0, 0, 0], [0, 0.5, 0], [0.5, 0, 0.5]]
        self.NiO_unphysical = Structure(
            latt, species, coords, site_properties={"magmom": [-3, 0, 0, 0]})

        warnings.simplefilter("ignore")
예제 #5
0
 def init_structure(self):
     self.structure = Structure.from_spacegroup(
         sg=self.space_group_number,
         lattice=self.lattice,
         species=self.species,
         coords=self.atoms_coord,
         coords_are_cartesian=self.atom_coords_are_cartesian,
         tol=self.structure_tolerance,
     )
예제 #6
0
    def setUp(self):

        self.maxDiff = None

        # trivial example, simple square lattice for testing
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ["H"], [[0, 0, 0]])
        self.square_sg = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))
        # TODO: decorating still fails because the structure graph gives a CN of 8 for this square lattice
        # self.square_sg.decorate_structure_with_ce_info()

        # body-centered square lattice for testing
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ["H", "He"], [[0, 0, 0], [0.5, 0.5, 0.5]])
        self.bc_square_sg = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.bc_square_sg.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(-1, -1, 0))
        self.bc_square_sg.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))

        # body-centered square lattice for testing
        # directions reversed, should be equivalent to bc_square
        structure = Structure(Lattice.tetragonal(5.0, 50.0), ["H", "He"], [[0, 0, 0], [0.5, 0.5, 0.5]])
        self.bc_square_sg_r = StructureGraph.with_empty_graph(structure, edge_weight_name="", edge_weight_units="")
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(1, 0, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(-1, 0, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, 1, 0))
        self.bc_square_sg_r.add_edge(0, 0, from_jimage=(0, 0, 0), to_jimage=(0, -1, 0))
        self.bc_square_sg_r.add_edge(0, 1, from_jimage=(0, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(-1, 0, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(-1, -1, 0), to_jimage=(0, 0, 0))
        self.bc_square_sg_r.add_edge(1, 0, from_jimage=(0, -1, 0), to_jimage=(0, 0, 0))

        # MoS2 example, structure graph obtained from critic2
        # (not ground state, from mp-1023924, single layer)
        stdout_file = os.path.join(PymatgenTest.TEST_FILES_DIR, "critic2/MoS2_critic2_stdout.txt")
        with open(stdout_file) as f:
            reference_stdout = f.read()
        self.structure = Structure.from_file(os.path.join(PymatgenTest.TEST_FILES_DIR, "critic2/MoS2.cif"))
        c2o = Critic2Analysis(self.structure, reference_stdout)
        self.mos2_sg = c2o.structure_graph(include_critical_points=False)

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords).get_primitive_structure()

        # BCC example.
        self.bcc = Structure(Lattice.cubic(5.0), ["He", "He"], [[0, 0, 0], [0.5, 0.5, 0.5]])

        warnings.simplefilter("ignore")
예제 #7
0
    def test_metal_check(self):
        structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                              ["Cu"], [[0, 0, 0]])

        with warnings.catch_warnings(record=True) as w:
            # Cause all warnings to always be triggered.
            warnings.simplefilter("always")
            # Trigger a warning.
            vis = MITRelaxSet(structure)
            incar = vis.incar
            # Verify some things
            self.assertIn("ISMEAR", str(w[-1].message))
예제 #8
0
    def test_metal_check(self):
        structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                              ["Cu"], [[0, 0, 0]])

        with warnings.catch_warnings(record=True) as w:
            # Cause all warnings to always be triggered.
            warnings.simplefilter("always")
            # Trigger a warning.
            vis = MITRelaxSet(structure)
            incar = vis.incar
            # Verify some things
            self.assertIn("ISMEAR", str(w[-1].message))
예제 #9
0
    def structure(self):
        si = self["=.in"].structure_information

        elements = []
        coords = []
        for wp in si.wyckoff_positions:
            elements.append(wp.element)
            coords.append([float(x) for x in wp.tau])

        structure = Structure.from_spacegroup(self.spacegroup_number,
                                              self.lattice, elements, coords)

        return structure
예제 #10
0
    def setUp(self):
        super(TestAdsorptionWorkflow, self).setUp()

        self.struct_ir = Structure.from_spacegroup("Fm-3m",
                                                   Lattice.cubic(3.875728),
                                                   ["Ir"], [[0, 0, 0]])
        sgp = {"max_index": 1, "min_slab_size": 7.0, "min_vacuum_size": 20.0}
        self.slabs = generate_all_slabs(self.struct_ir, **sgp)
        self.slab_100 = [
            slab for slab in self.slabs if slab.miller_index == (1, 0, 0)
        ][0]
        self.wf_1 = get_wf_slab(self.slab_100,
                                True, [Molecule("H", [[0, 0, 0]])],
                                db_file=os.path.join(db_dir, "db.json"))
예제 #11
0
def multi_component_structure():
    """
    Setup a complex pymatgen structure (i.e. Li6PS5Br) comprising multiple
    different species.
    """
    from pymatgen import Lattice, Structure
    lattice = Lattice.cubic(a=1.0E1)
    species, positions = list(
        zip(*[
            ('Li', [0.183, 0.183, 0.024]),
            ('S', [0.250, 0.250, 0.250]),
            ('S', [0.618, 0.618, 0.618]),
            ('P', [0.500, 0.500, 0.500]),
            ('Br', [0.000, 0.000, 0.000]),
        ]))
    structure = Structure.from_spacegroup(216, lattice, species, positions)
    yield structure
예제 #12
0
    def setUp(self):
        parser = CifParser(os.path.join(test_dir, 'Fe.cif'))
        self.Fe = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'LiFePO4.cif'))
        self.LiFePO4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'Fe3O4.cif'))
        self.Fe3O4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'magnetic.ncl.example.GdB4.mcif'))
        self.GdB4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'magnetic.example.NiO.mcif'))
        self.NiO_expt = parser.get_structures()[0]

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0],
                  [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords)

        latt = Lattice([[2.085, 2.085, 0.0],
                        [0.0, -2.085, -2.085],
                        [-2.085, 2.085, -4.17]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0, 0.5],
                  [0, 0, 0],
                  [0.25, 0.5, 0.25],
                  [0.75, 0.5, 0.75]]
        self.NiO_AFM_111 = Structure(latt, species, coords, site_properties={'magmom': [-5, 5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0],
                        [0, 0, -4.17],
                        [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5],
                  [0, 0, 0],
                  [0, 0.5, 0],
                  [0.5, 0, 0.5]]
        self.NiO_AFM_001 = Structure(latt, species, coords, site_properties={'magmom': [-5, 5, 0, 0]})
예제 #13
0
    def setUp(self):
        parser = CifParser(os.path.join(test_dir, 'Fe.cif'))
        self.Fe = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'LiFePO4.cif'))
        self.LiFePO4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'Fe3O4.cif'))
        self.Fe3O4 = parser.get_structures()[0]

        parser = CifParser(
            os.path.join(test_dir, 'magnetic.ncl.example.GdB4.mcif'))
        self.GdB4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'magnetic.example.NiO.mcif'))
        self.NiO_expt = parser.get_structures()[0]

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords)

        latt = Lattice([[2.085, 2.085, 0.0], [0.0, -2.085, -2.085],
                        [-2.085, 2.085, -4.17]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0, 0.5], [0, 0, 0], [0.25, 0.5, 0.25],
                  [0.75, 0.5, 0.75]]
        self.NiO_AFM_111 = Structure(latt,
                                     species,
                                     coords,
                                     site_properties={'magmom': [-5, 5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0], [0, 0, -4.17], [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5], [0, 0, 0], [0, 0.5, 0], [0.5, 0, 0.5]]
        self.NiO_AFM_001 = Structure(latt,
                                     species,
                                     coords,
                                     site_properties={'magmom': [-5, 5, 0, 0]})
예제 #14
0
    [cmsa.matches_ordering(s) for s in matched_structures].index(True)

    # Enforce all magmom magnitudes to match the gs
    for s in matched_structures:
        ms = s.site_properties["magmom"]
        magmoms = [np.sign(m1) * m2 for m1, m2 in zip(ms, gs_magmoms)]
        s.add_site_property("magmom", magmoms)

    return matched_structures, input_index, ordered_structure_origins


if __name__ == "__main__":

    # for trying workflows

    from fireworks import LaunchPad

    latt = Lattice.cubic(4.17)
    species = ["Ni", "O"]
    coords = [[0.00000, 0.00000, 0.00000], [0.50000, 0.50000, 0.50000]]
    NiO = Structure.from_spacegroup(225, latt, species, coords)

    wf_deformation = get_wf_magnetic_deformation(NiO)

    wf_orderings = MagneticOrderingsWF(NiO).get_wf()

    lpad = LaunchPad.auto_load()
    lpad.add_wf(wf_orderings)
    lpad.add_wf(wf_deformation)
예제 #15
0
directory = 'runs/melting_point'
supercell = np.array([5, 5, 5], dtype=np.int)
# Inital Guess 3150
# Iter 1: 3010 K
melting_point_guess = 3010  # Kelvin
processors = '4'
lammps_command = 'lmp_mpi'

a = 4.1990858  # From evaluation of potential
lattice = Lattice.from_parameters(a, a, a, 90, 90, 90)
mg = Specie('Mg', 1.4)
o = Specie('O', -1.4)
atoms = [mg, o]
sites = [[0, 0, 0], [0.5, 0.5, 0.5]]
structure = Structure.from_spacegroup(225, lattice, atoms, sites)

initial_structure = structure * (supercell * np.array([2, 1, 1], dtype=np.int))
sorted_structure = initial_structure.get_sorted_structure(
    key=partial(distance_from_miller_index, miller_index=[1, 0, 0]))
num_atoms = len(sorted_structure)

lammps_potentials = LammpsPotentials(
    pair={
        (mg, mg): '1309362.2766468062  0.104    0.0',
        (mg, o): '9892.357            0.20199  0.0',
        (o, o): '2145.7345           0.3      30.2222'
    })

mgo_potential_settings = [
    ('pair_style', 'buck/coul/long 10.0'),
예제 #16
0
    def gen_struc_mol_break_sym(self, nstruc, rot_mol=None,
                                id_offset=0, init_pos_path=None):
        '''
        Generate random molecular crystal structures
        one have to run self.set_mol() in advance
        molecules are put a Wyckoff position without consideration of symmetry

        # ---------- args
        nstruc (int): number of generated structures

        rot_mol (str): default: None
                       None, 'random', 'random_mol', or 'random_wyckoff'

        id_offset (int): default: 0
                         structure ID starts from id_offset
                         e.g. nstruc = 3, id_offset = 10
                              you obtain ID 10, ID 11, ID 12

        init_pos_path (str): default: None
                             specify a path of file
                             if you write POSCAR data of init_struc_data
                             ATTENSION: data are appended to the specified file

        # ---------- comment
        generated structure data are saved in self.init_struc_data
        '''
        # ---------- check args
        if not (type(nstruc) is int and nstruc > 0):
            raise ValueError('nstruc must be positive int')
        if type(id_offset) is not int:
            raise TypeError('id_offset must be int')
        if init_pos_path is None or type(init_pos_path) is str:
            pass
        else:
            raise ValueError('init_pos_path is wrong.'
                             ' init_pos_path = {}'.format(init_pos_path))
        if rot_mol not in [None, 'random', 'random_mol', 'random_wyckoff']:
            raise ValueError('error in rot_mol')
        noble_gas = ['Rn', 'Xe', 'Kr', 'Ar', 'Ne', 'He']
        if len(self.mol_data) > len(noble_gas):
            raise ValueError('len(mol_data) > len(noble_gas)')
        # ---------- initialize
        self.init_struc_data = {}
        # ------ dummy atom type
        tmp_atype = noble_gas[:len(self.mol_data)]
        # ---------- loop for structure generattion
        while len(self.init_struc_data) < nstruc:
            # ------ spgnum --> spg
            if self.spgnum == 'all':
                spg = random.randint(1, 230)
            else:
                spg = random.choice(self.spgnum)
            if spg in self.spg_error:
                continue
            # ------ vol_factor
            rand_vol = random.uniform(self.vol_factor[0], self.vol_factor[1])
            # ------ generate structure
            tmp_crystal = pyxtal()
            try:
                tmp_crystal.from_random(dim=3, group=spg, species=tmp_atype,
                                        numIons=self.nmol, factor=rand_vol,
                                        conventional=False)
            except RuntimeError:
                sys.stderr.write('RuntimeError in spg = {} retry.\n'.format(spg))
                self.spg_error.append(spg)
                continue
            if tmp_crystal.valid:
                # -- each wyckoff position --> dummy atom
                dums = []        # dummy atoms
                dum_pos = []     # internal position of dummy
                dum_type = {}    # type of dummy
                                 #  e.g. {DummySpecie X00+: 'Rn',
                                 #        DummySpecie X10+: 'Rn',
                                 #        DummySpecie X20+: 'Xe',
                                 #        DummySpecie X30+: 'Xe'}
                for i, site in enumerate(tmp_crystal.atom_sites):
                    dum = DummySpecie("X{}".format(i))
                    dums.append(dum)
                    dum_pos.append(site.position)
                    dum_type[dum] = site.specie
                # -- tmp_struc with dummy atoms
                lattice = tmp_crystal.lattice.get_matrix()
                tmp_struc = Structure.from_spacegroup(spg, lattice, dums, dum_pos)
                tmp_struc = tmp_struc.get_primitive_structure()
                # -- scale volume
                if self.vol_mu is not None:
                    vol = random.gauss(mu=self.vol_mu, sigma=self.vol_sigma)
                    tmp_struc.scale_lattice(volume=vol)
                # -- rotate molecules
                if rot_mol == 'random_mol':
                    # each mol_data
                    mol_angles = []    # [angles of mol 1, angles of mol 2, ...]
                    for i in range(len(self.mol_data)):
                        mol_angles.append(2 * np.pi * np.random.rand(3))
                if rot_mol == 'random_wyckoff':
                    # each Wyckoff
                    dum_angles = {}    # e.g.
                                       # {DummySpecie X00+: array([ , , ]),
                                       #  DummySpecie X10+: array([ , , ]),
                                       #  DummySpecie X20+: array([ , , ]),
                                       #  DummySpecie X30+: array([ , , ])}
                    angles = 2 * np.pi * np.random.rand(len(dums), 3)
                    for (dum, angle) in zip(dums, angles):
                        dum_angles[dum] = angle
                # -- replace dummy with mol
                dum_species = tmp_struc.species
                dum_coords = tmp_struc.cart_coords
                for (dum_specie, dum_coord) in zip(dum_species, dum_coords):
                    mol_index = tmp_atype.index(dum_type[dum_specie])
                    mol = self.mol_data[mol_index]
                    # rotation option
                    if rot_mol is None:
                        rot_mol_coord = mol.cart_coords
                    if rot_mol == 'random':
                        angle = 2 * np.pi * np.random.rand(3)
                        R = rot_mat(angle)
                        rot_mol_coord = np.matmul(mol.cart_coords, R)
                    if rot_mol == 'random_mol':
                        angle = mol_angles[mol_index]
                        R = rot_mat(angle)
                        rot_mol_coord = np.matmul(mol.cart_coords, R)
                    if rot_mol == 'random_wyckoff':
                        angle = dum_angles[dum_specie]
                        R = rot_mat(angle)
                        rot_mol_coord = np.matmul(mol.cart_coords, R)
                    # rotate coord
                    coord = rot_mol_coord + dum_coord
                    # append mol
                    for i, ms in enumerate(mol.species):
                        tmp_struc.append(ms, coord[i], coords_are_cartesian=True)
                # -- remove dummy
                tmp_struc.remove_sites(range(0, len(dum_species)))
                # -- check nat
                if not self._check_nat(tmp_struc):
                    # pyxtal returns conventional cell,
                    # too many atoms if centering
                    tmp_struc = tmp_struc.get_primitive_structure()
                    # recheck nat
                    if not self._check_nat(tmp_struc):    # failure
                        continue
                # -- sort, necessary in molecular crystal
                tmp_struc = sort_by_atype(tmp_struc, self.atype)
                # -- check minimum distance
                if self.mindist is not None:
                    success, mindist_ij, dist = check_distance(tmp_struc,
                                                               self.atype,
                                                               self.mindist)
                    if not success:
                        sys.stderr.write('mindist: {} - {}, {}. retry.\n'.format(
                            self.atype[mindist_ij[0]],
                            self.atype[mindist_ij[1]],
                            dist))
                        continue    # failure
                # -- check actual space group
                try:
                    spg_sym, spg_num = tmp_struc.get_space_group_info(
                        symprec=self.symprec)
                except TypeError:
                    spg_num = 0
                    spg_sym = None
                # -- register the structure in pymatgen format
                cid = len(self.init_struc_data) + id_offset
                self.init_struc_data[cid] = tmp_struc
                print('Structure ID {0:>6} was generated.'
                      ' Space group: {1:>3} --> {2:>3} {3}'.format(
                       cid, spg, spg_num, spg_sym))
                # -- save init_POSCARS
                if init_pos_path is not None:
                    out_poscar(tmp_struc, cid, init_pos_path)
            else:
                self.spg_error.append(spg)
예제 #17
0
        if scan:
            wf_name += " - SCAN"
        wf = Workflow(fws, name=wf_name)

        wf = add_additional_fields_to_taskdocs(wf, {"wf_meta": self.wf_meta})

        tag = "magnetic_orderings group: >>{}<<".format(self.uuid)
        wf = add_tags(wf, [tag, ordered_structure_origins])

        return wf


if __name__ == "__main__":

    # for trying workflows

    from fireworks import LaunchPad

    latt = Lattice.cubic(4.17)
    species = ["Ni", "O"]
    coords = [[0.00000, 0.00000, 0.00000], [0.50000, 0.50000, 0.50000]]
    NiO = Structure.from_spacegroup(225, latt, species, coords)

    wf_deformation = get_wf_magnetic_deformation(NiO)

    wf_orderings = MagneticOrderingsWF(NiO).get_wf()

    lpad = LaunchPad.auto_load()
    lpad.add_wf(wf_orderings)
    lpad.add_wf(wf_deformation)
예제 #18
0
            f.write(str(self._tags) + "\n")
            f.write(str(self._potentials) + "\n")
            f.write(str(self._atoms) + "\n")


if __name__ == '__main__':
    print('-> you run ', __file__, ' file in the main mode (Top-level script environment)')
    zno_lattice_init = Lattice.from_parameters(
        a=3.25330, b=3.25330, c=5.20730,
        alpha=90.00000, beta=90.00000, gamma=120.00000,
    )
    zno_structure = Structure.from_spacegroup(
        sg=186, lattice=zno_lattice_init,
        species=[Element('Zn'), Element('O')],
        coords=[
            [1 / 3, 2 / 3, 0.00000],
            [1 / 3, 2 / 3, 0.37780],
        ],
        coords_are_cartesian=False,
        tol=1e-9,
    )
    print(zno_structure)
    print(zno_structure.get_space_group_info())
    out_file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.new2'
    file_name = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.old'
    atoms_obj = Atoms(zno_structure, 'O', 12)
    pprint(atoms_obj.struct.cart_coords)
    pprint(atoms_obj.get_lines())

    header_obj = Header(struct=zno_structure)
    pot_obj = Potential(zno_structure, 'O')