Example #1
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"],
     )
Example #2
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"],
     )
Example #3
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"],
     )
Example #4
0
def test_magnetism_setup():
    from jarvis.db.figshare import get_jid_data

    atoms = Atoms.from_dict(
        get_jid_data(jid="JVASP-78681", dataset="dft_3d")["atoms"]
    )
    mag = MagneticOrdering(atoms)
    symm_list, ss = mag.get_minimum_configs(min_configs=3)

    assert len(symm_list) == 3
    assert ss.num_atoms == 8
    mag_atoms = mag.get_mag_ions()
    assert mag_atoms == ["Mn"]
    tc = mag.tc_mean_field()
    assert round(tc["Tc"], 2) == round(3868.17, 2)
Example #5
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])
    print("jid1", jid1)
    print(mat1)
    print("jid2", jid2)
    print(mat2)
    combined = make_interface(
        film=mat1.center_around_origin(),
        # max_area=1000,
        max_area=400,
        max_area_ratio_tol=0.09,
        # ltol=0.5,
        ltol=0.05,
        # atol=1.1,
        atol=0.1,
        subs=mat2.center_around_origin(),
    )["interface"]
    return combined
Example #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)
Example #7
0
def test_graph():
    from jarvis.core.atoms import Atoms
    from jarvis.db.figshare import get_jid_data

    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)
        print(i, g)
    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)
Example #8
0
 def from_dict(self, d={}):
     """Construct class from a dictionary."""
     if d["atoms"] is not None:
         atoms = Atoms.from_dict(d["atoms"])
     else:
         atoms = None
     return Chgcar(
         filename=d["filename"],
         atoms=atoms,
         chg=d["chg"],
         dim=d["dim"],
         chgdif=d["chgdif"],
         aug=d["aug"],
         augdiff=d["augdiff"],
         nsets=d["nsets"],
     )
Example #9
0
def test_magnetism_setup():
    from jarvis.db.figshare import get_jid_data
    from jarvis.core.atoms import get_supercell_dims
    atoms = Atoms.from_dict(
        get_jid_data(jid="JVASP-78681", dataset="dft_3d")["atoms"]
    )
    dim = get_supercell_dims(atoms)
    print("dim=", dim)
    dim = [2, 2, 2]
    symm_list, ss = get_unique_magnetic_structures(
        atoms, supercell_dim=dim, magnetic_ions=["Mn"]
    )
    
    print("dim=", dim, len(symm_list))
    assert len(symm_list)==5
    assert ss.num_atoms == 16
Example #10
0
def test_dataset():
    d = data("dft_2d")
    d = pd.DataFrame(d[:100])

    graphs = []
    for i, row in d.iterrows():
        structure = Atoms.from_dict(row["atoms"])
        g = Graph.atom_dgl_multigraph(
            structure,
            atom_features="atomic_number",
            compute_line_graph=False,
        )
        graphs.append(g)

    s = StructureDataset(d, graphs, "formation_energy_peratom")
    col = s.collate
Example #11
0
    def __init__(
        self,
        structures,
        targets,
        ids=None,
        cutoff=8.0,
        maxrows=np.inf,
        atom_features="atomic_number",
        transform=None,
        enforce_undirected=False,
        max_neighbors=12,
        classification=False,
    ):
        """Initialize the class."""
        self.graphs = []
        self.labels = []
        self.ids = []

        for idx, (structure, target,
                  id) in enumerate(tqdm(zip(structures, targets, ids))):

            if idx >= maxrows:
                break
            a = Atoms.from_dict(structure)
            g = Graph.atom_dgl_multigraph(
                a,
                atom_features=atom_features,
                enforce_undirected=enforce_undirected,
                cutoff=cutoff,
                max_neighbors=max_neighbors,
                id=id,
            )

            self.graphs.append(g)
            self.labels.append(target)
            self.ids.append(id)

        self.labels = torch.tensor(self.labels).type(torch.get_default_dtype())
        if classification:
            self.labels = self.labels.view(-1).long()
            print("Classification dataset.", self.labels)

        self.transform = transform
Example #12
0
def test_graph():
    from jarvis.core.atoms import Atoms
    from jarvis.db.figshare import get_jid_data

    atoms = Atoms.from_dict(get_jid_data("JVASP-664")["atoms"])
    g = Graph.from_atoms(atoms=atoms, features="atomic_number")
    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")
    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 == 2304
    assert (g.adjacency_matrix.shape) == (48, 48)
Example #13
0
def test_lat():
    box = [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
    lat = Lattice(box)
    td = lat.to_dict()
    fd = Lattice.from_dict(td)
    frac_coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
    cart_coords = [[0, 0, 0], [5, 5, 5]]
    lll = lat._calculate_lll()
    # print ('lll',lll[0][0][0])
    lll_red = lat.get_lll_reduced_lattice()._lat
    # print("lll_educed", lat.get_lll_reduced_lattice()._lat[0][0])
    assert (
        lat.lat_lengths(),
        lat.lat_angles(),
        round(lat.inv_lattice()[0][0], 2),
        [round(i, 2) for i in lat.lat_angles(radians=True)],
        lat.cart_coords(frac_coords)[1][1],
        lat.frac_coords(cart_coords)[1][1],
        lat.volume,
        lat.parameters,
        lll[0][0][0],
        lll_red[0][0],
    ) == (
        [10.0, 10.0, 10.0],
        [90.0, 90.0, 90.0],
        0.1,
        [1.57, 1.57, 1.57],
        5.0,
        0.5,
        1000.0,
        [10.0, 10.0, 10.0, 90.0, 90.0, 90.0],
        10.0,
        10.0,
    )
    d = data('dft_3d')
    for i in d:
        if i['jid'] == 'JVASP-588':
            atoms = Atoms.from_dict(i['atoms'])
            lll = atoms.lattice._calculate_lll()
            assert lll[1][0][0] == -1
Example #14
0
def test_dataset():
    d = data("dft_2d")
    d = pd.DataFrame(d[:100])

    graphs = []
    for i, row in d.iterrows():
        structure = Atoms.from_dict(row["atoms"])
        g = Graph.atom_dgl_multigraph(
            structure,
            atom_features="atomic_number",
            compute_line_graph=False,
        )
        graphs.append(g)

    s = StructureDataset(
        d, graphs, "formation_energy_peratom", line_graph=True
    )
    col = s.collate
    col1 = s.collate_line_graph
    ix = s[0]
    sz = len(s)
    s_std = s.setup_standardizer([1, 2])
Example #15
0
def test_basic_atoms():

    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"]
    Si = Atoms(lattice_mat=box, coords=coords, elements=elements)
    dim = get_supercell_dims(Si)
    assert dim == [3, 3, 3]
    polar = Si.check_polar
    Si.props = ["a", "a"]
    vac_pad = VacuumPadding(Si)
    den_2d = round(vac_pad.get_effective_2d_slab().density, 2)
    den_0d = round(vac_pad.get_effective_molecule().density, 2)
    den_lll_red = round(Si.get_lll_reduced_structure().density, 2)
    strng = Si.get_string()
    scell_nat = Si.make_supercell([2, 2, 2]).num_atoms
    scell_nat2 = Si.make_supercell_matrix([[2, 0, 0], [0, 2, 0],
                                           [0, 0, 2]]).num_atoms
    # print("scell_nat,scell_nat2", scell_nat, scell_nat2)
    # print(Si.make_supercell([2, 2, 2]))
    # print()
    # print(Si.make_supercell_matrix([[2, 0, 0], [0, 2, 0], [0, 0, 2]]))
    com = round(Si.get_center_of_mass()[0], 3)
    rem = (Si.make_supercell([2, 2, 2]).remove_site_by_index(site=0)).num_atoms
    prim = Si.get_primitive_atoms
    print(prim.cart_coords)
    assert round(prim.cart_coords[0][0], 2) == round(4.37815150, 2)
    # print ('raw_distance_matrix', prim.raw_distance_matrix)
    # print ('raw_distance_matrix', Si.raw_distance_matrix)
    # print ('distance_matrix', Si.pymatgen_converter().distance_matrix)
    assert round(prim.raw_distance_matrix[0][1],
                 2) == round(4.42386329832851, 2)
    print(prim.raw_angle_matrix)
    d = Si.to_dict()
    new_at = Atoms.from_dict(d)
    angs_a = d["angles"][0]
    Si_2_den = Atoms(
        lattice_mat=d["lattice_mat"],
        coords=d["coords"],
        elements=d["elements"],
    ).density
    Si_xyz = Si.get_xyz_string
    Si.write_xyz(filename="atoms.xyz")
    tmp = Atoms.from_xyz(filename="atoms.xyz")
    cmd = 'rm atoms.xyz'
    os.system(cmd)
    Si.center_around_origin()
    # print ('scell_nat', Si_2)
    assert (
        round(Si.volume, 2),
        Si.atomic_numbers,
        Si.num_atoms,
        Si.frac_coords[0][0],
        Si.cart_coords[0][0],
        round(Si.density, 2),
        Si.spacegroup(),
        Si.pymatgen_converter() != {},
        polar,
        Si.props[0],
        den_2d,
        den_0d,
        round(Si.packing_fraction, 2),
        Si.composition.to_dict(),
        strng != "",
        den_lll_red,
        scell_nat,
        com,
        rem,
        angs_a,
        round(Si_2_den, 2),
    ) == (
        40.03,
        [14, 14],
        2,
        0,
        0.0,
        2.33,
        "C2/m (12)",
        True,
        False,
        "a",
        0.35,
        0.01,
        0.28,
        {
            "Si": 2
        },
        True,
        2.33,
        16,
        0.679,
        15,
        60.0,
        2.33,
    )
    cc = Si.center()
    cc = Si.center(axis=[0, 0, 1])

    m1 = Atoms.from_dict(get_jid_data("JVASP-6640")["atoms"])
    assert m1.check_polar == True
    print("Strain test")
    print(m1)
    m1.apply_strain(0.1)
    print(m1)
    assert m1.lattice_mat[2][2] == 32.8717576
    m1.apply_strain([0, 0, 0.1])
    assert m1.lattice_mat[2][2] == 36.158933360000006
    filename = "atoms.cif"
    m1.write_cif(filename)
    a = Atoms.from_cif(filename)
    filename = "POSCAR"
    m1.write_poscar(filename)
    m2 = Atoms.from_poscar(filename)

    filename = "atoms.xyz"
    m1.write_xyz(filename)
    m3 = Atoms.from_xyz(filename)

    cmd = "rm atoms.xyz POSCAR atoms.cif"
    os.system(cmd)
Example #16
0
def test_extra_spgs():
    from jarvis.db.figshare import data

    d = data("dft_3d")
    few_spgs = {
        "JVASP-4663": 119,
        "JVASP-4666": 194,
        "JVASP-588": 160,
        "JVASP-4669": 191,
        "JVASP-4672": 141,
        "JVASP-581": 164,
        "JVASP-4687": 139,
        "JVASP-4693": 62,
        "JVASP-4696": 187,
        "JVASP-4711": 225,
        "JVASP-4714": 2,
        "JVASP-4723": 60,
        "JVASP-32": 167,
        "JVASP-107": 186,
        "JVASP-4756": 63,
        "JVASP-96": 216,
        "JVASP-4334": 123,
        "JVASP-4222": 11,
        "JVASP-4804": 156,
        "JVASP-329": 129,
        "JVASP-4852": 163,
        "JVASP-155": 61,
        "JVASP-4340": 51,
        "JVASP-4343": 15,
        "JVASP-4361": 14,
        "JVASP-137": 72,
        "JVASP-4879": 166,
        "JVASP-4885": 19,
        "JVASP-4894": 31,
        "JVASP-4216": 12,
        "JVASP-4918": 121,
        "JVASP-4948": 25,
        "JVASP-4957": 221,
        "JVASP-4960": 65,
        "JVASP-5059": 189,
        "JVASP-5071": 66,
        "JVASP-5074": 150,
        "JVASP-5086": 74,
        "JVASP-4388": 64,
        "JVASP-4391": 136,
        "JVASP-5155": 127,
        "JVASP-5185": 43,
        "JVASP-5197": 59,
        "JVASP-5212": 29,
        "JVASP-164": 176,
        "JVASP-5224": 137,
        "JVASP-5227": 148,
        "JVASP-4234": 193,
        "JVASP-5257": 7,
        "JVASP-5266": 140,
        "JVASP-4397": 33,
        "JVASP-5317": 8,
        "JVASP-5332": 13,
        "JVASP-5353": 16,
        "JVASP-5371": 4,
        "JVASP-5407": 229,
        "JVASP-5416": 147,
        "JVASP-5509": 52,
        "JVASP-5536": 70,
        "JVASP-5560": 71,
        "JVASP-5680": 28,
        "JVASP-5740": 6,
        "JVASP-5839": 162,
        "JVASP-5863": 79,
        "JVASP-110": 99,
        "JVASP-579": 38,
        "JVASP-4501": 5,
        "JVASP-91": 227,
        "JVASP-41": 154,
        "JVASP-4516": 96,
        "JVASP-4564": 82,
        "JVASP-4645": 130,
        "JVASP-152": 55,
        "JVASP-4792": 88,
        "JVASP-5041": 107,
        "JVASP-5425": 87,
        "JVASP-5464": 115,
        "JVASP-5650": 157,
        "JVASP-4450": 36,
        "JVASP-22520": 152,
        "JVASP-22523": 205,
        "JVASP-11998": 53,
        "JVASP-22528": 58,
        "JVASP-22533": 41,
        "JVASP-12091": 32,
        "JVASP-22541": 215,
        "JVASP-22543": 97,
        "JVASP-22549": 9,
        "JVASP-12103": 138,
        "JVASP-22575": 40,
        "JVASP-22602": 180,
        "JVASP-22611": 182,
        "JVASP-12022": 85,
        "JVASP-22637": 111,
        "JVASP-12139": 10,
        "JVASP-22709": 92,
        "JVASP-12060": 20,
        "JVASP-12064": 1,
        "JVASP-12194": 185,
        "JVASP-13885": 128,
        "JVASP-14096": 56,
        "JVASP-14020": 122,
        "JVASP-13904": 54,
        "JVASP-13783": 135,
        "JVASP-14213": 26,
        "JVASP-14034": 23,
        "JVASP-14158": 113,
        "JVASP-14256": 21,
        "JVASP-32150": 217,
        "JVASP-28392": 224,
        "JVASP-32180": 146,
        "JVASP-32197": 57,
        "JVASP-31813": 67,
        "JVASP-31819": 219,
        "JVASP-29262": 39,
        "JVASP-29281": 102,
        "JVASP-31825": 226,
        "JVASP-29425": 143,
        "JVASP-29441": 42,
        "JVASP-29520": 73,
        "JVASP-29526": 18,
        "JVASP-29555": 149,
        "JVASP-29597": 151,
        "JVASP-29705": 174,
        "JVASP-31921": 199,
        "JVASP-33147": 161,
        "JVASP-33220": 46,
        "JVASP-33344": 114,
        "JVASP-30263": 44,
        "JVASP-33832": 155,
        "JVASP-30458": 69,
        "JVASP-30461": 144,
        "JVASP-30518": 132,
        "JVASP-36540": 198,
        "JVASP-36548": 220,
        "JVASP-36568": 3,
        "JVASP-36573": 145,
        "JVASP-35061": 131,
        "JVASP-35137": 125,
        "JVASP-35222": 204,
        "JVASP-35344": 109,
        "JVASP-42053": 173,
        "JVASP-40216": 91,
        "JVASP-38594": 165,
        "JVASP-37330": 86,
        "JVASP-37573": 84,
        "JVASP-36714": 47,
        "JVASP-36754": 98,
        "JVASP-59313": 230,
        "JVASP-46893": 95,
        "JVASP-46896": 76,
        "JVASP-45779": 30,
        "JVASP-45831": 158,
        "JVASP-46446": 35,
        "JVASP-44393": 159,
        "JVASP-44773": 22,
        "JVASP-47741": 78,
        "JVASP-47811": 181,
        "JVASP-48055": 94,
        "JVASP-48916": 34,
        "JVASP-49907": 190,
        "JVASP-50342": 223,
        "JVASP-50360": 68,
        "JVASP-50431": 37,
        "JVASP-52902": 142,
        "JVASP-52377": 24,
        "JVASP-50791": 214,
        "JVASP-54512": 108,
        "JVASP-56567": 213,
        "JVASP-54867": 126,
        "JVASP-55180": 81,
        "JVASP-57780": 212,
        "JVASP-57807": 118,
        "JVASP-57816": 50,
        "JVASP-57100": 197,
        "JVASP-57138": 116,
        "JVASP-58233": 124,
        "JVASP-59682": 200,
        "JVASP-20180": 206,
        "JVASP-21448": 203,
        "JVASP-40468": 90,
        "JVASP-42914": 17,
        "JVASP-21594": 100,
        "JVASP-21706": 188,
        "JVASP-22783": 218,
        "JVASP-24006": 202,
        "JVASP-30879": 83,
        "JVASP-31186": 49,
        "JVASP-21031": 110,
        "JVASP-21116": 192,
        "JVASP-25245": 134,
        "JVASP-7066": 169,
        "JVASP-13017": 112,
        "JVASP-58953": 105,
        "JVASP-8682": 183,
        "JVASP-9902": 80,
        "JVASP-34882": 208,
        "JVASP-34330": 179,
        "JVASP-34502": 48,
        "JVASP-62982": 178,
    }
    """
 mem=[]
 spgs=[]
 pos=[]
 info=defaultdict()
 for i in d:
     a=Atoms.from_dict(i['atoms'])
     spg=Spacegroup3D(a).space_group_number
     if spg not in spgs:
        spgs.append(spg)
        pos.append(i['jid'])
        info[i['jid']]=spg
        print (info)
        if len(spgs)==230:
            break
 """
    for i, j in few_spgs.items():
        for ii in d:
            if ii["jid"] == i:

                a = Atoms.from_dict(ii["atoms"])
                spg = Spacegroup3D(a).space_group_number
                assert j == spg

                lattice_mat = a.lattice_mat
                kp = Kpoints3D().automatic_length_mesh(lattice_mat=lattice_mat,
                                                       length=40)
                sym = kp.high_symm_path(a)._path
                # print (ii['jid'],a)
                # TODO: following line failing for JVASP-4222
                # x, y = kp.interpolated_points(a)
                break
Example #17
0
 def from_dict(self, d={}):
     """Construct Poscar object from a dictionary."""
     return Poscar(atoms=Atoms.from_dict(d["atoms"]), comment=d["comment"])
Example #18
0
from jarvis.tasks.lammps.lammps import LammpsJob, JobFactory
from jarvis.core.atoms import Atoms
from jarvis.db.figshare import get_jid_data
from jarvis.analysis.structure.spacegroup import Spacegroup3D

# atoms = Atoms.from_poscar('POSCAR')
# Get Aluminum FCC
tmp_dict = get_jid_data(jid="JVASP-816", dataset="dft_3d")["atoms"]
atoms = Atoms.from_dict(tmp_dict)
# Get conventional cell
spg = Spacegroup3D(atoms)
cvn_atoms = spg.conventional_standard_structure
ff = "/users/knc6/Software/LAMMPS/lammps-master/potentials/Al_zhou.eam.alloy"
mod = "/users/knc6/Software/Devs/jarvis/jarvis/tasks/lammps/templates/inelast.mod"
cmd = "/users/knc6/Software/LAMMPS/lammps-master/src/lmp_serial<in.main>out"
parameters = {
    "pair_style": "eam/alloy",
    "pair_coeff": ff,
    "atom_style": "charge",
    "control_file": mod,
}
# Test LammpsJob
lmp = LammpsJob(atoms=cvn_atoms,
                parameters=parameters,
                lammps_cmd=cmd,
                jobname="Test").runjob()

# Test high-throughput
job_fact = JobFactory(pair_style="eam/alloy", name="my_first_lammps_run")
job_fact.all_props_eam_alloy(atoms=cvn_atoms, ff_path=ff, lammps_cmd=cmd)
Example #19
0
def test_spg229():
    d = loadjson(os.path.join(os.path.dirname(__file__), "spg229.json"))
    for i in d:
        atoms = Atoms.from_dict(i["atoms"])
        spg = Spacegroup3D(atoms).space_group_number
        assert spg == i["spg_number"]
Example #20
0
def upload_sample_data(curate_xml=False):
    """
    Generate and upload XML files.

    Set curate_xml==True to upload all the XML documents.
    """
    d = data("dft_2d")

    count = 0
    for i in d[0:1]:
        filname = str(i["jid"]) + str(".xml")
        if not os.path.exists(filname):
            count = count + 1
            energy = (str(i["optb88vdw_total_energy"]) + str(",") +
                      str(i["formation_energy_peratom"]))
            atoms = Atoms.from_dict(i["atoms"])
            formula = str(atoms.composition.reduced_formula)
            sgp = str(Spacegroup3D(atoms).space_group_symbol)
            name = str(i["jid"])
            print(name)
            # ref = str("")
            func = str("OptB88vdW")
            elem = ""
            species = atoms.elements
            for j in species:
                elem = str(elem) + str(j) + str("-")
            encut = str(i["encut"])
            kpoints = (str(i["kpoints_array"][0]) + str("x") +
                       str(i["kpoints_array"][1]) + str("x") +
                       str(i["kpoints_array"][2]))
            el_tens = "na"
            try:
                el_tens = str(",".join(
                    map(str,
                        np.array(i["elastic_tensor"]).flatten())))
            except Exception:
                pass
            KV = str(i["bulk_modulus_kv"])
            GV = str(i["shear_modulus_gv"])
            op_eg = str(i["optb88vdw_bandgap"])
            mbj_eg = str(i["mbj_bandgap"])
            realx_arr = str(i["epsx"])
            mrealx_arr = str(i["mepsx"])
            realy_arr = str(i["epsy"])
            mrealy_arr = str(i["mepsy"])
            realz_arr = str(i["epsz"])
            mrealz_arr = str(i["mepsz"])
            typ = str("2D")  # 3D
            other = str(
                "Citation: 1) DOI:10.1038/s41598-017-05402-0" +
                ",2) DOI: 10.1038/sdata.2018.82, 3) arXiv:1804.01033v2 ")
            struct = atoms.get_string()
            data_json(
                other=other,
                energy=energy,
                typ=typ,
                formula=formula,
                sgp=sgp,
                name=name,
                func=func,
                elem=elem,
                encut=encut,
                kpoints=kpoints,
                el_tens=el_tens,
                KV=KV,
                GV=GV,
                op_eg=op_eg,
                mbj_eg=mbj_eg,
                realx_arr=realx_arr,
                mrealx_arr=mrealx_arr,
                realy_arr=realy_arr,
                mrealy_arr=mrealy_arr,
                realz_arr=realz_arr,
                mrealz_arr=mrealz_arr,
                struct=struct,
                curate_xml=curate_xml,
            )
Example #21
0
from jarvis.db.figshare import data, get_jid_data

from jarvis.core.atoms import Atoms, crop_square
from jarvis.io.prismatic.inputs import write_prismatic_xyz

a = Atoms.from_dict(get_jid_data("JVASP-667")["atoms"])


def test_inputs():
    c = crop_square(a)
    lines = write_prismatic_xyz(c)
Example #22
0
from jarvis.tasks.vasp.vasp import VaspJob, write_jobfact_optb88vdw
from jarvis.io.vasp.inputs import Potcar, Incar, Poscar
from jarvis.db.jsonutils import dumpjson
from jarvis.core.atoms import Atoms
from jarvis.core.kpoints import Kpoints3D
from jarvis.tasks.queue_jobs import Queue
import os
from jarvis.tasks.vasp.vasp import JobFactory, write_jobfact_optb88vdw
from jarvis.db.figshare import get_jid_data

tmp_dict = get_jid_data(jid="JVASP-816", dataset="dft_3d")["atoms"]
atoms = Atoms.from_dict(tmp_dict)

vasp_cmd = "mpirun /users/knc6/VASP/vasp54/src/vasp.5.4.1DobbySOC2/bin/vasp_std"
copy_files = ["/users/knc6/bin/vdw_kernel.bindat"]
submit_cmd = ["qsub", "submit_job"]
jids = ["JVASP-1002", "JVASP-1067"]

for jid in jids:
    d = get_jid_data(jid=jid, dataset="dft_3d")
    atoms = Atoms.from_dict(d["atoms"]).get_primitive_atoms
    mat = Poscar(atoms)
    mat.comment = "bulk@" + str(jid)
    cwd_home = os.getcwd()
    dir_name = d["jid"] + "_" + str("PBEBO")
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)
    os.chdir(dir_name)
    job = JobFactory(
        vasp_cmd=vasp_cmd,
        poscar=mat,
Example #23
0
 def get_enp_jid(jid=""):
     for i in dft2d:
         if i["jid"] == jid:
             return (i["optb88vdw_total_energy"] /
                     Atoms.from_dict(i["atoms"]).num_atoms)
Example #24
0
def test_2d():
    p = Poscar.from_file(C).atoms
    vacs = Vacancy(atoms=p).generate_defects(enforce_c_size=10.0, extend=1)
    # print (vacs[0]._defect_structure)
    assert (Atoms.from_dict(
        vacs[0].to_dict()["defect_structure"]).num_atoms == 49)