From 99eaf3f7ba2e9a2395fb38257e5e99ae3bac4907 Mon Sep 17 00:00:00 2001 From: fraricci Date: Tue, 11 Oct 2022 18:58:15 -0700 Subject: [PATCH 1/6] fix static mag wf --- atomate/vasp/fireworks/core.py | 8 +++++--- atomate/vasp/workflows/base/magnetism.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/atomate/vasp/fireworks/core.py b/atomate/vasp/fireworks/core.py index 9cd8e9c2b..7ad211109 100644 --- a/atomate/vasp/fireworks/core.py +++ b/atomate/vasp/fireworks/core.py @@ -333,9 +333,10 @@ def __init__( vasptodb_kwargs["additional_fields"] = {} vasptodb_kwargs["additional_fields"]["task_label"] = name - formula = structure.composition.reduced_formula if structure else "unknown" + formula = structure.composition.reduced_formula if structure is not None else "unknown" fw_name = f"{formula}-{name}" - + print(formula,spec_structure_key,type(structure),len(structure.structures)) + if spec_structure_key is not None: vasp_input_set = vasp_input_set or MPStaticSet( structure, **vasp_input_set_params @@ -356,7 +357,8 @@ def __init__( CopyVaspOutputs(calc_loc=prev_calc_loc, contcar_to_poscar=True) ) t.append(WriteVaspStaticFromPrev(other_params=vasp_input_set_params)) - elif structure: + elif structure is not None: + print('here') vasp_input_set = vasp_input_set or MPStaticSet( structure, **vasp_input_set_params ) diff --git a/atomate/vasp/workflows/base/magnetism.py b/atomate/vasp/workflows/base/magnetism.py index 6410a0e97..65a6947bb 100644 --- a/atomate/vasp/workflows/base/magnetism.py +++ b/atomate/vasp/workflows/base/magnetism.py @@ -293,7 +293,7 @@ def _add_metadata(structure): user_incar_settings.update({"LAECHG": True}) user_incar_settings.update(c.get("user_incar_settings", {})) c["user_incar_settings"] = user_incar_settings - + print(len(ordered_structures)) for idx, ordered_structure in enumerate(ordered_structures): analyzer = CollinearMagneticStructureAnalyzer(ordered_structure) @@ -328,8 +328,8 @@ def _add_metadata(structure): vasp_cmd=c["VASP_CMD"], db_file=c["DB_FILE"], name=name + " static", - prev_calc_loc=True, - parents=fws[-1], + prev_calc_loc = True if not self.static else False, + parents=fws[-1] if not self.static else None, vasptodb_kwargs={"parse_chgcar": True, "parse_aeccar": True}, ) ) From ddcdc04b7f5f74f677e0089b6fae8348dfd3475e Mon Sep 17 00:00:00 2001 From: fraricci Date: Wed, 12 Oct 2022 14:42:22 -0700 Subject: [PATCH 2/6] fixed ToDb task as well --- atomate/vasp/firetasks/parse_outputs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/atomate/vasp/firetasks/parse_outputs.py b/atomate/vasp/firetasks/parse_outputs.py index dc870c146..aeeef16d9 100644 --- a/atomate/vasp/firetasks/parse_outputs.py +++ b/atomate/vasp/firetasks/parse_outputs.py @@ -1376,6 +1376,10 @@ def run_task(self, fw_spec): {"wf_meta.wf_uuid": uuid, "task_label": optimize_task_label} ) ) + #input_structure = Structure.from_dict(optimize_task["input"]["structure"]) + #input_magmoms = optimize_task["input"]["incar"]["MAGMOM"] + #input_structure.add_site_property("magmom", input_magmoms) + # used to determine if ordering changed during relaxation # stored for checking suitable convergence is reached energy_diff_relax_static = ( @@ -1384,11 +1388,14 @@ def run_task(self, fw_spec): ) else: energy_diff_relax_static = None + #initial_structure = Structure.from_dict(d["output"]["structure"]) + #initial_magmoms = initial_structure.site_properties["magmom"] + optimize_task = d input_structure = Structure.from_dict(optimize_task["input"]["structure"]) input_magmoms = optimize_task["input"]["incar"]["MAGMOM"] input_structure.add_site_property("magmom", input_magmoms) - + final_structure = Structure.from_dict(d["output"]["structure"]) # picking a fairly large threshold so that default 0.6 µB magmoms don't From 5b69e518be42f386530073a569caf4ec0d7db40d Mon Sep 17 00:00:00 2001 From: fraricci Date: Thu, 5 Jan 2023 16:09:55 -0800 Subject: [PATCH 3/6] prints removed --- atomate/vasp/fireworks/core.py | 2 -- atomate/vasp/workflows/base/magnetism.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/atomate/vasp/fireworks/core.py b/atomate/vasp/fireworks/core.py index 7ad211109..844aad5ed 100644 --- a/atomate/vasp/fireworks/core.py +++ b/atomate/vasp/fireworks/core.py @@ -335,7 +335,6 @@ def __init__( formula = structure.composition.reduced_formula if structure is not None else "unknown" fw_name = f"{formula}-{name}" - print(formula,spec_structure_key,type(structure),len(structure.structures)) if spec_structure_key is not None: vasp_input_set = vasp_input_set or MPStaticSet( @@ -358,7 +357,6 @@ def __init__( ) t.append(WriteVaspStaticFromPrev(other_params=vasp_input_set_params)) elif structure is not None: - print('here') vasp_input_set = vasp_input_set or MPStaticSet( structure, **vasp_input_set_params ) diff --git a/atomate/vasp/workflows/base/magnetism.py b/atomate/vasp/workflows/base/magnetism.py index 65a6947bb..689b8d51a 100644 --- a/atomate/vasp/workflows/base/magnetism.py +++ b/atomate/vasp/workflows/base/magnetism.py @@ -293,7 +293,7 @@ def _add_metadata(structure): user_incar_settings.update({"LAECHG": True}) user_incar_settings.update(c.get("user_incar_settings", {})) c["user_incar_settings"] = user_incar_settings - print(len(ordered_structures)) + for idx, ordered_structure in enumerate(ordered_structures): analyzer = CollinearMagneticStructureAnalyzer(ordered_structure) From af70d0b269e964b47f16e5e201f08ad80171be89 Mon Sep 17 00:00:00 2001 From: fraricci Date: Mon, 9 Jan 2023 10:50:25 -0800 Subject: [PATCH 4/6] comments removed --- atomate/vasp/firetasks/parse_outputs.py | 7 +------ atomate/vasp/fireworks/core.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/atomate/vasp/firetasks/parse_outputs.py b/atomate/vasp/firetasks/parse_outputs.py index aeeef16d9..7b1388e74 100644 --- a/atomate/vasp/firetasks/parse_outputs.py +++ b/atomate/vasp/firetasks/parse_outputs.py @@ -1376,9 +1376,6 @@ def run_task(self, fw_spec): {"wf_meta.wf_uuid": uuid, "task_label": optimize_task_label} ) ) - #input_structure = Structure.from_dict(optimize_task["input"]["structure"]) - #input_magmoms = optimize_task["input"]["incar"]["MAGMOM"] - #input_structure.add_site_property("magmom", input_magmoms) # used to determine if ordering changed during relaxation # stored for checking suitable convergence is reached @@ -1388,14 +1385,12 @@ def run_task(self, fw_spec): ) else: energy_diff_relax_static = None - #initial_structure = Structure.from_dict(d["output"]["structure"]) - #initial_magmoms = initial_structure.site_properties["magmom"] optimize_task = d input_structure = Structure.from_dict(optimize_task["input"]["structure"]) input_magmoms = optimize_task["input"]["incar"]["MAGMOM"] input_structure.add_site_property("magmom", input_magmoms) - + final_structure = Structure.from_dict(d["output"]["structure"]) # picking a fairly large threshold so that default 0.6 µB magmoms don't diff --git a/atomate/vasp/fireworks/core.py b/atomate/vasp/fireworks/core.py index 844aad5ed..398bfc532 100644 --- a/atomate/vasp/fireworks/core.py +++ b/atomate/vasp/fireworks/core.py @@ -335,7 +335,7 @@ def __init__( formula = structure.composition.reduced_formula if structure is not None else "unknown" fw_name = f"{formula}-{name}" - + if spec_structure_key is not None: vasp_input_set = vasp_input_set or MPStaticSet( structure, **vasp_input_set_params From 29048ab652d26bc46c02bbc894cdcac89595d136 Mon Sep 17 00:00:00 2001 From: fraricci Date: Mon, 9 Jan 2023 11:08:29 -0800 Subject: [PATCH 5/6] fix tot mag per fu --- atomate/vasp/firetasks/parse_outputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atomate/vasp/firetasks/parse_outputs.py b/atomate/vasp/firetasks/parse_outputs.py index 7b1388e74..32af4133c 100644 --- a/atomate/vasp/firetasks/parse_outputs.py +++ b/atomate/vasp/firetasks/parse_outputs.py @@ -1464,7 +1464,7 @@ def run_task(self, fw_spec): d["calcs_reversed"][0]["composition_reduced"].values() ) / sum(d["calcs_reversed"][0]["composition_unit_cell"].values()) total_magnetization_per_formula_unit = ( - total_magnetization / num_formula_units + total_magnetization * num_formula_units ) total_magnetization_per_unit_volume = ( total_magnetization / final_structure.volume From 104e0a8553bda34746b0ac1dad14903a3d65d460 Mon Sep 17 00:00:00 2001 From: fraricci Date: Mon, 20 Feb 2023 10:10:11 -0800 Subject: [PATCH 6/6] fix num_formula_units --- atomate/vasp/firetasks/parse_outputs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/atomate/vasp/firetasks/parse_outputs.py b/atomate/vasp/firetasks/parse_outputs.py index 32af4133c..33f83c18f 100644 --- a/atomate/vasp/firetasks/parse_outputs.py +++ b/atomate/vasp/firetasks/parse_outputs.py @@ -1461,10 +1461,10 @@ def run_task(self, fw_spec): d["calcs_reversed"][0]["output"]["outcar"]["total_magnetization"] ) num_formula_units = sum( - d["calcs_reversed"][0]["composition_reduced"].values() - ) / sum(d["calcs_reversed"][0]["composition_unit_cell"].values()) + d["calcs_reversed"][0]["composition_unit_cell"].values() + ) / sum(d["calcs_reversed"][0]["composition_reduced"].values()) total_magnetization_per_formula_unit = ( - total_magnetization * num_formula_units + total_magnetization / num_formula_units ) total_magnetization_per_unit_volume = ( total_magnetization / final_structure.volume