本文整理汇总了Python中pymatgen.matproj.snl.StructureNL.as_dict方法的典型用法代码示例。如果您正苦于以下问题:Python StructureNL.as_dict方法的具体用法?Python StructureNL.as_dict怎么用?Python StructureNL.as_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.matproj.snl.StructureNL
的用法示例。
在下文中一共展示了StructureNL.as_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_from_dict
# 需要导入模块: from pymatgen.matproj.snl import StructureNL [as 别名]
# 或者: from pymatgen.matproj.snl.StructureNL import as_dict [as 别名]
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)
示例2: run_task
# 需要导入模块: from pymatgen.matproj.snl import StructureNL [as 别名]
# 或者: from pymatgen.matproj.snl.StructureNL import as_dict [as 别名]
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)
示例3: structure_to_mock_job
# 需要导入模块: from pymatgen.matproj.snl import StructureNL [as 别名]
# 或者: from pymatgen.matproj.snl.StructureNL import as_dict [as 别名]
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