def get_run_result():
        random.seed(10)
        subs_db = SubsMaterialsDatabase()
        result_list = []
        filterstring = {"purpose": "converged_ionic", "achievement": "running"}
        for x in subs_db.find(filterstring):
            id_ = x["_id"]
            # hostname = x["hostname"]
            basedir_prefix = x["basedir"]
            calc = fakeVaspRunNode(basedir_prefix)
            result_list.append(calc.run_result())
            subs_db.delete_one({"_id": id_})
            subs_db.add_files_under(basedir_prefix, StructureNode)

        result = [x["converged_ionic"] for x in result_list]
        counter = Counter(result)
        print(counter, "True if converged")
        n = subs_db.count_documents({"achievement": "executed"})
        print(n, "executed")
    def run_them():
        random.seed(10)
        subs_db = SubsMaterialsDatabase()
        filterstring = {"purpose": "converged_ionic",
                        "achievement": "to_relax"}
        for x in subs_db.find(filterstring):
            id_ = x["_id"]
            # hostname = x["hostname"]
            basedir_prefix = x["basedir"]
            # struc = StructureNode(basedir_prefix)
            # kind = x["kind"]
            # positionfile = x["positionfile"]

            print("run", basedir_prefix)
            calc = fakeVaspRunNode(basedir_prefix)
            calc.place_files()
            calc.run()
            subs_db.delete_one({"_id": id_})
            subs_db.add_files_under(basedir_prefix, StructureNode)

        n = subs_db.count_documents({"achievement": "running"})
        print(n, "running")
import os
import random
from pymatgen.core.structure import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher

from subsMat.structure import SubsStructure
from subsMat.node import subs_elms_to_prefix, StructureNode
from subsMat.database import SubsMaterialsDatabase

if __name__ == "__main__":

    random.seed(10)

    subs_db = SubsMaterialsDatabase()

    subs_elm_list = [[["Cu", "Fe"]]]
    subs_elm_list.append([["Cu", "Ni"]])
    subs_elm_list.append([["Cu", "Co"]])

    for subs_elm in subs_elm_list:
        print("substitute elements", subs_elm)

        for x in subs_db.find_subs_elems(subs_elm):
            basedir = x["basedir"]
            positionfilename = x["positionfile"]
            struc = StructureNode(basedir)
            current_dir = struc.get_currentdir()
            position_path = os.path.join(current_dir, positionfilename)
            source_uuid = x["uuid"]
            struc = SubsStructure.from_file(position_path)
            new_struc = struc.substitute_elements(subs_elm)
Exemple #4
0
from subsMat.database import SubsMaterialsDatabase

if __name__ == "__main__":
    subs_db = SubsMaterialsDatabase()
    subs_db.collection_remove()
    print("collection is removed")
import random
from collections import Counter

from subsMat.database import SubsMaterialsDatabase
from subsMat.node import StructureNode

from subsMat.fakenode import fakeVaspRunNode

if __name__ == "__main__":
    random.seed(10)
    subs_db = SubsMaterialsDatabase()
    filter = {"purpose": "converged_ionic", "achievement": "executed"}

    result_list = []
    for x in subs_db.find(filter):
        id_ = x["_id"]
        hostname = x["hostname"]
        basedir_prefix = x["basedir"]
        # current_dir = StructureNode(basedir_prefix).get_currentdir()
        # kind = x["kind"]
        # positionfile = x["positionfile"]

        calc = fakeVaspRunNode(basedir_prefix)
        result = calc.check_result()
        result_list.append(result)

        subs_db.delete_one({"_id": id_})
        subs_db.add_files_under(basedir_prefix, StructureNode)

    print(len(result_list), "data processed.")
Exemple #6
0
        # argparser = argparse.ArgumentParser()
        # argparser.add_argument("--increase_data",
        #                        default=False, action="store_true")
        # args = argparser.parse_args()

        action = ["step2"]
        if True:
            action.append("step1")
        return action

    action = parse_argument()

    if "step1" in action:
        metadata = {"purpose": "prototype", "achievement": "completed"}

        subs_db = SubsMaterialsDatabase().\
            initialize_with_dirs("Calc/MGI/mp-*", StructureNode)
        n = subs_db.count_documents()
        print("initial database size", n)

        subs_elm_list = [[["Fe", "Cu"]]]
        subs_elm_list.append([["Ni", "Cu"]])
        subs_elm_list.append([["Cu", "Co"]])
        subs_elm_list.append([["Zn", "Cu"]])

        subs_elm_list.append([["Gd", "Y"]])
        subs_elm_list.append([["Yb", "Y"]])

        count_list = []
        for subs_elm in subs_elm_list:

            print("subsitute elements", subs_elm)