def test_append_fw(self): fw_new = Firework(Task1()) fws = [self.fw1, self.fw2, self.fw3] wflow = Workflow(fws) leaf_ids = wflow.leaf_fw_ids append_fw_wf(wflow, fw_new) new_lead_ids = wflow.leaf_fw_ids for i in leaf_ids: self.assertEqual(wflow.links[i], [new_lead_ids[0]])
def get_wf_gibbs_free_energy(structure, deformations, vasp_input_set=None, vasp_cmd="vasp", db_file=None, user_kpoints_settings=None, t_step=10, t_min=0, t_max=1000, mesh=(20, 20, 20), eos="vinet", qha_type="debye_model", pressure=0.0): """ Returns quasi-harmonic gibbs free energy workflow. Note: phonopy package is required for the final analysis step if qha_type="phonopy" Args: structure (Structure): input structure. deformations (list): list of deformation matrices(list of lists). vasp_input_set (VaspInputSet) vasp_cmd (str): vasp command to run. db_file (str): path to the db file. user_kpoints_settings (dict): example: {"grid_density": 7000} t_step (float): temperature step (in K) t_min (float): min temperature (in K) t_max (float): max temperature (in K) mesh (list/tuple): reciprocal space density eos (str): equation of state used for fitting the energies and the volumes. options supported by phonopy: "vinet", "murnaghan", "birch_murnaghan". Note: pymatgen supports more options than phonopy. see pymatgen.analysis.eos.py qha_type(str): quasi-harmonic approximation type: "debye_model" or "phonopy", default is "debye_model" pressure (float): in GPa Returns: Workflow """ lepsilon = False if qha_type not in ["debye_model"]: lepsilon = True try: from phonopy import Phonopy except ImportError: logger.warn("'phonopy' package NOT installed. Required for the final analysis step." "The debye model for the quasi harmonic approximation will be used.") qha_type = "debye_model" lepsilon = False tag = datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S-%f') deformations = [Deformation(defo_mat) for defo_mat in deformations] wf_gibbs = get_wf_deformations(structure, deformations, name="gibbs deformation", vasp_input_set=vasp_input_set, lepsilon=lepsilon, vasp_cmd=vasp_cmd, db_file=db_file, user_kpoints_settings=user_kpoints_settings, tag=tag) fw_analysis = Firework(GibbsFreeEnergyTask(tag=tag, db_file=db_file, t_step=t_step, t_min=t_min, t_max=t_max, mesh=mesh, eos=eos, qha_type=qha_type, pressure=pressure), name="Gibbs Free Energy") append_fw_wf(wf_gibbs, fw_analysis) wf_gibbs.name = "{}:{}".format(structure.composition.reduced_formula, "gibbs free energy") return wf_gibbs
def get_wf_thermal_expansion(structure, deformations, vasp_input_set=None, vasp_cmd="vasp", db_file=None, user_kpoints_settings=None, t_step=10, t_min=0, t_max=1000, mesh=(20, 20, 20), eos="vinet", pressure=0.0): """ Returns quasi-harmonic thermal expansion workflow. Note: phonopy package is required for the final analysis step. Args: structure (Structure): input structure. deformations (list): list of deformation matrices(list of lists). vasp_input_set (VaspInputSet) vasp_cmd (str): vasp command to run. db_file (str): path to the db file. user_kpoints_settings (dict): example: {"grid_density": 7000} t_step (float): temperature step (in K) t_min (float): min temperature (in K) t_max (float): max temperature (in K) mesh (list/tuple): reciprocal space density eos (str): equation of state used for fitting the energies and the volumes. options supported by phonopy: "vinet", "murnaghan", "birch_murnaghan". Note: pymatgen supports more options than phonopy. see pymatgen.analysis.eos.py pressure (float): in GPa Returns: Workflow """ try: from phonopy import Phonopy except ImportError: logger.warn("'phonopy' package NOT installed. Required for the final analysis step.") tag = datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S-%f') deformations = [Deformation(defo_mat) for defo_mat in deformations] wf_alpha = get_wf_deformations(structure, deformations, name="thermal_expansion deformation", vasp_input_set=vasp_input_set, lepsilon=True, vasp_cmd=vasp_cmd, db_file=db_file, user_kpoints_settings=user_kpoints_settings, tag=tag) fw_analysis = Firework(ThermalExpansionCoeffTask(tag=tag, db_file=db_file, t_step=t_step, t_min=t_min, t_max=t_max, mesh=mesh, eos=eos, pressure=pressure), name="Thermal expansion") append_fw_wf(wf_alpha, fw_analysis) wf_alpha.name = "{}:{}".format(structure.composition.reduced_formula, "thermal expansion") return wf_alpha
def get_wf_bulk_modulus(structure, deformations, vasp_input_set=None, vasp_cmd="vasp", db_file=None, user_kpoints_settings=None, eos="vinet"): """ Returns the workflow that computes the bulk modulus by fitting to the given equation of state. Args: structure (Structure): input structure. deformations (list): list of deformation matrices(list of lists). vasp_input_set (VaspInputSet) vasp_cmd (str): vasp command to run. db_file (str): path to the db file. user_kpoints_settings (dict): example: {"grid_density": 7000} eos (str): equation of state used for fitting the energies and the volumes. supported equation of states: "quadratic", "murnaghan", "birch", "birch_murnaghan", "pourier_tarantola", "vinet", "deltafactor". See pymatgen.analysis.eos.py Returns: Workflow """ tag = datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S-%f') deformations = [Deformation(defo_mat) for defo_mat in deformations] wf_bulk_modulus = get_wf_deformations(structure, deformations, name="bulk_modulus deformation", vasp_input_set=vasp_input_set, lepsilon=False, vasp_cmd=vasp_cmd, db_file=db_file, user_kpoints_settings=user_kpoints_settings, tag=tag) fw_analysis = Firework(FitEquationOfStateTask(tag=tag, db_file=db_file, eos=eos), name="fit equation of state") append_fw_wf(wf_bulk_modulus, fw_analysis) wf_bulk_modulus.name = "{}:{}".format(structure.composition.reduced_formula, "Bulk modulus") return wf_bulk_modulus
def get_wf_elastic_constant( structure, vasp_input_set=None, vasp_cmd="vasp", norm_deformations=None, shear_deformations=None, additional_deformations=None, db_file=None, user_kpoints_settings=None, add_analysis_task=True, conventional=True, ): """ Returns a workflow to calculate elastic constants. Firework 1 : write vasp input set for structural relaxation, run vasp, pass run location, database insertion. Firework 2 - number of total deformations: Static runs on the deformed structures last Firework : Analyze Stress/Strain data and fit the elastic tensor Args: structure (Structure): input structure to be optimized and run. norm_deformations (list): list of values to for normal deformations. shear_deformations (list): list of values to for shear deformations. additional_deformations (list of 3x3 array-likes): list of additional deformations. vasp_input_set (DictVaspInputSet): vasp input set. vasp_cmd (str): command to run. db_file (str): path to file containing the database credentials. user_kpoints_settings (dict): example: {"grid_density": 7000} add_analysis_task (bool): boolean indicating whether to add analysis Returns: Workflow """ # Convert to conventional if conventional: structure = SpacegroupAnalyzer(structure).get_conventional_standard_structure() # Generate deformations deformations = [] if norm_deformations is not None: deformations.extend( [ Deformation.from_index_amount(ind, amount) for ind in [(0, 0), (1, 1), (2, 2)] for amount in norm_deformations ] ) if shear_deformations is not None: deformations.extend( [ Deformation.from_index_amount(ind, amount) for ind in [(0, 1), (0, 2), (1, 2)] for amount in shear_deformations ] ) if additional_deformations: deformations.extend([Deformation(defo_mat) for defo_mat in additional_deformations]) if not deformations: raise ValueError("deformations list empty") wf_elastic = get_wf_deformations( structure, deformations, vasp_input_set=vasp_input_set, lepsilon=False, vasp_cmd=vasp_cmd, db_file=db_file, user_kpoints_settings=user_kpoints_settings, pass_stress_strain=True, name="deformation", relax_deformed=True, tag="elastic", ) if add_analysis_task: fw_analysis = Firework( ElasticTensorToDbTask(structure=structure, db_file=db_file), name="Analyze Elastic Data", spec={"_allow_fizzled_parents": True}, ) append_fw_wf(wf_elastic, fw_analysis) wf_elastic.name = "{}:{}".format(structure.composition.reduced_formula, "elastic constants") return wf_elastic