def setUp(self): super().setUp() self.tf_loc = os.path.join(ref_dir, "elastic_wf") self.struct_si = PymatgenTest.get_structure("Si") self.struct_si = SpacegroupAnalyzer( self.struct_si ).get_conventional_standard_structure() self.opt_struct = Structure.from_file( os.path.join(self.tf_loc, "1", "inputs", "POSCAR") ) # Base WF self.base_wf = get_wf( self.struct_si, "optimize_only.yaml", params=[{"db_file": ">>db_file<<"}] ) self.base_wf.append_wf( get_wf_elastic_constant( self.struct_si, db_file=">>db_file<<", stencils=[[0.01]] * 3 + [[0.03]] * 3, copy_vasp_outputs=True, ), self.base_wf.leaf_fw_ids, ) self.base_wf_noopt = get_wf_elastic_constant( self.opt_struct, stencils=[[0.01]] * 3 + [[0.03]] * 3, copy_vasp_outputs=False, sym_reduce=False, db_file=">>db_file<<", ) ec_incar_update = {"incar_update": {"EDIFF": 1e-6, "ENCUT": 700}} self.base_wf = add_modify_incar(self.base_wf, ec_incar_update) self.base_wf_noopt = add_modify_incar(self.base_wf_noopt, ec_incar_update) # Full preset WF self.preset_wf = wf_elastic_constant(self.struct_si) # Minimal WF self.minimal_wf = wf_elastic_constant_minimal(self.opt_struct) self.minimal_wf = add_modify_incar(self.minimal_wf, ec_incar_update) # TOEC WF (minimal) self.toec_wf = wf_elastic_constant_minimal(self.struct_si, order=3) self.toec_wf = add_modify_incar(self.toec_wf, ec_incar_update) toec_data = loadfn(os.path.join(self.tf_loc, "toec_data.json")) # Rather than run entire workflow, preload the spec to test the analysis toec_analysis = Firework( [ ElasticTensorToDb( structure=self.struct_si, order=3, db_file=">>db_file<<" ) ], spec={"deformation_tasks": toec_data["deformation_tasks"]}, ) self.toec_analysis = Workflow([toec_analysis]) # Check 4th order to see if constructed correctly self.foec_wf = wf_elastic_constant_minimal(self.struct_si, order=4)
def setUp(self): super(TestElasticWorkflow, self).setUp() self.tf_loc = os.path.join(ref_dir, 'elastic_wf') self.struct_si = PymatgenTest.get_structure("Si") self.struct_si = SpacegroupAnalyzer( self.struct_si).get_conventional_standard_structure() self.opt_struct = Structure.from_file( os.path.join(self.tf_loc, '1', 'inputs', 'POSCAR')) # Base WF self.base_wf = get_wf(self.struct_si, "optimize_only.yaml", params=[{ "db_file": ">>db_file<<" }]) self.base_wf.append_wf( get_wf_elastic_constant(self.struct_si, db_file='>>db_file<<', stencils=[[0.01]] * 3 + [[0.03]] * 3, copy_vasp_outputs=True), self.base_wf.leaf_fw_ids) self.base_wf_noopt = get_wf_elastic_constant(self.opt_struct, stencils=[[0.01]] * 3 + [[0.03]] * 3, copy_vasp_outputs=False, sym_reduce=False, db_file='>>db_file<<') ec_incar_update = {'incar_update': {'EDIFF': 1e-6, 'ENCUT': 700}} self.base_wf = add_modify_incar(self.base_wf, ec_incar_update) self.base_wf_noopt = add_modify_incar(self.base_wf_noopt, ec_incar_update) # Full preset WF self.preset_wf = wf_elastic_constant(self.struct_si) # Minimal WF self.minimal_wf = wf_elastic_constant_minimal(self.opt_struct) self.minimal_wf = add_modify_incar(self.minimal_wf, ec_incar_update) # TOEC WF (minimal) self.toec_wf = wf_elastic_constant_minimal(self.struct_si, order=3) self.toec_wf = add_modify_incar(self.toec_wf, ec_incar_update) toec_data = loadfn(os.path.join(self.tf_loc, 'toec_data.json')) # Rather than run entire workflow, preload the spec to test the analysis toec_analysis = Firework( [ ElasticTensorToDb( structure=self.struct_si, order=3, db_file=">>db_file<<") ], spec={"deformation_tasks": toec_data['deformation_tasks']}) self.toec_analysis = Workflow([toec_analysis])
def setUp(self): super(TestElasticWorkflow, self).setUp() self.tf_loc = os.path.join(ref_dir, 'elastic_wf') self.struct_si = PymatgenTest.get_structure("Si") self.struct_si = SpacegroupAnalyzer(self.struct_si).get_conventional_standard_structure() self.opt_struct = Structure.from_file(os.path.join(self.tf_loc, '1', 'inputs', 'POSCAR')) # Base WF self.base_wf = get_wf(self.struct_si, "optimize_only.yaml", params=[{"db_file": ">>db_file<<"}]) self.base_wf.append_wf(get_wf_elastic_constant(self.struct_si, db_file='>>db_file<<', stencils=[[0.01]]*3 + [[0.03]]*3, copy_vasp_outputs=True), self.base_wf.leaf_fw_ids) self.base_wf_noopt = get_wf_elastic_constant(self.opt_struct, stencils=[[0.01]]*3 + [[0.03]]*3, copy_vasp_outputs=False, sym_reduce=False, db_file='>>db_file<<') ec_incar_update = {'incar_update': {'EDIFF': 1e-6, 'ENCUT': 700}} self.base_wf = add_modify_incar(self.base_wf, ec_incar_update) self.base_wf_noopt = add_modify_incar(self.base_wf_noopt, ec_incar_update) # Full preset WF self.preset_wf = wf_elastic_constant(self.struct_si) # Minimal WF self.minimal_wf = wf_elastic_constant_minimal(self.opt_struct) self.minimal_wf = add_modify_incar(self.minimal_wf, ec_incar_update) # TOEC WF (minimal) self.toec_wf = wf_elastic_constant_minimal(self.struct_si, order=3) self.toec_wf = add_modify_incar(self.toec_wf, ec_incar_update) toec_data = loadfn(os.path.join(self.tf_loc, 'toec_data.json')) # Rather than run entire workflow, preload the spec to test the analysis toec_analysis = Firework([ElasticTensorToDb(structure=self.struct_si, order=3, db_file=">>db_file<<")], spec={"deformation_tasks": toec_data['deformation_tasks']}) self.toec_analysis = Workflow([toec_analysis]) # Check 4th order to see if constructed correctly self.foec_wf = wf_elastic_constant_minimal(self.struct_si, order=4)
def wf_elastic_constant_minimal(structure, c=None, order=2, sym_reduce=True): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) stencil = np.arange(0.01, 0.01 * order, step=0.01) wf = get_wf_elastic_constant(structure, vasp_cmd=vasp_cmd, db_file=db_file, sym_reduce=sym_reduce, stencils=stencil, order=order, copy_vasp_outputs=False) wf = add_common_powerups(wf, c) if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_elastic_constant(structure, c=None, order=2, sym_reduce=False): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) uis_optimize = {"ENCUT": 700, "EDIFF": 1e-6, "LAECHG": False} if order > 2: uis_optimize.update({"EDIFF": 1e-10, "EDIFFG": -0.001, "ADDGRID": True, "LREAL": False, "ISYM": 0}) # This ensures a consistent k-point mesh across all calculations # We also turn off symmetry to prevent VASP from changing the # mesh internally kpts_settings = Kpoints.automatic_density(structure, 40000, force_gamma=True) stencils = np.linspace(-0.075, 0.075, 7) else: kpts_settings = {'grid_density': 7000} stencils = None uis_static = uis_optimize.copy() uis_static.update({'ISIF': 2, 'IBRION': 2, 'NSW': 99, 'ISTART': 1, "PREC": "High"}) # input set for structure optimization vis_relax = MPRelaxSet(structure, force_gamma=True, user_incar_settings=uis_optimize, user_kpoints_settings=kpts_settings) # optimization only workflow wf = get_wf(structure, "optimize_only.yaml", vis=vis_relax, params=[{"vasp_cmd": vasp_cmd, "db_file": db_file, "name": "elastic structure optimization"}]) vis_static = MPStaticSet(structure, force_gamma=True, lepsilon=False, user_kpoints_settings=kpts_settings, user_incar_settings=uis_static) # deformations wflow for elasticity calculation wf_elastic = get_wf_elastic_constant(structure, vasp_cmd=vasp_cmd, db_file=db_file, order=order, stencils=stencils, copy_vasp_outputs=True, vasp_input_set=vis_static, sym_reduce=sym_reduce) wf.append_wf(wf_elastic, wf.leaf_fw_ids) wf = add_common_powerups(wf, c) if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf
def wf_elastic_constant(structure, c=None): c = c or {} vasp_cmd = c.get("VASP_CMD", VASP_CMD) db_file = c.get("DB_FILE", DB_FILE) user_kpoints_settings = c.get("user_kpoints_settings", {"grid_density": 7000}) norm_deformations = c.get("norm_deformations", [-0.01, -0.005, 0.005, 0.01]) shear_deformations = c.get("shear_deformations", [-0.06, -0.03, 0.03, 0.06]) wf = get_wf_elastic_constant(structure, vasp_cmd=vasp_cmd, norm_deformations=norm_deformations, shear_deformations=shear_deformations, db_file=db_file, user_kpoints_settings=user_kpoints_settings) mip = {"incar_update":{"ENCUT": 700, "EDIFF": 1e-6, "LAECHG":False}} wf = add_modify_incar(wf, modify_incar_params=mip) wf = add_common_powerups(wf, c) if c.get("ADD_WF_METADATA", ADD_WF_METADATA): wf = add_wf_metadata(wf, structure) return wf