@@ -235,7 +235,6 @@ def run_task(self, fw_spec):
235
235
charges = [v .charge for v in SCG ]
236
236
237
237
def_structs .append ({'charges' : charges , 'defect' : vac .copy ()})
238
-
239
238
else :
240
239
#only create vacancies of interest...
241
240
for elt_type in vacancies :
@@ -345,55 +344,80 @@ def get_charges_from_inter( inter_elt):
345
344
charges = get_charges_from_inter ( elt_val )
346
345
def_structs .append ({'charges' : charges , 'defect' : elt_val .copy ()})
347
346
348
- stdrd_defect_incar_settings = {"EDIFF" : 0.0001 , "EDIFFG" : 0.001 , "IBRION" :2 , "ISMEAR" :0 , "SIGMA" :0.05 ,
349
- "ISPIN" :2 , "ISYM" :2 , "LVHAR" :True , "LVTOT" :True , "NSW" : 100 ,
350
- "NELM" : 60 , "ISIF" : 2 , "LAECHG" :False , "LWAVE" : True }
351
- stdrd_defect_incar_settings .update ( user_incar_settings )
352
347
353
348
# now that def_structs is assembled, set up Transformation FW for all defect + charge combinations
354
349
for defcalc in def_structs :
355
- #get defect supercell and defect site for parsing purposes
356
- defect = defcalc ['defect' ].copy ()
357
- defect_sc = defect .generate_defect_structure ( supercell = supercell_size )
358
- struct_for_defect_site = Structure (defect .bulk_structure .copy ().lattice ,
359
- [defect .site .specie ],
360
- [defect .site .frac_coords ],
361
- to_unit_cell = True , coords_are_cartesian = False )
362
- struct_for_defect_site .make_supercell (supercell_size )
363
- defect_site = struct_for_defect_site [0 ]
364
-
365
350
#iterate over all charges to be run
366
351
for charge in defcalc ['charges' ]:
367
- chgdstruct = defect_sc .copy ()
368
- chgdstruct .set_charge (charge ) #NOTE that the charge will be reflected in NELECT of INCAR because use_structure_charge=True
369
-
370
- reciprocal_density = 100
371
- kpoints_settings = user_kpoints_settings if user_kpoints_settings else {"reciprocal_density" : reciprocal_density }
372
- defect_input_set = MPRelaxSet ( chgdstruct ,
373
- user_incar_settings = stdrd_defect_incar_settings .copy (),
374
- user_kpoints_settings = kpoints_settings ,
375
- use_structure_charge = True )
376
-
377
- defect_for_trans_param = defect .copy ()
378
- defect_for_trans_param .set_charge (charge )
379
- chgdef_trans = ["DefectTransformation" ]
380
- chgdef_trans_params = [{"scaling_matrix" : supercell_size ,
381
- "defect" : defect_for_trans_param }]
382
- if structure != defect_for_trans_param .bulk_structure :
383
- raise ValueError ("Defect bulk_structure is not the same as input structure." )
384
-
385
- def_tag = "{}:{}_{}_{}atoms" .format (structure .composition .reduced_formula ,
386
- defect .name , charge , num_atoms )
387
- fw = TransmuterFW ( name = def_tag , structure = structure ,
388
- transformations = chgdef_trans ,
389
- transformation_params = chgdef_trans_params ,
390
- vasp_input_set = defect_input_set ,
391
- vasp_cmd = self .get ("vasp_cmd" , ">>vasp_cmd<<" ),
392
- copy_vasp_outputs = False ,
393
- db_file = self .get ("db_file" , ">>db_file<<" ),
394
- bandstructure_mode = "auto" ,
395
- defect_wf_parsing = defect_site )
352
+ defect = defcalc ['defect' ].copy ()
353
+ defect .set_charge (charge )
354
+
355
+ fw = get_fw_from_defect ( defect , supercell_size ,
356
+ user_kpoints_settings = user_kpoints_settings ,
357
+ user_incar_settings = user_incar_settings
358
+ )
396
359
397
360
fws .append (fw )
398
361
399
362
return FWAction (detours = fws )
363
+
364
+
365
+
366
+ def get_fw_from_defect ( defect , supercell_size , user_kpoints_settings = {},
367
+ user_incar_settings = {},
368
+ db_file = '>>db_file<<' , vasp_cmd = '>>vasp_cmd<<' ):
369
+ """
370
+ Simple function for grabbing fireworks for a defect, given a supercell_size
371
+ :param defect:
372
+ :param supercell_size:
373
+ :param user_kpoints_settings:
374
+ :param db_file:
375
+ :param vasp_cmd:
376
+ :return:
377
+ """
378
+ chgd_sc_struct = defect .generate_defect_structure (supercell = supercell_size )
379
+
380
+ reciprocal_density = 100
381
+
382
+ kpoints_settings = user_kpoints_settings if user_kpoints_settings else {"reciprocal_density" : reciprocal_density }
383
+
384
+ # NOTE that the charge will be reflected in NELECT of INCAR because use_structure_charge=True
385
+ stdrd_defect_incar_settings = {"EDIFF" : 0.0001 , "EDIFFG" : 0.001 , "IBRION" : 2 , "ISMEAR" : 0 , "SIGMA" : 0.05 ,
386
+ "ISPIN" : 2 , "ISYM" : 2 , "LVHAR" : True , "LVTOT" : True , "NSW" : 100 ,
387
+ "NELM" : 60 , "ISIF" : 2 , "LAECHG" : False , "LWAVE" : True }
388
+ stdrd_defect_incar_settings .update (user_incar_settings )
389
+ defect_input_set = MPRelaxSet (chgd_sc_struct ,
390
+ user_incar_settings = stdrd_defect_incar_settings .copy (),
391
+ user_kpoints_settings = kpoints_settings ,
392
+ use_structure_charge = True )
393
+
394
+ # get defect site for parsing purposes
395
+ struct_for_defect_site = Structure (defect .bulk_structure .copy ().lattice ,
396
+ [defect .site .specie ],
397
+ [defect .site .frac_coords ],
398
+ to_unit_cell = True , coords_are_cartesian = False )
399
+ struct_for_defect_site .make_supercell (supercell_size )
400
+ defect_site = struct_for_defect_site [0 ]
401
+
402
+ bulk_sc = defect .bulk_structure .copy ()
403
+ bulk_sc .make_supercell ( supercell_size )
404
+ num_atoms = len (bulk_sc )
405
+
406
+ chgdef_trans = ["DefectTransformation" ]
407
+ chgdef_trans_params = [{"scaling_matrix" : supercell_size ,
408
+ "defect" : defect .copy ()}]
409
+
410
+ def_tag = "{}:{}_{}_{}atoms" .format (defect .bulk_structure .composition .reduced_formula ,
411
+ defect .name , defect .charge , num_atoms )
412
+ fw = TransmuterFW (name = def_tag , structure = defect .bulk_structure ,
413
+ transformations = chgdef_trans ,
414
+ transformation_params = chgdef_trans_params ,
415
+ vasp_input_set = defect_input_set ,
416
+ vasp_cmd = vasp_cmd ,
417
+ copy_vasp_outputs = False ,
418
+ db_file = db_file ,
419
+ bandstructure_mode = "auto" ,
420
+ defect_wf_parsing = defect_site )
421
+
422
+ return fw
423
+
0 commit comments