• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python snl.StructureNL类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pymatgen.matproj.snl.StructureNL的典型用法代码示例。如果您正苦于以下问题:Python StructureNL类的具体用法?Python StructureNL怎么用?Python StructureNL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StructureNL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run_task

 def run_task(self, fw_spec):
     # Read structure from previous relaxation
     relaxed_struct = fw_spec['output']['crystal']
     # Generate deformed structures
     d_struct_set = DeformedStructureSet(relaxed_struct, ns=0.06)
     wf=[]
     for i, d_struct in enumerate(d_struct_set.def_structs):
         fws=[]
         connections={}
         f = Composition(d_struct.formula).alphabetical_formula
         snl = StructureNL(d_struct, 'Joseph Montoya <[email protected]>', 
                           projects=["Elasticity"])
         tasks = [AddSNLTask()]
         snl_priority = fw_spec.get('priority', 1)
         spec = {'task_type': 'Add Deformed Struct to SNL database', 
                 'snl': snl.as_dict(), 
                 '_queueadapter': QA_DB, 
                 '_priority': snl_priority}
         if 'snlgroup_id' in fw_spec and isinstance(snl, MPStructureNL):
             spec['force_mpsnl'] = snl.as_dict()
             spec['force_snlgroup_id'] = fw_spec['snlgroup_id']
             del spec['snl']
         fws.append(Firework(tasks, spec, 
                             name=get_slug(f + '--' + spec['task_type']), 
                             fw_id=-1000+i*10))
         connections[-1000+i*10] = [-999+i*10]
         spec = snl_to_wf._snl_to_spec(snl, 
                                       parameters={'exact_structure':True})
         spec = update_spec_force_convergence(spec)
         spec['deformation_matrix'] = d_struct_set.deformations[i].tolist()
         spec['original_task_id'] = fw_spec["task_id"]
         spec['_priority'] = fw_spec['_priority']*2
         #Turn off dupefinder for deformed structure
         del spec['_dupefinder']
         spec['task_type'] = "Optimize deformed structure"
         fws.append(Firework([VaspWriterTask(), SetupElastConstTask(),
                              get_custodian_task(spec)], 
                             spec, 
                             name=get_slug(f + '--' + spec['task_type']), 
                             fw_id=-999+i*10))
         
         priority = fw_spec['_priority']*3
         spec = {'task_type': 'VASP db insertion', 
                 '_priority': priority,
                 '_allow_fizzled_parents': True, 
                 '_queueadapter': QA_DB, 
                 'elastic_constant':"deformed_structure", 
                 'clean_task_doc':True,
                 'deformation_matrix':d_struct_set.deformations[i].tolist(), 
                 'original_task_id':fw_spec["task_id"]}
         fws.append(Firework([VaspToDBTask()], 
                             spec, 
                             name=get_slug(f + '--' + spec['task_type']), 
                             fw_id=-998+i*10))
         connections[-999+i*10] = [-998+i*10]
         wf.append(Workflow(fws, connections))
     return FWAction(additions=wf)
开发者ID:vanceeasleaf,项目名称:MPWorks,代码行数:57,代码来源:phonon_tasks.py


示例2: structure_to_mock_job

def structure_to_mock_job(structure):
    # Needs at least one author. This is for a mock job, so can put whatever.
    snl = StructureNL(structure, [{"name": "Saurabh Bajaj", "email": "[email protected]"},
                                  {"name": "Anubhav Jain", "email": "[email protected]"}])
    job = snl.as_dict()
    if 'is_valid' not in job:
        job.update(get_meta_from_structure(snl.structure))
    sorted_structure = snl.structure.get_sorted_structure()
    job.update(sorted_structure.as_dict())
    return job
开发者ID:saurabh02,项目名称:research_scripts,代码行数:10,代码来源:compare_and_submit_structs_to_MP.py


示例3: test_to_from_dict

    def test_to_from_dict(self):
        # no complicated objects in the 'data' or 'nodes' field
        a = StructureNL(self.s, self.hulk, ['test_project'], self.pmg,
                        ['remark1'], {"_my_data": "string"},
                        [self.valid_node, self.valid_node2])
        b = StructureNL.from_dict(a.as_dict())
        self.assertEqual(a, b)
        # complicated objects in the 'data' and 'nodes' field
        complicated_node = {
            "name": "complicated node",
            "url": "www.complicatednodegoeshere.com",
            "description": {
                "structure": self.s2
            }
        }
        a = StructureNL(self.s, self.hulk, ['test_project'], self.pmg,
                        ['remark1'], {"_my_data": {
                            "structure": self.s2
                        }}, [complicated_node, self.valid_node])
        b = StructureNL.from_dict(a.as_dict())
        self.assertEqual(
            a, b, 'to/from dict is broken when object embedding is '
            'used! Apparently MontyEncoding is broken...')

        #Test molecule
        molnl = StructureNL(self.mol, self.hulk, references=self.pmg)
        b = StructureNL.from_dict(molnl.as_dict())
        self.assertEqual(molnl, b)
开发者ID:Rongpeng,项目名称:pymatgen,代码行数:28,代码来源:test_snl.py


示例4: run_task

    def run_task(self, fw_spec):
        sma = SNLMongoAdapter.auto_load()
        snl = StructureNL.from_dict(fw_spec['snl'])
        mpsnl, snlgroup_id, spec_group = sma.add_snl(snl)
        mod_spec = [{"_push": {"run_tags": "species_group={}".format(spec_group)}}] if spec_group else None

        return FWAction(update_spec={'mpsnl': mpsnl.to_dict, 'snlgroup_id': snlgroup_id}, mod_spec=mod_spec)
开发者ID:matk86,项目名称:MPWorks,代码行数:7,代码来源:snl_tasks.py


示例5: run_task

    def run_task(self, fw_spec):
        # pass-through option for when we start with an mpsnl and don't actually want to add
        if 'force_mpsnl' in fw_spec and 'force_snlgroup_id' in fw_spec:
            print 'USING FORCED MPSNL'
            return FWAction(update_spec={'mpsnl': fw_spec['force_mpsnl'], 'snlgroup_id': fw_spec['force_snlgroup_id']})

        sma = SNLMongoAdapter.auto_load()
        snl = StructureNL.from_dict(fw_spec['snl'])
        mpsnl, snlgroup_id = sma.add_snl(snl)

        return FWAction(update_spec={'mpsnl': mpsnl.to_dict, 'snlgroup_id': snlgroup_id})
开发者ID:miaoliu,项目名称:MPWorks,代码行数:11,代码来源:snl_tasks.py


示例6: run_task

    def run_task(self, fw_spec):
        # get the SNL mongo adapter
        sma = SNLMongoAdapter.auto_load()

        # get the SNL
        snl = StructureNL.from_dict(fw_spec['snl'])

        # add snl
        mpsnl, snlgroup_id = sma.add_snl(snl)

        return FWAction(update_spec={'mpsnl': mpsnl.to_dict, 'snlgroup_id': snlgroup_id})
开发者ID:cmgtam,项目名称:MPWorks,代码行数:11,代码来源:snl_tasks.py


示例7: from_snl

    def from_snl(snl, snl_id, sg_num, sg_symbol, hall, xtal_system, lattice_type):
        # make a copy of SNL
        snl2 = StructureNL.from_dict(snl.to_dict)
        if '_materialsproject' not in snl2.data:
            snl2.data['_materialsproject'] = {}
        snl2.data['_materialsproject']['snl_id'] = snl_id
        snl2.data['_materialsproject']['sg_num'] = sg_num
        snl2.data['_materialsproject']['sg_symbol'] = sg_symbol
        snl2.data['_materialsproject']['hall'] = hall
        snl2.data['_materialsproject']['xtal_system'] = xtal_system
        snl2.data['_materialsproject']['lattice_type'] = lattice_type

        return MPStructureNL.from_dict(snl2.to_dict)
开发者ID:cmgtam,项目名称:MPWorks,代码行数:13,代码来源:mpsnl.py


示例8: submit_structures

    def submit_structures(self, structures, authors, projects=None,
                             references='', remarks=None, data=None,
                             histories=None, created_at=None):
        """
        Submits a list of structures to the Materials Project as SNL files.
        The argument list mirrors the arguments for the StructureNL object,
        except that a list of structures with the same metadata is used as an
        input.

        .. note::

            As of now, this MP REST feature is open only to a select group of
            users. Opening up submissions to all users is being planned for
            the future.

        Args:
            structures:
                A list of Structure objects
            authors:
                *List* of {"name":'', "email":''} dicts,
                *list* of Strings as 'John Doe <[email protected]>',
                or a single String with commas separating authors
            projects:
                List of Strings ['Project A', 'Project B']. This applies to
                all structures.
            references:
                A String in BibTeX format. Again, this applies to all
                structures.
            remarks:
                List of Strings ['Remark A', 'Remark B']
            data:
                A list of free form dict. Namespaced at the root level with an
                underscore, e.g. {"_materialsproject":<custom data>}. The
                length of data should be the same as the list of structures
                if not None.
            histories:
                List of list of dicts - [[{'name':'', 'url':'',
                'description':{}}], ...] The length of histories should be the
                same as the list of structures if not None.
            created_at:
                A datetime object

        Returns:
            A list of inserted submission ids.
        """
        snl_list = StructureNL.from_structures(structures,
                    authors, projects, references, remarks, data,
                    histories, created_at)

        self.submit_snl(snl_list)
开发者ID:isayev,项目名称:pymatgen,代码行数:50,代码来源:rest.py


示例9: test_from_structures

    def test_from_structures(self):
        s1 = Structure([[5, 0, 0], [0, 5, 0], [0, 0, 5]], ["Fe"], [[0, 0, 0]])
        s2 = Structure([[5, 0, 0], [0, 5, 0], [0, 0, 5]], ["Mn"], [[0, 0, 0]])
        remarks = ["unittest"]
        authors="Test User <[email protected]>"
        snl_list = StructureNL.from_structures([s1, s2], authors, remarks=remarks)

        self.assertEqual(len(snl_list), 2)
        snl1 = snl_list[0]
        snl2 = snl_list[1]
        self.assertEqual(snl1.remarks, remarks)
        self.assertEqual(snl2.remarks, remarks)
        self.assertEqual(snl1.authors, [Author.parse_author(authors)])
        self.assertEqual(snl2.authors, [Author.parse_author(authors)])
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:14,代码来源:test_snl.py


示例10: submit_new_workflow

    def submit_new_workflow(self):
        # finds a submitted job, creates a workflow, and submits it to FireWorks
        job = self.jobs.find_and_modify({'state': 'SUBMITTED'}, {'$set': {'state': 'WAITING'}})
        if job:
            submission_id = job['submission_id']
            try:
                if 'snl_id' in job:
                    snl = MPStructureNL.from_dict(job)
                else:
                    snl = StructureNL.from_dict(job)
                if len(snl.structure.sites) > SubmissionProcessor.MAX_SITES:
                    self.sma.update_state(submission_id, 'REJECTED', 'too many sites', {})
                    print 'REJECTED WORKFLOW FOR {} - too many sites ({})'.format(
                        snl.structure.formula, len(snl.structure.sites))
                elif not job['is_valid']:
                    self.sma.update_state(submission_id, 'REJECTED',
                                          'invalid structure (atoms too close)', {})
                    print 'REJECTED WORKFLOW FOR {} - invalid structure'.format(
                        snl.structure.formula)
                elif len(set(NO_POTCARS) & set(job['elements'])) > 0:
                    self.sma.update_state(submission_id, 'REJECTED',
                                          'invalid structure (no POTCAR)', {})
                    print 'REJECTED WORKFLOW FOR {} - invalid element (No POTCAR)'.format(
                        snl.structure.formula)
                elif not job['is_ordered']:
                    self.sma.update_state(submission_id, 'REJECTED',
                                          'invalid structure (disordered)', {})
                    print 'REJECTED WORKFLOW FOR {} - invalid structure'.format(
                        snl.structure.formula)
                else:
                    snl.data['_materialsproject'] = snl.data.get('_materialsproject', {})
                    snl.data['_materialsproject']['submission_id'] = submission_id

                    # create a workflow
                    if "Elasticity" in snl.projects:
                        from mpworks.workflows.snl_to_wf_phonon import snl_to_wf_phonon
                        wf=snl_to_wf_phonon(snl, job['parameters'])
                    else:
                        wf = snl_to_wf(snl, job['parameters'])
                    self.launchpad.add_wf(wf)
                    print 'ADDED WORKFLOW FOR {}'.format(snl.structure.formula)
            except:
                self.jobs.find_and_modify({'submission_id': submission_id},
                                          {'$set': {'state': 'ERROR'}})
                traceback.print_exc()

            return submission_id
开发者ID:vanceeasleaf,项目名称:MPWorks,代码行数:47,代码来源:process_submissions.py


示例11: from_snl

    def from_snl(snl, snl_id, sg_num, sg_symbol, hall, xtal_system, lattice_type, pointgroup):
        # make a copy of SNL
        snl2 = StructureNL.from_dict(snl.to_dict)
        if '_materialsproject' not in snl2.data:
            snl2.data['_materialsproject'] = {}

        snl2.data['_materialsproject']['snl_id'] = snl_id
        snl2.data['_materialsproject']['spacegroup'] = {}
        sg = snl2.data['_materialsproject']['spacegroup']
        sg['symbol'] = sg_symbol
        sg['number'] = sg_num
        sg['point_group'] = pointgroup
        sg['crystal_system'] = xtal_system
        sg['hall'] = hall
        sg['lattice_type'] = lattice_type

        return MPStructureNL.from_dict(snl2.to_dict)
开发者ID:matk86,项目名称:MPWorks,代码行数:17,代码来源:mpsnl.py


示例12: from_snl

    def from_snl(snl, snl_id, sg_num, sg_symbol, hall, xtal_system, lattice_type, pointgroup):
        # make a copy of SNL
        snl2 = StructureNL.from_dict(snl.as_dict())
        if "_materialsproject" not in snl2.data:
            snl2.data["_materialsproject"] = {}

        snl2.data["_materialsproject"]["snl_id"] = snl_id
        snl2.data["_materialsproject"]["spacegroup"] = {}
        sg = snl2.data["_materialsproject"]["spacegroup"]
        sg["symbol"] = sg_symbol
        sg["number"] = sg_num
        sg["point_group"] = pointgroup
        sg["crystal_system"] = xtal_system
        sg["hall"] = hall
        sg["lattice_type"] = lattice_type

        return MPStructureNL.from_dict(snl2.as_dict())
开发者ID:ctoher,项目名称:MPWorks,代码行数:17,代码来源:mpsnl.py


示例13: submit_new_workflow

    def submit_new_workflow(self):
        # finds a submitted job, creates a workflow, and submits it to FireWorks
        job = self.jobs.find_and_modify({'state': 'submitted'}, {'$set': {'state': 'waiting'}})
        if job:
            submission_id = job['submission_id']
            try:
                snl = StructureNL.from_dict(job)
                snl.data['_materialsproject'] = snl.data.get('_materialsproject', {})
                snl.data['_materialsproject']['submission_id'] = submission_id

                # create a workflow
                wf = snl_to_wf(snl)
                self.launchpad.add_wf(wf)
                print 'ADDED WORKFLOW FOR {}'.format(snl.structure.formula)
            except:
                self.jobs.find_and_modify({'submission_id': submission_id}, {'$set': {'state': 'error'}})
                traceback.print_exc()

            return submission_id
开发者ID:cmgtam,项目名称:MPWorks,代码行数:19,代码来源:submissions_mongo.py


示例14: job_is_submittable

def job_is_submittable(job):
    snl = StructureNL.from_dict(job)
    # mpworks.processors.process_submissions.SubmissionProcessor#submit_new_workflow
    max_sites = 200  # SubmissionProcessor.MAX_SITES above
    # from mpworks.workflows.wf_utils import NO_POTCARS
    no_potcars = ['Po', 'At', 'Rn', 'Fr', 'Ra', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr']
    if len(snl.structure.sites) > max_sites:
        print 'REJECTED WORKFLOW FOR {} - too many sites ({})'.format(
            snl.structure.formula, len(snl.structure.sites))
    elif not job['is_valid']:
        print 'REJECTED WORKFLOW FOR {} - invalid structure (atoms too close)'.format(
            snl.structure.formula)
    elif len(set(no_potcars) & set(job['elements'])) > 0:
        print 'REJECTED WORKFLOW FOR {} - invalid element (No POTCAR)'.format(
            snl.structure.formula)
    elif not job['is_ordered']:
        print 'REJECTED WORKFLOW FOR {} - invalid structure (disordered)'.format(
            snl.structure.formula)
    else:
        return True
    return False
开发者ID:saurabh02,项目名称:research_scripts,代码行数:21,代码来源:compare_and_submit_structs_to_MP.py


示例15: run_task

    def run_task(self, fw_spec):
        print "sleeping 10s for Mongo"
        time.sleep(10)
        print "done sleeping"
        print "the gap is {}, the cutoff is {}".format(fw_spec["analysis"]["bandgap"], self.gap_cutoff)
        if fw_spec["analysis"]["bandgap"] >= self.gap_cutoff:
            static_dens = 90
            uniform_dens = 1000
            line_dens = 20
        else:
            static_dens = 450
            uniform_dens = 1500
            line_dens = 30

        if fw_spec["analysis"]["bandgap"] <= self.metal_cutoff:
            user_incar_settings = {"ISMEAR": 1, "SIGMA": 0.2}
        else:
            user_incar_settings = {}

        print "Adding more runs..."

        type_name = "GGA+U" if "GGA+U" in fw_spec["prev_task_type"] else "GGA"

        snl = StructureNL.from_dict(fw_spec["mpsnl"])
        f = Composition(snl.structure.composition.reduced_formula).alphabetical_formula

        fws = []
        connections = {}

        priority = fw_spec["_priority"]
        trackers = [
            Tracker("FW_job.out"),
            Tracker("FW_job.error"),
            Tracker("vasp.out"),
            Tracker("OUTCAR"),
            Tracker("OSZICAR"),
        ]
        trackers_db = [Tracker("FW_job.out"), Tracker("FW_job.error")]

        # run GGA static
        spec = fw_spec  # pass all the items from the current spec to the new
        spec.update(
            {
                "task_type": "{} static v2".format(type_name),
                "_queueadapter": QA_VASP_SMALL,
                "_dupefinder": DupeFinderVasp().to_dict(),
                "_priority": priority,
                "_trackers": trackers,
            }
        )
        fws.append(
            Firework(
                [
                    VaspCopyTask({"use_CONTCAR": True, "skip_CHGCAR": True}),
                    SetupStaticRunTask({"kpoints_density": static_dens, "user_incar_settings": user_incar_settings}),
                    get_custodian_task(spec),
                ],
                spec,
                name=get_slug(f + "--" + spec["task_type"]),
                fw_id=-10,
            )
        )

        # insert into DB - GGA static
        spec = {
            "task_type": "VASP db insertion",
            "_queueadapter": QA_DB,
            "_allow_fizzled_parents": True,
            "_priority": priority * 2,
            "_dupefinder": DupeFinderDB().to_dict(),
            "_trackers": trackers_db,
        }
        fws.append(Firework([VaspToDBTask()], spec, name=get_slug(f + "--" + spec["task_type"]), fw_id=-9))
        connections[-10] = -9

        # run GGA Uniform
        spec = {
            "task_type": "{} Uniform v2".format(type_name),
            "_queueadapter": QA_VASP,
            "_dupefinder": DupeFinderVasp().to_dict(),
            "_priority": priority,
            "_trackers": trackers,
        }
        fws.append(
            Firework(
                [
                    VaspCopyTask({"use_CONTCAR": False}),
                    SetupNonSCFTask({"mode": "uniform", "kpoints_density": uniform_dens}),
                    get_custodian_task(spec),
                ],
                spec,
                name=get_slug(f + "--" + spec["task_type"]),
                fw_id=-8,
            )
        )
        connections[-9] = -8

        # insert into DB - GGA Uniform
        spec = {
            "task_type": "VASP db insertion",
#.........这里部分代码省略.........
开发者ID:ctoher,项目名称:MPWorks,代码行数:101,代码来源:controller_tasks.py


示例16: process_fw

    def process_fw(self, dir_name, d):
        d["task_id_deprecated"] = int(d["task_id"].split('-')[-1])  # useful for WC and AJ

        # update the run fields to give species group in root, if exists
        for r in d['run_tags']:
            if "species_group=" in r:
                d["species_group"] = int(r.split("=")[-1])
                break

        # custom Materials Project post-processing for FireWorks
        with zopen(zpath(os.path.join(dir_name, 'FW.json'))) as f:
            fw_dict = json.load(f)
            d['fw_id'] = fw_dict['fw_id']
            d['snl'] = fw_dict['spec']['mpsnl']
            d['snlgroup_id'] = fw_dict['spec']['snlgroup_id']
            d['vaspinputset_name'] = fw_dict['spec'].get('vaspinputset_name')
            d['task_type'] = fw_dict['spec']['task_type']
            # Process data for deformed structures
            if 'deformed' in d['task_type']:
                d['deformation_matrix'] = fw_dict['spec']['deformation_matrix']
                d['original_task_id'] = fw_dict['spec']['original_task_id']
            if not self.update_duplicates:
                if 'optimize structure' in d['task_type'] and 'output' in d:
                    # create a new SNL based on optimized structure
                    new_s = Structure.from_dict(d['output']['crystal'])
                    old_snl = StructureNL.from_dict(d['snl'])
                    history = old_snl.history
                    history.append(
                        {'name': 'Materials Project structure optimization',
                         'url': 'http://www.materialsproject.org',
                         'description': {'task_type': d['task_type'],
                                         'fw_id': d['fw_id'],
                                         'task_id': d['task_id']}})
                    new_snl = StructureNL(new_s, old_snl.authors, old_snl.projects,
                                          old_snl.references, old_snl.remarks,
                                          old_snl.data, history)

                    # enter new SNL into SNL db
                    # get the SNL mongo adapter
                    sma = SNLMongoAdapter.auto_load()

                    # add snl
                    mpsnl, snlgroup_id, spec_group = sma.add_snl(new_snl, snlgroup_guess=d['snlgroup_id'])
                    d['snl_final'] = mpsnl.as_dict()
                    d['snlgroup_id_final'] = snlgroup_id
                    d['snlgroup_changed'] = (d['snlgroup_id'] !=
                                             d['snlgroup_id_final'])
                else:
                    d['snl_final'] = d['snl']
                    d['snlgroup_id_final'] = d['snlgroup_id']
                    d['snlgroup_changed'] = False

        # custom processing for detecting errors
        new_style = os.path.exists(zpath(os.path.join(dir_name, 'FW.json')))
        vasp_signals = {}
        critical_errors = ["INPUTS_DONT_EXIST",
                           "OUTPUTS_DONT_EXIST", "INCOHERENT_POTCARS",
                           "VASP_HASNT_STARTED", "VASP_HASNT_COMPLETED",
                           "CHARGE_UNCONVERGED", "NETWORK_QUIESCED",
                           "HARD_KILLED", "WALLTIME_EXCEEDED",
                           "ATOMS_TOO_CLOSE", "DISK_SPACE_EXCEEDED", "NO_RELAX2", "POSITIVE_ENERGY"]

        last_relax_dir = dir_name

        if not new_style:
            # get the last relaxation dir
            # the order is relax2, current dir, then relax1. This is because
            # after completing relax1, the job happens in the current dir.
            # Finally, it gets moved to relax2.
            # There are some weird cases where both the current dir and relax2
            # contain data. The relax2 is good, but the current dir is bad.
            if is_valid_vasp_dir(os.path.join(dir_name, "relax2")):
                last_relax_dir = os.path.join(dir_name, "relax2")
            elif is_valid_vasp_dir(dir_name):
                pass
            elif is_valid_vasp_dir(os.path.join(dir_name, "relax1")):
                last_relax_dir = os.path.join(dir_name, "relax1")

        vasp_signals['last_relax_dir'] = last_relax_dir
        ## see what error signals are present

        print "getting signals for dir :{}".format(last_relax_dir)

        sl = SignalDetectorList()
        sl.append(VASPInputsExistSignal())
        sl.append(VASPOutputsExistSignal())
        sl.append(VASPOutSignal())
        sl.append(HitAMemberSignal())
        sl.append(SegFaultSignal())
        sl.append(VASPStartedCompletedSignal())

        if d['state'] == 'successful' and 'optimize structure' in d['task_type']:
            sl.append(Relax2ExistsSignal())

        signals = sl.detect_all(last_relax_dir)

        signals = signals.union(WallTimeSignal().detect(dir_name))
        if not new_style:
            root_dir = os.path.dirname(dir_name)  # one level above dir_name
            signals = signals.union(WallTimeSignal().detect(root_dir))
#.........这里部分代码省略.........
开发者ID:xhqu1981,项目名称:MPWorks,代码行数:101,代码来源:mp_vaspdrone.py


示例17: get_snls

 def get_snls(self, species):
     o = []
     for e in self.structures.find({'nspecies' : len(species), 
                                    'species' : {'$all' : species}}):
         o.append(StructureNL.from_dict(e['snl']))
     return o
开发者ID:miaoliu,项目名称:MPWorks,代码行数:6,代码来源:prediction_mongo.py


示例18: process_fw

    def process_fw(self, old_task, d):
        # AJ - this whole section is different
        sma = SNLMongoAdapter.auto_load()

        d["old_engine"] = old_task.get("engine")
        if "fw_id" in old_task:
            d["old_fw_id"] = old_task["fw_id"]

        d["fw_id"] = None
        d["task_type"] = "GGA+U optimize structure (2x)" if old_task["is_hubbard"] else "GGA optimize structure (2x)"
        d["submission_id"] = None
        d["vaspinputset_name"] = None

        snl_d = sma.snl.find_one({"about._materialsproject.deprecated.mps_ids": old_task["mps_id"]})
        if old_task.get("mps_id", -1) > 0 and snl_d:
            # grab the SNL from the SNL db
            del snl_d["_id"]
            d["snl"] = snl_d
            d["snlgroup_id"] = sma.snlgroups.find_one({"all_snl_ids": d["snl"]["snl_id"]}, {"snlgroup_id": 1})[
                "snlgroup_id"
            ]

        elif "mps" in old_task and old_task["mps"]:
            snl = mps_dict_to_snl(old_task["mps"])
            mpsnl, snlgroup_id = sma.add_snl(snl)
            d["snl"] = mpsnl.as_dict()
            d["snlgroup_id"] = snlgroup_id
        else:
            s = Structure.from_dict(old_task["input"]["crystal"])
            snl = StructureNL(s, "Anubhav Jain <[email protected]>", remarks=["origin unknown"])
            mpsnl, snlgroup_id = sma.add_snl(snl)
            d["snl"] = mpsnl.as_dict()
            d["snlgroup_id"] = snlgroup_id

        if "optimize structure" in d["task_type"] and "output" in d:
            # create a new SNL based on optimized structure
            new_s = Structure.from_dict(d["output"]["crystal"])
            old_snl = StructureNL.from_dict(d["snl"])
            history = old_snl.history
            history.append(
                {
                    "name": "Materials Project structure optimization",
                    "url": "http://www.materialsproject.org",
                    "description": {"task_type": d["task_type"], "fw_id": d["fw_id"], "task_id": d["task_id"]},
                }
            )
            new_snl = StructureNL(
                new_s, old_snl.authors, old_snl.projects, old_snl.references, old_snl.remarks, old_snl.data, history
            )

            # add snl
            mpsnl, snlgroup_id = sma.add_snl(new_snl, snlgroup_guess=d["snlgroup_id"])

            d["snl_final"] = mpsnl.as_dict()
            d["snlgroup_id_final"] = snlgroup_id
            d["snlgroup_changed"] = d["snlgroup_id"] != d["snlgroup_id_final"]

        # custom processing for detecting errors
        dir_name = old_task["dir_name"]
        new_style = os.path.exists(os.path.join(dir_name, "FW.json"))
        vasp_signals = {}
        critical_errors = [
            "INPUTS_DONT_EXIST",
            "OUTPUTS_DONT_EXIST",
            "INCOHERENT_POTCARS",
            "VASP_HASNT_STARTED",
            "VASP_HASNT_COMPLETED",
            "CHARGE_UNCONVERGED",
            "NETWORK_QUIESCED",
            "HARD_KILLED",
            "WALLTIME_EXCEEDED",
            "ATOMS_TOO_CLOSE",
            "DISK_SPACE_EXCEEDED",
        ]

        last_relax_dir = dir_name

        if not new_style:
            # get the last relaxation dir
            # the order is relax2, current dir, then relax1. This is because
            # after completing relax1, the job happens in the current dir.
            # Finally, it gets moved to relax2.
            # There are some weird cases where both the current dir and relax2
            # contain data. The relax2 is good, but the current dir is bad.
            if is_valid_vasp_dir(os.path.join(dir_name, "relax2")):
                last_relax_dir = os.path.join(dir_name, "relax2")
            elif is_valid_vasp_dir(dir_name):
                pass
            elif is_valid_vasp_dir(os.path.join(dir_name, "relax1")):
                last_relax_dir = os.path.join(dir_name, "relax1")

        vasp_signals["last_relax_dir"] = last_relax_dir
        ## see what error signals are present

        print "getting signals for dir :{}".format(last_relax_dir)

        sl = SignalDetectorList()
        sl.append(VASPInputsExistSignal())
        sl.append(VASPOutputsExistSignal())
        sl.append(VASPOutSignal())
#.........这里部分代码省略.........
开发者ID:ctoher,项目名称:MPWorks,代码行数:101,代码来源:old_task_drone.py


示例19: run_task

    def run_task(self, fw_spec):
        if '_fizzled_parents' in fw_spec and not 'prev_vasp_dir' in fw_spec:
            prev_dir = get_loc(fw_spec['_fizzled_parents'][0]['launches'][0]['launch_dir'])
            update_spec = {}  # add this later when creating new FW
            fizzled_parent = True
            parse_dos = False
        else:
            prev_dir = get_loc(fw_spec['prev_vasp_dir'])
            update_spec = {'prev_vasp_dir': prev_dir,
                           'prev_task_type': fw_spec['prev_task_type'],
                           'run_tags': fw_spec['run_tags'], 'parameters': fw_spec.get('parameters')}
            fizzled_parent = False
            parse_dos = 'Uniform' in fw_spec['prev_task_type']
        if 'run_tags' in fw_spec:
            self.additional_fields['run_tags'] = fw_spec['run_tags']
        else:
            self.additional_fields['run_tags'] = fw_spec['_fizzled_parents'][0]['spec']['run_tags']

        if MOVE_TO_GARDEN_DEV:
            prev_dir = move_to_garden(prev_dir, prod=False)

        elif MOVE_TO_GARDEN_PROD:
            prev_dir = move_to_garden(prev_dir, prod=True)

        # get the directory containing the db file
        db_dir = os.environ['DB_LOC']
        db_path = os.path.join(db_dir, 'tasks_db.json')

        logging.basicConfig(level=logging.INFO)
        logger = logging.getLogger('MPVaspDrone')
        logger.setLevel(logging.INFO)
        sh = logging.StreamHandler(stream=sys.stdout)
        sh.setLevel(getattr(logging, 'INFO'))
        logger.addHandler(sh)

        with open(db_path) as f:
            db_creds = json.load(f)
            drone = MPVaspDrone(
                host=db_creds['host'], port=db_creds['port'],
                database=db_creds['database'], user=db_creds['admin_user'],
                password=db_creds['admin_password'],
                collection=db_creds['collection'], parse_dos=parse_dos,
                additional_fields=self.additional_fields,
                update_duplicates=self.update_duplicates)
            t_id, d = drone.assimilate(prev_dir, launches_coll=LaunchPad.auto_load().launches)

        mpsnl = d['snl_final'] if 'snl_final' in d else d['snl']
        snlgroup_id = d['snlgroup_id_final'] if 'snlgroup_id_final' in d else d['snlgroup_id']
        update_spec.update({'mpsnl': mpsnl, 'snlgroup_id': snlgroup_id})

        print 'ENTERED task id:', t_id
        stored_data = {'task_id': t_id}
        if d['state'] == 'successful':
            update_spec['analysis'] = d['analysis']
            update_spec['output'] = d['output']
            return FWAction(stored_data=stored_data, update_spec=update_spec)

        # not successful - first test to see if UnconvergedHandler is needed
        if not fizzled_parent:
            unconverged_tag = 'unconverged_handler--{}'.format(fw_spec['prev_task_type'])
            output_dir = last_relax(os.path.join(prev_dir, 'vasprun.xml'))
            ueh = UnconvergedErrorHandler(output_filename=output_dir)
            if ueh.check() and unconverged_tag not in fw_spec['run_tags']:
                print 'Unconverged run! Creating dynamic FW...'

                spec = {'prev_vasp_dir': prev_dir,
                        'prev_task_type': fw_spec['task_type'],
                        'mpsnl': mpsnl, 'snlgroup_id': snlgroup_id,
                        'task_type': fw_spec['prev_task_type'],
                        'run_tags': list(fw_spec['run_tags']),
                        'parameters': fw_spec.get('parameters'),
                        '_dupefinder': DupeFinderVasp().to_dict(),
                        '_priority': fw_spec['_priority']}

                snl = StructureNL.from_dict(spec['mpsnl'])
                spec['run_tags'].append(unconverged_tag)
                spec['_queueadapter'] = QA_VASP

                fws = []
                connections = {}

                f = Composition.from_formula(
                    snl.structure.composition.reduced_formula).alphabetical_formula

                fws.append(FireWork(
                    [VaspCopyTask({'files': ['INCAR', 'KPOINTS', 'POSCAR', 'POTCAR', 'CONTCAR'],
                                   'use_CONTCAR': False}), SetupUnconvergedHandlerTask(),
                     get_custodian_task(spec)], spec, name=get_slug(f + '--' + spec['task_type']),
                    fw_id=-2))

                spec = {'task_type': 'VASP db insertion', '_allow_fizzled_parents': True,
                        '_priority': fw_spec['_priority'], '_queueadapter': QA_DB,
                        'run_tags': list(fw_spec['run_tags'])}
                spec['run_tags'].append(unconverged_tag)
                fws.append(
                    FireWork([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']),
                             fw_id=-1))
                connections[-2] = -1

                wf = Workflow(fws, connections)
#.........这里部分代码省略.........
开发者ID:matk86,项目名称:MPWorks,代码行数:101,代码来源:vasp_io_tasks.py


示例20: run_task

    def run_task(self, fw_spec):
        print 'sleeping 10s for Mongo'
        time.sleep(10)
        print 'done sleeping'
        print 'the gap is {}, the cutoff is {}'.format(fw_spec['analysis']['bandgap'], self.gap_cutoff)
        if fw_spec['analysis']['bandgap'] >= self.gap_cutoff:
            static_dens = 90
            uniform_dens = 1000
            line_dens = 20
        else:
            static_dens = 450
            uniform_dens = 1500
            line_dens = 30

        if fw_spec['analysis']['bandgap'] <= self.metal_cutoff:
            user_incar_settings = {"ISMEAR": 1, "SIGMA": 0.2}
        else:
            user_incar_settings = {}

        print 'Adding more runs...'

        type_name = 'GGA+U' if 'GGA+U' in fw_spec['prev_task_type'] else 'GGA'

        snl = StructureNL.from_dict(fw_spec['mpsnl'])
        f = Composition(snl.structure.composition.reduced_formula).alphabetical_formula

        fws = []
        connections = {}

        priority = fw_spec['_priority']
        trackers = [Tracker('FW_job.out'), Tracker('FW_job.error'), Tracker('vasp.out'), Tracker('OUTCAR'), Tracker('OSZICAR')]
        trackers_db = [Tracker('FW_ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python entries.PDEntryIO类代码示例发布时间:2022-05-27
下一篇:
Python rest.MPRester类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap