Example #1
0
class CalculationSettingsTest(unittest.TestCase):
    def setUp(self):
        self.calc_directory = "data/calculations_pto"
        self.incar = IncarSettings()
        self.incar.from_file("data/incar_pto")
        self.poscar = PoscarSettings()
        self.poscar.from_file("data/poscar_pto.vasp")
        self.potcar = PotcarSettings()
        self.potcar.from_file("data/potcar_pto")
        runscript_file_path = "data/run_cl.sh"

        run_settings = {
            "job_name": "scf_cl",
            "qos": "regular",
            "nodes": 1,
            "constraint": "knl",
            "time": "24:00:00"
        }
        modules = ["vasp/20181030-knl"]
        exports = ["OMP_NUM_THREADS=4"]
        execute = "vasp_std"
        self.runscript = RunscriptSettings(runscript_file_path, run_settings,
                                           modules, exports, execute)
        self.kpoints = KpointsSettings()
        self.kpoints.from_file("data/kpoints_pto")

    def test_makecalc(self):
        calc = Calculation(self.incar, self.kpoints, self.poscar, self.potcar,
                           self.runscript)
        calc.make_calculation("data/scf_calc_workdir")
Example #2
0
         def __init__(self, encut):
             """
             Sets default input parameters for scf ground state energy calculation

             **Args:
               encut (float): planewave energy cutoff for calculation
               name (str): name for scf setting [default="scf_settings"]

             """
             IncarSettings.__init__(self, name=name)
             self.update_settings(setting_type="electronic", "encut", encut)
Example #3
0
 def test_write_file(self):
     out_path = "data/incar_pto_out"
     incar_1 = IncarSettings(self.settings)
     incar_1.write_file(out_path)
     incar_2 = IncarSettings()
     incar_2.from_file(out_path)
     for key in self.settings:
         self.assertEqual(incar_1._settings[key], incar_2._settings[key])
Example #4
0
         def __init__(self, spinaxis, encut, ldaul, Uparam, Jparam):
             """
            Sets default input parameters for scf spin non-collinear calculation

             encut (flt): planewave energy cutoff for calculation
             spinaxis (ndarray): spinaxis  for calculation
             ldaul (list): list of  orbital types for each species
             Uparam (list): list of U parameters for each species
             Jparam (list): list of J paramters for each species
             name (str):  name for magnetic noncolinear calculation setting [default="DFTNCL_settings"]
             """
             ncl_settings =  {"ispin": 2, "magmom": None, "saxis": spinaxis, "lsorbit": ".TRUE.", "lnoncollinear": ".TRUE."}
             dftu_settings = {"ldau": ".TRUE.", "ldauu": Uparam, "ldatype": 2, "ldaul": ldaul, "ldauj": Jparam , "lmaxmix": 4}
             IncarSettings.__init__(self, magnetic_settings=ncl_settings, hubbard_settings=dftu_settings)
             self.update_electronic_settings("encut", encut)
Example #5
0
         def __init__(self, encut, ldaul, Uparam, Jparam):
             """
             Sets default input parameters for scf ground state energy calculation with +U correction

             encut (float): planewave energy cutoff for calculation
             ldaul (list): list of  orbital types for each species
             Uparam (list): list of U parameters for each species
             Jparam (list): list of J paramters for each species
             name (str):  name for scf+U setting [default="DFTU_settings"]

             """

             dftu_settings = {"ldau": ".TRUE." , "ldauu": Uparam, "ldatype": 2, "ldaul": ldaul, "ldauj": Jparam , "lmaxmix": 4}
             IncarSettings.__init__(self, hubbard_settings=dftu_settings)
             self.update_settings(setting_type="electronic", "encut", encut)
Example #6
0
    def setUp(self):
        ##runscript paramaters
        #  run_settings = {"job_name": "scf", "qos": "regular", "nodes": 1, "constraint": "knl", "time": "12:00:00"}
        #  modules = ["vasp/20181030-knl"]
        #  exports = ["OMP_NUM_THREADS=4"]
        #  links = ["ln -l ../scf_cl/WAVECAR .", "ln -l ../scf_cl/CHARGCAR ."]
        #  runscript_cl = RunscriptSettings(run_settings=run_settings,modules=modules,exports=exports, execute="vasp_std")
        #  self.runscript_ncl = RunscriptSettings(run_settings=run_settings,modules=modules,exports=exports, execute="vasp_ncl",links=links)

        ##cl_calculation settings
        incar = IncarSettings()
        incar.from_file("data/incar_pto")
        poscar = PoscarSettings()
        poscar.from_file("data/poscar_pto.vasp")
        potcar = PotcarSettings()
        potcar.from_file("data/potcar_pto")
        kpoints = KpointsSettings()
        kpoints.from_file("data/kpoints_pto")
        self.calc_cl = Calculation(incar=incar,
                                   kpoints=kpoints,
                                   poscar=poscar,
                                   potcar=potcar)
Example #7
0
    def __init__(self,
                 npoints,
                 work_dir,
                 cl_calculation=None,
                 cl_dir=None,
                 symm_reduce=False,
                 angle_range=None):

        #insert excpetion handeling for inputs
        self._work_dir = work_dir
        self._npoints = npoints

        os.mkdir(self._work_dir)
        #new_cl_dir = self._work_dir + "/scf_cl"
        if cl_calculation:
            #cl_calculation.make_calculation(new_cl_dir)
            self._cl_calculation = cl_calculation
        # If directory for calculation provided
        elif cl_dir:
            new_cl_dir = self._work_dir + "/scf_cl"
            copy(cl_dir, new_cl_dir)
            incar_cl = IncarSettings()
            incar_cl.from_file(cl_dir + "/INCAR")
            poscar = PoscarSettings()
            poscar.from_file(cl_dir + "/POSCAR")
            potcar = PotcarSettings()
            potcar.from_file(cl_dir + "/POTCAR")
            kpts = KPointsSettings()
            kpts.from_file(cl_dir + "/KPOINTS")
            #runscript = RunscriptSettings()
            #runscript.from_file(cl_dir+"/run.sh")
            self._cl_calculation = Calculation(incar_cl, kpt, poscar, potcar)
        else:
            pass

        self._cl_calculation.make_calculation(
            os.path.join(self._work_dir, "scf_cl"))
        struct = self._cl_calculation._poscar._structure
        space_group = SpacegroupAnalyzer(struct).get_space_group_number()

        if angle_range:
            spins = SpinVectors(npoints=npoints, angle_range=angle_range)
        elif symm_reduce is True:
            spins = SpinVectors(npoints=npoints, space_group=space_group)
        else:
            spins = SpinVectors(npoints=npoints)
        self._spins = spins._spin_axes.T

        def setup_ncl_calc(work_dir, spins, incar_cl, poscar, potcar, kpoints):
            ncl_calcs = []
            incar_ncl = incar_cl
            incar_ncl.remove_settings("MAGMOM")
            incar_ncl.update_settings("ISPIN", 1)
            incar_ncl.update_settings("LSORBIT", ".TRUE.")
            incar_ncl.update_settings("LNONCOLLINEAR", ".TRUE.")
            incar_ncl.update_settings("LPLANE", ".FALSE.")
            #incar_ncl.update_settings("NBANDS", str(2*nbands))
            ncl_dir = os.path.join(work_dir, "scf_ncl")
            os.mkdir(ncl_dir)
            itr = 0
            for spin in spins:
                itr += 1
                incar_ncl.update_settings("SAXIS", [spin[0], spin[1], spin[2]])
                calc = Calculation(incar_ncl, kpoints, poscar, potcar)
                calc.make_calculation(os.path.join(ncl_dir, "ncl_" + str(itr)))

        setup_ncl_calc(self._work_dir, self._spins,
                       self._cl_calculation._incar,
                       self._cl_calculation._poscar,
                       self._cl_calculation._potcar,
                       self._cl_calculation._kpoints)
Example #8
0
 def test_update_method(self):
     ## add update method for magmom
     incar = IncarSettings(self.settings)
     incar.update_settings("KPAR", 8)
     self.assertEqual(incar._settings["KPAR"], 8)
Example #9
0
 def test_get_method(self):
     ##add get method for magmom (and maybe also U paramaters)
     incar = IncarSettings(self.settings)
     out = incar.get_settings("KPAR")
     self.assertEqual(out, 4)
Example #10
0
 def test_from_file(self):
     incar_infile_sett = IncarSettings()
     incar_infile_sett.from_file(self.incar_file_path)
     incar_sett = incar_infile_sett._settings
     for key in self.settings:
         self.assertEqual(self.settings[key], incar_sett[key])