Beispiel #1
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)
Beispiel #2
0
    def pair(self, element_a, element_b, potential, separations):
        max_r = np.max(separations)
        lattice = Lattice.from_parameters(10*max_r, 10*max_r, 10*max_r, 90, 90, 90)

        if self.calculator_type == 'lammps':
            kwargs = {'lammps_set': load_lammps_set('static')}
        elif self.calculator_type == 'lammps_cython':
            kwargs = {'lammps_additional_commands': ['run 0']}

        async def calculate():
            futures = []
            for sep in separations:
                coord_a = (lattice.a*0.5-(sep/2), lattice.b*0.5, lattice.c*0.5)
                coord_b = (lattice.a*0.5+(sep/2), lattice.b*0.5, lattice.c*0.5)
                structure = Structure(
                    lattice,
                    [element_a, element_b],
                    [coord_a, coord_b], coords_are_cartesian=True)
                futures.append(await self.calculator.submit(
                    structure, potential,
                    properties={'energy'},
                    **kwargs))
            return await asyncio.gather(*futures)
        results = self._run_async_func(calculate())
        return np.array([r['results']['energy'] for r in results])
def get_matched_structure_mapping(base: Structure, inserted: Structure,
                                  sm: StructureMatcher):
    """
    Get the mapping from the inserted structure onto the base structure,
    assuming that the inserted structure sans the working ion is some kind
    of SC of the base.

    Args:
        base: host structure, smaller cell
        inserted: bigger cell
        sm: StructureMatcher instance

    Returns:
        sc_m : supercell matrix to apply to s1 to get s2
        total-t : translation to apply on s1 * sc_m to get s2
    """
    s1, s2 = sm._process_species([base, inserted])
    fu, _ = sm._get_supercell_size(s1, s2)
    try:
        val, dist, sc_m, total_t, mapping = sm._strict_match(s1,
                                                             s2,
                                                             fu=fu,
                                                             s1_supercell=True)
    except TypeError:
        return None
    sc = s1 * sc_m
    sc.lattice = Lattice.from_parameters(*sc.lattice.abc,
                                         *sc.lattice.angles,
                                         vesta=True)  # type: ignore
    return sc_m, total_t
    def __init__(self):
        super(ZnOCrystalMixin, self).__init__()
        self.lattice = Lattice.from_parameters(
            a=3.25330,
            b=3.25330,
            c=5.20730,
            alpha=90.00000,
            beta=90.00000,
            gamma=120.00000,
        )
        self.species = [Element('Zn'), Element('O')]
        self.space_group_number = 186
        self.atoms_coord = [
            [1 / 3, 2 / 3, 0.00000],
            [1 / 3, 2 / 3, 0.37780],
        ]
        self.atom_coords_are_cartesian = False
        self.structure_tolerance = 1e-9
        self.structure = None
        self.cluster_size = 12
        self.absorbing_atom = "O"
        self.path_to_src_feff_input = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.old'
        self.path_to_out_feff_input = '/home/yugin/PycharmProjects/neurons/data/src/feff.inp.new2'

        # struct: Structure object, See pymatgen.core.structure.Structure.
        #     source: User supplied identifier, i.e. for Materials Project this
        #         would be the material ID number
        #     comment: Comment for first header line
        self.header_user_identifier = 'author: Yevgen Syryanyy'
        self.header_comment = 'Automatic generated feff.inp file'
Beispiel #5
0
    def pair(self, element_a, element_b, potential, separations):
        max_r = np.max(separations)
        lattice = Lattice.from_parameters(10*max_r, 10*max_r, 10*max_r, 90, 90, 90)

        if self.calculator_type == 'lammps':
            kwargs = {'lammps_set': load_lammps_set('static')}
        elif self.calculator_type == 'lammps_cython':
            kwargs = {'lammps_additional_commands': ['run 0']}

        async def calculate():
            futures = []
            for sep in separations:
                coord_a = (lattice.a*0.5-(sep/2), lattice.b*0.5, lattice.c*0.5)
                coord_b = (lattice.a*0.5+(sep/2), lattice.b*0.5, lattice.c*0.5)
                structure = Structure(
                    lattice,
                    [element_a, element_b],
                    [coord_a, coord_b], coords_are_cartesian=True)
                futures.append(await self.calculator.submit(
                    structure, potential,
                    properties={'energy'},
                    **kwargs))
            return await asyncio.gather(*futures)
        results = self._run_async_func(calculate())
        return np.array([r['results']['energy'] for r in results])
Beispiel #6
0
 def test_relative_to_crystal_axes(self):
     lattice = Lattice.from_parameters(5, 10, 5, 90, 110, 90)
     moment = [1, 0, 2]
     magmom = Magmom.from_moment_relative_to_crystal_axes(moment, lattice)
     self.assertTrue(
         np.allclose(magmom.moment, [0.93969262, 0.0, 1.65797986]))
     self.assertTrue(
         np.allclose(magmom.get_moment_relative_to_crystal_axes(lattice),
                     moment))
Beispiel #7
0
 def setUp(self):
     coords = np.array([[0.5, 0.5, 0.5]])
     atom_list = ["S"]
     lattice = Lattice.from_parameters(a=1.0,
                                       b=1.0,
                                       c=1.0,
                                       alpha=90,
                                       beta=90,
                                       gamma=90)
     self.structure = Structure(lattice, atom_list, coords)
 def init(self):
     self.lattice = Lattice.from_parameters(
         a=self.a,
         b=self.b,
         c=self.c,
         alpha=90.00000,
         beta=90.00000,
         gamma=120.00000,
     )
     super(ZnOCrystalStructure, self).init()
Beispiel #9
0
def example_structure(species=None):
    if not species:
        species = ['S'] * 5
    lattice = Lattice.from_parameters(10.0, 10.0, 10.0, 90, 90, 90)
    cartesian_coords = np.array([[1.0, 1.0, 1.0], [9.0, 1.0, 1.0],
                                 [5.0, 5.0, 5.0], [1.0, 9.0, 9.0],
                                 [9.0, 9.0, 9.0]])
    structure = Structure(coords=cartesian_coords,
                          lattice=lattice,
                          species=species,
                          coords_are_cartesian=True)
    return structure
Beispiel #10
0
    def test_paramdict(self):
        coords = [[0.0, 0.0, 0.0], [0.75, 0.5, 0.75]]
        lattice = Lattice.from_parameters(a=3.84,
                                          b=3.84,
                                          c=3.84,
                                          alpha=120,
                                          beta=90,
                                          gamma=60)
        struct = Structure(lattice, ["Si", "Si"], coords)
        paradir = {
            "grst": {
                "do": "fromscratch",
                "ngridk": "8 8 8",
                "xctype": "GGA_PBE_SOL",
                "gmaxvr": "14.0",
            },
            "xs": {
                "xstype": "BSE",
                "ngridk": "4 4 4",
                "ngridq": "4 4 4",
                "nempty": "30",
                "gqmax": "3.0",
                "broad": "0.07",
                "tevout": "true",
                "energywindow": {
                    "intv": "0.0 1.0",
                    "points": "1200"
                },
                "screening": {
                    "screentype": "full",
                    "nempty": "100"
                },
                "BSE": {
                    "bsetype": "singlet",
                    "nstlbse": "1 5 1 4"
                },
            },
        }

        test_input = ExcitingInput(struct)
        test_string = test_input.write_string("unchanged", **paradir)

        # read reference file
        filepath = os.path.join(PymatgenTest.TEST_FILES_DIR,
                                "input_exciting2.xml")
        tree = ET.parse(filepath)
        root = tree.getroot()
        ref_string = ET.tostring(root, encoding="unicode")

        self.assertEqual(ref_string.strip(), test_string.strip())
 def test_rdf_coordination_number(self):
     # create a simple cubic lattice
     coords = np.array([[0.5, 0.5, 0.5]])
     atom_list = ["S"]
     lattice = Lattice.from_parameters(
         a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90
     )
     structure = Structure(lattice, atom_list, coords)
     rdf = RadialDistributionFunctionFast(
         structures=[structure], rmax=5.0, sigma=0.01, ngrid=500
     )
     self.assertEqual(
         np.round(rdf.get_coordination_number("S", "S")[1][110], 2), 6.0
     )
Beispiel #12
0
 def test_from_seed(self):
     coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
     lattice = pmg_Lattice.from_parameters(a=3.84,
                                           b=3.84,
                                           c=3.84,
                                           alpha=120,
                                           beta=90,
                                           gamma=60)
     struct = Structure(lattice, ["Si", "C"], coords)
     s1 = pyxtal()
     s1.from_seed(struct)
     s2 = s1.subgroup_once(eps=0)
     pmg_s1 = s1.to_pymatgen()
     pmg_s2 = s2.to_pymatgen()
     self.assertTrue(sm.StructureMatcher().fit(pmg_s1, pmg_s2))
Beispiel #13
0
 def set_vacuum(self, thick=20):
     self.reset_loc()
     new_lattice = self.poscar.structure.lattice
     new_c = new_lattice.c - self.vacuum_thick + thick
     new_lattice = Lattice.from_parameters(new_lattice.a, new_lattice.b,
                                           new_c, new_lattice.alpha,
                                           new_lattice.beta,
                                           new_lattice.gamma)
     min = np.mean(self.poscar.structure.frac_coords[:, 2])
     newcoor = self.poscar.structure.frac_coords - [0, 0, min]
     newcoor[:, 2] = newcoor[:, 2] * self.poscar.structure.lattice.c / new_c
     new_structure = Structure(new_lattice,
                               self.poscar.structure.species,
                               newcoor,
                               coords_are_cartesian=False)
     self.poscar = Poscar(new_structure)
     self.reset_loc()
Beispiel #14
0
 def test_rdf_coordination_number(self):
     # create a simple cubic lattice
     coords = np.array([[0.5, 0.5, 0.5]])
     atom_list = ["S"]
     lattice = Lattice.from_parameters(a=1.0,
                                       b=1.0,
                                       c=1.0,
                                       alpha=90,
                                       beta=90,
                                       gamma=90)
     structure = Structure(lattice, atom_list, coords)
     rdf = RadialDistributionFunction.from_species(structures=[structure],
                                                   species=["S"],
                                                   rmax=5.0,
                                                   sigma=0.1,
                                                   ngrid=500)
     self.assertEqual(rdf.coordination_number[100], 6.0)
Beispiel #15
0
 def test_site_index_mapping_one(self):
     a = 6.19399
     lattice = Lattice.from_parameters(a, a, a, 90, 90, 90)
     coords1 = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])
     coords2 = np.array([[0.1, 0.1, 0.1], [0.4, 0.6, 0.4]])
     sites1 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords1
     ]
     sites2 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords2
     ]
     structure1 = Structure.from_sites(sites1)
     structure2 = Structure.from_sites(sites2)
     mapping = site_index_mapping(structure1, structure2)
     np.testing.assert_array_equal(mapping, np.array([0, 1]))
Beispiel #16
0
 def test_site_index_mapping_with_species_1_as_string(self):
     a = 6.19399
     lattice = Lattice.from_parameters(a, a, a, 90, 90, 90)
     coords1 = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])
     coords2 = np.array([[0.4, 0.6, 0.4], [0.1, 0.1, 0.1]])
     species1 = ['Na', 'Cl']
     sites1 = [
         PeriodicSite(species=s, coords=c, lattice=lattice)
         for s, c in zip(species1, coords1)
     ]
     sites2 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords2
     ]
     structure1 = Structure.from_sites(sites1)
     structure2 = Structure.from_sites(sites2)
     mapping = site_index_mapping(structure1, structure2, species1='Na')
     np.testing.assert_array_equal(mapping, np.array([1]))
Beispiel #17
0
    def lattice(self):
        # lattice matrix: basis vectors are rows
        si = self["=.in"].structure_information

        # todo: convert non-angstrom units
        assert si.lengthunit.type == 2

        lattice = Lattice.from_parameters(
            *si.lattice_constants, 
            *si.axis_angles)

        # translate to FPLO convention
        # see also: https://www.listserv.dfn.de/sympa/arc/fplo-users/2020-01/msg00002.html
        if self.spacegroup.crystal_system in ('trigonal', 'hexagonal'):
            lattice = Lattice(lattice.matrix @ Rotation.from_rotvec([0, 0, 30], degrees=True).as_matrix())
        elif self.spacegroup.crystal_system not in ('cubic', 'tetragonal', 'orthorhombic'):
            log.warning('untested lattice, crystal orientation may not be correct')

        return lattice
Beispiel #18
0
 def test_site_index_mapping_with_one_to_one_mapping_raises_ValueError_one(
         self):
     a = 6.19399
     lattice = Lattice.from_parameters(a, a, a, 90, 90, 90)
     coords1 = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])
     coords2 = np.array([[0.4, 0.6, 0.4], [0.1, 0.1, 0.1]])
     species2 = ['Na', 'Cl']
     sites1 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords1
     ]
     sites2 = [
         PeriodicSite(species=s, coords=c, lattice=lattice)
         for s, c in zip(species2, coords2)
     ]
     structure1 = Structure.from_sites(sites1)
     structure2 = Structure.from_sites(sites2)
     with self.assertRaises(ValueError):
         site_index_mapping(structure1, structure2, species2='Na')
Beispiel #19
0
def get_rutile_structure():
    # rutile structure taken from mp-856
    a = 4.832
    c = 3.243
    x_4f = 0.3066

    lattice = Lattice.from_parameters(a, a, c, 90, 90, 90)
    species = ["Sn", "Sn", "O", "O", "O", "O"]
    # fmt: off
    frac_coords = np.array([
        [0, 0, 0],  # Sn(2a)
        [0.5, 0.5, 0.5],  # Sn(2a)
        [x_4f, x_4f, 0],  # O(4f)
        [1 - x_4f, 1 - x_4f, 0],  # O(4f)
        [0.5 - x_4f, 0.5 + x_4f, 0.5],  # O(4f)
        [0.5 + x_4f, 0.5 - x_4f, 0.5],  # O(4f)
    ])
    # fmt: on
    structure = Structure(lattice, species, frac_coords)
    return structure
Beispiel #20
0
 def test_site_index_mapping_with_return_mapping_distances(self):
     a = 6.19399
     lattice = Lattice.from_parameters(a, a, a, 90, 90, 90)
     coords1 = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])
     coords2 = np.array([[0.1, 0.1, 0.1], [0.4, 0.6, 0.4]])
     sites1 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords1
     ]
     sites2 = [
         PeriodicSite(species='Na', coords=c, lattice=lattice)
         for c in coords2
     ]
     structure1 = Structure.from_sites(sites1)
     structure2 = Structure.from_sites(sites2)
     mapping, distances = site_index_mapping(structure1,
                                             structure2,
                                             return_mapping_distances=True)
     np.testing.assert_array_equal(mapping, np.array([0, 1]))
     expected_distance = np.sqrt(3 * ((0.1 * a)**2))
     np.testing.assert_array_almost_equal(
         distances, np.array([expected_distance, expected_distance]))
Beispiel #21
0
    def get_pymatgen_structure(self):
        """
        Inputs: A np.ndarry structure with standard "geometry" format
        Outputs: A pymatgen core structure object with basic geometric properties
        """
        if self.get_lattice_vectors():
            frac_data = self.get_frac_data()
            coords = frac_data[0]  # frac coordinates
            atoms = frac_data[1]  # site labels
            lattice = LatticeP.from_parameters(a=frac_data[2],
                                               b=frac_data[3],
                                               c=frac_data[4],
                                               alpha=frac_data[5],
                                               beta=frac_data[6],
                                               gamma=frac_data[7])
            structp = StructureP(lattice, atoms, coords)
            return structp

        else:
            coords = self.get_geo_array()
            symbols = self.geometry['element']
            molp = Molecule(symbols, coords)
            return molp
Beispiel #22
0
 def test_relative_to_crystal_axes(self):
     lattice = Lattice.from_parameters(5, 10, 5, 90, 110, 90)
     moment = [1, 0, 2]
     magmom = Magmom.from_moment_relative_to_crystal_axes(moment, lattice)
     self.assertTrue(np.allclose(magmom.moment, [0.93969262, 0.0, 1.65797986]))
     self.assertTrue(np.allclose(magmom.get_moment_relative_to_crystal_axes(lattice), moment))
Beispiel #23
0
    def from_slabs(
        cls,
        substrate_slab: Slab,
        film_slab: Slab,
        in_plane_offset: Tuple[float, float] = (0, 0),
        gap: float = 1.6,
        vacuum_over_film: float = 0.0,
        interface_properties: Optional[Dict] = None,
        center_slab: bool = True,
    ) -> "Interface":
        """
        Makes an interface structure by merging a substrate and film slabs
        The film a- and b-vectors will be forced to be the substrate slab's
        a- and b-vectors.

        For now, it's suggested to use a factory method that will ensure the
        appropriate interface structure is already met.

        Args:
            sub_slab: slab for the substrate
            film_slab: slab for the film
            in_plane_offset: fractional shift in plane
                for the film with respect to the substrate
            gap: gap between substrate and film in Angstroms
            vacuum_over_film: vacuum space above the film in Angstroms
            structure_properties: dictionary of misc properties for this structure
            center_slab: center the slab
        """
        interface_properties = interface_properties or {}

        # Ensure c-axis is orthogonal to a/b plane
        if isinstance(substrate_slab, Slab):
            substrate_slab = substrate_slab.get_orthogonal_c_slab()
        if isinstance(film_slab, Slab):
            film_slab = film_slab.get_orthogonal_c_slab()
        assert np.allclose(film_slab.lattice.alpha, 90, 0.1)
        assert np.allclose(film_slab.lattice.beta, 90, 0.1)
        assert np.allclose(substrate_slab.lattice.alpha, 90, 0.1)
        assert np.allclose(substrate_slab.lattice.beta, 90, 0.1)

        # Ensure sub is right-handed
        # IE sub has surface facing "up"
        sub_vecs = substrate_slab.lattice.matrix.copy()
        if np.dot(np.cross(*sub_vecs[:2]), sub_vecs[2]) < 0:
            sub_vecs[2] *= -1.0
            substrate_slab.lattice = Lattice(sub_vecs)

        # Find the limits of C-coords
        sub_coords = substrate_slab.frac_coords
        film_coords = film_slab.frac_coords
        sub_min_c = np.min(sub_coords[:, 2]) * substrate_slab.lattice.c
        sub_max_c = np.max(sub_coords[:, 2]) * substrate_slab.lattice.c
        film_min_c = np.min(film_coords[:, 2]) * film_slab.lattice.c
        film_max_c = np.max(film_coords[:, 2]) * film_slab.lattice.c
        min_height = np.abs(film_max_c - film_min_c) + np.abs(sub_max_c -
                                                              sub_min_c)

        # construct new lattice
        abc = substrate_slab.lattice.abc[:2] + (min_height + gap +
                                                vacuum_over_film, )
        angles = substrate_slab.lattice.angles
        lattice = Lattice.from_parameters(*abc, *angles)

        # Get the species
        species = substrate_slab.species + film_slab.species

        # Get the coords
        # Shift substrate to bottom in new lattice
        sub_coords = np.subtract(sub_coords, [0, 0, np.min(sub_coords[:, 2])])
        sub_coords[:, 2] *= substrate_slab.lattice.c / lattice.c

        # Flip the film over
        film_coords[:, 2] *= -1.0
        film_coords[:, 2] *= film_slab.lattice.c / lattice.c

        # Shift the film coords to right over the substrate + gap
        film_coords = np.subtract(film_coords,
                                  [0, 0, np.min(film_coords[:, 2])])
        film_coords = np.add(
            film_coords, [0, 0, gap / lattice.c + np.max(sub_coords[:, 2])])

        # Build coords
        coords = np.concatenate([sub_coords, film_coords])

        # Shift coords to center
        if center_slab:
            coords = np.add(coords, [0, 0, 0.5 - np.average(coords[:, 2])])

        # Only merge site properties in both slabs
        site_properties = {}
        site_props_in_both = set(substrate_slab.site_properties.keys()) & set(
            film_slab.site_properties.keys())

        for key in site_props_in_both:
            site_properties[key] = [
                *substrate_slab.site_properties[key],
                *film_slab.site_properties[key],
            ]

        site_properties["interface_label"] = ["substrate"] * len(
            substrate_slab) + ["film"] * len(film_slab)

        iface = cls(
            lattice=lattice,
            species=species,
            coords=coords,
            to_unit_cell=False,
            coords_are_cartesian=False,
            site_properties=site_properties,
            validate_proximity=False,
            in_plane_offset=in_plane_offset,
            gap=gap,
            vacuum_over_film=vacuum_over_film,
            interface_properties=interface_properties,
        )

        iface.sort()
        return iface
Beispiel #24
0
def lat_in_to_sqs(atat_lattice_in, rename=True):
    """
    Convert a string-like ATAT-style lattice.in to an abstract SQS.

    Parameters
    ----------
    atat_lattice_in : str
        String-like of a lattice.in in the ATAT format.
    rename : bool
        If True, SQS format element names will be renamed, e.g. `a_B` -> `Xab`. Default is True.

    Returns
    -------
    SQS
        Abstract SQS.
    """
    # TODO: handle numeric species, e.g. 'g1'. Fixed
    # Problems: parser has trouble with matching next line and we have to rename it so pymatgen
    # doesn't think it's a charge.
    # parse the data
    parsed_data = _parse_atat_lattice(atat_lattice_in)
    atat_coord_system = parsed_data[0]
    atat_lattice = parsed_data[1]
    atat_atoms = parsed_data[2]
    # create the lattice
    if len(atat_coord_system) == 3:
        # we have a coordinate system matrix
        coord_system = Lattice(atat_coord_system.asList()).matrix
    else:
        # we have length and angles
        #coord_system = Lattice.from_lengths_and_angles(list(atat_coord_system[0]), list(atat_coord_system[1])).matrix
        (lat_a, lat_b, lat_c) = list(atat_coord_system[0])
        (lat_alpha, lat_beta, lat_gamma) = list(atat_coord_system[1])
        coord_system = Lattice.from_parameters(lat_a, lat_b, lat_c, lat_alpha,
                                               lat_beta, lat_gamma).matrix
    direct_lattice = Lattice(atat_lattice.asList())
    lattice = coord_system.dot(direct_lattice.matrix)
    # create the list of atoms, converted to the right coordinate system
    species_list = []
    species_positions = []
    subl_model = {
    }  # format {'subl_name': 'atoms_found_in_subl, e.g. "aaabbbb"'}
    for position, atoms in atat_atoms:
        # atoms can be a list of atoms, e.g. for not abstract SQS
        if len(atoms) > 1:
            raise NotImplementedError(
                'Cannot parse atom list {} because the sublattice is unclear.\nParsed data: {}'
                .format(atoms, atat_atoms))
        atom = atoms[0]
        if rename:
            # change from `a_B` style to `Xab`

            atom = atom.lower().split('_')
        else:
            raise NotImplementedError(
                'Cannot rename because the atom name and sublattice name may be ambigous.'
            )
        # add the abstract atom to the sublattice model
        subl = atom[0]
        #Replace the digital by alphas, 1->a, 2->b, 3->c, ...
        rep_items = re.findall(r"\d+", subl)
        for rep_item in rep_items:
            subl = subl.replace(rep_item, chr(96 + int(rep_item)))
        subl_atom = atom[1]
        subl_model[subl] = subl_model.get(subl, set()).union({subl_atom})
        # add the species and position to the lists
        species_list.append('X' + subl + subl_atom)
        species_positions.append(list(position))
    # create the structure
    sublattice_model = [[e for e in sorted(list(set(subl_model[s])))]
                        for s in sorted(subl_model.keys())]
    sublattice_names = [s for s in sorted(subl_model.keys())]
    sqs = AbstractSQS(direct_lattice,
                      species_list,
                      species_positions,
                      coords_are_cartesian=True,
                      sublattice_model=sublattice_model,
                      sublattice_names=sublattice_names)
    sqs.lattice = Lattice(lattice)
    #sqs.modify_lattice(Lattice(lattice))  #This will be deprecated in v2020

    return sqs
def distance_from_miller_index(site, miller_index):
    point, normal = plane_from_miller_index(site.lattice, miller_index)
    distance = np.dot(point - site.coords, normal) / np.linalg.norm(normal)
    return distance


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',
Beispiel #26
0
def load_molecule_structure():
    frac_coords = [
        [0.726519, 0.201998, 0.016235],
        [0.775561, 0.250288, 0.064178],
        [0.832526, 0.167475, 0.099370],
        [0.918099, 0.101210, 0.069812],
        [0.000739, 0.168940, 0.041705],
        [0.889961, 0.229669, 0.142974],
        [0.814331, 0.288193, 0.179060],
        [0.746484, 0.088734, 0.120518],
        [0.788525, 0.010777, 0.160482],
        [0.663668, 0.143668, 0.024956],
        [0.786126, 0.163662, 0.991722],
        [0.689009, 0.265892, 0.993749],
        [0.711951, 0.288002, 0.086680],
        [0.834448, 0.312093, 0.054333],
        [0.875310, 0.048715, 0.043226],
        [0.959446, 0.050619, 0.097701],
        [0.048267, 0.218407, 0.067667],
        [0.056960, 0.115868, 0.021837],
        [0.964699, 0.220910, 0.012857],
        [0.943334, 0.288263, 0.125005],
        [0.939537, 0.172011, 0.163884],
        [0.767475, 0.349964, 0.159581],
        [0.759199, 0.233972, 0.198677],
        [0.861487, 0.328887, 0.208539],
        [0.680818, 0.137077, 0.136038],
        [0.715376, 0.043017, 0.088095],
        [0.722655, 0.959258, 0.173358],
        [0.850704, 0.957870, 0.145277],
        [0.820082, 0.051357, 0.194224],
    ]
    species = [
        "C",
        "C",
        "N",
        "C",
        "C",
        "C",
        "C",
        "C",
        "C",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
        "H",
    ]
    lattice = Lattice.from_parameters(12.46433002, 12.46420102, 26.22526509,
                                      89.99366812, 90.00714732, 90.00004617)

    return Structure(coords=frac_coords, species=species, lattice=lattice)
Beispiel #27
0
            absorbing_atom=self.absorbing_atom,
            radius=self.cluster_size
        )

    def write_file(self):
        with open(self.path_to_out_feff_input, "w") as f:
            f.write(str(self._header) + "\n")
            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'