def run_task(self, fw_spec): chgcar_start = False # read the VaspInput from the previous run poscar = Poscar.from_file(zpath('POSCAR')) incar = Incar.from_file(zpath('INCAR')) # figure out what GGA+U values to use and override them # LDAU values to use mpvis = MPVaspInputSet() ggau_incar = mpvis.get_incar(poscar.structure).as_dict() incar_updates = {k: ggau_incar[k] for k in ggau_incar.keys() if 'LDAU' in k} for k in ggau_incar: # update any parameters not set explicitly in previous INCAR if k not in incar and k in ggau_incar: incar_updates[k] = ggau_incar[k] incar.update(incar_updates) # override the +U keys # start from the CHGCAR of previous run if os.path.exists('CHGCAR'): incar['ICHARG'] = 1 chgcar_start = True # write back the new INCAR to the current directory incar.write_file('INCAR') return FWAction(stored_data={'chgcar_start': chgcar_start})
def setUp(self): if "VASP_PSP_DIR" not in os.environ: os.environ["VASP_PSP_DIR"] = test_dir filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) self.struct = poscar.structure self.mitparamset = MITVaspInputSet() self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False) self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': { "Fe": 10, "S": -5, "Mn3+": 100 }}) self.mitggaparam = MITGGAVaspInputSet() self.mpstaticparamset = MPStaticVaspInputSet() self.mpnscfparamsetu = MPNonSCFVaspInputSet({"NBANDS": 50}, mode="Uniform") self.mpnscfparamsetl = MPNonSCFVaspInputSet({"NBANDS": 60}, mode="Line") self.mphseparamset = MPHSEVaspInputSet() self.mpbshseparamsetl = MPBSHSEVaspInputSet(mode="Line") self.mpbshseparamsetu = MPBSHSEVaspInputSet( mode="Uniform", added_kpoints=[[0.5, 0.5, 0.0]]) self.mpdielparamset = MPStaticDielectricDFPTVaspInputSet()
def setUp(self): if "VASP_PSP_DIR" not in os.environ: os.environ["VASP_PSP_DIR"] = test_dir filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) self.struct = poscar.structure self.mitparamset = MITVaspInputSet() self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False) self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}} ) self.mitggaparam = MITGGAVaspInputSet() self.mpstaticparamset = MPStaticVaspInputSet() self.mpnscfparamsetu = MPNonSCFVaspInputSet( {"NBANDS": 50}, mode="Uniform") self.mpnscfparamsetl = MPNonSCFVaspInputSet( {"NBANDS": 60}, mode="Line") self.mphseparamset = MPHSEVaspInputSet() self.mpbshseparamsetl = MPBSHSEVaspInputSet(mode="Line") self.mpbshseparamsetu = MPBSHSEVaspInputSet( mode="Uniform", added_kpoints=[[0.5, 0.5, 0.0]]) self.mpdielparamset = MPStaticDielectricDFPTVaspInputSet()
def test_to_from_dict(self): self.mitparamset = MITVaspInputSet() self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}} ) d = self.mitparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 4) d = self.mitggaparam.as_dict() v = dec.process_decoded(d) self.assertNotIn("LDAUU", v.incar_settings) d = self.mithseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.mphseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.paramset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 5.3) d = self.userparamset.as_dict() v = dec.process_decoded(d) #self.assertEqual(type(v), MPVaspInputSet) self.assertEqual(v.incar_settings["MAGMOM"], {"Fe": 10, "S": -5, "Mn3+": 100})
def get_INCARs(comp_name, mp_api_key, SOC): from pymatgen.matproj.rest import MPRester matproj = MPRester(mp_api_key) structure = matproj.get_structure_by_material_id(comp_name) from pymatgen.io.vasp.sets import MPVaspInputSet from pymatgen.io.vasp.sets import MPGGAVaspInputSet # +U is turned off (if any) from pymatgen.io.vasp.sets import MPHSEVaspInputSet from pymatgen.io.vasp.sets import MPStaticVaspInputSet from pymatgen.io.vasp.sets import MPNonSCFVaspInputSet from pymatgen.io.vasp.sets import MPStaticDielectricDFPTVaspInputSet from pymatgen.io.vasp.sets import MPBSHSEVaspInputSet from pymatgen.io.vasp.sets import MPOpticsNonSCFVaspInputSet v = MPVaspInputSet() indic = v.get_incar(structure) k = v.get_all_vasp_input(structure, generate_potcar=False) incar_file = open('INCAR', 'w') # if SOC in ['TRUE', 'True', 'true']: # indic['LMAXMIX'] = 4 # indic['NBANDS'] = soc_NBANDS # indic['LSORBIT'] = '.TRUE.' # indic.pop('MAGMOM', None) incar_file.write(str(indic)) self = MPStaticVaspInputSet() indic = self.get_incar(structure) indic['NEDOS'] = 9001 incar_file = open('INCAR_SELF', 'w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = soc_NBANDS indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic)) user_incar_settings = {"NBANDS": 100} nself = MPNonSCFVaspInputSet(user_incar_settings) indic = nself.get_incar(structure) incar_file = open('INCAR_NSELF', 'w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = soc_NBANDS indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic)) HSE = MPHSEVaspInputSet() indic = HSE.get_incar(structure) incar_file = open('INCAR_HSE', 'w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = soc_NBANDS indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic))
def get_INCARs(comp_name, mp_api_key, SOC): from pymatgen.matproj.rest import MPRester matproj = MPRester(mp_api_key) structure = matproj.get_structure_by_material_id(comp_name) from pymatgen.io.vasp.sets import MPVaspInputSet from pymatgen.io.vasp.sets import MPGGAVaspInputSet # +U is turned off (if any) from pymatgen.io.vasp.sets import MPHSEVaspInputSet from pymatgen.io.vasp.sets import MPStaticVaspInputSet from pymatgen.io.vasp.sets import MPNonSCFVaspInputSet from pymatgen.io.vasp.sets import MPStaticDielectricDFPTVaspInputSet from pymatgen.io.vasp.sets import MPBSHSEVaspInputSet from pymatgen.io.vasp.sets import MPOpticsNonSCFVaspInputSet v = MPVaspInputSet() indic = v.get_incar(structure) k = v.get_all_vasp_input(structure,generate_potcar = False) incar_file = open('INCAR','w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = 128 indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic)) self = MPStaticVaspInputSet() indic = self.get_incar(structure) indic['NEDOS'] = 9001 incar_file = open('INCAR_SELF','w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = 128 indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic)) user_incar_settings = {"NBANDS" : 100} nself = MPNonSCFVaspInputSet(user_incar_settings) indic = nself.get_incar(structure) incar_file = open('INCAR_NSELF','w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = 128 indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic)) HSE = MPHSEVaspInputSet() indic = HSE.get_incar(structure) incar_file = open('INCAR_HSE','w') if SOC in ['TRUE', 'True', 'true']: indic['LMAXMIX'] = 4 indic['NBANDS'] = 128 indic['LSORBIT'] = '.TRUE.' indic.pop('MAGMOM', None) incar_file.write(str(indic))
def test_get_kpoints(self): kpoints = self.paramset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mitparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpstaticparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[6, 6, 4]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpnscfparamsetl.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 140) self.assertEqual(kpoints.style, Kpoints.supported_modes.Reciprocal) kpoints = self.mpnscfparamsetu.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 168) kpoints = self.mpbshseparamsetl.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 164) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[26][0], 0.0714285714286) self.assertAlmostEqual(kpoints.kpts[26][1], 0.0) self.assertAlmostEqual(kpoints.kpts[26][2], 0.0) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.5) kpoints = self.mpbshseparamsetu.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 25) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.0) recip_paramset = MPVaspInputSet(force_gamma=True) recip_paramset.kpoints_settings = {"reciprocal_density": 40} kpoints = recip_paramset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
def __init__(self, compat_type="Advanced", correct_peroxide=True, check_potcar_hash=False): module_dir = os.path.dirname(os.path.abspath(__file__)) fp = os.path.join(module_dir, "MPCompatibility.yaml") i_s = MPVaspInputSet() super(MaterialsProjectAqueousCompatibility, self).__init__( [PotcarCorrection(i_s, check_hash=check_potcar_hash), GasCorrection(fp, correct_peroxide=correct_peroxide), UCorrection(fp, i_s, compat_type), AqueousCorrection(fp)])
def _snl_to_spec(snl, enforce_gga=False, parameters=None): parameters = parameters if parameters else {} parameters['boltztrap'] = parameters.get('boltztrap', True) # by default run boltztrap spec = {'parameters': parameters} incar_enforce = {'NPAR': 2} if 'exact_structure' in parameters and parameters['exact_structure']: structure = snl.structure else: structure = snl.structure.get_primitive_structure() mpvis = MPGGAVaspInputSet( user_incar_settings=incar_enforce) if enforce_gga else MPVaspInputSet( user_incar_settings=incar_enforce) incar = mpvis.get_incar(structure) poscar = mpvis.get_poscar(structure) kpoints = mpvis.get_kpoints(structure) potcar = mpvis.get_potcar(structure) spec['vasp'] = {} spec['vasp']['incar'] = incar.as_dict() spec['vasp']['poscar'] = poscar.as_dict() spec['vasp']['kpoints'] = kpoints.as_dict() spec['vasp']['potcar'] = potcar.as_dict() # Add run tags of pseudopotential spec['run_tags'] = spec.get('run_tags', [potcar.functional]) spec['run_tags'].extend(potcar.symbols) # Add run tags of +U u_tags = [ '%s=%s' % t for t in zip(poscar.site_symbols, incar.get('LDAUU', [0] * len(poscar.site_symbols))) ] spec['run_tags'].extend(u_tags) # add user run tags if 'run_tags' in parameters: spec['run_tags'].extend(parameters['run_tags']) del spec['parameters']['run_tags'] # add exact structure run tag automatically if we have a unique situation if 'exact_structure' in parameters and parameters[ 'exact_structure'] and snl.structure != snl.structure.get_primitive_structure( ): spec['run_tags'].extend('exact_structure') spec['_dupefinder'] = DupeFinderVasp().to_dict() spec['vaspinputset_name'] = mpvis.__class__.__name__ spec['task_type'] = 'GGA+U optimize structure (2x)' if spec['vasp'][ 'incar'].get('LDAU', False) else 'GGA optimize structure (2x)' return spec
def test_to_from_dict(self): self.mitparamset = MITVaspInputSet() self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': { "Fe": 10, "S": -5, "Mn3+": 100 }}) d = self.mitparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 4) d = self.mitggaparam.as_dict() v = dec.process_decoded(d) self.assertNotIn("LDAUU", v.incar_settings) d = self.mithseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.mphseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.paramset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 5.3) d = self.userparamset.as_dict() v = dec.process_decoded(d) #self.assertEqual(type(v), MPVaspInputSet) self.assertEqual(v.incar_settings["MAGMOM"], { "Fe": 10, "S": -5, "Mn3+": 100 })
def test_get_potcar_symbols(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.75, 0.25, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe", "O"], coords) syms = self.paramset.get_potcar_symbols(struct) self.assertEqual(syms, ['Fe_pv', 'P', 'O']) syms = MPVaspInputSet(sort_structure=False).get_potcar_symbols(struct) self.assertEqual(syms, ['P', 'Fe_pv', 'O'])
def test_get_vasp_input(self): vaspis = MPVaspInputSet() self.assertEqual( "Na_pv\nFe_pv\nP\nO", self.trans.get_vasp_input(vaspis, False)['POTCAR.spec']) self.assertEqual(len(self.trans.structures), 2)
class MITMPVaspInputSetTest(unittest.TestCase): def setUp(self): if "VASP_PSP_DIR" not in os.environ: os.environ["VASP_PSP_DIR"] = test_dir filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) self.struct = poscar.structure self.mitparamset = MITVaspInputSet() self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False) self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}} ) self.mitggaparam = MITGGAVaspInputSet() self.mpstaticparamset = MPStaticVaspInputSet() self.mpnscfparamsetu = MPNonSCFVaspInputSet( {"NBANDS": 50}, mode="Uniform") self.mpnscfparamsetl = MPNonSCFVaspInputSet( {"NBANDS": 60}, mode="Line") self.mphseparamset = MPHSEVaspInputSet() self.mpbshseparamsetl = MPBSHSEVaspInputSet(mode="Line") self.mpbshseparamsetu = MPBSHSEVaspInputSet( mode="Uniform", added_kpoints=[[0.5, 0.5, 0.0]]) self.mpdielparamset = MPStaticDielectricDFPTVaspInputSet() def test_get_poscar(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["Fe", "Mn"], coords) s_unsorted = self.mitparamset_unsorted.get_poscar(struct).structure s_sorted = self.mitparamset.get_poscar(struct).structure self.assertEqual(s_unsorted[0].specie.symbol, 'Fe') self.assertEqual(s_sorted[0].specie.symbol, 'Mn') def test_get_potcar_symbols(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.75, 0.25, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe", "O"], coords) syms = self.paramset.get_potcar_symbols(struct) self.assertEqual(syms, ['Fe_pv', 'P', 'O']) syms = MPVaspInputSet(sort_structure=False).get_potcar_symbols(struct) self.assertEqual(syms, ['P', 'Fe_pv', 'O']) def test_false_potcar_hash(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.75, 0.25, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe", "O"], coords) self.mitparamset.potcar_settings['Fe']['symbol'] = 'Fe_pv' self.assertRaises(ValueError, self.mitparamset.get_potcar, struct, check_hash=True) self.mitparamset.potcar_settings['Fe']['symbol'] = 'Fe' def test_lda_potcar(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe"], coords) p = MITVaspInputSet(potcar_functional="LDA").get_potcar(struct) self.assertEqual(p.functional, 'LDA') def test_get_nelect(self): coords = [[0]*3, [0.5]*3, [0.75]*3] lattice = Lattice.cubic(4) s = Structure(lattice, ['Si', 'Si', 'Fe'], coords) self.assertAlmostEqual(MITVaspInputSet().get_nelect(s), 16) def test_get_incar(self): incar = self.paramset.get_incar(self.struct) self.assertEqual(incar['LDAUU'], [5.3, 0, 0]) self.assertAlmostEqual(incar['EDIFF'], 0.0012) incar = self.mitparamset.get_incar(self.struct) self.assertEqual(incar['LDAUU'], [4.0, 0, 0]) self.assertAlmostEqual(incar['EDIFF'], 0.0012) incar_gga = self.mitggaparam.get_incar(self.struct) self.assertNotIn("LDAU", incar_gga) incar_static = self.mpstaticparamset.get_incar(self.struct) self.assertEqual(incar_static["NSW"], 0) incar_nscfl = self.mpnscfparamsetl.get_incar(self.struct) self.assertEqual(incar_nscfl["NBANDS"], 60) incar_nscfu = self.mpnscfparamsetu.get_incar(self.struct) self.assertEqual(incar_nscfu["ISYM"], 0) incar_hse = self.mphseparamset.get_incar(self.struct) self.assertEqual(incar_hse['LHFCALC'], True) self.assertEqual(incar_hse['HFSCREEN'], 0.2) incar_hse_bsl = self.mpbshseparamsetl.get_incar(self.struct) self.assertEqual(incar_hse_bsl['LHFCALC'], True) self.assertEqual(incar_hse_bsl['HFSCREEN'], 0.2) self.assertEqual(incar_hse_bsl['NSW'], 0) incar_hse_bsu = self.mpbshseparamsetu.get_incar(self.struct) self.assertEqual(incar_hse_bsu['LHFCALC'], True) self.assertEqual(incar_hse_bsu['HFSCREEN'], 0.2) self.assertEqual(incar_hse_bsu['NSW'], 0) incar_diel = self.mpdielparamset.get_incar(self.struct) self.assertEqual(incar_diel['IBRION'], 8) self.assertEqual(incar_diel['LEPSILON'], True) si = 14 coords = list() coords.append(np.array([0, 0, 0])) coords.append(np.array([0.75, 0.5, 0.75])) #Silicon structure for testing. latt = Lattice(np.array([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]])) struct = Structure(latt, [si, si], coords) incar = self.paramset.get_incar(struct) self.assertNotIn("LDAU", incar) incar = self.mithseparamset.get_incar(self.struct) self.assertTrue(incar['LHFCALC']) coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["Fe", "Mn"], coords) incar = self.paramset.get_incar(struct) self.assertNotIn('LDAU', incar) #check fluorides struct = Structure(lattice, ["Fe", "F"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['LDAUU'], [5.3, 0]) self.assertEqual(incar['MAGMOM'], [5, 0.6]) struct = Structure(lattice, ["Fe", "F"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [4.0, 0]) #Make sure this works with species. struct = Structure(lattice, ["Fe2+", "O2-"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['LDAUU'], [5.3, 0]) struct = Structure(lattice, ["Fe", "Mn"], coords, site_properties={'magmom': (5.2, -4.5)}) incar = self.paramset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [-4.5, 5.2]) incar = self.mpstaticparamset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [-4.5, 5.2]) incar = self.mitparamset_unsorted.get_incar(struct) self.assertEqual(incar['MAGMOM'], [5.2, -4.5]) struct = Structure(lattice, [Specie("Fe", 2, {'spin': 4.1}), "Mn"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [5, 4.1]) incar = self.mpnscfparamsetl.get_incar(struct) self.assertEqual(incar.get('MAGMOM', None), None) struct = Structure(lattice, ["Mn3+", "Mn4+"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [4, 3]) incar = self.mpnscfparamsetu.get_incar(struct) self.assertEqual(incar.get('MAGMOM', None), None) self.assertEqual(self.userparamset.get_incar(struct)['MAGMOM'], [100, 0.6]) #sulfide vs sulfate test coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.25, 0.5, 0]) struct = Structure(lattice, ["Fe", "Fe", "S"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [1.9, 0]) #Make sure Matproject sulfides are ok. self.assertNotIn('LDAUU', self.paramset.get_incar(struct)) self.assertNotIn('LDAUU', self.mpstaticparamset.get_incar(struct)) struct = Structure(lattice, ["Fe", "S", "O"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [4.0, 0, 0]) #Make sure Matproject sulfates are ok. self.assertEqual(self.paramset.get_incar(struct)['LDAUU'], [5.3, 0, 0]) self.assertEqual(self.mpnscfparamsetl.get_incar(struct)['LDAUU'], [5.3, 0, 0]) self.assertEqual(self.userparamset.get_incar(struct)['MAGMOM'], [10, -5, 0.6]) def test_optics(self): self.mpopticsparamset = MPOpticsNonSCFVaspInputSet.from_previous_vasp_run( '{}/static_silicon'.format(test_dir), output_dir='optics_test_dir', nedos=1145) self.assertTrue(os.path.exists('optics_test_dir/CHGCAR')) incar = Incar.from_file('optics_test_dir/INCAR') self.assertTrue(incar['LOPTICS']) self.assertEqual(incar['NEDOS'], 1145) #Remove the directory in which the inputs have been created shutil.rmtree('optics_test_dir') def test_get_kpoints(self): kpoints = self.paramset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mitparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpstaticparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[6, 6, 4]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpnscfparamsetl.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 140) self.assertEqual(kpoints.style, Kpoints.supported_modes.Reciprocal) kpoints = self.mpnscfparamsetu.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 168) kpoints = self.mpbshseparamsetl.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 164) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[26][0], 0.0714285714286) self.assertAlmostEqual(kpoints.kpts[26][1], 0.0) self.assertAlmostEqual(kpoints.kpts[26][2], 0.0) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.5) kpoints = self.mpbshseparamsetu.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 25) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.0) def test_get_all_vasp_input(self): d = self.mitparamset.get_all_vasp_input(self.struct) self.assertEqual(d["INCAR"]["ISMEAR"], -5) self.struct.make_supercell(4) d = self.mitparamset.get_all_vasp_input(self.struct) self.assertEqual(d["INCAR"]["ISMEAR"], 0) def test_to_from_dict(self): self.mitparamset = MITVaspInputSet() self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}} ) d = self.mitparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 4) d = self.mitggaparam.as_dict() v = dec.process_decoded(d) self.assertNotIn("LDAUU", v.incar_settings) d = self.mithseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.mphseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.paramset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 5.3) d = self.userparamset.as_dict() v = dec.process_decoded(d) #self.assertEqual(type(v), MPVaspInputSet) self.assertEqual(v.incar_settings["MAGMOM"], {"Fe": 10, "S": -5, "Mn3+": 100})
class MITMPVaspInputSetTest(unittest.TestCase): def setUp(self): if "VASP_PSP_DIR" not in os.environ: os.environ["VASP_PSP_DIR"] = test_dir filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) self.struct = poscar.structure self.mitparamset = MITVaspInputSet() self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False) self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': { "Fe": 10, "S": -5, "Mn3+": 100 }}) self.mitggaparam = MITGGAVaspInputSet() self.mpstaticparamset = MPStaticVaspInputSet() self.mpnscfparamsetu = MPNonSCFVaspInputSet({"NBANDS": 50}, mode="Uniform") self.mpnscfparamsetl = MPNonSCFVaspInputSet({"NBANDS": 60}, mode="Line") self.mphseparamset = MPHSEVaspInputSet() self.mpbshseparamsetl = MPBSHSEVaspInputSet(mode="Line") self.mpbshseparamsetu = MPBSHSEVaspInputSet( mode="Uniform", added_kpoints=[[0.5, 0.5, 0.0]]) self.mpdielparamset = MPStaticDielectricDFPTVaspInputSet() def test_get_poscar(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["Fe", "Mn"], coords) s_unsorted = self.mitparamset_unsorted.get_poscar(struct).structure s_sorted = self.mitparamset.get_poscar(struct).structure self.assertEqual(s_unsorted[0].specie.symbol, 'Fe') self.assertEqual(s_sorted[0].specie.symbol, 'Mn') def test_get_potcar_symbols(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.75, 0.25, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe", "O"], coords) syms = self.paramset.get_potcar_symbols(struct) self.assertEqual(syms, ['Fe_pv', 'P', 'O']) syms = MPVaspInputSet(sort_structure=False).get_potcar_symbols(struct) self.assertEqual(syms, ['P', 'Fe_pv', 'O']) def test_false_potcar_hash(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.75, 0.25, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe", "O"], coords) self.mitparamset.potcar_settings['Fe']['symbol'] = 'Fe_pv' self.assertRaises(ValueError, self.mitparamset.get_potcar, struct, check_hash=True) self.mitparamset.potcar_settings['Fe']['symbol'] = 'Fe' def test_lda_potcar(self): coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["P", "Fe"], coords) p = MITVaspInputSet(potcar_functional="LDA").get_potcar(struct) self.assertEqual(p.functional, 'LDA') def test_get_nelect(self): coords = [[0] * 3, [0.5] * 3, [0.75] * 3] lattice = Lattice.cubic(4) s = Structure(lattice, ['Si', 'Si', 'Fe'], coords) self.assertAlmostEqual(MITVaspInputSet().get_nelect(s), 16) def test_get_incar(self): incar = self.paramset.get_incar(self.struct) self.assertEqual(incar['LDAUU'], [5.3, 0, 0]) self.assertAlmostEqual(incar['EDIFF'], 0.0012) incar = self.mitparamset.get_incar(self.struct) self.assertEqual(incar['LDAUU'], [4.0, 0, 0]) self.assertAlmostEqual(incar['EDIFF'], 0.0012) incar_gga = self.mitggaparam.get_incar(self.struct) self.assertNotIn("LDAU", incar_gga) incar_static = self.mpstaticparamset.get_incar(self.struct) self.assertEqual(incar_static["NSW"], 0) incar_nscfl = self.mpnscfparamsetl.get_incar(self.struct) self.assertEqual(incar_nscfl["NBANDS"], 60) incar_nscfu = self.mpnscfparamsetu.get_incar(self.struct) self.assertEqual(incar_nscfu["ISYM"], 0) incar_hse = self.mphseparamset.get_incar(self.struct) self.assertEqual(incar_hse['LHFCALC'], True) self.assertEqual(incar_hse['HFSCREEN'], 0.2) incar_hse_bsl = self.mpbshseparamsetl.get_incar(self.struct) self.assertEqual(incar_hse_bsl['LHFCALC'], True) self.assertEqual(incar_hse_bsl['HFSCREEN'], 0.2) self.assertEqual(incar_hse_bsl['NSW'], 0) incar_hse_bsu = self.mpbshseparamsetu.get_incar(self.struct) self.assertEqual(incar_hse_bsu['LHFCALC'], True) self.assertEqual(incar_hse_bsu['HFSCREEN'], 0.2) self.assertEqual(incar_hse_bsu['NSW'], 0) incar_diel = self.mpdielparamset.get_incar(self.struct) self.assertEqual(incar_diel['IBRION'], 8) self.assertEqual(incar_diel['LEPSILON'], True) si = 14 coords = list() coords.append(np.array([0, 0, 0])) coords.append(np.array([0.75, 0.5, 0.75])) #Silicon structure for testing. latt = Lattice( np.array([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]])) struct = Structure(latt, [si, si], coords) incar = self.paramset.get_incar(struct) self.assertNotIn("LDAU", incar) incar = self.mithseparamset.get_incar(self.struct) self.assertTrue(incar['LHFCALC']) coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) lattice = Lattice([[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]) struct = Structure(lattice, ["Fe", "Mn"], coords) incar = self.paramset.get_incar(struct) self.assertNotIn('LDAU', incar) #check fluorides struct = Structure(lattice, ["Fe", "F"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['LDAUU'], [5.3, 0]) self.assertEqual(incar['MAGMOM'], [5, 0.6]) struct = Structure(lattice, ["Fe", "F"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [4.0, 0]) #Make sure this works with species. struct = Structure(lattice, ["Fe2+", "O2-"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['LDAUU'], [5.3, 0]) struct = Structure(lattice, ["Fe", "Mn"], coords, site_properties={'magmom': (5.2, -4.5)}) incar = self.paramset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [-4.5, 5.2]) incar = self.mpstaticparamset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [-4.5, 5.2]) incar = self.mitparamset_unsorted.get_incar(struct) self.assertEqual(incar['MAGMOM'], [5.2, -4.5]) struct = Structure(lattice, [Specie("Fe", 2, {'spin': 4.1}), "Mn"], coords) incar = self.paramset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [5, 4.1]) incar = self.mpnscfparamsetl.get_incar(struct) self.assertEqual(incar.get('MAGMOM', None), None) struct = Structure(lattice, ["Mn3+", "Mn4+"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['MAGMOM'], [4, 3]) incar = self.mpnscfparamsetu.get_incar(struct) self.assertEqual(incar.get('MAGMOM', None), None) self.assertEqual( self.userparamset.get_incar(struct)['MAGMOM'], [100, 0.6]) #sulfide vs sulfate test coords = list() coords.append([0, 0, 0]) coords.append([0.75, 0.5, 0.75]) coords.append([0.25, 0.5, 0]) struct = Structure(lattice, ["Fe", "Fe", "S"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [1.9, 0]) #Make sure Matproject sulfides are ok. self.assertNotIn('LDAUU', self.paramset.get_incar(struct)) self.assertNotIn('LDAUU', self.mpstaticparamset.get_incar(struct)) struct = Structure(lattice, ["Fe", "S", "O"], coords) incar = self.mitparamset.get_incar(struct) self.assertEqual(incar['LDAUU'], [4.0, 0, 0]) #Make sure Matproject sulfates are ok. self.assertEqual(self.paramset.get_incar(struct)['LDAUU'], [5.3, 0, 0]) self.assertEqual( self.mpnscfparamsetl.get_incar(struct)['LDAUU'], [5.3, 0, 0]) self.assertEqual( self.userparamset.get_incar(struct)['MAGMOM'], [10, -5, 0.6]) def test_optics(self): self.mpopticsparamset = MPOpticsNonSCFVaspInputSet.from_previous_vasp_run( '{}/static_silicon'.format(test_dir), output_dir='optics_test_dir', nedos=1145) self.assertTrue(os.path.exists('optics_test_dir/CHGCAR')) incar = Incar.from_file('optics_test_dir/INCAR') self.assertTrue(incar['LOPTICS']) self.assertEqual(incar['NEDOS'], 1145) #Remove the directory in which the inputs have been created shutil.rmtree('optics_test_dir') def test_get_kpoints(self): kpoints = self.paramset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mitparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[2, 4, 6]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpstaticparamset.get_kpoints(self.struct) self.assertEqual(kpoints.kpts, [[6, 6, 4]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = self.mpnscfparamsetl.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 140) self.assertEqual(kpoints.style, Kpoints.supported_modes.Reciprocal) kpoints = self.mpnscfparamsetu.get_kpoints(self.struct) self.assertEqual(kpoints.num_kpts, 168) kpoints = self.mpbshseparamsetl.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 164) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[26][0], 0.0714285714286) self.assertAlmostEqual(kpoints.kpts[26][1], 0.0) self.assertAlmostEqual(kpoints.kpts[26][2], 0.0) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.5) kpoints = self.mpbshseparamsetu.get_kpoints(self.struct) self.assertAlmostEqual(kpoints.num_kpts, 25) self.assertAlmostEqual(kpoints.kpts[10][0], 0.0) self.assertAlmostEqual(kpoints.kpts[10][1], 0.5) self.assertAlmostEqual(kpoints.kpts[10][2], 0.16666667) self.assertAlmostEqual(kpoints.kpts[-1][0], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][1], 0.5) self.assertAlmostEqual(kpoints.kpts[-1][2], 0.0) def test_get_all_vasp_input(self): d = self.mitparamset.get_all_vasp_input(self.struct) self.assertEqual(d["INCAR"]["ISMEAR"], -5) self.struct.make_supercell(4) d = self.mitparamset.get_all_vasp_input(self.struct) self.assertEqual(d["INCAR"]["ISMEAR"], 0) def test_to_from_dict(self): self.mitparamset = MITVaspInputSet() self.mithseparamset = MITHSEVaspInputSet() self.paramset = MPVaspInputSet() self.userparamset = MPVaspInputSet( user_incar_settings={'MAGMOM': { "Fe": 10, "S": -5, "Mn3+": 100 }}) d = self.mitparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 4) d = self.mitggaparam.as_dict() v = dec.process_decoded(d) self.assertNotIn("LDAUU", v.incar_settings) d = self.mithseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.mphseparamset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LHFCALC"], True) d = self.paramset.as_dict() v = dec.process_decoded(d) self.assertEqual(v.incar_settings["LDAUU"]["O"]["Fe"], 5.3) d = self.userparamset.as_dict() v = dec.process_decoded(d) #self.assertEqual(type(v), MPVaspInputSet) self.assertEqual(v.incar_settings["MAGMOM"], { "Fe": 10, "S": -5, "Mn3+": 100 })
def snl_to_wf(snl, parameters=None): fws = [] connections = defaultdict(list) parameters = parameters if parameters else {} snl_priority = parameters.get('priority', 1) priority = snl_priority * 2 # once we start a job, keep going! f = Composition( snl.structure.composition.reduced_formula).alphabetical_formula snl_spec = {} if 'snlgroup_id' in parameters: if 'mpsnl' in parameters: snl_spec['mpsnl'] = parameters['mpsnl'] elif isinstance(snl, MPStructureNL): snl_spec['mpsnl'] = snl.as_dict() else: raise ValueError("improper use of force SNL") snl_spec['snlgroup_id'] = parameters['snlgroup_id'] else: # add the SNL to the SNL DB and figure out duplicate group tasks = [AddSNLTask()] spec = { 'task_type': 'Add to SNL database', 'snl': snl.as_dict(), '_queueadapter': QA_DB, '_priority': snl_priority } fws.append( Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=0)) connections[0] = [1] trackers = [ Tracker('FW_job.out'), Tracker('FW_job.error'), Tracker('vasp.out'), Tracker('OUTCAR'), Tracker('OSZICAR'), Tracker('OUTCAR.relax1'), Tracker('OUTCAR.relax2') ] trackers_db = [Tracker('FW_job.out'), Tracker('FW_job.error')] # run GGA structure optimization spec = _snl_to_spec(snl, enforce_gga=True, parameters=parameters) spec.update(snl_spec) spec['_priority'] = priority spec['_queueadapter'] = QA_VASP spec['_trackers'] = trackers tasks = [VaspWriterTask(), get_custodian_task(spec)] fws.append( Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=1)) # insert into DB - GGA structure optimization spec = { 'task_type': 'VASP db insertion', '_priority': priority * 2, '_allow_fizzled_parents': True, '_queueadapter': QA_DB, "_dupefinder": DupeFinderDB().to_dict(), '_trackers': trackers_db } fws.append( Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=2)) connections[1] = [2] # determine if GGA+U FW is needed incar = MPVaspInputSet().get_incar(snl.structure).as_dict() ggau_compound = ('LDAU' in incar and incar['LDAU']) if not parameters.get('skip_bandstructure', False) and ( not ggau_compound or parameters.get('force_gga_bandstructure', False)): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( Firework([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=3)) connections[2] = [3] if ggau_compound: spec = _snl_to_spec(snl, enforce_gga=False, parameters=parameters) del spec[ 'vasp'] # we are stealing all VASP params and such from previous run spec['_priority'] = priority spec['_queueadapter'] = QA_VASP spec['_trackers'] = trackers fws.append( Firework( [VaspCopyTask(), SetupGGAUTask(), get_custodian_task(spec)], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=10)) connections[2].append(10) spec = { 'task_type': 'VASP db insertion', '_queueadapter': QA_DB, '_allow_fizzled_parents': True, '_priority': priority, "_dupefinder": DupeFinderDB().to_dict(), '_trackers': trackers_db } fws.append( Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=11)) connections[10] = [11] if not parameters.get('skip_bandstructure', False): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( Firework([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=12)) connections[11] = [12] wf_meta = get_meta_from_structure(snl.structure) wf_meta['run_version'] = 'May 2013 (1)' # not maintained if '_materialsproject' in snl.data and 'submission_id' in snl.data[ '_materialsproject']: wf_meta['submission_id'] = snl.data['_materialsproject'][ 'submission_id'] return Workflow( fws, connections, name=Composition( snl.structure.composition.reduced_formula).alphabetical_formula, metadata=wf_meta)
def __init__(self, vasp_cmd, output_file="vasp.out", suffix="", final=True, backup=True, default_vasp_input_set=MPVaspInputSet(), auto_npar=True, auto_gamma=True, settings_override=None, gamma_vasp_cmd=None, copy_magmom=False): """ This constructor is necessarily complex due to the need for flexibility. For standard kinds of runs, it's often better to use one of the static constructors. The defaults are usually fine too. Args: vasp_cmd (str): Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like ["mpirun", "pvasp.5.2.11"] output_file (str): Name of file to direct standard out to. Defaults to "vasp.out". suffix (str): A suffix to be appended to the final output. E.g., to rename all VASP output from say vasp.out to vasp.out.relax1, provide ".relax1" as the suffix. final (bool): Indicating whether this is the final vasp job in a series. Defaults to True. backup (bool): Whether to backup the initial input files. If True, the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a ".orig" appended. Defaults to True. default_vasp_input_set (VaspInputSet): Species the default input set (see pymatgen's documentation in pymatgen.io.vasp.sets to use for directories that do not contain full set of VASP input files. For example, if a directory contains only a POSCAR or a cif, the vasp input set will be used to generate the necessary input files for the run. If the directory already contain a full set of VASP input files, this input is ignored. Defaults to the MITVaspInputSet. auto_npar (bool): Whether to automatically tune NPAR to be sqrt( number of cores) as recommended by VASP for DFT calculations. Generally, this results in significant speedups. Defaults to True. Set to False for HF, GW and RPA calculations. auto_gamma (bool): Whether to automatically check if run is a Gamma 1x1x1 run, and whether a Gamma optimized version of VASP exists with ".gamma" appended to the name of the VASP executable (typical setup in many systems). If so, run the gamma optimized version of VASP instead of regular VASP. You can also specify the gamma vasp command using the gamma_vasp_cmd argument if the command is named differently. settings_override ([dict]): An ansible style list of dict to override changes. For example, to set ISTART=1 for subsequent runs and to copy the CONTCAR to the POSCAR, you will provide:: [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}}, {"file": "CONTCAR", "action": {"_file_copy": {"dest": "POSCAR"}}}] gamma_vasp_cmd (str): Command for gamma vasp version when auto_gamma is True. Should follow the list style of subprocess. Defaults to None, which means ".gamma" is added to the last argument of the standard vasp_cmd. copy_magmom (bool): Whether to copy the final magmom from the OUTCAR to the next INCAR. Useful for multi-relaxation runs where the CHGCAR and WAVECAR are sometimes deleted (due to changes in fft grid, etc.). Only applies to non-final runs. """ self.vasp_cmd = vasp_cmd self.output_file = output_file self.final = final self.backup = backup self.default_vis = default_vasp_input_set self.suffix = suffix self.settings_override = settings_override self.auto_npar = auto_npar self.auto_gamma = auto_gamma self.gamma_vasp_cmd = gamma_vasp_cmd self.copy_magmom = copy_magmom