Ejemplo n.º 1
0
def test_metal_ceramic_interface():
    m1 = get_jid_data(jid="JVASP-816", dataset="dft_3d")["atoms"]
    m2 = get_jid_data(jid="JVASP-32", dataset="dft_3d")["atoms"]
    mat_Al = Atoms.from_dict(m1)
    mat_Al2O3 = Atoms.from_dict(m2)
    from jarvis.analysis.defects.surface import Surface

    mat1 = Surface(atoms=mat_Al, indices=[1, 1, 1], layers=3).make_surface()
    mat2 = Surface(atoms=mat_Al2O3, indices=[0, 0, 1], layers=1).make_surface()
    combined = make_interface(
        film=mat1,  # .center_around_origin(),
        max_area=500,
        max_area_ratio_tol=0.09,
        ltol=0.01,
        apply_strain=True,
        subs=mat2,  # .center_around_origin(),
    )["interface"]
    print(combined)
    # from ase.lattice.surface import surface
    # from pymatgen.io.ase import AseAtomsAdaptor
    # from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
    # from pymatgen.io.vasp.inputs import Poscar
    # mat_cvn = SpacegroupAnalyzer(mat_Al.pymatgen_converter()).get_conventional_standard_structure()
    # ase_atoms = AseAtomsAdaptor().get_atoms(mat_cvn)
    # ase_slab = surface(ase_atoms, [1,1,1], 3)
    # ase_slab.center(vacuum=18, axis=2)
    # slab_pymatgen = AseAtomsAdaptor().get_structure(ase_slab)
    # slab_pymatgen.sort()
    # print (Poscar(slab_pymatgen))
    # print ()
    # print ()
    print(mat1.center_around_origin().get_string(cart=False))
Ejemplo n.º 2
0
 def from_dict(self, d={}):
     """Load from a dictionary."""
     return Vacancy(
         atoms=Atoms.from_dict(d["atoms"]),
         defect_structure=Atoms.from_dict(d["defect_structure"]),
         defect_index=d["defect_index"],
         wyckoff_multiplicity=d["wyckoff_multiplicity"],
         symbol=d["symbol"],
     )
Ejemplo n.º 3
0
def test_graph():
    from jarvis.core.atoms import Atoms
    from jarvis.db.figshare import get_jid_data

    atoms = Atoms.from_poscar(test_pos)
    g = Graph.atom_dgl_multigraph(atoms=atoms, atom_features="cgcnn")
    atoms = Atoms.from_dict(get_jid_data("JVASP-664")["atoms"])
    feature_sets = ("atomic_number", "basic", "cfid", "cgcnn")
    for i in feature_sets:
        g = Graph.atom_dgl_multigraph(atoms=atoms, atom_features=i)
        g = Graph.atom_dgl_multigraph(atoms=atoms, atom_features=i)
        print(i, g)
    batch = prepare_dgl_batch(torch.tensor([1, 1]))
    batch = prepare_line_graph_batch(torch.tensor([1, 1, 1]))
    g = Graph.from_atoms(atoms=atoms, features="atomic_number")
    gnx = g.to_networkx()
    g = Graph.from_atoms(atoms=atoms, features="atomic_number")
    g = Graph.from_atoms(atoms=atoms, features="atomic_fraction")
    g = Graph.from_atoms(
        atoms=atoms,
        features="basic",
        get_prim=True,
        zero_diag=True,
        node_atomwise_angle_dist=True,
        node_atomwise_rdf=True,
    )
    g = Graph.from_atoms(
        atoms=atoms,
        features="cfid",
        get_prim=True,
        zero_diag=True,
        node_atomwise_angle_dist=True,
        node_atomwise_rdf=True,
    )
    g = Graph.from_atoms(
        atoms=atoms,
        features="atomic_number",
        get_prim=True,
        zero_diag=True,
        node_atomwise_angle_dist=True,
        node_atomwise_rdf=True,
    )
    g = Graph.from_atoms(atoms=atoms, features="basic")
    g = Graph.from_atoms(
        atoms=atoms, features=["Z", "atom_mass", "max_oxid_s"]
    )
    g = Graph.from_atoms(atoms=atoms, features="cfid", max_cut=10000)
    print(g)
    d = g.to_dict()
    g = Graph.from_dict(d)
    num_nodes = g.num_nodes
    num_edges = g.num_edges
    print(num_nodes, num_edges)
    assert num_nodes == 48
    assert num_edges == 2256
    assert (g.adjacency_matrix.shape) == (48, 48)
Ejemplo n.º 4
0
def test_ldau():
    d = data('dft_3d')
    for i in d:
        if i['jid'] == 'JVASP-29569':
            atoms = Atoms.from_dict(i['atoms'])
            ld = find_ldau_magmom(atoms=atoms, lsorbit=True)
            ld = find_ldau_magmom(atoms=atoms, lsorbit=False)

        if i['jid'] == 'JVASP-45':
            atoms = Atoms.from_dict(i['atoms'])
            ld = find_ldau_magmom(atoms=atoms, lsorbit=True)
            assert ld['LDAUU'] == '3.0 0'
            ld = find_ldau_magmom(atoms=atoms, lsorbit=False)
Ejemplo n.º 5
0
def test_zur():
    m1 = get_jid_data("JVASP-664")["atoms"]
    m2 = get_jid_data("JVASP-652")["atoms"]
    s1 = Atoms.from_dict(m1)
    s2 = Atoms.from_dict(m2)
    info = make_interface(film=s1, subs=s2)
    combined = info["interface"]
    assert (
        round(info["mismatch_u"], 3),
        round(info["mismatch_angle"], 3),
    ) == (
        -0.041,
        0.0,
    )
Ejemplo n.º 6
0
def test_vacancy():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    v = Vacancy(atoms=Si)
    vacs = v.generate_defects(enforce_c_size=10.0)
    td = vacs[0].to_dict()
    fd = Vacancy.from_dict(td)
    # print ( len(vacs),(vacs[0].to_dict()["defect_structure"].num_atoms))
    # print (vacs[0].to_dict()["defect_structure"])
    assert (
        len(vacs),
        Atoms.from_dict(vacs[0].to_dict()["defect_structure"]).num_atoms,
    ) == (1, 53)
Ejemplo n.º 7
0
    def get_atoms(structure):
        """
        Returns JARVIS Atoms object from pymatgen structure.

        Args:
            structure: pymatgen.core.structure.Structure

        Returns:
            JARVIS Atoms object
        """
        if not structure.is_ordered:
            raise ValueError("JARVIS Atoms only supports ordered structures")
        if not jarvis_loaded:
            raise ImportError(
                "JarvisAtomsAdaptor requires jarvis-tools package.\nUse `pip install -U jarvis-tools`"
            )
        elements = [str(site.specie.symbol) for site in structure]
        coords = [site.frac_coords for site in structure]
        lattice_mat = structure.lattice.matrix
        return Atoms(
            lattice_mat=lattice_mat,
            elements=elements,
            coords=coords,
            cartesian=False,
        )
Ejemplo n.º 8
0
def test_kp():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    lattice_mat = Si.lattice_mat
    kp = Kpoints3D().automatic_length_mesh(lattice_mat=lattice_mat, length=20)
    td = kp.to_dict()
    fd = Kpoints3D.from_dict(td)
    sym = kp.high_symm_path(Si)._path
    x, y = kp.interpolated_points(Si)
    kpath = generate_kpath(kpath=[[0, 0, 0], [0, 0.5, 0.5]], num_k=5)
    kps = generate_kgrid(grid=[5, 5, 5])
    new_file, filename = tempfile.mkstemp()
    kp.write_file(filename)
    sym = kp.high_symm_path(s1)._path
    sym = kp.high_symm_path(s2)._path
    sym = kp.high_symm_path(s3)._path
    sym = kp.high_symm_path(s4)._path
    sym = kp.high_symm_path(s5)._path
    sym = kp.high_symm_path(s6)._path
    sym = kp.high_symm_path(s7)._path
    assert (len(x), x[0][0], y[0], kpath[0][0], kps[0][0]) == (
        166,
        0,
        "\Gamma",
        0.0,
        0.0,
    )
    kp = Kpoints3D().kpath(atoms=Si, unique_kp_only=True)
Ejemplo n.º 9
0
def get_jarvis_atoms(optimade_structure: OptimadeStructure) -> Atoms:
    """ Get jarvis Atoms from OPTIMADE structure

    NOTE: Cannot handle partial occupancies

    :param optimade_structure: OPTIMADE structure
    :return: jarvis.core.Atoms
    """
    if globals().get("Atoms", None) is None:
        warn(JARVIS_NOT_FOUND)
        return None

    attributes = optimade_structure.attributes

    # Cannot handle partial occupancies
    if "disorder" in attributes.structure_features:
        raise ConversionError(
            "jarvis-tools cannot handle structures with partial occupancies."
        )

    cartesian_site_positions, _ = pad_positions(attributes.cartesian_site_positions)

    return Atoms(
        lattice_mat=attributes.lattice_vectors,
        elements=[specie.name for specie in attributes.species],
        coords=cartesian_site_positions,
        cartesian=True,
    )
Ejemplo n.º 10
0
 def final_structure(self):
     """Get final atoms."""
     elements = []
     pos = []
     lat = []
     lat.append([
         float(i) for i in self.data["qes:espresso"]["step"][-1]
         ["atomic_structure"]["cell"]["a1"].split()
     ])
     lat.append([
         float(i) for i in self.data["qes:espresso"]["step"][-1]
         ["atomic_structure"]["cell"]["a2"].split()
     ])
     lat.append([
         float(i) for i in self.data["qes:espresso"]["step"][-1]
         ["atomic_structure"]["cell"]["a3"].split()
     ])
     for i in self.data["qes:espresso"]["step"][-1]["atomic_structure"][
             "atomic_positions"]["atom"]:
         elements.append(i["@name"])
         pos.append([float(j) for j in i["#text"].split()])
     atoms = Atoms(elements=elements,
                   coords=pos,
                   lattice_mat=lat,
                   cartesian=True)
     return atoms
Ejemplo n.º 11
0
def read_pdb(filename=""):
    """Read PDB file and make Atoms object."""
    f = open(filename, "r")
    lines = f.read().splitlines()
    f.close()
    coords = []
    species = []
    for i in lines:
        tmp = i.split()
        if "ATOM " in i and "REMARK" not in i and "SITE" not in i:
            coord = [float(tmp[6]), float(tmp[7]), float(tmp[8])]
            coords.append(coord)
            species.append(tmp[11])
            # print (coord,tmp[11])
    coords = np.array(coords)

    max_c = np.max(coords, axis=0)
    min_c = np.min(coords, axis=0)
    box = np.zeros((3, 3))
    for j in range(3):
        box[j, j] = abs(max_c[j] - min_c[j])
    pdb = Atoms(lattice_mat=box, elements=species,
                coords=coords, cartesian=True)
    mol = VacuumPadding(pdb, vacuum=20.0).get_effective_molecule()
    return mol
Ejemplo n.º 12
0
def get_jarvis_atoms(optimade_structure: OptimadeStructure) -> Atoms:
    """Get jarvis `Atoms` from OPTIMADE structure.

    Caution:
        Cannot handle partial occupancies.

    Parameters:
        optimade_structure: OPTIMADE structure.

    Returns:
        A jarvis `Atoms` object.

    """
    if "optimade.adapters" in repr(globals().get("Atoms")):
        warn(JARVIS_NOT_FOUND)
        return None

    attributes = optimade_structure.attributes

    # Cannot handle partial occupancies
    if StructureFeatures.DISORDER in attributes.structure_features:
        raise ConversionError(
            "jarvis-tools cannot handle structures with partial occupancies."
        )

    return Atoms(
        lattice_mat=attributes.lattice_vectors,
        elements=[specie.name for specie in attributes.species],
        coords=attributes.cartesian_site_positions,
        cartesian=True,
    )
Ejemplo n.º 13
0
def test_nbors():
    box = [[5.493642, 0, 0], [0, 5.493642, 0], [0, 0, 5.493642]]
    elements = ["Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si"]
    coords = [
        [0, 0, 0],
        [0.25, 0.25, 0.25],
        [0.000000, 0.500000, 0.500000],
        [0.250000, 0.750000, 0.750000],
        [0.500000, 0.000000, 0.500000],
        [0.750000, 0.250000, 0.750000],
        [0.500000, 0.500000, 0.000000],
        [0.750000, 0.750000, 0.250000],
    ]
    coords = np.array(coords)
    # box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    # coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    # elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    nbr = NeighborsAnalysis(Si)
    nb = nbr.get_all_distributions
    tmp = round((nb["rdf"][-3]), 2)
    assert (tmp) == (4.08)
    nbr.get_rdf(plot=True)
    # nbr.ang_dist(nbor_info=info,plot=True)
    nbr.ang_dist_first(plot=True)
    nbr.ang_dist_second(plot=True)
    nbr.get_ddf(plot=True)
    angs = nbr.atomwise_angle_dist()
    ardf = nbr.atomwise_radial_dist()
    cmd = "rm *.png"
    os.system(cmd)
Ejemplo n.º 14
0
def test_win():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    Wannier90win(struct=Si, efermi=0.0).write_win(name=win)
    w = Wannier90win(struct=Si, efermi=0.0)
    td = w.to_dict()
    fd = Wannier90win.from_dict(td)
    assert (os.path.isfile(win)) == (True)
    os.remove(win)

    Wannier90win(struct=s1, efermi=0.0).write_win(name=win)
    assert (os.path.isfile(win)) == (True)
    Wannier90win(struct=s1, efermi=0.0).write_hr_win(prev_win=win)
    os.remove(win)

    Wannier90win(struct=s2, efermi=0.0).write_win(name=win)
    assert (os.path.isfile(win)) == (True)
    os.remove(win)

    Wannier90win(struct=s3, efermi=0.0).write_win(name=win)
    assert (os.path.isfile(win)) == (True)
    os.remove(win)
    cmd = 'rm *.win'
    os.system(cmd)
Ejemplo n.º 15
0
def test_inputs():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Al", "Al"]
    Al = Atoms(lattice_mat=box, coords=coords, elements=elements)
    spg = Spacegroup3D(atoms=Al)
    Al = spg.conventional_standard_structure
    box = LammpsData().atoms_to_lammps(atoms=Al)
    td = box.to_dict()
    fd = LammpsData.from_dict(td)
    box.write_file(filename=data)
    d = box.to_dict()
    # print ('d=',d)
    reload_d = LammpsData.from_dict(d)
    # print ('d=',reload_d)
    atoms = box.lammps_to_atoms()
    lmp = LammpsData().read_data(filename=data, potential_file=pot)
    lmp = LammpsData().atoms_to_lammps(atoms=atoms)
    pair_coeff = "abc"
    inp = LammpsInput(LammpsDataObj=lmp).write_lammps_in(
        lammps_in=init,
        lammps_in1=pot,
        lammps_in2=inm,
        parameters={
            "pair_style": "eam/alloy",
            "pair_coeff": pair_coeff,
            "atom_style": "charge",
            "control_file": "/users/knc6/inelast.mod",
        },
    )
    d = LammpsInput(LammpsDataObj=lmp).to_dict()
    d = LammpsInput.from_dict(d)
    assert (lmp._lammps_box[1], atoms.num_atoms) == (5.43, 8)
Ejemplo n.º 16
0
def test_spg():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    spg = Spacegroup3D(atoms=Si)  # .spacegroup_data()
    cvn = spg.conventional_standard_structure
    ml = symmetrically_distinct_miller_indices(max_index=3, cvn_atoms=cvn)
    # print ('ml',ml)
    x = get_wyckoff_position_operators(488)
    # print  (x['wyckoff'][0]['letter'])
    assert (
        spg.space_group_number,
        spg.space_group_symbol,
        cvn.num_atoms,
        ml[0][0],
        x["wyckoff"][0]["letter"],
    ) == (227, "Fd-3m", 8, 1, "l")
    spg = Spacegroup3D(atoms=s1)
    assert spg.space_group_number == 191
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    spg = Spacegroup3D(atoms=s2)
    assert spg.space_group_number == 166
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    spg = Spacegroup3D(atoms=s3)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 139
    spg = Spacegroup3D(atoms=s4)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 63

    spg = Spacegroup3D(atoms=s5)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 39

    spg = Spacegroup3D(atoms=s6)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 12

    spg = Spacegroup3D(atoms=s7)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 7

    spg = Spacegroup3D(atoms=s8)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 2

    spg = Spacegroup3D(atoms=s9)
    print(spg.space_group_number)
    cvn = spg.conventional_standard_structure
    assert spg.space_group_number == 11
Ejemplo n.º 17
0
def test_cal():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.2, 0.25]]
    elements = ["Si", "Si"]
    atoms = Atoms(lattice_mat=box, coords=coords, elements=elements)
    decorated_atoms, hall_number, wsymbols = get_selective_dyn_decorated_atoms(
        atoms)
    assert (wsymbols, hall_number) == (["i", "i"], 63)
Ejemplo n.º 18
0
def get_2d_hetero_jids(jid1="JVASP-664", jid2="JVASP-52"):
    from jarvis.db.figshare import get_jid_data

    m1 = get_jid_data(jid1)["atoms"]
    m2 = get_jid_data(jid2)["atoms"]
    mat1 = Atoms.from_dict(m1)
    mat2 = Atoms.from_dict(m2)
    vac = max(mat1.lattice_mat[2][2], mat2.lattice_mat[2][2])
    combined = make_interface(
        film=mat1.center_around_origin(),
        max_area=400,
        max_area_ratio_tol=0.09,
        ltol=0.05,
        atol=0.1,
        subs=mat2.center_around_origin(),
    )["interface"]
    return combined
Ejemplo n.º 19
0
def test_conv_method():

    plt.switch_backend("agg")

    a = Atoms.from_dict(get_jid_data("JVASP-667")["atoms"])
    c = crop_square(a)
    # c = a.make_supercell_matrix([2, 2, 1])
    p = STEMConv(atoms=c).simulate_surface()
Ejemplo n.º 20
0
def test_kp():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.2, 0.25]]
    elements = ["Si", "Si"]
    s = Atoms(lattice_mat=box, coords=coords, elements=elements)
    data = get_wien_kpoints(atoms=s, write_file=True)
    cmd = "rm MyKpoints"
    os.system(cmd)
Ejemplo n.º 21
0
def test_input():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.25, 0.25]]
    elements = ["Si", "Si"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    spg = Spacegroup3D(Si)
    Si_cvn = spg.conventional_standard_structure
    p = PhonopyInputs(atoms=Si_cvn).generate_all_files()
Ejemplo n.º 22
0
def get_selective_dyn_decorated_atoms(atoms):
    """Freeze coordinates based on symmetry."""
    spg = Spacegroup3D(atoms=atoms)  # .spacegroup_data()
    frac_coords = atoms.frac_coords
    hall_number = spg._dataset["hall_number"]
    wdata = get_wyckoff_position_operators(hall_number)["wyckoff"]
    wsymbols = spg._dataset["wyckoffs"]
    info = defaultdict()
    for i in wdata:
        info[i["letter"]] = i["positions"]

    props = []
    for i, j in zip(wsymbols, frac_coords):
        ops = info[i]
        # print ('ops,j',ops, j)

        arr = ops
        new_arr = []
        for ii in arr:
            a = ii.split(",")
            b = []
            for jj in a:
                ind = jj
                if "(" in jj:
                    ind = jj.split("(")[1]  # .split(')')[0]
                if ")" in jj:
                    ind = jj.split(")")[0]  # .split(')')[0]
                # print (a,ind,j)
                if "/" in ind:
                    try:
                        tmp = ind.split("/")
                        ind = float(tmp[0]) / float(tmp[1])
                    except Exception:
                        pass
                try:
                    ind = float(ind)
                except Exception:
                    pass
                b.append(ind)

            new_arr.append(b)
        # print ('arr',arr)
        # print ('coord',j)
        # print ()
        arr_T_F = decorate_T_F(options=new_arr, coord=j)
        props.append(arr_T_F)
        # print ('new_arr',new_arr,j, arr_T_F)
        # print ()
        # print ()
        # print ()
    decorated_atoms = Atoms(
        lattice_mat=atoms.lattice_mat,
        elements=atoms.elements,
        coords=frac_coords,
        cartesian=False,
        props=props,
    )
    return decorated_atoms, hall_number, wsymbols
Ejemplo n.º 23
0
def test_wann():
    a = Atoms.from_poscar(pos)
    fc = read_fc(fc_file)
    get_phonon_tb(fc=fc, atoms=a, out_file=wtb)
    cvn = Spacegroup3D(a).conventional_standard_structure
    w = WannierHam(wtb)
    w.get_bandstructure_plot(atoms=cvn, yrange=[0, 550])
    cmd = "rm phonopyTB_hr.dat bs.png"
    os.system(cmd)
Ejemplo n.º 24
0
 def from_dict(self, d={}):
     """Construct class from a dictionary."""
     return Surface(
         atoms=Atoms.from_dict(d["atoms"]),
         indices=d["indices"],
         tol=d["tol"],
         vacuum=d["vacuum"],
         layers=d["layers"],
         from_conventional_structure=d["from_conventional_structure"],
     )
Ejemplo n.º 25
0
 def from_dict(self, d={}):
     """Load from a dictionary."""
     return LammpsJob(
         atoms=Atoms.from_dict(d["atoms"]),
         element_order=self.element_order,
         parameters=d["parameters"],
         lammps_cmd=d["lammps_cmd"],
         output_file=d["output_file"],
         stderr_file=d["stderr_file"],
         jobname=d["jobname"],
         attempts=d["attempts"],
         copy_files=d["copy_files"],
     )
Ejemplo n.º 26
0
def test_cal():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.2, 0.25]]
    elements = ["Si", "Si"]
    atoms = Atoms(lattice_mat=box, coords=coords, elements=elements)
    decorated_atoms, hall_number, wsymbols = get_selective_dyn_decorated_atoms(
        atoms)
    print(decorated_atoms)
    p = Poscar(decorated_atoms)
    p.write_file('POSCAR')
    #p2 = Poscar.from_file('POSCAR')
    #print (p2)
    assert (wsymbols, hall_number) == (["i", "i"], 63)
Ejemplo n.º 27
0
 def from_dict(self, d={}):
     """Convert class from a dictionary."""
     return Wannier90win(
         struct=Atoms.from_dict(d["struct"]),
         efermi=d["efermi"],
         soc=d["soc"],
         dis_num_iter=d["dis_num_iter"],
         dis_mix_ratio=d["dis_mix_ratio"],
         num_iter=d["num_iter"],
         num_print_cycles=d["num_print_cycles"],
         frozen_tol=d["frozen_tol"],
         semi_core_states=d["semi_core_states"],
         kmesh_tol=d["kmesh_tol"],
     )
Ejemplo n.º 28
0
 def from_dict(self, d={}):
     """Construct class from a dictionary."""
     return WTin(
         atoms=Atoms.from_dict(d["atoms"]),
         nelect=d["nelect"],
         wannierout=d["wannierout"],
         efermi=d["efermi"],
         soc=d["soc"],
         exclude=d["exclude"],
         nwan=d["nwan"],
         wtin=d["wtin"],
         miller=d["miller"],
         semi_core_states=d["semi_core_states"],
     )
Ejemplo n.º 29
0
 def final_structure(self):
     """Get final atoms."""
     line = self.data["qes:espresso"][self.set_key]
     if isinstance(line, list):
         line = line[-1]
     elements = []
     pos = []
     lat = []
     lat.append(
         [float(i) for i in line["atomic_structure"]["cell"]["a1"].split()])
     lat.append(
         [float(i) for i in line["atomic_structure"]["cell"]["a2"].split()])
     lat.append(
         [float(i) for i in line["atomic_structure"]["cell"]["a3"].split()])
     if isinstance(line["atomic_structure"]["atomic_positions"]["atom"],
                   list):
         for i in line["atomic_structure"]["atomic_positions"]["atom"]:
             elements.append(i["@name"])
             pos.append([float(j) for j in i["#text"].split()])
         atoms = Atoms(elements=elements,
                       coords=pos,
                       lattice_mat=lat,
                       cartesian=True)
     else:
         elements = [
             line["atomic_structure"]["atomic_positions"]["atom"]["@name"]
         ]
         pos = [[
             float(j) for j in line["atomic_structure"]["atomic_positions"]
             ["atom"]["#text"].split()
         ]]
         atoms = Atoms(elements=elements,
                       coords=pos,
                       lattice_mat=lat,
                       cartesian=True)
     return atoms
Ejemplo n.º 30
0
 def vrun_structure_to_atoms(self, s={}):
     """Convert structure to Atoms object."""
     tmp = s["crystal"]["varray"][0]["v"]
     lattice_mat = np.array([[float(j) for j in i.split()] for i in tmp])
     frac_coords = np.array(
         [[float(j) for j in i.split()] for i in s["varray"]["v"]]
     )
     elements = self.elements
     atoms = Atoms(
         lattice_mat=lattice_mat,
         elements=elements,
         coords=frac_coords,
         cartesian=False,
     )
     return atoms