From 900e31a695dd2f9c3340c72a5e2813600e8d63f4 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 4 Oct 2021 16:58:14 -0400 Subject: [PATCH 001/111] Update Installation.rst --- docs/source/Installation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/Installation.rst b/docs/source/Installation.rst index 20012bd6..13a44c03 100644 --- a/docs/source/Installation.rst +++ b/docs/source/Installation.rst @@ -7,7 +7,7 @@ It is recommended to install DFTTK under the `anaconda Date: Tue, 5 Oct 2021 15:30:21 -0400 Subject: [PATCH 002/111] update --- dfttk/analysis/ywutils.py | 9 +++++++++ dfttk/scripts/assign_fworker_name.py | 1 + 2 files changed, 10 insertions(+) diff --git a/dfttk/analysis/ywutils.py b/dfttk/analysis/ywutils.py index 1eb236b9..9aad7ddc 100644 --- a/dfttk/analysis/ywutils.py +++ b/dfttk/analysis/ywutils.py @@ -227,10 +227,19 @@ def get_Magnetic_State(calc): magmoms = [k for k in magmoms] magmoms = np.array(magmoms) fmax = max(magmoms) + sdw = magmoms[magmoms>0.1] + if len(sdw)>0: + smin = min(sdw) + smax = max(sdw) + else: + smin = 0.0 + smax = 0.0 + fmax = max(magmoms) fmin = min(magmoms) fsum = sum(magmoms) if fmax>0.1 and fmin<=-0.1: if abs(fsum) > 0.1: return "_FIM" + elif smax-smin > 0.1: return "_SDW" else: return "_AFM" elif fmax>0.1 or fmin<=-0.1: return "_FM" else: return "" diff --git a/dfttk/scripts/assign_fworker_name.py b/dfttk/scripts/assign_fworker_name.py index 2c9cdf42..e14b7be7 100644 --- a/dfttk/scripts/assign_fworker_name.py +++ b/dfttk/scripts/assign_fworker_name.py @@ -278,6 +278,7 @@ def get_powerups_options(override_default_vasp_params): def Customizing_Workflows(wfs, powerups_options=None): if powerups_options is None: powerups_options = get_powerups(wfs) + if powerups_options is None: return wfs if isinstance(wfs, list) : _wfs = [] From ef9e4197e99f835ea4fe4cc251b6082b58da9622 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 6 Oct 2021 11:23:25 -0400 Subject: [PATCH 003/111] added workflow "singleV" for single volume relaxation --- dfttk/scripts/run_dfttk.py | 5 ++++- dfttk/wflows.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index af504302..da0f6b25 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -3,7 +3,7 @@ import argparse from pymatgen.ext.matproj import MPRester, Structure from pymatgen.io.vasp.inputs import Potcar, Incar -from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_gibbs_robust, get_wf_borncharge, get_wf_elastic +from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_singleV, get_wf_gibbs_robust, get_wf_borncharge, get_wf_elastic from dfttk.utils import recursive_glob from dfttk.structure_builders.parse_anrl_prototype import multi_replace from dfttk.scripts.querydb import get_eq_structure_by_metadata @@ -308,6 +308,9 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) if WORKFLOW == "eos": wf = get_wf_EV_bjb(structure, deformation_fraction=deformation_fraction, store_volumetric_data=store_volumetric_data, num_deformations=num_deformations, override_symmetry_tolerances=override_default_vasp_params, metadata=metadata) + elif WORKFLOW == "singleV": + wf = get_wf_singleV(structure, store_volumetric_data=store_volumetric_data, metadata=metadata, + override_default_vasp_params=override_default_vasp_params) elif WORKFLOW == "robust" or WORKFLOW == "get_wf_gibbs": wf = get_wf_gibbs_robust(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index a7089e65..d35037c2 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -76,6 +76,38 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf +def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None): + """ + Perform single volume relaxation calculation. + + Parameters + ---------- + structure : pymatgen.Structure + """ + metadata = metadata or {} + tag = metadata.get('tag', '{}'.format(str(uuid4()))) + metadata.update({'tag': tag}) + common_kwargs = {"metadata": metadata, "tag":tag, + 'override_default_vasp_params': override_default_vasp_params} + fws = [] + full_relax_fw = OptimizeFW(structure, isif=3, vasp_cmd=VASP_CMD, db_file=DB_FILE, + name=structure.composition.reduced_formula+'-Fullrelax', + store_volumetric_data=store_volumetric_data, **common_kwargs) + fws.append(full_relax_fw) + static_fw = StaticFW(structure, isif=2, , vasp_cmd=VASP_CMD, db_file=DB_FILE, + name=structure.composition.reduced_formula+'-Staitc', + vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, + store_volumetric_data=store_volumetric_data, **common_kwargs) + fws.append(static_fw) + if metadata is not None and all(x in metadata for x in ('phase_name', 'sublattice_configuration')): + # create a nicer name for the workflow + subl_config = ':'.join(','.join(subl_comps) for subl_comps in metadata['sublattice_configuration']) + wfname = f"{metadata['phase_name']}:{subl_config}:{structure.composition.reduced_formula}" + else: + wfname = f"unknown:{structure.composition.reduced_formula}:unknown" + wf = Workflow(fws, name=wfname, metadata=metadata) + return wf + def vol_in_volumes(vol, volumes): for v in volumes: From 7fa90aa03f3463a8fde4ba4d4b195c4d96ada5fc Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 6 Oct 2021 11:59:50 -0400 Subject: [PATCH 004/111] for single volume full relaxation --- dfttk/scripts/assign_fworker_name.py | 3 ++- dfttk/scripts/run_dfttk.py | 2 +- dfttk/wflows.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dfttk/scripts/assign_fworker_name.py b/dfttk/scripts/assign_fworker_name.py index e14b7be7..64022a99 100644 --- a/dfttk/scripts/assign_fworker_name.py +++ b/dfttk/scripts/assign_fworker_name.py @@ -278,7 +278,8 @@ def get_powerups_options(override_default_vasp_params): def Customizing_Workflows(wfs, powerups_options=None): if powerups_options is None: powerups_options = get_powerups(wfs) - if powerups_options is None: return wfs + if not powerups_options: return wfs + if isinstance(wfs, list) : _wfs = [] diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index da0f6b25..5a392004 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -451,7 +451,7 @@ def run(args): user_settings.update({"phonon_supercell_matrix": "atoms"}) wf = get_wf_single(structure, WORKFLOW=WORKFLOW, settings=user_settings) - wf = Customizing_Workflows(wf) + wf = Customizing_Workflows(wf,powerups_options=user_settings.get('powerups', None)) metadatas[STR_FILE] = wf.as_dict()["metadata"] wfs.append(wf) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index d35037c2..df51590b 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -91,11 +91,11 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri 'override_default_vasp_params': override_default_vasp_params} fws = [] full_relax_fw = OptimizeFW(structure, isif=3, vasp_cmd=VASP_CMD, db_file=DB_FILE, - name=structure.composition.reduced_formula+'-Fullrelax', + name='Fullrelax', store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(full_relax_fw) - static_fw = StaticFW(structure, isif=2, , vasp_cmd=VASP_CMD, db_file=DB_FILE, - name=structure.composition.reduced_formula+'-Staitc', + static_fw = StaticFW(structure, isif=2, vasp_cmd=VASP_CMD, db_file=DB_FILE, + name='Staitc', vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(static_fw) From fee1eb43b31e4dc213e1d642362335206f49be71 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 6 Oct 2021 17:44:51 -0400 Subject: [PATCH 005/111] improve OptimizeFW to EDIFFG = -xxx settings --- dfttk/fworks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index d77ea9d9..692d4070 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -68,9 +68,14 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole raise ValueError('The store_volumetric_data should be list or bool') override_default_vasp_params = override_default_vasp_params or {} + tmp = copy.deepcopy(override_default_vasp_params) + if isif!=4 and isif!=3: + if 'user_incar_settings' in tmp: + if 'EDIFFG' in tmp['user_incar_settings']: + tmp['user_incar_settings'].pop('EDIFFG') override_symmetry_tolerances = override_symmetry_tolerances or {} vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, - **override_default_vasp_params) + **tmp) site_properties = deepcopy(structure).site_properties t = [] From 6521ac64f5e9d2bb68ab5869963fe794eb44143a Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 8 Oct 2021 16:36:03 -0400 Subject: [PATCH 006/111] added function for lattice shape constrained relaxation --- dfttk/scripts/run_dfttk.py | 2 +- dfttk/wflows.py | 93 ++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 11 deletions(-) diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index 5a392004..e0d2c0c2 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -310,7 +310,7 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) num_deformations=num_deformations, override_symmetry_tolerances=override_default_vasp_params, metadata=metadata) elif WORKFLOW == "singleV": wf = get_wf_singleV(structure, store_volumetric_data=store_volumetric_data, metadata=metadata, - override_default_vasp_params=override_default_vasp_params) + override_default_vasp_params=override_default_vasp_params, settings=settings) elif WORKFLOW == "robust" or WORKFLOW == "get_wf_gibbs": wf = get_wf_gibbs_robust(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index df51590b..36962294 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -8,6 +8,7 @@ os.environ["HOME"] = str(Path.home()) import numpy as np +import copy from uuid import uuid4 from copy import deepcopy from fireworks import Workflow, Firework @@ -24,6 +25,29 @@ import sys +from pymatgen.core import Structure +from pymatgen.symmetry.analyzer import SpacegroupAnalyzer + + +def scale_lattice_vector(structure, factor: float, axisa=False, axisb=False, axisc=True,): + """ + Performs a scaling of the lattice vectors so that angles are preserved + axisx(x=a,b,c) = True: + x lattice scale. + Args: + factor (float): scaling factor. + """ + struct = copy.deepcopy(structure).as_dict() + matrix = np.array(struct['lattice']['matrix']) + if axisa: + matrix[0] *= factor + if axisb: + matrix[1] *= factor + if axisc: + matrix[2] *= factor + struct['lattice']['matrix']=list(matrix) + return Structure.from_dict(struct) + def _get_deformations(def_frac, num_def): if isinstance(def_frac, (list, tuple)): return np.linspace(1 + def_frac[0], 1 + def_frac[1], num_def) @@ -76,7 +100,7 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf -def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None): +def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): """ Perform single volume relaxation calculation. @@ -89,16 +113,65 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri metadata.update({'tag': tag}) common_kwargs = {"metadata": metadata, "tag":tag, 'override_default_vasp_params': override_default_vasp_params} + + num_deformations = settings.get('num_deformations', 1) + #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume + deformation_fraction = settings.get('deformation_fraction', (-0.0, +0.0)) + deformation_scheme = settings.get('deformation_scheme', 'volume') + dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 + + isif = settings.get('run_isif', None) + if not isif: + isif=3 + if num_deformations>1: + if deformation_scheme=='volume': isif = 4 + else: isif = 2 + + if deformation_scheme=='volume': + axisa=True + axisb=True + axisc=True + elif deformation_scheme=='a': + axisa=True + axisb=False + axisc=False + elif deformation_scheme=='b': + axisa=False + axisb=True + axisc=False + elif deformation_scheme=='c': + axisa=False + axisb=False + axisc=True + elif deformation_scheme=='bc' or deformation_scheme=='cb': + axisa=False + axisb=True + axisc=True + elif deformation_scheme=='ca' or deformation_scheme=='ac': + axisa=True + axisb=False + axisc=True + elif deformation_scheme=='ab' or deformation_scheme=='ba': + axisa=True + axisb=True + axisc=False + + + deformations = _get_deformations((dmin,dmax), num_deformations) + fws = [] - full_relax_fw = OptimizeFW(structure, isif=3, vasp_cmd=VASP_CMD, db_file=DB_FILE, - name='Fullrelax', - store_volumetric_data=store_volumetric_data, **common_kwargs) - fws.append(full_relax_fw) - static_fw = StaticFW(structure, isif=2, vasp_cmd=VASP_CMD, db_file=DB_FILE, - name='Staitc', - vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, - store_volumetric_data=store_volumetric_data, **common_kwargs) - fws.append(static_fw) + for defo in deformations: + struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) + full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, + name='Structure_relax_with_ISIF='+str(isif), + store_volumetric_data=store_volumetric_data, **common_kwargs) + fws.append(full_relax_fw) + static_fw = StaticFW(struct, isif=2, vasp_cmd=VASP_CMD, db_file=DB_FILE, + name='Staitc', + vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, + store_volumetric_data=store_volumetric_data, **common_kwargs) + fws.append(static_fw) if metadata is not None and all(x in metadata for x in ('phase_name', 'sublattice_configuration')): # create a nicer name for the workflow subl_config = ':'.join(','.join(subl_comps) for subl_comps in metadata['sublattice_configuration']) From 89277b91fe659309f4cbcce6ee5334845ecd5edd Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 12:50:01 -0400 Subject: [PATCH 007/111] cloud calculation without computer dependentce --- dfttk/ftasks.py | 66 ++++++++++++++++++++++++++ dfttk/fworks.py | 13 +++++- dfttk/scripts/run_dfttk.py | 11 ++++- dfttk/wflows.py | 95 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 4 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 8550ee44..db2151b0 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -740,6 +740,72 @@ def run_task(self, fw_spec): kpoint.write_file('KPOINTS') +@explicit_serialize +class AppendCalculation(FiretaskBase): + """Continue Static/Phonon calculations + """ + + required_params = [] + optional_params = ['db_file', 'vasp_cmd', + 'parents', 'db_insert', 'tag', 'metadata', 'name', 'vasp_input_set', + 'phonon', 'phonon_supercell_matrix', 't_min', 't_max', 't_step', + 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'site_properties', + 'override_default_vasp_params', + 'store_volumetric_data', 'settings', 'static'] + + def run_task(self, fw_spec): + db_file = db_file or DB_FILE + vasp_cmd = vasp_cmd or VASP_CMD + parents = self.get('parents', None) + db_insert = self.get('db_insert', None) + tag = self.get('tag') + metadata = self.get('metadata') + name = self.get('name', "AppendCalculation") + phonon = self.get('phonon', False) + phonon_supercell_matrix = self.get('phonon_supercell_matrix', None) + t_min = self.get('t_min') + t_max = self.get('t_max', None) + t_step = self.get('t_step', None) + modify_incar_params = self.get('modify_incar_params', None) + modify_kpoints_params = self.get('modify_kpoints_params', None) + site_properties = self.get('site_properties', None) + override_default_vasp_params = self.get('override_default_vasp_params', None) + store_volumetric_data = self.get('store_volumetric_data', False) + settings = self.get('settings', None) + + return FWAction(detours=self.get_detour_workflow( + db_file, vasp_cmd, parents, db_insert, tag, metadata, name, + phonon, phonon_supercell_matrix, t_min, t_max, t_step, + modify_incar_params, modify_kpoints_params, site_properties, + override_default_vasp_params, + store_volumetric_data, settings + )) + + def get_detour_workflow(self, + db_file, vasp_cmd, parents, db_insert, tag, metadata, name, + phonon, phonon_supercell_matrix, t_min, t_max, t_step, + modify_incar_params, modify_kpoints_params, site_properties, + override_default_vasp_params, + store_volumetric_data, settings): + from fireworks import Workflow + from .fworks import PhononFW, StaticFW + + detour_fws = [] + inp_structure = Structure.from_file('CONTCAR') + if len(site_properties)>0: + for prop, vals in site_properties.items(): + inp_structure.add_site_property(prop, vals) + + detour_fws.append(StaticFW(inp_structure, name="static", + vasp_cmd=vasp_cmd, metadata=metadata, prev_calc_loc=False, modify_incar=modify_incar_params, + db_file=db_file, parents=parents, tag=tag, + override_default_vasp_params=override_default_vasp_params, + store_volumetric_data=store_volumetric_data)) + override_default_vasp_params = self.get('override_default_vasp_params',{}) + user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) + return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) + + @explicit_serialize class CheckRelaxation(FiretaskBase): """Run VASP calculations to get symmetry conserved and symmetry broken structures. diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 692d4070..04634019 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -13,7 +13,8 @@ from dfttk.input_sets import RelaxSet, StaticSet, ForceConstantsSet, ATATIDSet, BornChargeSet from dfttk.ftasks import WriteVaspFromIOSetPrevStructure, SupercellTransformation, CalculatePhononThermalProperties, \ CheckSymmetry, CheckRelaxation, ScaleVolumeTransformation, TransmuteStructureFile, WriteATATFromIOSet, RunATATCustodian, RunVaspCustodianNoValidate, \ - Record_relax_running_path, Record_PreStatic_result, CheckSymmetryToDb, PhononStable, BornChargeToDb + Record_relax_running_path, Record_PreStatic_result, CheckSymmetryToDb, PhononStable, BornChargeToDb, \ + AppendCalculation from atomate import __version__ as atomate_ver from dfttk import __version__ as dfttk_ver from dfttk.run_task_ext import run_task_ext @@ -48,7 +49,8 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole metadata=None, override_default_vasp_params=None, db_file=None, record_path=False, prev_calc_loc=True, parents=None, db_insert=False, tag=None, run_isif2=False, pass_isif4=False, force_gamma=True, store_volumetric_data=False, - modify_incar=None, modify_incar_params={}, modify_kpoints_params={}, **kwargs): + modify_incar=None, modify_incar_params={}, modify_kpoints_params={}, + t_kwargs=None, a_kwargs=None, **kwargs): metadata = metadata or {} tag = tag or metadata.get('tag') # generate a tag with a warning @@ -102,6 +104,13 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole if db_insert: t.append(VaspToDb(db_file=">>db_file<<", additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data)) t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) + if a_kwargs.get("static", False): + t.append(AppendCalculation( + name=name, vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, + metadata=metadata, site_properties=site_properties, + parents=parents, db_insert=db_insert, tag=tag, + store_volumetric_data=store_volumetric_data, + modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, **a_kwargs, **kwargs)) super(OptimizeFW, self).__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs) diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index e0d2c0c2..8fd0529d 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -3,7 +3,8 @@ import argparse from pymatgen.ext.matproj import MPRester, Structure from pymatgen.io.vasp.inputs import Potcar, Incar -from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_singleV, get_wf_gibbs_robust, get_wf_borncharge, get_wf_elastic +from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_singleV, get_wf_cloud, \ + get_wf_gibbs_robust, get_wf_borncharge, get_wf_elastic from dfttk.utils import recursive_glob from dfttk.structure_builders.parse_anrl_prototype import multi_replace from dfttk.scripts.querydb import get_eq_structure_by_metadata @@ -310,7 +311,13 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) num_deformations=num_deformations, override_symmetry_tolerances=override_default_vasp_params, metadata=metadata) elif WORKFLOW == "singleV": wf = get_wf_singleV(structure, store_volumetric_data=store_volumetric_data, metadata=metadata, - override_default_vasp_params=override_default_vasp_params, settings=settings) + override_default_vasp_params=override_default_vasp_params, settings=settings) + elif WORKFLOW == "cloud": + wf = get_wf_cloud(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, + phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, + metadata=metadata, name='EV_QHA_cloud', + override_default_vasp_params=override_default_vasp_params, + store_volumetric_data=store_volumetric_data, settings=settings) elif WORKFLOW == "robust" or WORKFLOW == "get_wf_gibbs": wf = get_wf_gibbs_robust(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 36962294..fc6bc341 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -182,6 +182,101 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri return wf +def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.15), phonon=False, isif4=False, + phonon_supercell_matrix=None, t_min=5, t_max=2000, + t_step=5, vasp_cmd=None, db_file=None, + metadata=None, name='EV_QHA_cloud', store_volumetric_data=False, override_default_vasp_params=None, settings=None): + """ + Perform cloud QHA calculation without computer dependent. + + Parameters + ---------- + structure : pymatgen.Structure + """ + vasp_cmd = vasp_cmd or VASP_CMD + db_file = db_file or DB_FILE + metadata = metadata or {} + tag = metadata.get('tag', '{}'.format(str(uuid4()))) + metadata.update({'tag': tag}) + + t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + + if phonon: + if isinstance(phonon_supercell_matrix, str): + if phonon_supercell_matrix=='Yphon': + phonon_supercell_matrix = supercell_scaling_by_Yphon(structure, + supercellsize=phonon_supercell_matrix_max) + else: + phonon_supercell_matrix = supercell_scaling_by_atom_lat_vol(structure, min_obj=phonon_supercell_matrix_min, + max_obj=phonon_supercell_matrix_max, scale_object=phonon_supercell_matrix, + target_shape='sc', lower_search_limit=-2, upper_search_limit=2, + verbose=verbose, sc_tolerance=1e-5, optimize_sc=optimize_sc) + common_kwargs = {"metadata": metadata, "tag":tag} + a_kwargs = { + 'override_default_vasp_params': override_default_vasp_params, + "static": True, "phonon":phonon, + "phonon_supercell_matrix":phonon_supercell_matrix} + + num_deformations = num_deformations or 1 + #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume + deformation_fraction = deformation_fraction or (-0.0, +0.0) + deformation_scheme = settings.get('deformation_scheme', 'volume') + dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 + + isif = settings.get('run_isif', None) + if not isif: + isif=3 + if num_deformations>1: + if deformation_scheme=='volume': isif = 4 + else: isif = 2 + + if deformation_scheme=='volume': + axisa=True + axisb=True + axisc=True + elif deformation_scheme=='a': + axisa=True + axisb=False + axisc=False + elif deformation_scheme=='b': + axisa=False + axisb=True + axisc=False + elif deformation_scheme=='c': + axisa=False + axisb=False + axisc=True + elif deformation_scheme=='bc' or deformation_scheme=='cb': + axisa=False + axisb=True + axisc=True + elif deformation_scheme=='ca' or deformation_scheme=='ac': + axisa=True + axisb=False + axisc=True + elif deformation_scheme=='ab' or deformation_scheme=='ba': + axisa=True + axisb=True + axisc=False + + + deformations = _get_deformations((dmin,dmax), num_deformations) + + fws = [] + for defo in deformations: + struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) + full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, + name='Structure_relax_with_ISIF='+str(isif), + store_volumetric_data=store_volumetric_data, + t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs) + fws.append(full_relax_fw) + + wfname = "{}:{}".format(structure.composition.reduced_formula, name) + wf = Workflow(fws, name=wfname, metadata=metadata) + return wf + + def vol_in_volumes(vol, volumes): for v in volumes: ncell = int(v/vol+1.e-12) From 034d437f18c37dc3a567a4501267aee587e6170c Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 15:49:33 -0400 Subject: [PATCH 008/111] further updates --- dfttk/ftasks.py | 12 +++++++++++- dfttk/wflows.py | 32 ++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index db2151b0..cd6ac01b 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -796,11 +796,21 @@ def get_detour_workflow(self, for prop, vals in site_properties.items(): inp_structure.add_site_property(prop, vals) - detour_fws.append(StaticFW(inp_structure, name="static", + detour_fws.append(StaticFW(inp_structure, name="cloud-static", vasp_cmd=vasp_cmd, metadata=metadata, prev_calc_loc=False, modify_incar=modify_incar_params, db_file=db_file, parents=parents, tag=tag, override_default_vasp_params=override_default_vasp_params, store_volumetric_data=store_volumetric_data)) + + if phonon: + t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, + 'override_default_vasp_params': override_default_vasp_params} + detour_fws.append(PhononFW(inp_structure, phonon_supercell_matrix, + vasp_input_set=None, + name='cloud-phonon', prev_calc_loc=False, + parents=parents, **t_kwargs, **common_kwargs)) + override_default_vasp_params = self.get('override_default_vasp_params',{}) user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index fc6bc341..6a45d73c 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -118,8 +118,6 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume deformation_fraction = settings.get('deformation_fraction', (-0.0, +0.0)) deformation_scheme = settings.get('deformation_scheme', 'volume') - dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 isif = settings.get('run_isif', None) if not isif: @@ -129,30 +127,44 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri else: isif = 2 if deformation_scheme=='volume': + dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 axisa=True axisb=True axisc=True elif deformation_scheme=='a': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=True axisb=False axisc=False elif deformation_scheme=='b': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=False axisb=True axisc=False elif deformation_scheme=='c': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=False axisb=False axisc=True elif deformation_scheme=='bc' or deformation_scheme=='cb': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=False axisb=True axisc=True elif deformation_scheme=='ca' or deformation_scheme=='ac': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=True axisb=False axisc=True elif deformation_scheme=='ab' or deformation_scheme=='ba': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=True axisb=True axisc=False @@ -221,8 +233,6 @@ def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.1 #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume deformation_fraction = deformation_fraction or (-0.0, +0.0) deformation_scheme = settings.get('deformation_scheme', 'volume') - dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 isif = settings.get('run_isif', None) if not isif: @@ -232,30 +242,44 @@ def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.1 else: isif = 2 if deformation_scheme=='volume': + dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 axisa=True axisb=True axisc=True elif deformation_scheme=='a': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=True axisb=False axisc=False elif deformation_scheme=='b': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=False axisb=True axisc=False elif deformation_scheme=='c': + dmin = deformation_fraction) + dmax = deformation_fraction) axisa=False axisb=False axisc=True elif deformation_scheme=='bc' or deformation_scheme=='cb': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=False axisb=True axisc=True elif deformation_scheme=='ca' or deformation_scheme=='ac': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=True axisb=False axisc=True elif deformation_scheme=='ab' or deformation_scheme=='ba': + dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 axisa=True axisb=True axisc=False From 452c555bd7360d427baff9bf1365729eb5ce024c Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 16:03:17 -0400 Subject: [PATCH 009/111] updates --- dfttk/fworks.py | 2 +- dfttk/wflows.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 04634019..0d80a401 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -106,7 +106,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) if a_kwargs.get("static", False): t.append(AppendCalculation( - name=name, vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, + name="AppendCalculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, metadata=metadata, site_properties=site_properties, parents=parents, db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 6a45d73c..a2f9d23c 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -133,20 +133,20 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri axisb=True axisc=True elif deformation_scheme=='a': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=True axisb=False axisc=False elif deformation_scheme=='b': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=False axisb=True axisc=False elif deformation_scheme=='c': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=False axisb=False axisc=True @@ -248,20 +248,20 @@ def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.1 axisb=True axisc=True elif deformation_scheme=='a': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=True axisb=False axisc=False elif deformation_scheme=='b': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=False axisb=True axisc=False elif deformation_scheme=='c': - dmin = deformation_fraction) - dmax = deformation_fraction) + dmin = deformation_fraction + dmax = deformation_fraction axisa=False axisb=False axisc=True From 154188437e70d47110623879ea102fd4aa3bef24 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 16:41:18 -0400 Subject: [PATCH 010/111] Update fworks.py --- dfttk/fworks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 0d80a401..a039fcf4 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -70,12 +70,16 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole raise ValueError('The store_volumetric_data should be list or bool') override_default_vasp_params = override_default_vasp_params or {} + if len (override_default_vasp_params)==0: + override_default_vasp_params = a_kwargs.get("override_default_vasp_params", {}) + tmp = copy.deepcopy(override_default_vasp_params) if isif!=4 and isif!=3: if 'user_incar_settings' in tmp: if 'EDIFFG' in tmp['user_incar_settings']: tmp['user_incar_settings'].pop('EDIFFG') override_symmetry_tolerances = override_symmetry_tolerances or {} + vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, **tmp) site_properties = deepcopy(structure).site_properties @@ -106,7 +110,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) if a_kwargs.get("static", False): t.append(AppendCalculation( - name="AppendCalculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, + name="could-AppendCalculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, metadata=metadata, site_properties=site_properties, parents=parents, db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, From 701a2a5475e5b98201c57fb29b619d6fe01d63fa Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 17:13:36 -0400 Subject: [PATCH 011/111] Update ftasks.py --- dfttk/ftasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index cd6ac01b..b513d61c 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -754,8 +754,8 @@ class AppendCalculation(FiretaskBase): 'store_volumetric_data', 'settings', 'static'] def run_task(self, fw_spec): - db_file = db_file or DB_FILE - vasp_cmd = vasp_cmd or VASP_CMD + db_file = self.get('db_file') or DB_FILE + vasp_cmd = self.get('vasp_cmd') or VASP_CMD parents = self.get('parents', None) db_insert = self.get('db_insert', None) tag = self.get('tag') From 1d9de8d539de706aec8d26ad0eed9d9b4218e174 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 11 Oct 2021 17:59:40 -0400 Subject: [PATCH 012/111] Update fworks.py --- dfttk/fworks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index a039fcf4..52a9d9b4 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -442,7 +442,7 @@ def __init__(self, structure, supercell_matrix, t_min=5, t_max=2000, t_step=5, else: # write the input set first, just to get the POSCAR file in the directory # the other inputs will get overridden by WriteVaspFromIOSetPrevStructure - t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=site_properties)) + t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=supercell_site_properties)) t.append(SupercellTransformation(supercell_matrix=supercell_matrix)) t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=supercell_site_properties)) From 5e5bcbdf31e84801b0575e2e769e42473f89c2db Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 10:11:44 -0400 Subject: [PATCH 013/111] Update fworks.py --- dfttk/fworks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 52a9d9b4..835668d5 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -442,7 +442,7 @@ def __init__(self, structure, supercell_matrix, t_min=5, t_max=2000, t_step=5, else: # write the input set first, just to get the POSCAR file in the directory # the other inputs will get overridden by WriteVaspFromIOSetPrevStructure - t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=supercell_site_properties)) + t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=structure.site_properties)) t.append(SupercellTransformation(supercell_matrix=supercell_matrix)) t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=supercell_site_properties)) From a7d76f1ac45f999621d415b899de4adcae035986 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 14:43:15 -0400 Subject: [PATCH 014/111] updates --- dfttk/EVcheck_QHA.py | 401 +++++++++++++++++++++++++++++++++++++ dfttk/ftasks.py | 45 +++-- dfttk/fworks.py | 12 +- dfttk/scripts/run_dfttk.py | 10 +- dfttk/wflows.py | 141 +++++++++---- 5 files changed, 537 insertions(+), 72 deletions(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 578b3fa5..20ae67cd 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -580,6 +580,407 @@ def check_fit(self, volumes, energies): self.eos_fit = eos.fit(volumes, energies) +@explicit_serialize +class Crosscom_EVcheck_QHA(FiretaskBase): + ''' + If EVcheck(Energies versus Volumes) meets the tolerance, it will launch QHA; + otherwise it will append more volumes to VASP calculation and take EVcheck again. + The maximum appending VASP running times set by run_num; + + Important Properties: + correct: whether result satisfies the tolerance + points: the selected data index + error: actual fitting error + eos_fit: eos fitting + + required_params + None - but you must specify structure or ensure the structure exists in fw_spec(e.g. run the CheckRelaxScheme) + optional_paramms + structure + ''' + _fw_name = 'EVcheck' + required_params = [] + optional_params = ['tag', 'metadata', 'deformations', 'eos_tolerance', 'threshold', + 'del_limited', 'vol_spacing', 't_min', 't_max', 't_step', + 'verbose', 'modify_incar_params', 'run_num','modify_kpoints_params', + 'override_default_vasp_params', 'db_file', 'vasp_cmd', + 'force_phonon', 'stable_tor', 'store_volumetric_data','a_kwargs', 'test'] + + def run_task(self, fw_spec): + ''' + run_num: maximum number of appending VASP running; this limitation is to avoid always running due to bad settings; + only for internal usage; + + Important args: + eos_tolerance: acceptable value for average RMS, recommend >= 0.005; + threshold: total point number above the value should be reduced, recommend < 16 or much time to run; + del_limited: maximum deletion ration for large results; + vol_spacing: the maximum ratio step between two volumes, larger step will be inserted points to calculate; + ''' + # Get the parameters from the object + max_run = 10 + db_file = env_chk(self.get('db_file', DB_FILE), fw_spec) #always concrete db_fiel + vasp_cmd = ">>vasp_cmd<<" #chould change for user to provide the change + deformations = self.get('deformations', []) + run_num = self.get('run_num', 0) + eos_tolerance = self.get('eos_tolerance', 0.005) + threshold = self.get('threshold', 14) + del_limited = self.get('del_limited', 0.3) + vol_spacing = self.get('vol_spacing', 0.05) + t_min = self.get('t_min', 5) + t_max = self.get('t_max', 2000) + t_step = self.get('t_step', 5) + phonon = self.get('phonon', False) + force_phonon = self.get('force_phonon', False) + phonon_supercell_matrix = self.get('phonon_supercell_matrix', None) + verbose = self.get('verbose', False) + modify_kpoints_params = self.get('modify_kpoints_params', {}) + site_properties = self.get('site_properties', None) + + modify_incar_params = self.get('modify_incar_params', {}) + powerups_options=modify_incar_params.get('powerups', None) + + override_default_vasp_params = self.get('override_default_vasp_params', {}) + user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) + powerups_options=user_incar_settings.get('powerups', powerups_options) + + override_symmetry_tolerances = self.get('override_symmetry_tolerances', {}) + store_volumetric_data = self.get('store_volumetric_data', False) + + stable_tor = self.get('stable_tor', 0.01) + force_phonon = self.get('force_phonon', False) + test = self.get('test', False) + + relax_structure = self.get('structure') or fw_spec.get('structure', None) + relax_scheme = self.get('relax_scheme') or fw_spec.get('relax_scheme', [2]) + relax_phonon = fw_spec.get('relax_phonon', False) + + #Only set phonon=True and ISIF=4 passed, then run phonon + if not force_phonon: + phonon = phonon and relax_phonon + + metadata = self.get('metadata', {}) + tag = self.get('tag', metadata.get('tag', None)) + if tag is None: + tag = str(uuid4()) + metadata['tag'] = tag + + common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': self.get('db_file', DB_FILE), "metadata": metadata, "tag": tag, + 'override_default_vasp_params': override_default_vasp_params,} + vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} + t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + eos_kwargs = {'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} + + run_num += 1 + + #Some initial checks + #TODO: add phonon after RobustOptimizeFW + if phonon: + #To check if the consistent of phonon and optimize + if not consistent_check_db(db_file, tag): + print('Please check DB, DFTTK running ended!') + return + + if relax_structure is not None: + structure = deepcopy(relax_structure) + else: + raise ValueError('Not structure in spec, please provide structure as input') + + if site_properties: + for pkey in site_properties: + structure.add_site_property(pkey, site_properties[pkey]) + # get original EV curve + volumes, energies, dos_objs = self.get_orig_EV(db_file, tag) + vol_adds = check_deformations_in_volumes(deformations, volumes, structure.volume) + if (len(vol_adds)) == 0: + self.check_points(db_file, metadata, eos_tolerance, threshold, del_limited, volumes, energies, verbose) + else: + self.correct = True + self.error = 1e10 + + EVcheck_result = init_evcheck_result(append_run_num=run_num, correct=self.correct, volumes=volumes, + energies=energies, eos_tolerance=eos_tolerance, threshold=threshold, vol_spacing=vol_spacing, + error=self.error, metadata=metadata) + + if self.correct: + vol_orig = structure.volume + if (len(vol_adds)) == 0: + volume, energy, dos_obj = gen_volenergdos(self.points, volumes, energies, dos_objs) + vol_adds = self.check_vol_coverage(volume, vol_spacing, vol_orig, run_num, + energy, structure, dos_obj, phonon, + db_file, tag, t_min, t_max, t_step, + EVcheck_result) # Normalized to 1 + EVcheck_result['selected'] = volume + EVcheck_result['append'] = (vol_adds).tolist() + # Marked as adopted in db + mark_adopted(tag, db_file, volume, phonon=phonon) + lpad = LaunchPad.auto_load() + fws = [] + if len(vol_adds) > 0: # VASP calculations need to append + if run_num < max_run: + # Do VASP and check again + print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) + calcs = [] + #vis_relax = RelaxSet(structure) + #vis_static = StaticSet(structure) + #isif2 = 5 if 'infdet' in relax_path else 4 + for vol_add in vol_adds: + struct = deepcopy(structure) + struct.scale_lattice(structure.volume * vol_add) + + relax_Crosscom_EVcheck_QHA_fw = None + for isif_i in relax_scheme: + #record_path=record_path + relax_fw = OptimizeFW(struct, isif=isif_i, store_volumetric_data=store_volumetric_data, + name="relax_Vol{:.3f}".format(vol_add), vasp_input_set=None, job_type="normal", + override_symmetry_tolerances=override_symmetry_tolerances, + prev_calc_loc=True, Crosscom_EVcheck_QHA=relax_Crosscom_EVcheck_QHA_fw, db_insert=False, force_gamma=True, + modify_incar={}, **vasp_kwargs, **common_kwargs) + relax_parents_fw = deepcopy(relax_fw) + fws.append(relax_fw) + calcs.append(relax_fw) + + static_fw = StaticFW(struct, isif=relax_scheme[-1], name='static_Vol{:.3f}'.format(vol_add), + vasp_input_set=None, prev_calc_loc=True, parents=relax_parents_fw, + store_volumetric_data=store_volumetric_data, + **common_kwargs) + fws.append(static_fw) + calcs.append(static_fw) + + if phonon: + #visphonon = ForceConstantsSet(struct) + phonon_fw = PhononFW(struct, phonon_supercell_matrix, vasp_input_set=None, stable_tor=stable_tor, + name='structure_{:.3f}-phonon'.format(vol_add), prev_calc_loc=True, + parents=static_fw, **t_kwargs, **common_kwargs) + fws.append(phonon_fw) + calcs.append(phonon_fw) + check_result = Firework(EVcheck_QHA(structure=relax_structure, relax_scheme=relax_scheme, store_volumetric_data=store_volumetric_data, + run_num=run_num, verbose=verbose, site_properties=site_properties, stable_tor=stable_tor, + phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, force_phonon=force_phonon, + **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), + parents=calcs, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) + fws.append(check_result) + strname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_Append') + wfs = Workflow(fws, name = strname, metadata=metadata) + + if modify_incar_params != {}: + from dfttk.utils import add_modify_incar_by_FWname + add_modify_incar_by_FWname(wfs, modify_incar_params = modify_incar_params) + if modify_kpoints_params != {}: + from dfttk.utils import add_modify_kpoints_by_FWname + add_modify_kpoints_by_FWname(wfs, modify_kpoints_params = modify_kpoints_params) + wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + if not test: lpad.add_wf(wfs) + else: + too_many_run_error() + else: # No need to do more VASP calculation, QHA could be running + print('Success in Volumes-Energies checking, enter QHA ...') + debye_fw = Firework(QHAAnalysis(phonon=phonon, t_min=t_min, t_max=t_max, t_step=t_step, db_file=self.get('db_file', DB_FILE), tag=tag, metadata=metadata), + name="{}-qha_analysis".format(structure.composition.reduced_formula)) + fws.append(debye_fw) + ''' + # Debye + debye_fw = Firework(QHAAnalysis(phonon=False, t_min=t_min, t_max=t_max, t_step=t_step, db_file=db_file, tag=tag, metadata=metadata), + name="{}-qha_analysis-Debye".format(structure.composition.reduced_formula)) + fws.append(debye_fw) + if phonon: + phonon_supercell_matrix = self.get('phonon_supercell_matrix') + # do a Debye run Staticore the phonon, so they can be done in stages. + phonon_fw = Firework(QHAAnalysis(phonon=True, t_min=t_min, t_max=t_max, t_step=t_step, db_file=db_file, tag=tag, + metadata=metadata), parents=debye_fw, name="{}-qha_analysis-phonon".format(structure.composition.reduced_formula)) + fws.append(phonon_fw) + ''' + strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') + wfs = Workflow(fws, name = strname, metadata=metadata) + wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + if not test: lpad.add_wf(wfs) + else: # failure to meet the tolerance + if len(volumes) == 0: #self.error == 1e10: # Bad initial running set + pass_result_error() + else: # fitting fails + tol_error() + import json + with open('EV_check_summary.json', 'w') as fp: + json.dump(EVcheck_result, fp, indent=4) + + def get_orig_EV(self, db_file, tag): + vasp_db = VaspCalcDb.from_db_file(db_file=db_file, admin = True) + volumes, energies, dos_objs, _ \ + = get_static_calculations(vasp_db, tag) + print('%s Volumes = %s' %(len(volumes), volumes)) + print('%s Energies = %s' %(len(energies), energies)) + return(list(volumes), list(energies), dos_objs) + + def check_points(self, db_file, metadata, eos_tolerance, threshold, del_limited, volumes, energies, verbose = False): + """ + Check the existing points if they reached the tolerance, + if reached, update self.correct as True + if not, reduce the point to 4 + """ + self.correct = False + self.error = 1e11 + error = 1e10 + num = np.arange(len(volumes)) + comb = num + limit = len(volumes) * del_limited + + # For len(num) > threshold case, do a whole number fitting to pass numbers delete if met tolerance + for i in range(1): # To avoid the codes after except running, ? + if (len(num) > threshold): + try: + self.check_fit(volumes, energies) + except: + if verbose: + print('Fitting error in: ', comb, '. If you can not achieve QHA result, try to run far negative deformations.') + break + temperror = eosfit_stderr(self.eos_fit, volumes, energies) + error = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb) + + # Decrease the quantity of large results + while (error > eos_tolerance) and (len(num) > limit) and (len(num) > threshold): + volume, energy = gen_volenergdos(num, volumes, energies) + try: + self.check_fit(volume, energy) + except: + if verbose: + print('Fetal error in Fitting : ', num) # Seldom + break + fit_value = self.eos_fit.func(volume) + errors = abs(fit_value - energy) + num = sort_x_by_y(num, errors) + errors = sorted(errors) + for m in range(min(len(errors) - threshold, 1)): + errors.pop(-1) + num.pop(-1) + temperror = cal_stderr(errors) + error, comb = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb, temp_ind=num) + + # combinations + len_comb = len(comb) + if (error > eos_tolerance) and (len_comb <= threshold): + comb_source = comb + while (error > eos_tolerance) and (len_comb >= 4): + print('Combinations in "%s"...' %len_comb) + combination = combinations(comb_source, len_comb) + for combs in combination: + print(volumes) + print(energies) + volume, energy = gen_volenergdos(combs, volumes, energies) + try: + self.check_fit(volume, energy) + except: + if verbose: + print('Fitting error in: ', combs, '. If you can not achieve QHA result, try to run far negative deformations.') + continue + temperror = eosfit_stderr(self.eos_fit, volume, energy) + error, comb = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb, temp_ind=combs) + len_comb -= 1 + + print('Minimum error = %s' %error, comb) + if error <= eos_tolerance: + self.correct = True + comb = list(comb) + comb.sort() + self.points = comb + self.error = error + + def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, structure, + dos_objects, phonon, db_file, tag, t_min, t_max, t_step, EVcheck_result): + result = [] + volumer = volume.copy() + + # Check minimum spacing + volumer = [vol_i / vol_orig for vol_i in volumer] + """ + decimals = 4 + for m in range(len(volumer) - 1): + vol_space_m = volumer[m + 1] - volumer[m] + if np.around(vol_space_m, decimals) > np.around(vol_spacing, decimals): + vol = np.linspace(volumer[m], volumer[m + 1], math.ceil(vol_space_m / vol_spacing) + 1).tolist() + print('Additional volume({}) is appended for the volume space({}) is larger than specified({})'.format(vol[1:-1], vol_space_m, vol_spacing)) + result.append(vol[1:-1]) + #result.extend(vol[1:-1]) + """ + + # To check (and extend) deformation coverage + # To make sure that coverage extension smaller than interpolation spacing + vol_spacing = vol_spacing * 0.98 + + qha = Quasiharmonic(energy, volume, structure, dos_objects=dos_objects, F_vib=None, + t_min=t_min, t_max=t_max, t_step=t_step, poisson=0.363615, bp2gru=2./3.) + vol_max = np.nanmax(qha.optimum_volumes) + vol_min = np.nanmin(qha.optimum_volumes) + EVcheck_result['debye'] = qha.get_summary_dict() + EVcheck_result['debye']['temperatures'] = EVcheck_result['debye']['temperatures'].tolist() + if phonon: + # get the vibrational properties from the FW spec + # TODO: add a stable check in Quasiharmonic + vasp_db = VaspCalcDb.from_db_file(db_file = db_file, admin=True) + phonon_calculations = list(vasp_db.db['phonon'].find({'$and':[ {'metadata.tag': tag}, {'adopted': True} ]})) + #vol_vol = [calc['volume'] for calc in phonon_calculations] # these are just used for sorting and will be thrown away + #vol_f_vib = [calc['F_vib'] for calc in phonon_calculations] + vol_vol = [] + vol_f_vib = [] + for calc in phonon_calculations: + if calc['volume'] in vol_vol: continue + if calc['volume'] not in volume: continue + vol_vol.append(calc['volume']) + vol_f_vib.append(calc['F_vib']) + # sort them order of the unit cell volumes + vol_f_vib = sort_x_by_y(vol_f_vib, vol_vol) + f_vib = np.vstack(vol_f_vib) + qha_phonon = Quasiharmonic(energy, volume, structure, dos_objects=dos_objects, F_vib=f_vib, + t_min=t_min, t_max=t_max, t_step=t_step, poisson=0.363615, bp2gru=2./3.) + vol_max = max(np.nanmax(qha_phonon.optimum_volumes), vol_max) + vol_min = min(np.nanmax(qha_phonon.optimum_volumes), vol_min) + EVcheck_result['phonon'] = qha_phonon.get_summary_dict() + EVcheck_result['phonon']['temperatures'] = EVcheck_result['phonon']['temperatures'].tolist() + EVcheck_result['MIN_volume_Evaluated'] = '%.3f' %vol_min + EVcheck_result['MAX_volume_Evaluated'] = '%.3f' %vol_max + print('Evaluated MIN volume is %.3f;' %vol_min) + print('Evaluated MAX volume is %.3f;' %vol_max) + + """ + vol_max = vol_max / vol_orig + vol_min = vol_min / vol_orig + counter = 1 + # Using max_append for reducing unnecessary calculations because of rough fitting + max_append = 1 if phonon else 2 + # Over coverage ratio set to 1.01 as following + if volumer[-1] * 1.01 < vol_max: + print('The current maximum volume is smaller than maximum volume evaluated by quasiharmonic analysis') + result.append(volumer[-1] + vol_spacing) + # counter is set to limit calculation times when exception occurs + while (counter < max_append) and (result[-1] < vol_max): + result.append(result[-1] + vol_spacing) + counter += 1 + counter = 1 + if volumer[0] * 0.99 > vol_min: + print('The current minimum volume is larger than minimum volume evaluated by quasiharmonic analysis') + result.append(volumer[0] - vol_spacing) + while (counter < max_append) and (result[-1] > vol_min): + result.append(result[-1] - vol_spacing) + counter += 1 + """ + val, idx = min((val, idx) for (idx, val) in enumerate(energy)) + nV = len(energy) + nV_addL = 3 + if nV_addL - idx > 0: + vol_spacing = volumer[1] - volumer[0] + for i in range(nV_addL-idx): + result.append(volumer[0] - (nV_addL-idx-i)*vol_spacing) + nV_addR = 4 + if idx+1+nV_addR - nV > 0: + vol_spacing = volumer[-1] - volumer[-2] + for i in range(idx+1+nV_addR-nV): + result.append(volumer[-1] + (i+1)*vol_spacing) + return(np.array(result)) + + def check_fit(self, volumes, energies): + eos = EOS('vinet') + self.eos_fit = eos.fit(volumes, energies) + + @explicit_serialize class PreEV_check(FiretaskBase): ''' diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index b513d61c..fd7db269 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -741,64 +741,66 @@ def run_task(self, fw_spec): @explicit_serialize -class AppendCalculation(FiretaskBase): +class Crosscom_Calculation(FiretaskBase): """Continue Static/Phonon calculations """ required_params = [] - optional_params = ['db_file', 'vasp_cmd', - 'parents', 'db_insert', 'tag', 'metadata', 'name', 'vasp_input_set', + optional_params = ['db_file', 'vasp_cmd', 'a_kwargs', + 'db_insert', 'tag', 'metadata', 'name', 'vasp_input_set', 'phonon', 'phonon_supercell_matrix', 't_min', 't_max', 't_step', - 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'site_properties', + 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'override_default_vasp_params', 'store_volumetric_data', 'settings', 'static'] def run_task(self, fw_spec): db_file = self.get('db_file') or DB_FILE vasp_cmd = self.get('vasp_cmd') or VASP_CMD - parents = self.get('parents', None) db_insert = self.get('db_insert', None) tag = self.get('tag') metadata = self.get('metadata') - name = self.get('name', "AppendCalculation") - phonon = self.get('phonon', False) - phonon_supercell_matrix = self.get('phonon_supercell_matrix', None) + name = self.get('name', "Crosscom_Calculation") t_min = self.get('t_min') t_max = self.get('t_max', None) t_step = self.get('t_step', None) modify_incar_params = self.get('modify_incar_params', None) modify_kpoints_params = self.get('modify_kpoints_params', None) - site_properties = self.get('site_properties', None) override_default_vasp_params = self.get('override_default_vasp_params', None) store_volumetric_data = self.get('store_volumetric_data', False) settings = self.get('settings', None) + return FWAction(detours=self.get_detour_workflow( - db_file, vasp_cmd, parents, db_insert, tag, metadata, name, - phonon, phonon_supercell_matrix, t_min, t_max, t_step, + db_file, vasp_cmd, db_insert, tag, metadata, name, + t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, site_properties, - override_default_vasp_params, - store_volumetric_data, settings - )) + override_default_vasp_params, + store_volumetric_data, settings, a_kwargs=a_kwargs) + ) def get_detour_workflow(self, - db_file, vasp_cmd, parents, db_insert, tag, metadata, name, - phonon, phonon_supercell_matrix, t_min, t_max, t_step, + db_file, vasp_cmd, db_insert, tag, metadata, name, + t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, site_properties, override_default_vasp_params, - store_volumetric_data, settings): + store_volumetric_data, settings, a_kwargs=None): from fireworks import Workflow from .fworks import PhononFW, StaticFW + phonon = settings.get('phonon', False) + phonon_supercell_matrix = a_kwargs.get('phonon_supercell_matrix', None) + structure=a_kwargs.get('structure', None) + site_properties = structure.site_properties + detour_fws = [] inp_structure = Structure.from_file('CONTCAR') if len(site_properties)>0: for prop, vals in site_properties.items(): inp_structure.add_site_property(prop, vals) - detour_fws.append(StaticFW(inp_structure, name="cloud-static", + detour_fws.append(StaticFW(inp_structure, name="crosscom-static", vasp_cmd=vasp_cmd, metadata=metadata, prev_calc_loc=False, modify_incar=modify_incar_params, - db_file=db_file, parents=parents, tag=tag, + db_file=db_file, tag=tag, override_default_vasp_params=override_default_vasp_params, store_volumetric_data=store_volumetric_data)) @@ -808,10 +810,9 @@ def get_detour_workflow(self, 'override_default_vasp_params': override_default_vasp_params} detour_fws.append(PhononFW(inp_structure, phonon_supercell_matrix, vasp_input_set=None, - name='cloud-phonon', prev_calc_loc=False, - parents=parents, **t_kwargs, **common_kwargs)) + name='crosscom-phonon', prev_calc_loc=False, + **t_kwargs, **common_kwargs)) - override_default_vasp_params = self.get('override_default_vasp_params',{}) user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 835668d5..8a2baa8e 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -14,7 +14,7 @@ from dfttk.ftasks import WriteVaspFromIOSetPrevStructure, SupercellTransformation, CalculatePhononThermalProperties, \ CheckSymmetry, CheckRelaxation, ScaleVolumeTransformation, TransmuteStructureFile, WriteATATFromIOSet, RunATATCustodian, RunVaspCustodianNoValidate, \ Record_relax_running_path, Record_PreStatic_result, CheckSymmetryToDb, PhononStable, BornChargeToDb, \ - AppendCalculation + Crosscom_Calculation from atomate import __version__ as atomate_ver from dfttk import __version__ as dfttk_ver from dfttk.run_task_ext import run_task_ext @@ -109,12 +109,12 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole t.append(VaspToDb(db_file=">>db_file<<", additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data)) t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) if a_kwargs.get("static", False): - t.append(AppendCalculation( - name="could-AppendCalculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, - metadata=metadata, site_properties=site_properties, - parents=parents, db_insert=db_insert, tag=tag, + t.append(Crosscom_Calculation( + name="Crosscom_Calculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, + metadata=metadata, + db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, - modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, **a_kwargs, **kwargs)) + modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, a_kwargs=a_kwargs, **kwargs)) super(OptimizeFW, self).__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs) diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index 8fd0529d..820e8735 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -3,7 +3,7 @@ import argparse from pymatgen.ext.matproj import MPRester, Structure from pymatgen.io.vasp.inputs import Potcar, Incar -from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_singleV, get_wf_cloud, \ +from dfttk.wflows import get_wf_gibbs, get_wf_EV_bjb, get_wf_singleV, get_wf_crosscom, \ get_wf_gibbs_robust, get_wf_borncharge, get_wf_elastic from dfttk.utils import recursive_glob from dfttk.structure_builders.parse_anrl_prototype import multi_replace @@ -312,12 +312,8 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) elif WORKFLOW == "singleV": wf = get_wf_singleV(structure, store_volumetric_data=store_volumetric_data, metadata=metadata, override_default_vasp_params=override_default_vasp_params, settings=settings) - elif WORKFLOW == "cloud": - wf = get_wf_cloud(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, - phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, - metadata=metadata, name='EV_QHA_cloud', - override_default_vasp_params=override_default_vasp_params, - store_volumetric_data=store_volumetric_data, settings=settings) + elif WORKFLOW == "crosscom": + wf = get_wf_crosscom(structure, metadata=metadata, settings=settings) elif WORKFLOW == "robust" or WORKFLOW == "get_wf_gibbs": wf = get_wf_gibbs_robust(structure, num_deformations=num_deformations, deformation_fraction=deformation_fraction, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, t_min=t_min, t_max=t_max, t_step=t_step, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index a2f9d23c..27fe42b7 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -16,7 +16,7 @@ from dfttk.fworks import OptimizeFW, StaticFW, PhononFW, RobustOptimizeFW, BornChargeFW from dfttk.ftasks import CheckRelaxScheme from dfttk.input_sets import PreStaticSet, RelaxSet, ForceConstantsSet, ElasticSet -from dfttk.EVcheck_QHA import EVcheck_QHA, PreEV_check +from dfttk.EVcheck_QHA import EVcheck_QHA, Crosscom_EVcheck_QHA, PreEV_check from dfttk.utils import check_relax_path, add_modify_incar_by_FWname, add_modify_kpoints_by_FWname, supercell_scaling_by_atom_lat_vol from dfttk.scripts.querydb import is_property_exist_in_db, get_eq_structure_by_metadata #from atomate.vasp.workflows.base.elastic import get_wf_elastic_constant @@ -194,24 +194,74 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri return wf -def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.15), phonon=False, isif4=False, - phonon_supercell_matrix=None, t_min=5, t_max=2000, - t_step=5, vasp_cmd=None, db_file=None, - metadata=None, name='EV_QHA_cloud', store_volumetric_data=False, override_default_vasp_params=None, settings=None): +def get_wf_crosscom(structure, metadata=None, settings=None, + new_num_deformations=None, new_deformation_fraction=None): """ - Perform cloud QHA calculation without computer dependent. + Perform cross computer QHA calculation without computer dependent. Parameters ---------- structure : pymatgen.Structure """ - vasp_cmd = vasp_cmd or VASP_CMD - db_file = db_file or DB_FILE - metadata = metadata or {} + ################ PARAMETERS FOR WF ############################# + #str, the absolute path of db.json file, e.g. /storage/home/mjl6505/atomate/config/db.json + # If None, it will use the configuration in fireworks + db_file = settings.get('db_file', DB_FILE) + #str, the vasp command, if None then find in the FWorker configuration + vasp_cmd = settings.get('vasp_cmd', VASP_CMD) + #dict, metadata to be included, this parameter is useful for filter the data, e.g. metadata={"phase": "BCC_A2", "tag": "AFM"} + metadata = settings.get('metadata', None) tag = metadata.get('tag', '{}'.format(str(uuid4()))) metadata.update({'tag': tag}) - t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + #int, the number of initial deformations, e.g. 7 + num_deformations = settings.get('num_deformations', 8) + #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume + deformation_fraction = settings.get('deformation_fraction', (-0.15, 0.20)) + + #bool, run phonon(True) or not(False) + phonon = settings.get('phonon', False) + #list(3x3), the supercell matrix for phonon, e.g. [[2.0, 0, 0], [0, 2.0, 0], [0, 0, 2.0]] + phonon_supercell_matrix = settings.get('phonon_supercell_matrix', None) + phonon_supercell_matrix_min = settings.get('phonon_supercell_matrix_min', None) + phonon_supercell_matrix_max = settings.get('phonon_supercell_matrix_max', None) + optimize_sc = settings.get('optimize_sc', False) + #run phonon always, no matter ISIF=4 passed or not + force_phonon = settings.get('force_phonon', False) + #The tolerance for phonon stable + stable_tor = settings.get('stable_tor', 0.01) + #float, the mimimum of temperature in QHA process, e.g. 5 + t_min = settings.get('t_min', 5) + #float, the maximum of temperature in QHA process, e.g. 2000 + t_max = settings.get('t_max', 2000) + #float, the step of temperature in QHA process, e.g. 5 + t_step = settings.get('t_step', 5) + #float, acceptable value for average RMS, recommend >= 0.005 + eos_tolerance = settings.get('eos_tolerance', 0.01) + + #Global settings for all vasp job, e.g. + #override_default_vasp_params = {'user_incar_settings': {}, 'user_kpoints_settings': {}, 'user_potcar_functional': str} + #If some value in 'user_incar_settings' is set to None, it will use vasp's default value + override_default_vasp_params = settings.get('override_default_vasp_params', {}) + + #dict, dict of class ModifyIncar with keywords in Workflow name. e.g. + modify_incar_params = settings.get('modify_incar_params', {}) + + #check if fworker_name is assigned + powerups = settings.get('powerups', {}) + if len(powerups)>0: + if 'user_incar_settings' not in override_default_vasp_params: + override_default_vasp_params.update({'user_incar_settings':{}}) + override_default_vasp_params['user_incar_settings'].update({'powerups':powerups}) + modify_incar_params.update({'powerups':powerups}) + + #dict, dict of class ModifyKpoints with keywords in Workflow name, similar with modify_incar_params + modify_kpoints_params = settings.get('modify_kpoints_params', {}) + #bool, print(True) or not(False) some informations, used for debug + verbose = settings.get('verbose', False) + #Save the volume data or not ("chgcar", "aeccar0", "aeccar2", "elfcar", "locpot") + store_volumetric_data = settings.get('store_volumetric_data', False) + if phonon: if isinstance(phonon_supercell_matrix, str): @@ -223,17 +273,19 @@ def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.1 max_obj=phonon_supercell_matrix_max, scale_object=phonon_supercell_matrix, target_shape='sc', lower_search_limit=-2, upper_search_limit=2, verbose=verbose, sc_tolerance=1e-5, optimize_sc=optimize_sc) - common_kwargs = {"metadata": metadata, "tag":tag} - a_kwargs = { - 'override_default_vasp_params': override_default_vasp_params, - "static": True, "phonon":phonon, - "phonon_supercell_matrix":phonon_supercell_matrix} - num_deformations = num_deformations or 1 - #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume - deformation_fraction = deformation_fraction or (-0.0, +0.0) + _deformations = _get_deformations(deformation_fraction, num_deformations) + if num_deformations > 1: vol_spacing = _deformations[1]-_deformations[0] + else: vol_spacing=0.05 + + if new_deformation_fraction is None: + new_deformation_fraction = copy.deepcopy(deformation_fraction) + new_num_deformations = num_deformations + deformation_scheme = settings.get('deformation_scheme', 'volume') - + single_volume = settings.get('single_volume', False) + + isif = settings.get('run_isif', None) if not isif: isif=3 @@ -241,62 +293,77 @@ def get_wf_cloud(structure, num_deformations=7, deformation_fraction=(-0.15, 0.1 if deformation_scheme=='volume': isif = 4 else: isif = 2 + t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, + 'override_default_vasp_params': override_default_vasp_params} + vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} + eos_kwargs = {'deformations': _deformations, 'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} + a_kwargs = {"structure":structure, "settings":settings, "eos_kwargs":eos_kwargs, + "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} + if deformation_scheme=='volume': - dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 1./3.) - 1.0 axisa=True axisb=True axisc=True elif deformation_scheme=='a': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = new_deformation_fraction + dmax = new_deformation_fraction axisa=True axisb=False axisc=False elif deformation_scheme=='b': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = new_deformation_fraction + dmax = new_deformation_fraction axisa=False axisb=True axisc=False elif deformation_scheme=='c': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = new_deformation_fraction + dmax = new_deformation_fraction axisa=False axisb=False axisc=True elif deformation_scheme=='bc' or deformation_scheme=='cb': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 axisa=False axisb=True axisc=True elif deformation_scheme=='ca' or deformation_scheme=='ac': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 axisa=True axisb=False axisc=True elif deformation_scheme=='ab' or deformation_scheme=='ba': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 axisa=True axisb=True axisc=False - deformations = _get_deformations((dmin,dmax), num_deformations) + deformations = _get_deformations((dmin,dmax), new_num_deformations) + fws = [] for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) - full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, + full_relax_fw = OptimizeFW(struct, isif=isif, name='Structure_relax_with_ISIF='+str(isif), store_volumetric_data=store_volumetric_data, t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs) fws.append(full_relax_fw) - - wfname = "{}:{}".format(structure.composition.reduced_formula, name) + if not single_volume: + check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, + store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, + **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), + parents=fws, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) + fws.append(check_qha_fw) + + wfname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_crosscom') wf = Workflow(fws, name=wfname, metadata=metadata) return wf From 36740e26bc9c71dae2a4fd8443dd46ceffe8fec5 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 15:45:54 -0400 Subject: [PATCH 015/111] Update ftasks.py --- dfttk/ftasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index fd7db269..06799c15 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -773,7 +773,7 @@ def run_task(self, fw_spec): return FWAction(detours=self.get_detour_workflow( db_file, vasp_cmd, db_insert, tag, metadata, name, t_min, t_max, t_step, - modify_incar_params, modify_kpoints_params, site_properties, + modify_incar_params, modify_kpoints_params, override_default_vasp_params, store_volumetric_data, settings, a_kwargs=a_kwargs) ) @@ -781,7 +781,7 @@ def run_task(self, fw_spec): def get_detour_workflow(self, db_file, vasp_cmd, db_insert, tag, metadata, name, t_min, t_max, t_step, - modify_incar_params, modify_kpoints_params, site_properties, + modify_incar_params, modify_kpoints_params, override_default_vasp_params, store_volumetric_data, settings, a_kwargs=None): from fireworks import Workflow From 9cb3ee26fecd9791680eaffa7e048fe94aeb7a36 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 15:55:57 -0400 Subject: [PATCH 016/111] Update wflows.py --- dfttk/wflows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 27fe42b7..627dd025 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -210,7 +210,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, #str, the vasp command, if None then find in the FWorker configuration vasp_cmd = settings.get('vasp_cmd', VASP_CMD) #dict, metadata to be included, this parameter is useful for filter the data, e.g. metadata={"phase": "BCC_A2", "tag": "AFM"} - metadata = settings.get('metadata', None) + metadata = metadata or {} tag = metadata.get('tag', '{}'.format(str(uuid4()))) metadata.update({'tag': tag}) From fc13f7264d8e3bf425e2e8acd977b471bc58dac8 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 18:33:07 -0400 Subject: [PATCH 017/111] updates --- dfttk/ftasks.py | 9 ++++++--- dfttk/wflows.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 06799c15..ba82af52 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -768,7 +768,7 @@ def run_task(self, fw_spec): override_default_vasp_params = self.get('override_default_vasp_params', None) store_volumetric_data = self.get('store_volumetric_data', False) settings = self.get('settings', None) - + a_kwargs = self.get('a_kwargs', None) return FWAction(detours=self.get_detour_workflow( db_file, vasp_cmd, db_insert, tag, metadata, name, @@ -786,8 +786,11 @@ def get_detour_workflow(self, store_volumetric_data, settings, a_kwargs=None): from fireworks import Workflow from .fworks import PhononFW, StaticFW + settings = settings or {} + stable_tor = settings.get('stable_tor', 0.01) phonon = settings.get('phonon', False) + a_kwargs = a_kwargs or {} phonon_supercell_matrix = a_kwargs.get('phonon_supercell_matrix', None) structure=a_kwargs.get('structure', None) site_properties = structure.site_properties @@ -809,10 +812,10 @@ def get_detour_workflow(self, common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, 'override_default_vasp_params': override_default_vasp_params} detour_fws.append(PhononFW(inp_structure, phonon_supercell_matrix, - vasp_input_set=None, - name='crosscom-phonon', prev_calc_loc=False, + name='crosscom-phonon', prev_calc_loc=False, stable_tor=stable_tor, **t_kwargs, **common_kwargs)) + override_default_vasp_params = override_default_vasp_params or {} user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 627dd025..3168a958 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -360,7 +360,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), - parents=fws, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) + parents=fws, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) fws.append(check_qha_fw) wfname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_crosscom') From 1489cc3e0647f8f3eebeb86006673b79acee9c76 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 20:32:49 -0400 Subject: [PATCH 018/111] update --- dfttk/ftasks.py | 21 ++++++++++----------- dfttk/wflows.py | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index ba82af52..c15cadec 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -751,7 +751,7 @@ class Crosscom_Calculation(FiretaskBase): 'phonon', 'phonon_supercell_matrix', 't_min', 't_max', 't_step', 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'override_default_vasp_params', - 'store_volumetric_data', 'settings', 'static'] + 'store_volumetric_data', 'static'] def run_task(self, fw_spec): db_file = self.get('db_file') or DB_FILE @@ -760,22 +760,21 @@ def run_task(self, fw_spec): tag = self.get('tag') metadata = self.get('metadata') name = self.get('name', "Crosscom_Calculation") - t_min = self.get('t_min') + t_min = self.get('t_min', None) t_max = self.get('t_max', None) t_step = self.get('t_step', None) - modify_incar_params = self.get('modify_incar_params', None) - modify_kpoints_params = self.get('modify_kpoints_params', None) - override_default_vasp_params = self.get('override_default_vasp_params', None) + modify_incar_params = self.get('modify_incar_params', {}}) + modify_kpoints_params = self.get('modify_kpoints_params', {}) + override_default_vasp_params = self.get('override_default_vasp_params', {}) store_volumetric_data = self.get('store_volumetric_data', False) - settings = self.get('settings', None) - a_kwargs = self.get('a_kwargs', None) + a_kwargs = self.get('a_kwargs', {}) return FWAction(detours=self.get_detour_workflow( db_file, vasp_cmd, db_insert, tag, metadata, name, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, settings, a_kwargs=a_kwargs) + store_volumetric_data, a_kwargs=a_kwargs) ) def get_detour_workflow(self, @@ -783,14 +782,14 @@ def get_detour_workflow(self, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, settings, a_kwargs=None): + store_volumetric_data, a_kwargs=None): from fireworks import Workflow from .fworks import PhononFW, StaticFW - settings = settings or {} + a_kwargs = a_kwargs or {} + settings = a_kwargs.get('settings', {}) stable_tor = settings.get('stable_tor', 0.01) phonon = settings.get('phonon', False) - a_kwargs = a_kwargs or {} phonon_supercell_matrix = a_kwargs.get('phonon_supercell_matrix', None) structure=a_kwargs.get('structure', None) site_properties = structure.site_properties diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 3168a958..34dab8da 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -219,6 +219,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume deformation_fraction = settings.get('deformation_fraction', (-0.15, 0.20)) + settings = settings or {} #bool, run phonon(True) or not(False) phonon = settings.get('phonon', False) #list(3x3), the supercell matrix for phonon, e.g. [[2.0, 0, 0], [0, 2.0, 0], [0, 0, 2.0]] From 5a1fe2ad9138a67bca10381cb11d6672879d085d Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 12 Oct 2021 20:34:58 -0400 Subject: [PATCH 019/111] Update ftasks.py --- dfttk/ftasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index c15cadec..89d0d8d1 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -763,7 +763,7 @@ def run_task(self, fw_spec): t_min = self.get('t_min', None) t_max = self.get('t_max', None) t_step = self.get('t_step', None) - modify_incar_params = self.get('modify_incar_params', {}}) + modify_incar_params = self.get('modify_incar_params', {}) modify_kpoints_params = self.get('modify_kpoints_params', {}) override_default_vasp_params = self.get('override_default_vasp_params', {}) store_volumetric_data = self.get('store_volumetric_data', False) From e91684818437610f2b5139e187c2db89b75c2b49 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 10:00:02 -0400 Subject: [PATCH 020/111] updates --- dfttk/ftasks.py | 2 +- dfttk/input_sets.py | 15 +++++ dfttk/wflows.py | 136 ++++++++++++++++---------------------------- 3 files changed, 66 insertions(+), 87 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 89d0d8d1..498b3db0 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -748,7 +748,7 @@ class Crosscom_Calculation(FiretaskBase): required_params = [] optional_params = ['db_file', 'vasp_cmd', 'a_kwargs', 'db_insert', 'tag', 'metadata', 'name', 'vasp_input_set', - 'phonon', 'phonon_supercell_matrix', 't_min', 't_max', 't_step', + 't_min', 't_max', 't_step', 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'override_default_vasp_params', 'store_volumetric_data', 'static'] diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 4c2b1a40..8806fb7f 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -343,6 +343,21 @@ def __init__(self, structure, isif=2, **kwargs): elif uis['ISPIN']==1: if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] + + if 'Static_settings' in uis: + static = uis['Static_settings'] + for ff in static: + if ff.lower()=='prec': + if 'ENCUT' in new_config['INCAR']: + new_config['INCAR'].pop('ENCUT') + new_config['INCAR'].update({ff:static.get(ff)}) + elif ff=='KPAR': + new_config['INCAR'].update({ff:static.get(ff)}) + elif ff=='grid_density': + new_config['KPOINTS'].update({ff:static.get(ff)}) + elif ff=='k_mesh': + kpoints = Kpoints(kpts=static.get(ff)) + new_config['KPOINTS'] = kpoints new_config['INCAR'].update(uis) pot = self.kwargs.get('user_potcar_functional', None) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 34dab8da..1c4df711 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -100,76 +100,81 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf -def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): - """ - Perform single volume relaxation calculation. - Parameters - ---------- - structure : pymatgen.Structure - """ - metadata = metadata or {} - tag = metadata.get('tag', '{}'.format(str(uuid4()))) - metadata.update({'tag': tag}) - common_kwargs = {"metadata": metadata, "tag":tag, - 'override_default_vasp_params': override_default_vasp_params} - - num_deformations = settings.get('num_deformations', 1) - #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume - deformation_fraction = settings.get('deformation_fraction', (-0.0, +0.0)) - deformation_scheme = settings.get('deformation_scheme', 'volume') - - isif = settings.get('run_isif', None) - if not isif: - isif=3 - if num_deformations>1: - if deformation_scheme=='volume': isif = 4 - else: isif = 2 +def get_constrain(deformation_scheme): if deformation_scheme=='volume': - dmin = pow(1.0+min(deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 1./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 1./3.) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 1./3.) - 1.0 axisa=True axisb=True axisc=True elif deformation_scheme=='a': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = min(new_deformation_fraction) + dmax = max(new_deformation_fraction) axisa=True axisb=False axisc=False elif deformation_scheme=='b': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = min(new_deformation_fraction) + dmax = max(new_deformation_fraction) axisa=False axisb=True axisc=False elif deformation_scheme=='c': - dmin = deformation_fraction - dmax = deformation_fraction + dmin = min(new_deformation_fraction) + dmax = max(new_deformation_fraction) axisa=False axisb=False axisc=True elif deformation_scheme=='bc' or deformation_scheme=='cb': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 axisa=False axisb=True axisc=True elif deformation_scheme=='ca' or deformation_scheme=='ac': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 axisa=True axisb=False axisc=True elif deformation_scheme=='ab' or deformation_scheme=='ba': - dmin = pow(1.0+min(deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(deformation_fraction), 2./3.) - 1.0 + dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 + dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 axisa=True axisb=True axisc=False + return axisa, axisb, axisc, dmin, dmax +def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): + """ + Perform single volume relaxation calculation. + + Parameters + ---------- + structure : pymatgen.Structure + """ + metadata = metadata or {} + tag = metadata.get('tag', '{}'.format(str(uuid4()))) + metadata.update({'tag': tag}) + common_kwargs = {"metadata": metadata, "tag":tag, + 'override_default_vasp_params': override_default_vasp_params} + + num_deformations = settings.get('num_deformations', 1) + #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume + deformation_fraction = settings.get('deformation_fraction', (-0.0, +0.0)) + deformation_scheme = settings.get('deformation_scheme', 'volume') + + isif = settings.get('run_isif', None) + if not isif: + isif=3 + if num_deformations>1: + if deformation_scheme=='volume': isif = 4 + else: isif = 2 + + axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme) deformations = _get_deformations((dmin,dmax), num_deformations) fws = [] @@ -214,11 +219,12 @@ def get_wf_crosscom(structure, metadata=None, settings=None, tag = metadata.get('tag', '{}'.format(str(uuid4()))) metadata.update({'tag': tag}) - #int, the number of initial deformations, e.g. 7 - num_deformations = settings.get('num_deformations', 8) #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume deformation_fraction = settings.get('deformation_fraction', (-0.15, 0.20)) - + #int, the number of initial deformations, e.g. 7 + num_deformations = settings.get('num_deformations', 8) + if num_deformations==1: + deformation_fraction[1] = deformation_fraction[0] settings = settings or {} #bool, run phonon(True) or not(False) phonon = settings.get('phonon', False) @@ -302,53 +308,10 @@ def get_wf_crosscom(structure, metadata=None, settings=None, a_kwargs = {"structure":structure, "settings":settings, "eos_kwargs":eos_kwargs, "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} - if deformation_scheme=='volume': - dmin = pow(1.0+min(new_deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 1./3.) - 1.0 - axisa=True - axisb=True - axisc=True - elif deformation_scheme=='a': - dmin = new_deformation_fraction - dmax = new_deformation_fraction - axisa=True - axisb=False - axisc=False - elif deformation_scheme=='b': - dmin = new_deformation_fraction - dmax = new_deformation_fraction - axisa=False - axisb=True - axisc=False - elif deformation_scheme=='c': - dmin = new_deformation_fraction - dmax = new_deformation_fraction - axisa=False - axisb=False - axisc=True - elif deformation_scheme=='bc' or deformation_scheme=='cb': - dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 - axisa=False - axisb=True - axisc=True - elif deformation_scheme=='ca' or deformation_scheme=='ac': - dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 - axisa=True - axisb=False - axisc=True - elif deformation_scheme=='ab' or deformation_scheme=='ba': - dmin = pow(1.0+min(new_deformation_fraction), 2./3.) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 2./3.) - 1.0 - axisa=True - axisb=True - axisc=False - + axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme) deformations = _get_deformations((dmin,dmax), new_num_deformations) - fws = [] for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) @@ -357,11 +320,12 @@ def get_wf_crosscom(structure, metadata=None, settings=None, store_volumetric_data=store_volumetric_data, t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs) fws.append(full_relax_fw) + tmp = copy.deepcopy(fws) if not single_volume: check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), - parents=fws, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) + parents=tmp, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) fws.append(check_qha_fw) wfname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_crosscom') From b8f23d995ef93de56a480cbb4cd59bcb2f4bc3fb Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 10:02:40 -0400 Subject: [PATCH 021/111] Update wflows.py --- dfttk/wflows.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 1c4df711..4318d1af 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -100,9 +100,7 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf - - -def get_constrain(deformation_scheme): +def get_constrain(deformation_scheme, new_deformation_fraction): if deformation_scheme=='volume': dmin = pow(1.0+min(new_deformation_fraction), 1./3.) - 1.0 dmax = pow(1.0+max(new_deformation_fraction), 1./3.) - 1.0 @@ -174,7 +172,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri if deformation_scheme=='volume': isif = 4 else: isif = 2 - axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme) + axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme, deformation_fraction) deformations = _get_deformations((dmin,dmax), num_deformations) fws = [] @@ -309,7 +307,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} - axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme) + axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme, new_deformation_fraction) deformations = _get_deformations((dmin,dmax), new_num_deformations) fws = [] From dd7c587848ee7e4c799919f3a0602b19ea789f2f Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 15:50:22 -0400 Subject: [PATCH 022/111] updates --- dfttk/EVcheck_QHA.py | 140 ++++++------------------------------------- dfttk/fworks.py | 1 + dfttk/wflows.py | 6 +- 3 files changed, 23 insertions(+), 124 deletions(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 20ae67cd..1bf65639 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -603,8 +603,8 @@ class Crosscom_EVcheck_QHA(FiretaskBase): optional_params = ['tag', 'metadata', 'deformations', 'eos_tolerance', 'threshold', 'del_limited', 'vol_spacing', 't_min', 't_max', 't_step', 'verbose', 'modify_incar_params', 'run_num','modify_kpoints_params', - 'override_default_vasp_params', 'db_file', 'vasp_cmd', - 'force_phonon', 'stable_tor', 'store_volumetric_data','a_kwargs', 'test'] + 'override_default_vasp_params', 'db_file', 'vasp_cmd', 'site_properties', + 'stable_tor', 'store_volumetric_data', 'a_kwargs', 'test'] def run_task(self, fw_spec): ''' @@ -618,9 +618,9 @@ def run_task(self, fw_spec): vol_spacing: the maximum ratio step between two volumes, larger step will be inserted points to calculate; ''' # Get the parameters from the object - max_run = 10 + max_run = 16 db_file = env_chk(self.get('db_file', DB_FILE), fw_spec) #always concrete db_fiel - vasp_cmd = ">>vasp_cmd<<" #chould change for user to provide the change + vasp_cmd = env_chk(self.get('vasp_cmd', VASP_CMD), fw_spec) #chould change for user to provide the change deformations = self.get('deformations', []) run_num = self.get('run_num', 0) eos_tolerance = self.get('eos_tolerance', 0.005) @@ -630,13 +630,15 @@ def run_task(self, fw_spec): t_min = self.get('t_min', 5) t_max = self.get('t_max', 2000) t_step = self.get('t_step', 5) - phonon = self.get('phonon', False) - force_phonon = self.get('force_phonon', False) - phonon_supercell_matrix = self.get('phonon_supercell_matrix', None) - verbose = self.get('verbose', False) - modify_kpoints_params = self.get('modify_kpoints_params', {}) - site_properties = self.get('site_properties', None) + a_kwargs = self.get('a_kwargs', {}) + phonon = a_kwargs.get('phonon', False) + phonon_supercell_matrix = a_kwargs.get('phonon_supercell_matrix', None) + settings = a_kwargs.get('settings', None) + structure = a_kwargs.get('structure', None) + site_properties = structures.ite_properties + modify_kpoints_params = self.get('modify_kpoints_params', {}) + verbose = self.get('verbose', False) modify_incar_params = self.get('modify_incar_params', {}) powerups_options=modify_incar_params.get('powerups', None) @@ -644,20 +646,11 @@ def run_task(self, fw_spec): user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) powerups_options=user_incar_settings.get('powerups', powerups_options) - override_symmetry_tolerances = self.get('override_symmetry_tolerances', {}) store_volumetric_data = self.get('store_volumetric_data', False) stable_tor = self.get('stable_tor', 0.01) - force_phonon = self.get('force_phonon', False) test = self.get('test', False) - relax_structure = self.get('structure') or fw_spec.get('structure', None) - relax_scheme = self.get('relax_scheme') or fw_spec.get('relax_scheme', [2]) - relax_phonon = fw_spec.get('relax_phonon', False) - - #Only set phonon=True and ISIF=4 passed, then run phonon - if not force_phonon: - phonon = phonon and relax_phonon metadata = self.get('metadata', {}) tag = self.get('tag', metadata.get('tag', None)) @@ -681,11 +674,6 @@ def run_task(self, fw_spec): print('Please check DB, DFTTK running ended!') return - if relax_structure is not None: - structure = deepcopy(relax_structure) - else: - raise ValueError('Not structure in spec, please provide structure as input') - if site_properties: for pkey in site_properties: structure.add_site_property(pkey, site_properties[pkey]) @@ -714,61 +702,16 @@ def run_task(self, fw_spec): EVcheck_result['append'] = (vol_adds).tolist() # Marked as adopted in db mark_adopted(tag, db_file, volume, phonon=phonon) + lpad = LaunchPad.auto_load() - fws = [] if len(vol_adds) > 0: # VASP calculations need to append if run_num < max_run: # Do VASP and check again print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) - calcs = [] - #vis_relax = RelaxSet(structure) - #vis_static = StaticSet(structure) - #isif2 = 5 if 'infdet' in relax_path else 4 - for vol_add in vol_adds: - struct = deepcopy(structure) - struct.scale_lattice(structure.volume * vol_add) - - relax_Crosscom_EVcheck_QHA_fw = None - for isif_i in relax_scheme: - #record_path=record_path - relax_fw = OptimizeFW(struct, isif=isif_i, store_volumetric_data=store_volumetric_data, - name="relax_Vol{:.3f}".format(vol_add), vasp_input_set=None, job_type="normal", - override_symmetry_tolerances=override_symmetry_tolerances, - prev_calc_loc=True, Crosscom_EVcheck_QHA=relax_Crosscom_EVcheck_QHA_fw, db_insert=False, force_gamma=True, - modify_incar={}, **vasp_kwargs, **common_kwargs) - relax_parents_fw = deepcopy(relax_fw) - fws.append(relax_fw) - calcs.append(relax_fw) - - static_fw = StaticFW(struct, isif=relax_scheme[-1], name='static_Vol{:.3f}'.format(vol_add), - vasp_input_set=None, prev_calc_loc=True, parents=relax_parents_fw, - store_volumetric_data=store_volumetric_data, - **common_kwargs) - fws.append(static_fw) - calcs.append(static_fw) - - if phonon: - #visphonon = ForceConstantsSet(struct) - phonon_fw = PhononFW(struct, phonon_supercell_matrix, vasp_input_set=None, stable_tor=stable_tor, - name='structure_{:.3f}-phonon'.format(vol_add), prev_calc_loc=True, - parents=static_fw, **t_kwargs, **common_kwargs) - fws.append(phonon_fw) - calcs.append(phonon_fw) - check_result = Firework(EVcheck_QHA(structure=relax_structure, relax_scheme=relax_scheme, store_volumetric_data=store_volumetric_data, - run_num=run_num, verbose=verbose, site_properties=site_properties, stable_tor=stable_tor, - phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, force_phonon=force_phonon, - **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), - parents=calcs, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) - fws.append(check_result) - strname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_Append') - wfs = Workflow(fws, name = strname, metadata=metadata) - - if modify_incar_params != {}: - from dfttk.utils import add_modify_incar_by_FWname - add_modify_incar_by_FWname(wfs, modify_incar_params = modify_incar_params) - if modify_kpoints_params != {}: - from dfttk.utils import add_modify_kpoints_by_FWname - add_modify_kpoints_by_FWname(wfs, modify_kpoints_params = modify_kpoints_params) + wfs = get_wf_crosscom(structure, run_num = run_num, + new_num_deformations = len(vol_adds), + new_deformation_fraction = (min(vol_adds)-1.0, max(vol_adds)-1.0), + metadata=metadata, settings=settings) wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) if not test: lpad.add_wf(wfs) else: @@ -778,18 +721,7 @@ def run_task(self, fw_spec): debye_fw = Firework(QHAAnalysis(phonon=phonon, t_min=t_min, t_max=t_max, t_step=t_step, db_file=self.get('db_file', DB_FILE), tag=tag, metadata=metadata), name="{}-qha_analysis".format(structure.composition.reduced_formula)) fws.append(debye_fw) - ''' - # Debye - debye_fw = Firework(QHAAnalysis(phonon=False, t_min=t_min, t_max=t_max, t_step=t_step, db_file=db_file, tag=tag, metadata=metadata), - name="{}-qha_analysis-Debye".format(structure.composition.reduced_formula)) - fws.append(debye_fw) - if phonon: - phonon_supercell_matrix = self.get('phonon_supercell_matrix') - # do a Debye run Staticore the phonon, so they can be done in stages. - phonon_fw = Firework(QHAAnalysis(phonon=True, t_min=t_min, t_max=t_max, t_step=t_step, db_file=db_file, tag=tag, - metadata=metadata), parents=debye_fw, name="{}-qha_analysis-phonon".format(structure.composition.reduced_formula)) - fws.append(phonon_fw) - ''' + strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') wfs = Workflow(fws, name = strname, metadata=metadata) wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) @@ -891,20 +823,6 @@ def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, str # Check minimum spacing volumer = [vol_i / vol_orig for vol_i in volumer] - """ - decimals = 4 - for m in range(len(volumer) - 1): - vol_space_m = volumer[m + 1] - volumer[m] - if np.around(vol_space_m, decimals) > np.around(vol_spacing, decimals): - vol = np.linspace(volumer[m], volumer[m + 1], math.ceil(vol_space_m / vol_spacing) + 1).tolist() - print('Additional volume({}) is appended for the volume space({}) is larger than specified({})'.format(vol[1:-1], vol_space_m, vol_spacing)) - result.append(vol[1:-1]) - #result.extend(vol[1:-1]) - """ - - # To check (and extend) deformation coverage - # To make sure that coverage extension smaller than interpolation spacing - vol_spacing = vol_spacing * 0.98 qha = Quasiharmonic(energy, volume, structure, dos_objects=dos_objects, F_vib=None, t_min=t_min, t_max=t_max, t_step=t_step, poisson=0.363615, bp2gru=2./3.) @@ -940,28 +858,6 @@ def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, str print('Evaluated MIN volume is %.3f;' %vol_min) print('Evaluated MAX volume is %.3f;' %vol_max) - """ - vol_max = vol_max / vol_orig - vol_min = vol_min / vol_orig - counter = 1 - # Using max_append for reducing unnecessary calculations because of rough fitting - max_append = 1 if phonon else 2 - # Over coverage ratio set to 1.01 as following - if volumer[-1] * 1.01 < vol_max: - print('The current maximum volume is smaller than maximum volume evaluated by quasiharmonic analysis') - result.append(volumer[-1] + vol_spacing) - # counter is set to limit calculation times when exception occurs - while (counter < max_append) and (result[-1] < vol_max): - result.append(result[-1] + vol_spacing) - counter += 1 - counter = 1 - if volumer[0] * 0.99 > vol_min: - print('The current minimum volume is larger than minimum volume evaluated by quasiharmonic analysis') - result.append(volumer[0] - vol_spacing) - while (counter < max_append) and (result[-1] > vol_min): - result.append(result[-1] - vol_spacing) - counter += 1 - """ val, idx = min((val, idx) for (idx, val) in enumerate(energy)) nV = len(energy) nV_addL = 3 diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 8a2baa8e..891af35d 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -108,6 +108,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole if db_insert: t.append(VaspToDb(db_file=">>db_file<<", additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data)) t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) + a_kwargs = a_kwargs or {} if a_kwargs.get("static", False): t.append(Crosscom_Calculation( name="Crosscom_Calculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 4318d1af..04fa61da 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -174,7 +174,6 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme, deformation_fraction) deformations = _get_deformations((dmin,dmax), num_deformations) - fws = [] for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) @@ -197,7 +196,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri return wf -def get_wf_crosscom(structure, metadata=None, settings=None, +def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, new_num_deformations=None, new_deformation_fraction=None): """ Perform cross computer QHA calculation without computer dependent. @@ -321,6 +320,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, tmp = copy.deepcopy(fws) if not single_volume: check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, + run_num = run_num, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), parents=tmp, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) @@ -328,6 +328,8 @@ def get_wf_crosscom(structure, metadata=None, settings=None, wfname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_crosscom') wf = Workflow(fws, name=wfname, metadata=metadata) + add_modify_incar_by_FWname(wf, modify_incar_params = modify_incar_params) + add_modify_kpoints_by_FWname(wf, modify_kpoints_params = modify_kpoints_params) return wf From a2b4eaca98a1912e0df93f49a2fa6e2764e9f22c Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 16:01:15 -0400 Subject: [PATCH 023/111] Update fworks.py --- dfttk/fworks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 891af35d..10d5e6b0 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -115,6 +115,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole metadata=metadata, db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, + override_default_vasp_params=override_default_vasp_params, modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, a_kwargs=a_kwargs, **kwargs)) super(OptimizeFW, self).__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs) From d9bfb505bafc7e03f9440ad2e684986a29ec62ec Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 16:03:12 -0400 Subject: [PATCH 024/111] Update EVcheck_QHA.py --- dfttk/EVcheck_QHA.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 1bf65639..080dbbc6 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -635,7 +635,7 @@ def run_task(self, fw_spec): phonon_supercell_matrix = a_kwargs.get('phonon_supercell_matrix', None) settings = a_kwargs.get('settings', None) structure = a_kwargs.get('structure', None) - site_properties = structures.ite_properties + site_properties = structure.site_properties modify_kpoints_params = self.get('modify_kpoints_params', {}) verbose = self.get('verbose', False) From 12f79ef7ffb49d06bff1745aaf0636ba73de6141 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 16:17:11 -0400 Subject: [PATCH 025/111] Update EVcheck_QHA.py --- dfttk/EVcheck_QHA.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 080dbbc6..ab5f8581 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -15,6 +15,7 @@ from monty.serialization import loadfn, dumpfn from dfttk.input_sets import PreStaticSet, RelaxSet, StaticSet, ForceConstantsSet from dfttk.fworks import OptimizeFW, StaticFW, PhononFW +from dfttk.wflows import get_wf_crosscom from dfttk.ftasks import QHAAnalysis from dfttk.analysis.quasiharmonic import Quasiharmonic from dfttk.scripts.assign_fworker_name import Customizing_Workflows From 943831ed61e2d7dfbeda66055c0b5a3d191a93d0 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 16:26:08 -0400 Subject: [PATCH 026/111] up --- dfttk/EVcheck_QHA.py | 1 - dfttk/wflows.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index ab5f8581..080dbbc6 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -15,7 +15,6 @@ from monty.serialization import loadfn, dumpfn from dfttk.input_sets import PreStaticSet, RelaxSet, StaticSet, ForceConstantsSet from dfttk.fworks import OptimizeFW, StaticFW, PhononFW -from dfttk.wflows import get_wf_crosscom from dfttk.ftasks import QHAAnalysis from dfttk.analysis.quasiharmonic import Quasiharmonic from dfttk.scripts.assign_fworker_name import Customizing_Workflows diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 04fa61da..9a0d9536 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -319,6 +319,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, fws.append(full_relax_fw) tmp = copy.deepcopy(fws) if not single_volume: + from dfttk.wflows import get_wf_crosscom check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, run_num = run_num, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, From 339dfaee6bd280bf3482001181c4449a1885c8e0 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 16:37:49 -0400 Subject: [PATCH 027/111] up --- dfttk/EVcheck_QHA.py | 1 + dfttk/wflows.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 080dbbc6..c53e82f9 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -708,6 +708,7 @@ def run_task(self, fw_spec): if run_num < max_run: # Do VASP and check again print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) + from dfttk.wflows import get_wf_crosscom wfs = get_wf_crosscom(structure, run_num = run_num, new_num_deformations = len(vol_adds), new_deformation_fraction = (min(vol_adds)-1.0, max(vol_adds)-1.0), diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 9a0d9536..04fa61da 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -319,7 +319,6 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, fws.append(full_relax_fw) tmp = copy.deepcopy(fws) if not single_volume: - from dfttk.wflows import get_wf_crosscom check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, run_num = run_num, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, From 244950c133fd027ea9bcdc9bec20556924ef4cc6 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 17:34:39 -0400 Subject: [PATCH 028/111] Update wflows.py --- dfttk/wflows.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 04fa61da..06e9cac3 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -178,7 +178,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, - name='Structure_relax_with_ISIF='+str(isif), + name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(full_relax_fw) static_fw = StaticFW(struct, isif=2, vasp_cmd=VASP_CMD, db_file=DB_FILE, @@ -313,7 +313,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, - name='Structure_relax_with_ISIF='+str(isif), + name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), store_volumetric_data=store_volumetric_data, t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs) fws.append(full_relax_fw) From 456780aeed3d06fd0f295b065cb0ba8e2d0c256b Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 20:50:10 -0400 Subject: [PATCH 029/111] Update EVcheck_QHA.py --- dfttk/EVcheck_QHA.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index c53e82f9..ee9a3f34 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -573,6 +573,7 @@ def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, str vol_spacing = volumer[-1] - volumer[-2] for i in range(idx+1+nV_addR-nV): result.append(volumer[-1] + (i+1)*vol_spacing) + raise ValueError('************* {}'.format(results)) return(np.array(result)) def check_fit(self, volumes, energies): From 15ec5c928407b14b03cf71f7459a935d75260473 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 21:05:25 -0400 Subject: [PATCH 030/111] update DFTTK References --- docs/source/References.rst | 8 ++++++++ docs/source/index.rst | 1 + 2 files changed, 9 insertions(+) create mode 100644 docs/source/References.rst diff --git a/docs/source/References.rst b/docs/source/References.rst new file mode 100644 index 00000000..31c6a5f3 --- /dev/null +++ b/docs/source/References.rst @@ -0,0 +1,8 @@ +References +========== + +If you use some of functionality of DFTTKin your research, you may wish to consider citing the following work(s): + +.. code-block:: bash + + Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, “DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations”, CALPHAD 75 (2021) 102355. https://doi.org/10.1016/j.calphad.2021.102355 diff --git a/docs/source/index.rst b/docs/source/index.rst index 4eec2e22..9c5bca88 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -139,6 +139,7 @@ The solution is to make the best use of `ISIF Date: Wed, 13 Oct 2021 21:11:28 -0400 Subject: [PATCH 031/111] Update References.rst --- docs/source/References.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/References.rst b/docs/source/References.rst index 31c6a5f3..e4bd4ff4 100644 --- a/docs/source/References.rst +++ b/docs/source/References.rst @@ -1,8 +1,6 @@ References ========== -If you use some of functionality of DFTTKin your research, you may wish to consider citing the following work(s): - -.. code-block:: bash +If you use some of functionality of DFTTKin your research, you may wish to consider citing the following work(s):: Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, “DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations”, CALPHAD 75 (2021) 102355. https://doi.org/10.1016/j.calphad.2021.102355 From 97735b10c31c95042b1a47c8a0263ca65d537531 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 13 Oct 2021 21:20:18 -0400 Subject: [PATCH 032/111] Update References.rst --- docs/source/References.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/References.rst b/docs/source/References.rst index e4bd4ff4..ed0293aa 100644 --- a/docs/source/References.rst +++ b/docs/source/References.rst @@ -3,4 +3,6 @@ References If you use some of functionality of DFTTKin your research, you may wish to consider citing the following work(s):: - Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, “DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations”, CALPHAD 75 (2021) 102355. https://doi.org/10.1016/j.calphad.2021.102355 + Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, + “DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations”, + CALPHAD 75 (2021) 102355. `https://doi.org/10.1016/j.calphad.2021.102355 ` From 78b38eab0fe0e7dbf6541dfecfa4ade804d9b6c1 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:04:45 -0400 Subject: [PATCH 033/111] Update References.rst --- docs/source/References.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/References.rst b/docs/source/References.rst index ed0293aa..8e503427 100644 --- a/docs/source/References.rst +++ b/docs/source/References.rst @@ -5,4 +5,4 @@ If you use some of functionality of DFTTKin your research, you may wish to consi Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, “DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations”, - CALPHAD 75 (2021) 102355. `https://doi.org/10.1016/j.calphad.2021.102355 ` + CALPHAD 75 (2021) 102355. https://doi.org/10.1016/j.calphad.2021.102355 From 3bf80bd771f8e34499ae77e113eb80024c2d94df Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:15:38 -0400 Subject: [PATCH 034/111] Update index.rst --- docs/source/index.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index 9c5bca88..8a80f837 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,6 +18,29 @@ :height: 300px :figclass: align-right +Citing DFTTK +------------ + +If you use DFTTK for work presented in a publication, we ask that you cite the following publication: + +Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese, L. Q. Chen, and Z. K. Liu, DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations, CALPHAD 75 (2021) 102355. doi:`10.1016/j.calphad.2021.102355 `_. + +:: + + @article{Bocklund2019ESPEI, + archivePrefix = {arXiv}, + arxivId = {1902.01269}, + author = {Bocklund, Brandon and Otis, Richard and Egorov, Aleksei and Obaied, Abdulmonem and Roslyakova, Irina and Liu, Zi-Kui}, + doi = {10.1557/mrc.2019.59}, + eprint = {1902.01269}, + issn = {2159-6859}, + journal = {MRS Communications}, + month = {jun}, + pages = {1--10}, + title = {{ESPEI for efficient thermodynamic database development, modification, and uncertainty quantification: application to Cu–Mg}}, + year = {2019} + } + Project Goal ------------ From 040641094663ad6bf140429d940a4228cb9b0356 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:19:55 -0400 Subject: [PATCH 035/111] Update index.rst --- docs/source/index.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 8a80f837..6b5c236b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -17,6 +17,15 @@ :align: right :height: 300px :figclass: align-right + +Project Goal +------------ + +The goal of DFTTK is to make high-throughput first-principles calculations as simple as possible. +The density functional theory (DFT) based software VASP is employed to perform first-principles calculations. In addition thermodynamic properties via the quasiharmonic approach, we proposed that any property, as long as it is dependent on the volume or stain, can be predicted using a quasi-static approach implemented by our group according to (i) the predicted property-volume/strain relationship from first-principles calculations directly and (ii) the volume/strain-temperature relationship of materials from the quasiharmonic approach. + +For a given structure and elements, calculate all kinds of thermodynamic properties at finite temperature and pressure by first-principles approach based on density functional theory, including lattice vibration, thermal electron excitation, Seebeck coefficient, Lorenz number, effective charge carrier concentration etc. + Citing DFTTK ------------ @@ -40,14 +49,6 @@ Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese title = {{ESPEI for efficient thermodynamic database development, modification, and uncertainty quantification: application to Cu–Mg}}, year = {2019} } - -Project Goal ------------- - -The goal of DFTTK is to make high-throughput first-principles calculations as simple as possible. -The density functional theory (DFT) based software VASP is employed to perform first-principles calculations. In addition thermodynamic properties via the quasiharmonic approach, we proposed that any property, as long as it is dependent on the volume or stain, can be predicted using a quasi-static approach implemented by our group according to (i) the predicted property-volume/strain relationship from first-principles calculations directly and (ii) the volume/strain-temperature relationship of materials from the quasiharmonic approach. - -For a given structure and elements, calculate all kinds of thermodynamic properties at finite temperature and pressure by first-principles approach based on density functional theory, including lattice vibration, thermal electron excitation, Seebeck coefficient, Lorenz number, effective charge carrier concentration etc. High-throughput calculations ---------------------------- From c97b5da6918edfba539d9d4c9218440ce46b3983 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:33:05 -0400 Subject: [PATCH 036/111] Update index.rst --- docs/source/index.rst | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 6b5c236b..d9d04c85 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -38,15 +38,15 @@ Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese @article{Bocklund2019ESPEI, archivePrefix = {arXiv}, - arxivId = {1902.01269}, - author = {Bocklund, Brandon and Otis, Richard and Egorov, Aleksei and Obaied, Abdulmonem and Roslyakova, Irina and Liu, Zi-Kui}, - doi = {10.1557/mrc.2019.59}, - eprint = {1902.01269}, - issn = {2159-6859}, - journal = {MRS Communications}, - month = {jun}, - pages = {1--10}, - title = {{ESPEI for efficient thermodynamic database development, modification, and uncertainty quantification: application to Cu–Mg}}, + arxivId = {2107.03966}, + author = {Yi Wang, Mingqing Liao, Brandon J. Bocklund, Peng Gao, Shun-Li Shang, Hojong Kim, Allison M. Beese, Long-Qing Chen, Zi-Kui Liu}, + doi = {10.1016/j.calphad.2021.102355}, + eprint = {2107.03966}, + issn = {0364-5916}, + journal = {CALPHAD}, + month = {december}, + pages = {102355}, + title = {{DFTTK: Density functional theory toolkit for high-throughput lattice dynamics calculations}}, year = {2019} } @@ -163,8 +163,6 @@ The solution is to make the best use of `ISIF `_ +.. [Bocklund2019] Bocklund *et al.*, MRS Communications 9(2) (2019) 1–10. doi:`10.1557/mrc.2019.59 `_ +.. [Coughanowr1991] Coughanowr *et al.*, Assessment of the Cu-Mg system. Zeitschrift f{ü}r Met. 82, 574–581 (1991). +.. [Dinsdale1991] Dinsdale, Calphad 15(4) (1991) 317-425, doi:`10.1016/0364-5916(91)90030-N `_ +.. [Lukas2007] Lukas, Fries, and Sundman, Computational Thermodynamics: The Calphad Method. (Cambridge University Press, 2007). doi:`10.1017/CBO9780511804137 `_ +.. [Otis2016] Otis, Ph.D. Dissertation, The Pennsylvania State University (2016). https://etda.libraries.psu.edu/catalog/s1784k73d +.. [Otis2017] Otis *et al.*, JOM 69 (2017) doi:`10.1007/s11837-017-2318-6 `_ +.. [Roslyakova2016] Roslyakova *et al.*, Calphad 55 (2016) 165–180. doi:`10.1016/j.calphad.2016.09.001 `_ +.. [Shang2010] Shang, Wang, and Liu, Magnes. Technol. 2010 617-622 (2010). +.. [Zhou2007] Zhou *et al.*, J. Phase Equilibria Diffus. 28, 158–166 (2007). doi:`10.1007/s11669-007-9022-0 `_ +.. [Zuo1993] Zuo and Chang, Zeitschrift f{ü}r Met. 84, 662–667 (1993). \ No newline at end of file From ced215c62ec0b6bb1f22967f92ffa990b371b8e6 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:34:44 -0400 Subject: [PATCH 037/111] Update index.rst --- docs/source/index.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index d9d04c85..d9536e2f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -176,12 +176,7 @@ References .. [Wang2021] Wang *et al.*, CALPHAD 75 (2021) 102355. doi:`10.1016/j.calphad.2021.102355 `_ .. [Bocklund2019] Bocklund *et al.*, MRS Communications 9(2) (2019) 1–10. doi:`10.1557/mrc.2019.59 `_ -.. [Coughanowr1991] Coughanowr *et al.*, Assessment of the Cu-Mg system. Zeitschrift f{ü}r Met. 82, 574–581 (1991). .. [Dinsdale1991] Dinsdale, Calphad 15(4) (1991) 317-425, doi:`10.1016/0364-5916(91)90030-N `_ -.. [Lukas2007] Lukas, Fries, and Sundman, Computational Thermodynamics: The Calphad Method. (Cambridge University Press, 2007). doi:`10.1017/CBO9780511804137 `_ .. [Otis2016] Otis, Ph.D. Dissertation, The Pennsylvania State University (2016). https://etda.libraries.psu.edu/catalog/s1784k73d .. [Otis2017] Otis *et al.*, JOM 69 (2017) doi:`10.1007/s11837-017-2318-6 `_ -.. [Roslyakova2016] Roslyakova *et al.*, Calphad 55 (2016) 165–180. doi:`10.1016/j.calphad.2016.09.001 `_ .. [Shang2010] Shang, Wang, and Liu, Magnes. Technol. 2010 617-622 (2010). -.. [Zhou2007] Zhou *et al.*, J. Phase Equilibria Diffus. 28, 158–166 (2007). doi:`10.1007/s11669-007-9022-0 `_ -.. [Zuo1993] Zuo and Chang, Zeitschrift f{ü}r Met. 84, 662–667 (1993). \ No newline at end of file From 58ebe873e8e4769688236f95922b496b4c6aaaaa Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 09:39:19 -0400 Subject: [PATCH 038/111] Update index.rst --- docs/source/index.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index d9536e2f..a1522e6b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -164,12 +164,14 @@ The solution is to make the best use of `ISIF Date: Thu, 14 Oct 2021 09:42:36 -0400 Subject: [PATCH 039/111] Update index.rst --- docs/source/index.rst | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index a1522e6b..d9536e2f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -164,14 +164,12 @@ The solution is to make the best use of `ISIF Date: Thu, 14 Oct 2021 09:44:37 -0400 Subject: [PATCH 040/111] Update index.rst --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index d9536e2f..18445299 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -36,7 +36,7 @@ Y. Wang, M. Q. Liao, B. J. Bocklund, P. Gao, S. L. Shang, H. J. Kim, A. M. Beese :: - @article{Bocklund2019ESPEI, + @article{Wang2021DFTTK, archivePrefix = {arXiv}, arxivId = {2107.03966}, author = {Yi Wang, Mingqing Liao, Brandon J. Bocklund, Peng Gao, Shun-Li Shang, Hojong Kim, Allison M. Beese, Long-Qing Chen, Zi-Kui Liu}, From b399d083ac2c868a58d1db1240470df3a8e88115 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 10:47:14 -0400 Subject: [PATCH 041/111] updates --- dfttk/pythelec.py | 4 ++-- dfttk/wflows.py | 34 ++++++++++++++-------------------- tests/test_QHAAnalysis.py | 2 +- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index ae7fc461..5912046f 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -931,8 +931,8 @@ def get_static_calculations(vasp_db, tag): _dos_objs.append(vasp_db.get_dos(calc['task_id'])) tvolumes = np.array(sorted(volumes)) - if len(tvolumes)>1: - dvolumes = tvolumes[1:-1] - tvolumes[0:-2] + if len(tvolumes)>=3: + dvolumes = tvolumes[1:] - tvolumes[0:-1] dvolumes = sorted(dvolumes) if abs(dvolumes[-1]-dvolumes[-2]) > 0.01*dvolumes[-1]: #adding useful contraint calculations if not calculated statically diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 06e9cac3..1d9c8071 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -100,50 +100,45 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf -def get_constrain(deformation_scheme, new_deformation_fraction): +def get_constrain(deformation_scheme, new_deformation_fraction, new_num_deformations): + deformations = _get_deformations(new_deformation_fraction, new_num_deformations) + print("xxxxxxxxx", deformations) if deformation_scheme=='volume': - dmin = pow(1.0+min(new_deformation_fraction), 1./3.) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 1./3.) - 1.0 + ppp = 1./3. axisa=True axisb=True axisc=True elif deformation_scheme=='a': - dmin = min(new_deformation_fraction) - dmax = max(new_deformation_fraction) + ppp = 1. axisa=True axisb=False axisc=False elif deformation_scheme=='b': - dmin = min(new_deformation_fraction) - dmax = max(new_deformation_fraction) + ppp = 1. axisa=False axisb=True axisc=False elif deformation_scheme=='c': - dmin = min(new_deformation_fraction) - dmax = max(new_deformation_fraction) + ppp = 1. axisa=False axisb=False axisc=True elif deformation_scheme=='bc' or deformation_scheme=='cb': - dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 + ppp = 0.5 axisa=False axisb=True axisc=True elif deformation_scheme=='ca' or deformation_scheme=='ac': - dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 + ppp = 0.5 axisa=True axisb=False axisc=True elif deformation_scheme=='ab' or deformation_scheme=='ba': - dmin = pow(1.0+min(new_deformation_fraction), 0.5) - 1.0 - dmax = pow(1.0+max(new_deformation_fraction), 0.5) - 1.0 + ppp = 0.5 axisa=True axisb=True axisc=False - return axisa, axisb, axisc, dmin, dmax + return axisa, axisb, axisc, pow(deformations,ppp) def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): @@ -172,8 +167,8 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri if deformation_scheme=='volume': isif = 4 else: isif = 2 - axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme, deformation_fraction) - deformations = _get_deformations((dmin,dmax), num_deformations) + axisa, axisb, axisc, deformations = get_constrain(deformation_scheme, deformation_fraction, num_deformations) + fws = [] for defo in deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) @@ -306,8 +301,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} - axisa, axisb, axisc, dmin, dmax = get_constrain(deformation_scheme, new_deformation_fraction) - deformations = _get_deformations((dmin,dmax), new_num_deformations) + axisa, axisb, axisc, deformations = get_constrain(deformation_scheme, new_deformation_fraction, num_deformations) fws = [] for defo in deformations: diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index 2ca856bc..02ce0872 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -115,7 +115,7 @@ def test_EVcheck_QHA_2(): @pytest.mark.get_static_calculations def test_get_static_calculations(): - tag = '0267947f-b5a0-4993-8b5e-58f9dfb4e362' + tag = '8e7b216d-c6b6-4da4-905e-e7afd44195aa' vasp_db = VaspCalcDb.from_db_file(db_file=db_file, admin = True) volumes, energies, dos_objs, _ = get_static_calculations(vasp_db,tag) #print(volumes, energies) From 11f7d87d8b7a7e880b10550da937dfa74dafb391 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 11:52:13 -0400 Subject: [PATCH 042/111] up --- dfttk/analysis/ywutils.py | 4 ++-- dfttk/wflows.py | 1 - tests/test_QHAAnalysis.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dfttk/analysis/ywutils.py b/dfttk/analysis/ywutils.py index 9aad7ddc..46977942 100644 --- a/dfttk/analysis/ywutils.py +++ b/dfttk/analysis/ywutils.py @@ -297,8 +297,8 @@ def get_rec_from_metatag(vasp_db,m, test=False): else: pressures.append(None) if not gapfound: gapfound = float(gap) > 0.0 tvolumes = np.array(sorted(volumes)) - if len(tvolumes)>1: - dvolumes = tvolumes[1:-1] - tvolumes[0:-2] + if len(tvolumes)>=3: + dvolumes = tvolumes[1:] - tvolumes[0:-1] dvolumes = sorted(dvolumes) if abs(dvolumes[-1]-dvolumes[-2]) > 0.01*dvolumes[-1]: all_static_calculations = vasp_db.collection.\ diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 1d9c8071..5e641b70 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -102,7 +102,6 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri def get_constrain(deformation_scheme, new_deformation_fraction, new_num_deformations): deformations = _get_deformations(new_deformation_fraction, new_num_deformations) - print("xxxxxxxxx", deformations) if deformation_scheme=='volume': ppp = 1./3. axisa=True diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index 02ce0872..87e16b01 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -98,11 +98,11 @@ def test_check_points_2(): tag = '19c9e217-4159-4bfe-9c3a-940fb40e023e' tag = 'd054780c-f051-4450-a611-d374d41d1884' tag = 'ed85a69b-4054-41d4-a724-7373934cdcc6' - tag = '0267947f-b5a0-4993-8b5e-58f9dfb4e362' + tag = '8e7b216d-c6b6-4da4-905e-e7afd44195aa' vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) EV, POSCAR, INCAR = get_rec_from_metatag(vasp_db, tag, test=True) structure = Structure.from_str(POSCAR, fmt='POSCAR') - proc = EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) + proc = Crosscom_EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) proc.run_task({}) #assert False From b7f5a265f54fca4eb1c6dc5d09eb72da67a17e35 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 12:09:55 -0400 Subject: [PATCH 043/111] Update test_QHAAnalysis.py --- tests/test_QHAAnalysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index 87e16b01..1f89fec7 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -102,6 +102,7 @@ def test_check_points_2(): vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) EV, POSCAR, INCAR = get_rec_from_metatag(vasp_db, tag, test=True) structure = Structure.from_str(POSCAR, fmt='POSCAR') + #proc = Crosscom_EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) proc = Crosscom_EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) proc.run_task({}) #assert False From ce336dee82ae258a1de263c889f819b41fb6e047 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 17:33:00 -0400 Subject: [PATCH 044/111] up --- EV_check_summary.json | 21 ++++ dfttk/EVcheck_QHA.py | 216 +++++++------------------------------- pytest.ini | 1 + tests/test_QHAAnalysis.py | 127 +++++++++++++++++++++- 4 files changed, 184 insertions(+), 181 deletions(-) create mode 100644 EV_check_summary.json diff --git a/EV_check_summary.json b/EV_check_summary.json new file mode 100644 index 00000000..357a1371 --- /dev/null +++ b/EV_check_summary.json @@ -0,0 +1,21 @@ +{ + "append_run_num": 1, + "correct": false, + "volumes": [ + 16.36874910841387, + 17.230249999999998, + 18.091774704563658 + ], + "energies": [ + -3.76941213, + -3.76436362, + -3.74118152 + ], + "eos_tolerance": 0.01, + "threshold": 14, + "vol_spacing": 0.050000000000000044, + "error": 10000000000.0, + "metadata": { + "tag": "67783198-6d5a-40c2-8d49-4f03e50ac130" + } +} \ No newline at end of file diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index ee9a3f34..8c3e8473 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -81,8 +81,8 @@ def check_deformations_in_volumes(deformations, volumes, orig_vol=None): if orig_vol is None: orig_vol = (max(volumes) + min(volumes))/2. result = [] - min_vol = min(volumes) / orig_vol - max_vol = max(volumes) / orig_vol + min_vol = min(volumes) / orig_vol*(1.0-1.0e-6) + max_vol = max(volumes) / orig_vol*(1.0+1.0e-6) for deformation in deformations: if deformation < min_vol or deformation > max_vol: result.append(deformation) @@ -620,8 +620,14 @@ def run_task(self, fw_spec): ''' # Get the parameters from the object max_run = 16 - db_file = env_chk(self.get('db_file', DB_FILE), fw_spec) #always concrete db_fiel - vasp_cmd = env_chk(self.get('vasp_cmd', VASP_CMD), fw_spec) #chould change for user to provide the change + test = self.get('test', False) + if test: + db_file = self.get('db_file', DB_FILE) + vasp_cmd = self.get('vasp_cmd', VASP_CMD) + else: + db_file = env_chk(self.get('db_file', DB_FILE), fw_spec) #always concrete db_fiel + vasp_cmd = env_chk(self.get('vasp_cmd', VASP_CMD), fw_spec) #chould change for user to provide the change + deformations = self.get('deformations', []) run_num = self.get('run_num', 0) eos_tolerance = self.get('eos_tolerance', 0.005) @@ -648,10 +654,7 @@ def run_task(self, fw_spec): powerups_options=user_incar_settings.get('powerups', powerups_options) store_volumetric_data = self.get('store_volumetric_data', False) - stable_tor = self.get('stable_tor', 0.01) - test = self.get('test', False) - metadata = self.get('metadata', {}) tag = self.get('tag', metadata.get('tag', None)) @@ -659,12 +662,6 @@ def run_task(self, fw_spec): tag = str(uuid4()) metadata['tag'] = tag - common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': self.get('db_file', DB_FILE), "metadata": metadata, "tag": tag, - 'override_default_vasp_params': override_default_vasp_params,} - vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} - t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} - eos_kwargs = {'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} - run_num += 1 #Some initial checks @@ -680,62 +677,34 @@ def run_task(self, fw_spec): structure.add_site_property(pkey, site_properties[pkey]) # get original EV curve volumes, energies, dos_objs = self.get_orig_EV(db_file, tag) - vol_adds = check_deformations_in_volumes(deformations, volumes, structure.volume) - if (len(vol_adds)) == 0: - self.check_points(db_file, metadata, eos_tolerance, threshold, del_limited, volumes, energies, verbose) - else: - self.correct = True - self.error = 1e10 - - EVcheck_result = init_evcheck_result(append_run_num=run_num, correct=self.correct, volumes=volumes, - energies=energies, eos_tolerance=eos_tolerance, threshold=threshold, vol_spacing=vol_spacing, - error=self.error, metadata=metadata) - - if self.correct: - vol_orig = structure.volume - if (len(vol_adds)) == 0: - volume, energy, dos_obj = gen_volenergdos(self.points, volumes, energies, dos_objs) - vol_adds = self.check_vol_coverage(volume, vol_spacing, vol_orig, run_num, - energy, structure, dos_obj, phonon, - db_file, tag, t_min, t_max, t_step, - EVcheck_result) # Normalized to 1 - EVcheck_result['selected'] = volume - EVcheck_result['append'] = (vol_adds).tolist() - # Marked as adopted in db - mark_adopted(tag, db_file, volume, phonon=phonon) + vol_orig = structure.volume + vol_adds = self.check_vol_coverage(volumes, energies, vol_orig) + # Marked as adopted in db + mark_adopted(tag, db_file, volumes, phonon=phonon) - lpad = LaunchPad.auto_load() - if len(vol_adds) > 0: # VASP calculations need to append - if run_num < max_run: - # Do VASP and check again - print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) - from dfttk.wflows import get_wf_crosscom - wfs = get_wf_crosscom(structure, run_num = run_num, - new_num_deformations = len(vol_adds), - new_deformation_fraction = (min(vol_adds)-1.0, max(vol_adds)-1.0), - metadata=metadata, settings=settings) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) - if not test: lpad.add_wf(wfs) - else: - too_many_run_error() - else: # No need to do more VASP calculation, QHA could be running - print('Success in Volumes-Energies checking, enter QHA ...') - debye_fw = Firework(QHAAnalysis(phonon=phonon, t_min=t_min, t_max=t_max, t_step=t_step, db_file=self.get('db_file', DB_FILE), tag=tag, metadata=metadata), - name="{}-qha_analysis".format(structure.composition.reduced_formula)) - fws.append(debye_fw) - - strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') - wfs = Workflow(fws, name = strname, metadata=metadata) + lpad = LaunchPad.auto_load() + if len(vol_adds) > 0: # VASP calculations need to append + if run_num < max_run: + # Do VASP and check again + print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) + from dfttk.wflows import get_wf_crosscom + wfs = get_wf_crosscom(structure, run_num = run_num, + new_num_deformations = len(vol_adds), + new_deformation_fraction = (min(vol_adds)-1.0, max(vol_adds)-1.0), + metadata=metadata, settings=settings) wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) if not test: lpad.add_wf(wfs) - else: # failure to meet the tolerance - if len(volumes) == 0: #self.error == 1e10: # Bad initial running set - pass_result_error() - else: # fitting fails - tol_error() - import json - with open('EV_check_summary.json', 'w') as fp: - json.dump(EVcheck_result, fp, indent=4) + else: # No need to do more VASP calculation, QHA could be running + print('Success in Volumes-Energies checking, enter QHA ...') + debye_fw = Firework(QHAAnalysis(phonon=phonon, t_min=t_min, t_max=t_max, t_step=t_step, db_file=self.get('db_file', DB_FILE), tag=tag, metadata=metadata), + name="{}-qha_analysis".format(structure.composition.reduced_formula)) + fws=[debye_fw] + + strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') + wfs = Workflow(fws, name = strname, metadata=metadata) + wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + if not test: lpad.add_wf(wfs) + def get_orig_EV(self, db_file, tag): vasp_db = VaspCalcDb.from_db_file(db_file=db_file, admin = True) @@ -745,120 +714,13 @@ def get_orig_EV(self, db_file, tag): print('%s Energies = %s' %(len(energies), energies)) return(list(volumes), list(energies), dos_objs) - def check_points(self, db_file, metadata, eos_tolerance, threshold, del_limited, volumes, energies, verbose = False): - """ - Check the existing points if they reached the tolerance, - if reached, update self.correct as True - if not, reduce the point to 4 - """ - self.correct = False - self.error = 1e11 - error = 1e10 - num = np.arange(len(volumes)) - comb = num - limit = len(volumes) * del_limited - - # For len(num) > threshold case, do a whole number fitting to pass numbers delete if met tolerance - for i in range(1): # To avoid the codes after except running, ? - if (len(num) > threshold): - try: - self.check_fit(volumes, energies) - except: - if verbose: - print('Fitting error in: ', comb, '. If you can not achieve QHA result, try to run far negative deformations.') - break - temperror = eosfit_stderr(self.eos_fit, volumes, energies) - error = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb) - # Decrease the quantity of large results - while (error > eos_tolerance) and (len(num) > limit) and (len(num) > threshold): - volume, energy = gen_volenergdos(num, volumes, energies) - try: - self.check_fit(volume, energy) - except: - if verbose: - print('Fetal error in Fitting : ', num) # Seldom - break - fit_value = self.eos_fit.func(volume) - errors = abs(fit_value - energy) - num = sort_x_by_y(num, errors) - errors = sorted(errors) - for m in range(min(len(errors) - threshold, 1)): - errors.pop(-1) - num.pop(-1) - temperror = cal_stderr(errors) - error, comb = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb, temp_ind=num) - - # combinations - len_comb = len(comb) - if (error > eos_tolerance) and (len_comb <= threshold): - comb_source = comb - while (error > eos_tolerance) and (len_comb >= 4): - print('Combinations in "%s"...' %len_comb) - combination = combinations(comb_source, len_comb) - for combs in combination: - print(volumes) - print(energies) - volume, energy = gen_volenergdos(combs, volumes, energies) - try: - self.check_fit(volume, energy) - except: - if verbose: - print('Fitting error in: ', combs, '. If you can not achieve QHA result, try to run far negative deformations.') - continue - temperror = eosfit_stderr(self.eos_fit, volume, energy) - error, comb = update_err(temperror=temperror, error=error, verbose=verbose, ind=comb, temp_ind=combs) - len_comb -= 1 - - print('Minimum error = %s' %error, comb) - if error <= eos_tolerance: - self.correct = True - comb = list(comb) - comb.sort() - self.points = comb - self.error = error - - def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, structure, - dos_objects, phonon, db_file, tag, t_min, t_max, t_step, EVcheck_result): + def check_vol_coverage(self, volume, energy, vol_orig, ): result = [] volumer = volume.copy() - # Check minimum spacing volumer = [vol_i / vol_orig for vol_i in volumer] - - qha = Quasiharmonic(energy, volume, structure, dos_objects=dos_objects, F_vib=None, - t_min=t_min, t_max=t_max, t_step=t_step, poisson=0.363615, bp2gru=2./3.) - vol_max = np.nanmax(qha.optimum_volumes) - vol_min = np.nanmin(qha.optimum_volumes) - EVcheck_result['debye'] = qha.get_summary_dict() - EVcheck_result['debye']['temperatures'] = EVcheck_result['debye']['temperatures'].tolist() - if phonon: - # get the vibrational properties from the FW spec - # TODO: add a stable check in Quasiharmonic - vasp_db = VaspCalcDb.from_db_file(db_file = db_file, admin=True) - phonon_calculations = list(vasp_db.db['phonon'].find({'$and':[ {'metadata.tag': tag}, {'adopted': True} ]})) - #vol_vol = [calc['volume'] for calc in phonon_calculations] # these are just used for sorting and will be thrown away - #vol_f_vib = [calc['F_vib'] for calc in phonon_calculations] - vol_vol = [] - vol_f_vib = [] - for calc in phonon_calculations: - if calc['volume'] in vol_vol: continue - if calc['volume'] not in volume: continue - vol_vol.append(calc['volume']) - vol_f_vib.append(calc['F_vib']) - # sort them order of the unit cell volumes - vol_f_vib = sort_x_by_y(vol_f_vib, vol_vol) - f_vib = np.vstack(vol_f_vib) - qha_phonon = Quasiharmonic(energy, volume, structure, dos_objects=dos_objects, F_vib=f_vib, - t_min=t_min, t_max=t_max, t_step=t_step, poisson=0.363615, bp2gru=2./3.) - vol_max = max(np.nanmax(qha_phonon.optimum_volumes), vol_max) - vol_min = min(np.nanmax(qha_phonon.optimum_volumes), vol_min) - EVcheck_result['phonon'] = qha_phonon.get_summary_dict() - EVcheck_result['phonon']['temperatures'] = EVcheck_result['phonon']['temperatures'].tolist() - EVcheck_result['MIN_volume_Evaluated'] = '%.3f' %vol_min - EVcheck_result['MAX_volume_Evaluated'] = '%.3f' %vol_max - print('Evaluated MIN volume is %.3f;' %vol_min) - print('Evaluated MAX volume is %.3f;' %vol_max) + print('Finished volumes of : %s to calculate in VASP!' % volumer) val, idx = min((val, idx) for (idx, val) in enumerate(energy)) nV = len(energy) @@ -874,10 +736,6 @@ def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, str result.append(volumer[-1] + (i+1)*vol_spacing) return(np.array(result)) - def check_fit(self, volumes, energies): - eos = EOS('vinet') - self.eos_fit = eos.fit(volumes, energies) - @explicit_serialize class PreEV_check(FiretaskBase): diff --git a/pytest.ini b/pytest.ini index e49973f3..3ef4c603 100644 --- a/pytest.ini +++ b/pytest.ini @@ -17,5 +17,6 @@ markers = check_symmetry_magmom: check_points_1: check_points_2: + check_points_3: EVcheck_QHA_2: get_static_calculations diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index 1f89fec7..15e4e264 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -35,6 +35,7 @@ from dfttk import __version__ as dfttk_ver from pymatgen.core import __version__ as pymatgen_ver +from dfttk.wflows import _get_deformations from dfttk.EVcheck_QHA import * from dfttk.pythelec import get_static_calculations from pymatgen.core import Structure @@ -102,11 +103,133 @@ def test_check_points_2(): vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) EV, POSCAR, INCAR = get_rec_from_metatag(vasp_db, tag, test=True) structure = Structure.from_str(POSCAR, fmt='POSCAR') - #proc = Crosscom_EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) - proc = Crosscom_EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) + proc = EVcheck_QHA(db_file=db_file, metadata={'tag':tag}, structure=structure, deformations = np.linspace(0.94,1.06,7), test=True) proc.run_task({}) #assert False +POSCAR_STR = """STa1 +4.10 +0 .5 .5 +.5 0 .5 +.5 .5 0 +Al +1 +direct +0.000000 0.000000 0.000000 Al""" + + +@pytest.mark.check_points_3 +def test_check_points_3(): + tag = '19c9e217-4159-4bfe-9c3a-940fb40e023e' + tag = 'd054780c-f051-4450-a611-d374d41d1884' + tag = 'ed85a69b-4054-41d4-a724-7373934cdcc6' + tag = '67783198-6d5a-40c2-8d49-4f03e50ac130' + settings = {'deformation_fraction': [-0.05, 0.05], 'num_deformations': 3, 'deformation_scheme': 'volume', 'run_isif': 4, 'phonon': True, 'phonon_supercell_matrix': [[-2, 2, 2], [2, -2, 2], [2, 2, -2]], 'override_default_vasp_params': {'user_incar_settings': {'EDIFF_PER_ATOM': 1e-07, 'Relax_settings': {'PREC': 'HIGH', 'grid_density': 1000}, 'Static_settings': {'PREC': 'HIGH', 'grid_density': 1000}}, 'user_kpoints_settings': {'grid_density': 1000}}, 'metadata': {'tag': '67783198-6d5a-40c2-8d49-4f03e50ac130'}} + + ################ PARAMETERS FOR WF ############################# + #str, the absolute path of db.json file, e.g. /storage/home/mjl6505/atomate/config/db.json + # If None, it will use the configuration in fireworks + #db_file = settings.get('db_file', DB_FILE) + db_file = loadfn(config_to_dict()["FWORKER_LOC"])["env"]["db_file"] + #str, the vasp command, if None then find in the FWorker configuration + vasp_cmd = settings.get('vasp_cmd', VASP_CMD) + #dict, metadata to be included, this parameter is useful for filter the data, e.g. metadata={"phase": "BCC_A2", "tag": "AFM"} + metadata = settings.get('metadata',{}) + tag = metadata.get('tag', '{}'.format(str(uuid4()))) + metadata.update({'tag': tag}) + + #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume + deformation_fraction = settings.get('deformation_fraction', (-0.15, 0.20)) + #int, the number of initial deformations, e.g. 7 + num_deformations = settings.get('num_deformations', 8) + if num_deformations==1: + deformation_fraction[1] = deformation_fraction[0] + settings = settings or {} + #bool, run phonon(True) or not(False) + phonon = settings.get('phonon', False) + #list(3x3), the supercell matrix for phonon, e.g. [[2.0, 0, 0], [0, 2.0, 0], [0, 0, 2.0]] + phonon_supercell_matrix = settings.get('phonon_supercell_matrix', None) + phonon_supercell_matrix_min = settings.get('phonon_supercell_matrix_min', None) + phonon_supercell_matrix_max = settings.get('phonon_supercell_matrix_max', None) + optimize_sc = settings.get('optimize_sc', False) + #run phonon always, no matter ISIF=4 passed or not + force_phonon = settings.get('force_phonon', False) + #The tolerance for phonon stable + stable_tor = settings.get('stable_tor', 0.01) + #float, the mimimum of temperature in QHA process, e.g. 5 + t_min = settings.get('t_min', 5) + #float, the maximum of temperature in QHA process, e.g. 2000 + t_max = settings.get('t_max', 2000) + #float, the step of temperature in QHA process, e.g. 5 + t_step = settings.get('t_step', 5) + #float, acceptable value for average RMS, recommend >= 0.005 + eos_tolerance = settings.get('eos_tolerance', 0.01) + + #Global settings for all vasp job, e.g. + #override_default_vasp_params = {'user_incar_settings': {}, 'user_kpoints_settings': {}, 'user_potcar_functional': str} + #If some value in 'user_incar_settings' is set to None, it will use vasp's default value + override_default_vasp_params = settings.get('override_default_vasp_params', {}) + + #dict, dict of class ModifyIncar with keywords in Workflow name. e.g. + modify_incar_params = settings.get('modify_incar_params', {}) + + #check if fworker_name is assigned + powerups = settings.get('powerups', {}) + if len(powerups)>0: + if 'user_incar_settings' not in override_default_vasp_params: + override_default_vasp_params.update({'user_incar_settings':{}}) + override_default_vasp_params['user_incar_settings'].update({'powerups':powerups}) + modify_incar_params.update({'powerups':powerups}) + + #dict, dict of class ModifyKpoints with keywords in Workflow name, similar with modify_incar_params + modify_kpoints_params = settings.get('modify_kpoints_params', {}) + #bool, print(True) or not(False) some informations, used for debug + verbose = settings.get('verbose', False) + #Save the volume data or not ("chgcar", "aeccar0", "aeccar2", "elfcar", "locpot") + store_volumetric_data = settings.get('store_volumetric_data', False) + + if phonon: + if isinstance(phonon_supercell_matrix, str): + if phonon_supercell_matrix=='Yphon': + phonon_supercell_matrix = supercell_scaling_by_Yphon(structure, + supercellsize=phonon_supercell_matrix_max) + else: + phonon_supercell_matrix = supercell_scaling_by_atom_lat_vol(structure, min_obj=phonon_supercell_matrix_min, + max_obj=phonon_supercell_matrix_max, scale_object=phonon_supercell_matrix, + target_shape='sc', lower_search_limit=-2, upper_search_limit=2, + verbose=verbose, sc_tolerance=1e-5, optimize_sc=optimize_sc) + + _deformations = _get_deformations(deformation_fraction, num_deformations) + if num_deformations > 1: vol_spacing = _deformations[1]-_deformations[0] + else: vol_spacing=0.05 + + deformation_scheme = settings.get('deformation_scheme', 'volume') + single_volume = settings.get('single_volume', False) + + + isif = settings.get('run_isif', None) + if not isif: + isif=3 + if num_deformations>1: + if deformation_scheme=='volume': isif = 4 + else: isif = 2 + + structure = Structure.from_str(POSCAR_STR, fmt='POSCAR') + t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} + common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, + 'override_default_vasp_params': override_default_vasp_params} + vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} + eos_kwargs = {'deformations': _deformations, 'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} + a_kwargs = {"structure":structure, "settings":settings, "eos_kwargs":eos_kwargs, + "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} + + proc = Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, + run_num = 0, + store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, + **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs, test=True) + proc.run_task({}) + assert False + @pytest.mark.EVcheck_QHA_2 def test_EVcheck_QHA_2(): tag = '19c9e217-4159-4bfe-9c3a-940fb40e023e' From 420c0a561e8d467fb160675b7b36b72b9e6c607e Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 17:37:40 -0400 Subject: [PATCH 045/111] Delete EV_check_summary.json --- EV_check_summary.json | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 EV_check_summary.json diff --git a/EV_check_summary.json b/EV_check_summary.json deleted file mode 100644 index 357a1371..00000000 --- a/EV_check_summary.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "append_run_num": 1, - "correct": false, - "volumes": [ - 16.36874910841387, - 17.230249999999998, - 18.091774704563658 - ], - "energies": [ - -3.76941213, - -3.76436362, - -3.74118152 - ], - "eos_tolerance": 0.01, - "threshold": 14, - "vol_spacing": 0.050000000000000044, - "error": 10000000000.0, - "metadata": { - "tag": "67783198-6d5a-40c2-8d49-4f03e50ac130" - } -} \ No newline at end of file From 9866ca9b04af065063a14c47c8b3eb4b20ed1d76 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 21:23:13 -0400 Subject: [PATCH 046/111] up --- dfttk/EVcheck_QHA.py | 3 +-- dfttk/wflows.py | 27 +++++++++++++-------------- tests/test_QHAAnalysis.py | 18 ------------------ 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 8c3e8473..8d5b0d7d 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -689,8 +689,7 @@ def run_task(self, fw_spec): print('Appending the volumes of : %s to calculate in VASP!' %(vol_adds).tolist()) from dfttk.wflows import get_wf_crosscom wfs = get_wf_crosscom(structure, run_num = run_num, - new_num_deformations = len(vol_adds), - new_deformation_fraction = (min(vol_adds)-1.0, max(vol_adds)-1.0), + new_deformation_fraction = vol_adds, metadata=metadata, settings=settings) wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) if not test: lpad.add_wf(wfs) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 5e641b70..f1d3a672 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -100,8 +100,7 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri return wf -def get_constrain(deformation_scheme, new_deformation_fraction, new_num_deformations): - deformations = _get_deformations(new_deformation_fraction, new_num_deformations) +def get_constrain(deformation_scheme, new_deformation_fraction): if deformation_scheme=='volume': ppp = 1./3. axisa=True @@ -137,7 +136,7 @@ def get_constrain(deformation_scheme, new_deformation_fraction, new_num_deformat axisa=True axisb=True axisc=False - return axisa, axisb, axisc, pow(deformations,ppp) + return axisa, axisb, axisc, pow(np.array(new_deformation_fraction),ppp) def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): @@ -158,7 +157,8 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri #list/tuple(min, max) or float(-max, max), the maximum amplitude of deformation, e.g. (-0.15, 0.15) means (0.95, 1.1) in volume deformation_fraction = settings.get('deformation_fraction', (-0.0, +0.0)) deformation_scheme = settings.get('deformation_scheme', 'volume') - + new_deformation_fraction = _get_deformations(deformation_fraction, num_deformations) + isif = settings.get('run_isif', None) if not isif: isif=3 @@ -166,10 +166,10 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri if deformation_scheme=='volume': isif = 4 else: isif = 2 - axisa, axisb, axisc, deformations = get_constrain(deformation_scheme, deformation_fraction, num_deformations) + axisa, axisb, axisc, new_deformations = get_constrain(deformation_scheme, new_deformation_fraction) fws = [] - for defo in deformations: + for defo in new_deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), @@ -191,7 +191,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, - new_num_deformations=None, new_deformation_fraction=None): + new_deformation_fraction=None): """ Perform cross computer QHA calculation without computer dependent. @@ -272,13 +272,12 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, target_shape='sc', lower_search_limit=-2, upper_search_limit=2, verbose=verbose, sc_tolerance=1e-5, optimize_sc=optimize_sc) - _deformations = _get_deformations(deformation_fraction, num_deformations) - if num_deformations > 1: vol_spacing = _deformations[1]-_deformations[0] + deformations = _get_deformations(deformation_fraction, num_deformations) + if num_deformations > 1: vol_spacing = deformations[1]-deformations[0] else: vol_spacing=0.05 if new_deformation_fraction is None: - new_deformation_fraction = copy.deepcopy(deformation_fraction) - new_num_deformations = num_deformations + new_deformation_fraction = copy.deepcopy(deformations) deformation_scheme = settings.get('deformation_scheme', 'volume') single_volume = settings.get('single_volume', False) @@ -295,15 +294,15 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, 'override_default_vasp_params': override_default_vasp_params} vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} - eos_kwargs = {'deformations': _deformations, 'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} + eos_kwargs = {'deformations': deformations, 'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} a_kwargs = {"structure":structure, "settings":settings, "eos_kwargs":eos_kwargs, "static": True, "phonon":phonon, "phonon_supercell_matrix":phonon_supercell_matrix} - axisa, axisb, axisc, deformations = get_constrain(deformation_scheme, new_deformation_fraction, num_deformations) + axisa, axisb, axisc, new_deformations = get_constrain(deformation_scheme, new_deformation_fraction) fws = [] - for defo in deformations: + for defo in new_deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index 15e4e264..c73e7545 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -120,10 +120,6 @@ def test_check_points_2(): @pytest.mark.check_points_3 def test_check_points_3(): - tag = '19c9e217-4159-4bfe-9c3a-940fb40e023e' - tag = 'd054780c-f051-4450-a611-d374d41d1884' - tag = 'ed85a69b-4054-41d4-a724-7373934cdcc6' - tag = '67783198-6d5a-40c2-8d49-4f03e50ac130' settings = {'deformation_fraction': [-0.05, 0.05], 'num_deformations': 3, 'deformation_scheme': 'volume', 'run_isif': 4, 'phonon': True, 'phonon_supercell_matrix': [[-2, 2, 2], [2, -2, 2], [2, 2, -2]], 'override_default_vasp_params': {'user_incar_settings': {'EDIFF_PER_ATOM': 1e-07, 'Relax_settings': {'PREC': 'HIGH', 'grid_density': 1000}, 'Static_settings': {'PREC': 'HIGH', 'grid_density': 1000}}, 'user_kpoints_settings': {'grid_density': 1000}}, 'metadata': {'tag': '67783198-6d5a-40c2-8d49-4f03e50ac130'}} ################ PARAMETERS FOR WF ############################# @@ -144,7 +140,6 @@ def test_check_points_3(): num_deformations = settings.get('num_deformations', 8) if num_deformations==1: deformation_fraction[1] = deformation_fraction[0] - settings = settings or {} #bool, run phonon(True) or not(False) phonon = settings.get('phonon', False) #list(3x3), the supercell matrix for phonon, e.g. [[2.0, 0, 0], [0, 2.0, 0], [0, 0, 2.0]] @@ -152,8 +147,6 @@ def test_check_points_3(): phonon_supercell_matrix_min = settings.get('phonon_supercell_matrix_min', None) phonon_supercell_matrix_max = settings.get('phonon_supercell_matrix_max', None) optimize_sc = settings.get('optimize_sc', False) - #run phonon always, no matter ISIF=4 passed or not - force_phonon = settings.get('force_phonon', False) #The tolerance for phonon stable stable_tor = settings.get('stable_tor', 0.01) #float, the mimimum of temperature in QHA process, e.g. 5 @@ -203,17 +196,6 @@ def test_check_points_3(): if num_deformations > 1: vol_spacing = _deformations[1]-_deformations[0] else: vol_spacing=0.05 - deformation_scheme = settings.get('deformation_scheme', 'volume') - single_volume = settings.get('single_volume', False) - - - isif = settings.get('run_isif', None) - if not isif: - isif=3 - if num_deformations>1: - if deformation_scheme=='volume': isif = 4 - else: isif = 2 - structure = Structure.from_str(POSCAR_STR, fmt='POSCAR') t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, From 2a754e34f0d5485fc2cb569ea849aeb400af2fcc Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 14 Oct 2021 22:19:00 -0400 Subject: [PATCH 047/111] up --- dfttk/ftasks.py | 12 +++++++----- dfttk/fworks.py | 4 ++-- dfttk/wflows.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 498b3db0..18b10d8a 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -751,7 +751,7 @@ class Crosscom_Calculation(FiretaskBase): 't_min', 't_max', 't_step', 'verbose', 'modify_incar_params', 'modify_kpoints_params', 'override_default_vasp_params', - 'store_volumetric_data', 'static'] + 'store_volumetric_data', 'static', 'defo'] def run_task(self, fw_spec): db_file = self.get('db_file') or DB_FILE @@ -768,13 +768,14 @@ def run_task(self, fw_spec): override_default_vasp_params = self.get('override_default_vasp_params', {}) store_volumetric_data = self.get('store_volumetric_data', False) a_kwargs = self.get('a_kwargs', {}) + defo = self.get('defo', 1.0) return FWAction(detours=self.get_detour_workflow( db_file, vasp_cmd, db_insert, tag, metadata, name, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, a_kwargs=a_kwargs) + store_volumetric_data, a_kwargs=a_kwargs, defo=defo) ) def get_detour_workflow(self, @@ -782,7 +783,7 @@ def get_detour_workflow(self, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, a_kwargs=None): + store_volumetric_data, a_kwargs=None, defo=1.0): from fireworks import Workflow from .fworks import PhononFW, StaticFW a_kwargs = a_kwargs or {} @@ -800,7 +801,7 @@ def get_detour_workflow(self, for prop, vals in site_properties.items(): inp_structure.add_site_property(prop, vals) - detour_fws.append(StaticFW(inp_structure, name="crosscom-static", + detour_fws.append(StaticFW(inp_structure, name="crosscom-static"+'-defo={:5.3f}'.format(defo), vasp_cmd=vasp_cmd, metadata=metadata, prev_calc_loc=False, modify_incar=modify_incar_params, db_file=db_file, tag=tag, override_default_vasp_params=override_default_vasp_params, @@ -811,7 +812,8 @@ def get_detour_workflow(self, common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, 'override_default_vasp_params': override_default_vasp_params} detour_fws.append(PhononFW(inp_structure, phonon_supercell_matrix, - name='crosscom-phonon', prev_calc_loc=False, stable_tor=stable_tor, + name='crosscom-phonon'+'-defo={:5.3f}'.format(defo), + prev_calc_loc=False, stable_tor=stable_tor, **t_kwargs, **common_kwargs)) override_default_vasp_params = override_default_vasp_params or {} diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 10d5e6b0..35e73dbf 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -50,7 +50,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole prev_calc_loc=True, parents=None, db_insert=False, tag=None, run_isif2=False, pass_isif4=False, force_gamma=True, store_volumetric_data=False, modify_incar=None, modify_incar_params={}, modify_kpoints_params={}, - t_kwargs=None, a_kwargs=None, **kwargs): + t_kwargs=None, a_kwargs=None, defo=1.0, **kwargs): metadata = metadata or {} tag = tag or metadata.get('tag') # generate a tag with a warning @@ -111,7 +111,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole a_kwargs = a_kwargs or {} if a_kwargs.get("static", False): t.append(Crosscom_Calculation( - name="Crosscom_Calculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, + name="Crosscom_Calculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, defo=defo, metadata=metadata, db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, diff --git a/dfttk/wflows.py b/dfttk/wflows.py index f1d3a672..8ccf941e 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -307,7 +307,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, full_relax_fw = OptimizeFW(struct, isif=isif, name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), store_volumetric_data=store_volumetric_data, - t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs) + t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs, defo=defo) fws.append(full_relax_fw) tmp = copy.deepcopy(fws) if not single_volume: From 1b0837d5d7f75aa32f529b43f4290379c540ecb0 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 15 Oct 2021 21:26:07 -0400 Subject: [PATCH 048/111] great framework change on settings --- dfttk/EVcheck_QHA.py | 48 +++++++++++++++++++++++--------------- dfttk/ftasks.py | 36 +++++++++++++++++----------- dfttk/fworks.py | 33 ++++++++++++++++---------- dfttk/input_sets.py | 31 ++++++++++++------------ dfttk/scripts/run_dfttk.py | 13 +++++++---- dfttk/wflows.py | 43 ++++++++++++++++++++++------------ 6 files changed, 125 insertions(+), 79 deletions(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index 8d5b0d7d..be827409 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -203,7 +203,7 @@ class EVcheck_QHA(FiretaskBase): 'del_limited', 'vol_spacing', 't_min', 't_max', 't_step', 'phonon', 'phonon_supercell_matrix', 'verbose', 'modify_incar_params', 'run_num','modify_kpoints_params', 'site_properties', 'override_symmetry_tolerances', 'override_default_vasp_params', 'db_file', 'vasp_cmd', - 'force_phonon', 'stable_tor', 'store_volumetric_data','test'] + 'force_phonon', 'stable_tor', 'store_volumetric_data', 'a_kwargs', 'test'] def run_task(self, fw_spec): ''' @@ -237,11 +237,14 @@ def run_task(self, fw_spec): site_properties = self.get('site_properties', None) modify_incar_params = self.get('modify_incar_params', {}) - powerups_options=modify_incar_params.get('powerups', None) + #powerups_options=modify_incar_params.get('powerups', None) override_default_vasp_params = self.get('override_default_vasp_params', {}) - user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) - powerups_options=user_incar_settings.get('powerups', powerups_options) + #user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) + #powerups_options=user_incar_settings.get('powerups', powerups_options) + a_kwargs = self.get('a_kwargs', {}) + settings = a_kwargs.get('settings', None) + override_symmetry_tolerances = self.get('override_symmetry_tolerances', {}) store_volumetric_data = self.get('store_volumetric_data', False) @@ -334,7 +337,7 @@ def run_task(self, fw_spec): name="relax_Vol{:.3f}".format(vol_add), vasp_input_set=None, job_type="normal", override_symmetry_tolerances=override_symmetry_tolerances, prev_calc_loc=True, parents=relax_parents_fw, db_insert=False, force_gamma=True, - modify_incar={}, **vasp_kwargs, **common_kwargs) + modify_incar={}, **vasp_kwargs, a_kwargs=a_kwargs, **common_kwargs) relax_parents_fw = deepcopy(relax_fw) fws.append(relax_fw) calcs.append(relax_fw) @@ -342,7 +345,7 @@ def run_task(self, fw_spec): static_fw = StaticFW(struct, isif=relax_scheme[-1], name='static_Vol{:.3f}'.format(vol_add), vasp_input_set=None, prev_calc_loc=True, parents=relax_parents_fw, store_volumetric_data=store_volumetric_data, - **common_kwargs) + a_kwargs=a_kwargs, **common_kwargs) fws.append(static_fw) calcs.append(static_fw) @@ -350,12 +353,13 @@ def run_task(self, fw_spec): #visphonon = ForceConstantsSet(struct) phonon_fw = PhononFW(struct, phonon_supercell_matrix, vasp_input_set=None, stable_tor=stable_tor, name='structure_{:.3f}-phonon'.format(vol_add), prev_calc_loc=True, - parents=static_fw, **t_kwargs, **common_kwargs) + parents=static_fw, **t_kwargs, a_kwargs=a_kwargs, **common_kwargs) fws.append(phonon_fw) calcs.append(phonon_fw) check_result = Firework(EVcheck_QHA(structure=relax_structure, relax_scheme=relax_scheme, store_volumetric_data=store_volumetric_data, run_num=run_num, verbose=verbose, site_properties=site_properties, stable_tor=stable_tor, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, force_phonon=force_phonon, + a_kwargs = a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), parents=calcs, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) fws.append(check_result) @@ -368,7 +372,7 @@ def run_task(self, fw_spec): if modify_kpoints_params != {}: from dfttk.utils import add_modify_kpoints_by_FWname add_modify_kpoints_by_FWname(wfs, modify_kpoints_params = modify_kpoints_params) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups',None)) if not test: lpad.add_wf(wfs) else: too_many_run_error() @@ -391,7 +395,7 @@ def run_task(self, fw_spec): ''' strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') wfs = Workflow(fws, name = strname, metadata=metadata) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups',None)) if not test: lpad.add_wf(wfs) else: # failure to meet the tolerance if len(volumes) == 0: #self.error == 1e10: # Bad initial running set @@ -646,12 +650,14 @@ def run_task(self, fw_spec): modify_kpoints_params = self.get('modify_kpoints_params', {}) verbose = self.get('verbose', False) + """ modify_incar_params = self.get('modify_incar_params', {}) powerups_options=modify_incar_params.get('powerups', None) + """ override_default_vasp_params = self.get('override_default_vasp_params', {}) - user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) - powerups_options=user_incar_settings.get('powerups', powerups_options) + #user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) + #powerups_options=user_incar_settings.get('powerups', powerups_options) store_volumetric_data = self.get('store_volumetric_data', False) stable_tor = self.get('stable_tor', 0.01) @@ -691,7 +697,7 @@ def run_task(self, fw_spec): wfs = get_wf_crosscom(structure, run_num = run_num, new_deformation_fraction = vol_adds, metadata=metadata, settings=settings) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups', None)) if not test: lpad.add_wf(wfs) else: # No need to do more VASP calculation, QHA could be running print('Success in Volumes-Energies checking, enter QHA ...') @@ -701,7 +707,7 @@ def run_task(self, fw_spec): strname = "{}:{}".format(structure.composition.reduced_formula, 'QHA') wfs = Workflow(fws, name = strname, metadata=metadata) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups', None)) if not test: lpad.add_wf(wfs) @@ -755,7 +761,7 @@ class PreEV_check(FiretaskBase): optional_params = ['deformations', 'relax_path', 'run_num', 'tolerance', 'threshold', 'del_limited', 'vol_spacing', 't_min', 't_max', 't_step', 'phonon', 'phonon_supercell_matrix', 'verbose', 'modify_incar_params', 'structure', 'modify_kpoints_params', 'symmetry_tolerance', 'run_isif2', 'pass_isif4', 'site_properties', - 'store_volumetric_data'] + 'store_volumetric_data', 'a_kwargs'] def run_task(self, fw_spec): ''' @@ -789,12 +795,13 @@ def run_task(self, fw_spec): verbose = self.get('verbose') or False modify_incar_params = self.get('modify_incar_params') or {} modify_kpoints_params = self.get('modify_kpoints_params') or {} - powerups_options=modify_incar_params.get('powerups', None) symmetry_tolerance = self.get('symmetry_tolerance') or None run_isif2 = self.get('run_isif2') or None pass_isif4 = self.get('pass_isif4') or False site_properties = self.get('site_properties') or None store_volumetric_data = self.get('store_volumetric_data', False) + a_kwargs = self.get('a_kwargs', {}) + settings = a_kwargs.get('settings', None) run_num += 1 volumes, energies = self.get_orig_EV_structure(db_file, tag) @@ -831,7 +838,7 @@ def run_task(self, fw_spec): for vol_add in vol_adds: prestatic = StaticFW(structure=structure, job_type='normal', name='VR_%.3f-PreStatic' %vol_add, prev_calc_loc=False, vasp_input_set=vis_prestatic, vasp_cmd=">>vasp_cmd<<", db_file=self.get('db_file', DB_FILE), - metadata=metadata, Prestatic=True) + metadata=metadata, a_kwargs=a_kwargs, Prestatic=True) fws.append(prestatic) prestatic_calcs.append(prestatic) @@ -839,7 +846,8 @@ def run_task(self, fw_spec): tolerance = tolerance, threshold = 14, vol_spacing = vol_spacing, vasp_cmd = ">>vasp_cmd<<", pass_isif4=pass_isif4, metadata = metadata, t_min=t_min, t_max=t_max, t_step=t_step, phonon = phonon, symmetry_tolerance = symmetry_tolerance, phonon_supercell_matrix = phonon_supercell_matrix, verbose = verbose, site_properties=site_properties, - modify_incar_params=modify_incar_params, modify_kpoints_params = modify_kpoints_params), + modify_incar_params=modify_incar_params, modify_kpoints_params = modify_kpoints_params, + a_kwargs=a_kwargs), parents=prestatic_calcs, name='%s-PreEV_check%s' %(structure.composition.reduced_formula, run_num)) fws.append(check_result) strname = "{}:{}".format(structure.composition.reduced_formula, 'PreEV_check') @@ -850,7 +858,7 @@ def run_task(self, fw_spec): if modify_kpoints_params != {}: from dfttk.utils import add_modify_kpoints_by_FWname add_modify_kpoints_by_FWname(wfs, modify_kpoints_params = modify_kpoints_params) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups', None)) lpad.add_wf(wfs) else: too_many_run_error() @@ -863,6 +871,7 @@ def run_task(self, fw_spec): prev_calc_loc=False, vasp_input_set=vis_relax, vasp_cmd=">>vasp_cmd<<", db_file=self.get('db_file', DB_FILE), metadata=metadata, record_path = True, modify_incar = {'ISIF': 2}, run_isif2=run_isif2, pass_isif4=pass_isif4, modify_incar_params=modify_incar_params, modify_kpoints_params = modify_kpoints_params, + a_kwargs=a_kwargs, spec={'_preserve_fworker': True}, store_volumetric_data=store_volumetric_data) fws.append(ps2_relax_fw) else: @@ -873,6 +882,7 @@ def run_task(self, fw_spec): metadata = metadata, t_min = t_min, t_max = t_max, t_step = t_step, phonon = phonon, deformations =deformations, phonon_supercell_matrix = phonon_supercell_matrix, symmetry_tolerance = symmetry_tolerance, modify_incar_params = modify_incar_params, verbose = verbose, pass_isif4=pass_isif4, + a_kwargs=a_kwargs, modify_kpoints_params = modify_kpoints_params, site_properties=site_properties), parents = ps2_relax_fw, name='%s-EVcheck_QHA' %structure.composition.reduced_formula, store_volumetric_data=store_volumetric_data) fws.append(check_result) @@ -884,7 +894,7 @@ def run_task(self, fw_spec): if modify_kpoints_params != {}: from dfttk.utils import add_modify_kpoints_by_FWname add_modify_kpoints_by_FWname(wfs, modify_kpoints_params = modify_kpoints_params) - wfs=Customizing_Workflows(wfs,powerups_options = powerups_options) + wfs=Customizing_Workflows(wfs,powerups_options = settings.get('powerups', None)) lpad.add_wf(wfs) else: # failure to meet the tolerance if len(volumes) == 0: #self.error == 1e10: # Bad initial running set diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 18b10d8a..99ca8e09 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -33,7 +33,7 @@ from dfttk import __version__ as dfttk_ver from pymatgen.core import __version__ as pymatgen_ver from dfttk.pythelec import get_static_calculations -from dfttk.scripts.assign_fworker_name import Customizing_Workflows, get_powerups_options +from dfttk.scripts.assign_fworker_name import Customizing_Workflows def extend_calc_locs(name, fw_spec): """ @@ -767,15 +767,13 @@ def run_task(self, fw_spec): modify_kpoints_params = self.get('modify_kpoints_params', {}) override_default_vasp_params = self.get('override_default_vasp_params', {}) store_volumetric_data = self.get('store_volumetric_data', False) - a_kwargs = self.get('a_kwargs', {}) - defo = self.get('defo', 1.0) return FWAction(detours=self.get_detour_workflow( db_file, vasp_cmd, db_insert, tag, metadata, name, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, a_kwargs=a_kwargs, defo=defo) + store_volumetric_data) ) def get_detour_workflow(self, @@ -783,10 +781,10 @@ def get_detour_workflow(self, t_min, t_max, t_step, modify_incar_params, modify_kpoints_params, override_default_vasp_params, - store_volumetric_data, a_kwargs=None, defo=1.0): + store_volumetric_data): from fireworks import Workflow from .fworks import PhononFW, StaticFW - a_kwargs = a_kwargs or {} + a_kwargs = self.get('a_kwargs',{}) settings = a_kwargs.get('settings', {}) stable_tor = settings.get('stable_tor', 0.01) @@ -801,9 +799,10 @@ def get_detour_workflow(self, for prop, vals in site_properties.items(): inp_structure.add_site_property(prop, vals) - detour_fws.append(StaticFW(inp_structure, name="crosscom-static"+'-defo={:5.3f}'.format(defo), + detour_fws.append(StaticFW(inp_structure, name="crosscom-static"+'-defo={:5.3f}'.format(self.get('defo',1.0)), vasp_cmd=vasp_cmd, metadata=metadata, prev_calc_loc=False, modify_incar=modify_incar_params, db_file=db_file, tag=tag, + a_kwargs=a_kwargs, override_default_vasp_params=override_default_vasp_params, store_volumetric_data=store_volumetric_data)) @@ -812,13 +811,15 @@ def get_detour_workflow(self, common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': db_file, "metadata": metadata, "tag": tag, 'override_default_vasp_params': override_default_vasp_params} detour_fws.append(PhononFW(inp_structure, phonon_supercell_matrix, - name='crosscom-phonon'+'-defo={:5.3f}'.format(defo), + name='crosscom-phonon'+'-defo={:5.3f}'.format(self.get('defo',1.0)), prev_calc_loc=False, stable_tor=stable_tor, + a_kwargs=a_kwargs, **t_kwargs, **common_kwargs)) - + """ override_default_vasp_params = override_default_vasp_params or {} user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) - return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) + """ + return Customizing_Workflows(detour_fws, powerups_options=settings.get('powerups', None)) @explicit_serialize @@ -887,7 +888,8 @@ class CheckRelaxation(FiretaskBase): required_params = ["db_file", "tag", "common_kwargs"] optional_params = ["metadata", "tol_energy", "tol_strain", "tol_bond", 'level', 'isif4', "energy_with_isif", - "static_kwargs", "relax_kwargs", 'store_volumetric_data', 'site_properties'] + "static_kwargs", "relax_kwargs", 'store_volumetric_data', + 'a_kwargs', 'site_properties'] def run_task(self, fw_spec): self.db_file = env_chk(self.get("db_file"), fw_spec) @@ -1011,6 +1013,8 @@ def get_detour_workflow(self, next_steps, final_energy, energy_with_isif={}): symmetry_options = self.symmetry_options static_kwargs = self.get('static_kwargs', {}) + a_kwargs = self.get('a_kwargs', {}) + settings = a_kwargs.get('settings', {}) # Assume the data for the current step is already in the database db = VaspCalcDb.from_db_file(self.db_file, admin=True).db['relaxations'] @@ -1030,17 +1034,21 @@ def _get_input_structure_for_step(step): md['symmetry_type'] = step["symmetry_type"] common_copy["metadata"] = md detour_fws.append(StaticFW(inp_structure, isif=step['isif'], store_volumetric_data=self.store_volumetric_data, - **static_kwargs, **common_copy)) + a_kwargs=a_kwargs, + **static_kwargs, **common_copy)) elif job_type == "relax": detour_fws.append(RobustOptimizeFW(inp_structure, isif=step["isif"], energy_with_isif=energy_with_isif, - override_symmetry_tolerances=symmetry_options, store_volumetric_data=self.store_volumetric_data, **self["common_kwargs"])) + override_symmetry_tolerances=symmetry_options, store_volumetric_data=self.store_volumetric_data, + a_kwargs=a_kwargs, **self["common_kwargs"])) else: raise ValueError(f"Unknown job_type {job_type} for step {step}.") + """ common_kwargs = self.get('common_kwargs',{}) override_default_vasp_params = common_kwargs.get('override_default_vasp_params',{}) user_incar_settings = override_default_vasp_params.get('user_incar_settings',{}) #user_incar_settings = common_kwargs.get('modify_incar_params',{}) - return Customizing_Workflows(detour_fws, powerups_options=user_incar_settings.get('powerups', None)) + """ + return Customizing_Workflows(detour_fws, powerups_options=settings.get('powerups', None)) @explicit_serialize diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 35e73dbf..25705932 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -50,7 +50,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole prev_calc_loc=True, parents=None, db_insert=False, tag=None, run_isif2=False, pass_isif4=False, force_gamma=True, store_volumetric_data=False, modify_incar=None, modify_incar_params={}, modify_kpoints_params={}, - t_kwargs=None, a_kwargs=None, defo=1.0, **kwargs): + t_kwargs=None, a_kwargs={}, defo=1.0, **kwargs): metadata = metadata or {} tag = tag or metadata.get('tag') # generate a tag with a warning @@ -70,8 +70,10 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole raise ValueError('The store_volumetric_data should be list or bool') override_default_vasp_params = override_default_vasp_params or {} + """ if len (override_default_vasp_params)==0: override_default_vasp_params = a_kwargs.get("override_default_vasp_params", {}) + """ tmp = copy.deepcopy(override_default_vasp_params) if isif!=4 and isif!=3: @@ -81,7 +83,7 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole override_symmetry_tolerances = override_symmetry_tolerances or {} vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, - **tmp) + a_kwargs=a_kwargs, **tmp) site_properties = deepcopy(structure).site_properties t = [] @@ -108,7 +110,6 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole if db_insert: t.append(VaspToDb(db_file=">>db_file<<", additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data)) t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties)) - a_kwargs = a_kwargs or {} if a_kwargs.get("static", False): t.append(Crosscom_Calculation( name="Crosscom_Calculation", vasp_input_set=None, vasp_cmd=vasp_cmd, db_file=db_file, defo=defo, @@ -116,7 +117,8 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole db_insert=db_insert, tag=tag, store_volumetric_data=store_volumetric_data, override_default_vasp_params=override_default_vasp_params, - modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, a_kwargs=a_kwargs, **kwargs)) + modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, **t_kwargs, + a_kwargs=a_kwargs, **kwargs)) super(OptimizeFW, self).__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs) @@ -147,7 +149,8 @@ def __init__(self, structure, isif=7, name="structure optimization", isif4=False override_symmetry_tolerances=None, job_type="normal", vasp_input_set=None, vasp_cmd="vasp", metadata=None, override_default_vasp_params=None, db_file=None, prev_calc_loc=True, parents=None, db_insert=False, tag=None, modify_incar_params={}, - modify_kpoints_params={}, energy_with_isif={}, store_volumetric_data=False, + modify_kpoints_params={}, energy_with_isif={}, store_volumetric_data=False, + a_kwargs={}, **kwargs): metadata = metadata or {} tag = tag or metadata.get('tag') @@ -174,7 +177,7 @@ def __init__(self, structure, isif=7, name="structure optimization", isif4=False tmp['user_incar_settings'].pop('EDIFFG') override_symmetry_tolerances = override_symmetry_tolerances or {} - vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, **tmp) + vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, a_kwargs=a_kwargs, **tmp) site_properties = deepcopy(structure).site_properties t = [] @@ -198,6 +201,7 @@ def __init__(self, structure, isif=7, name="structure optimization", isif4=False t.append(CheckRelaxation(db_file=">>db_file<<", metadata=metadata, tag=tag, isif4=isif4, level=level, energy_with_isif=energy_with_isif, common_kwargs=common_kwargs, relax_kwargs=relax_kwargs, static_kwargs=static_kwargs, site_properties=site_properties, store_volumetric_data=store_volumetric_data, + a_kwargs=a_kwargs, **override_symmetry_tolerances)) super().__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs) @@ -232,7 +236,8 @@ class StaticFW(Firework): def __init__(self, structure, isif=2, scale_lattice=None, name="static", vasp_input_set=None, vasp_cmd="vasp", metadata=None, prev_calc_loc=True, Prestatic=False, modify_incar=None, db_file=None, parents=None, tag=None, override_default_vasp_params=None, - store_volumetric_data=False, **kwargs): + store_volumetric_data=False, + a_kwargs={}, **kwargs): # TODO: @computron - I really don't like how you need to set the structure even for # prev_calc_loc jobs. Sometimes it makes appending new FWs to an existing workflow @@ -256,7 +261,7 @@ def __init__(self, structure, isif=2, scale_lattice=None, name="static", vasp_in override_default_vasp_params = override_default_vasp_params or {} self.override_default_vasp_params = override_default_vasp_params - vasp_input_set = vasp_input_set or StaticSet(structure, isif=isif, **override_default_vasp_params) + vasp_input_set = vasp_input_set or StaticSet(structure, isif=isif, a_kwargs=a_kwargs, **override_default_vasp_params) self.vasp_input_set = vasp_input_set site_properties = deepcopy(structure).site_properties # Avoids delivery (prev_calc_loc == '' (instead by True)) @@ -325,7 +330,9 @@ class InflectionDetectionFW(Firework): """ def __init__(self, structure, name="infdet", input_set=None, metadata=None, prev_calc_loc=True, - db_file=None, parents=None, continuation=False, run_isif2=False, pass_isif4=False, **kwargs): + db_file=None, parents=None, continuation=False, run_isif2=False, pass_isif4=False, + a_kwargs={}, + **kwargs): metadata = metadata or {} input_set = input_set or ATATIDSet(structure) @@ -399,6 +406,7 @@ def __init__(self, structure, supercell_matrix, t_min=5, t_max=2000, t_step=5, name="phonon", vasp_input_set=None, override_default_vasp_params=None, vasp_cmd="vasp", metadata=None, tag=None, qpoint_mesh=(50, 50, 50), prev_calc_loc=True, db_file=None, parents=None, stable_tor=0.01, + a_kwargs={}, **kwargs): metadata = metadata or {} @@ -432,7 +440,7 @@ def __init__(self, structure, supercell_matrix, t_min=5, t_max=2000, t_step=5, supercell_structure = deepcopy(structure) supercell_structure.make_supercell(supercell_matrix) supercell_site_properties = deepcopy(supercell_structure.site_properties) - vasp_input_set = vasp_input_set or ForceConstantsSet(supercell_structure, **tmp) + vasp_input_set = vasp_input_set or ForceConstantsSet(supercell_structure, a_kwargs=a_kwargs, **tmp) t = [] @@ -489,7 +497,8 @@ class BornChargeFW(Firework): """ def __init__(self, structure, isif=2, scale_lattice=None, name="born charge", vasp_input_set=None, vasp_cmd="vasp", metadata=None, override_default_vasp_params=None, tag=None, - prev_calc_loc=True, modify_incar=None, db_file=None, parents=None, **kwargs): + prev_calc_loc=True, modify_incar=None, db_file=None, parents=None, + a_kwargs={}, **kwargs): metadata = metadata or {} tag = tag or metadata.get('tag') @@ -500,7 +509,7 @@ def __init__(self, structure, isif=2, scale_lattice=None, name="born charge", va override_default_vasp_params = override_default_vasp_params or {} - vasp_input_set = vasp_input_set or BornChargeSet(structure, isif=isif, **override_default_vasp_params) + vasp_input_set = vasp_input_set or BornChargeSet(structure, isif=isif, a_kwargs=a_kwargs, **override_default_vasp_params) site_properties = deepcopy(structure).site_properties # Avoids delivery (prev_calc_loc == '' (instead by True)) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 8806fb7f..c73665ce 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -98,7 +98,7 @@ class RelaxSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, volume_relax=False, isif=None, **kwargs): + def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwargs): """If volume relax is True, will do volume only, ISIF 7""" self.kwargs = copy.deepcopy(kwargs) self.volume_relax = volume_relax @@ -125,9 +125,9 @@ def __init__(self, structure, volume_relax=False, isif=None, **kwargs): elif uis['ISPIN']==1: if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] - - if 'Relax_settings' in uis: - relax = uis['Relax_settings'] + settings = a_kwargs.get('settings', {}) + relax = settings.get('Relax_settings', None) or uis.get('Relax_settings', None) + if relax: for ff in relax: if ff.lower()=='prec': if 'ENCUT' in new_config['INCAR']: @@ -180,7 +180,7 @@ class PreStaticSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, **kwargs): + def __init__(self, structure, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet old_kwargs = ['prev_incar', 'prev_kpoints', 'grid_density', 'lepsilon', 'lcalcpol'] for k in old_kwargs: @@ -249,7 +249,7 @@ class ForceConstantsSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, **kwargs): + def __init__(self, structure, a_kwargs={}, **kwargs): self.kwargs = copy.deepcopy(kwargs) uis = copy.deepcopy(self.kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(ForceConstantsSet.CONFIG) @@ -279,10 +279,10 @@ def __init__(self, structure, **kwargs): kpoints = Kpoints(kpts=[[3,3,3],]) new_config['KPOINTS'] = kpoints pot = self.kwargs.get('user_potcar_functional', None) - if pot: + if pot: new_config['POTCAR_FUNCTIONAL'] = pot super(ForceConstantsSet, self).__init__( - structure, new_config, sort_structure=False, **self.kwargs) + structure, new_config, sort_structure=False, force_gamma=True, **self.kwargs) class StaticSet(DictSet): @@ -316,7 +316,7 @@ class StaticSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, isif=2, **kwargs): + def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet self.isif = isif @@ -343,9 +343,10 @@ def __init__(self, structure, isif=2, **kwargs): elif uis['ISPIN']==1: if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] - - if 'Static_settings' in uis: - static = uis['Static_settings'] + + settings = a_kwargs.get('settings', {}) + static = settings.get('Static_settings', None) or uis.get('Static_settings', None) + if static: for ff in static: if ff.lower()=='prec': if 'ENCUT' in new_config['INCAR']: @@ -435,7 +436,7 @@ class ForcesSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, **kwargs): + def __init__(self, structure, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet old_kwargs = ['prev_incar', 'prev_kpoints', 'grid_density', 'lepsilon', 'lcalcpol'] for k in old_kwargs: @@ -482,7 +483,7 @@ class BornChargeSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, isif=2, **kwargs): + def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet self.isif = isif @@ -568,7 +569,7 @@ class ElasticSet(DictSet): CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' CONFIG['POTCAR'].update(POTCAR_UPDATES) - def __init__(self, structure, **kwargs): + def __init__(self, structure, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet uis = copy.deepcopy(kwargs.get('user_incar_settings', {})) diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index 820e8735..bc222372 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -238,11 +238,13 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) #check if fworker_name is assigned powerups = settings.get('powerups', {}) + """ if len(powerups)>0: if 'user_incar_settings' not in override_default_vasp_params: override_default_vasp_params.update({'user_incar_settings':{}}) override_default_vasp_params['user_incar_settings'].update({'powerups':powerups}) modify_incar_params.update({'powerups':powerups}) + """ #dict, dict of class ModifyKpoints with keywords in Workflow name, similar with modify_incar_params modify_kpoints_params = settings.get('modify_kpoints_params', {}) @@ -308,7 +310,7 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) """ if WORKFLOW == "eos": wf = get_wf_EV_bjb(structure, deformation_fraction=deformation_fraction, store_volumetric_data=store_volumetric_data, - num_deformations=num_deformations, override_symmetry_tolerances=override_default_vasp_params, metadata=metadata) + num_deformations=num_deformations, settings=settings, override_symmetry_tolerances=override_default_vasp_params, metadata=metadata) elif WORKFLOW == "singleV": wf = get_wf_singleV(structure, store_volumetric_data=store_volumetric_data, metadata=metadata, override_default_vasp_params=override_default_vasp_params, settings=settings) @@ -322,14 +324,17 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) override_default_vasp_params=override_default_vasp_params, modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, verbose=verbose, phonon_supercell_matrix_min=phonon_supercell_matrix_min, phonon_supercell_matrix_max=phonon_supercell_matrix_max, optimize_sc=optimize_sc, level=level, - force_phonon=force_phonon, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data) + force_phonon=force_phonon, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data' + settings=settings) elif WORKFLOW == "born": wf = get_wf_borncharge(structure=structure, metadata=metadata, db_file=db_file, isif=2, name="born charge", vasp_cmd=">>vasp_cmd<<", override_default_vasp_params=override_default_vasp_params, - modify_incar=modify_incar_params) + modify_incar=modify_incar_params, settings=settings) elif WORKFLOW == 'elastic': wf = get_wf_elastic(structure=structure, metadata=metadata, vasp_cmd=">>vasp_cmd<<", db_file=">>db_file<<", name="elastic", - override_default_vasp_params=override_default_vasp_params, strain_states=strain_states, + override_default_vasp_params=override_default_vasp_params, + settings=settings, + strain_states=strain_states, stencils=stencils, analysis=analysis, sym_reduce=sym_reduce, order=order, conventional=conventional) else: raise ValueError("Currently, only the gibbs energy workflow is supported.") diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 8ccf941e..96a16b4c 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -56,6 +56,7 @@ def _get_deformations(def_frac, num_def): def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetric_data=False, + settings={}, num_deformations=11, override_symmetry_tolerances=None, metadata=None): """ Perform an E-V curve, robustly relaxating all structures on the curve. @@ -82,13 +83,14 @@ def get_wf_EV_bjb(structure, deformation_fraction=(-0.08, 0.12), store_volumetri """ deformations = _get_deformations(deformation_fraction, num_deformations)*structure.volume + a_kwargs = {"settings":settings} fws = [] for defo in deformations: struct = deepcopy(structure) struct.scale_lattice(defo) full_relax_fw = RobustOptimizeFW(struct, isif=5, vasp_cmd=VASP_CMD, db_file=DB_FILE, - store_volumetric_data=store_volumetric_data) + a_kwargs = a_kwargs, store_volumetric_data=store_volumetric_data) fws.append(full_relax_fw) if metadata is not None and all(x in metadata for x in ('phase_name', 'sublattice_configuration')): # create a nicer name for the workflow @@ -139,7 +141,7 @@ def get_constrain(deformation_scheme, new_deformation_fraction): return axisa, axisb, axisc, pow(np.array(new_deformation_fraction),ppp) -def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings=None): +def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, override_default_vasp_params=None, settings={}): """ Perform single volume relaxation calculation. @@ -167,16 +169,17 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri else: isif = 2 axisa, axisb, axisc, new_deformations = get_constrain(deformation_scheme, new_deformation_fraction) - + a_kwargs = {"settings":settings} fws = [] for defo in new_deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, vasp_cmd=VASP_CMD, db_file=DB_FILE, name='Relax_with_ISIF='+str(isif)+'_and_defo={:5.3f}'.format(defo), + a_kwargs = a_kwargs, store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(full_relax_fw) static_fw = StaticFW(struct, isif=2, vasp_cmd=VASP_CMD, db_file=DB_FILE, - name='Staitc', + name='Staitc', a_kwargs = a_kwargs, vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(static_fw) @@ -190,7 +193,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri return wf -def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, +def get_wf_crosscom(structure, metadata=None, settings={}, run_num = 0, new_deformation_fraction=None): """ Perform cross computer QHA calculation without computer dependent. @@ -216,7 +219,6 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, num_deformations = settings.get('num_deformations', 8) if num_deformations==1: deformation_fraction[1] = deformation_fraction[0] - settings = settings or {} #bool, run phonon(True) or not(False) phonon = settings.get('phonon', False) #list(3x3), the supercell matrix for phonon, e.g. [[2.0, 0, 0], [0, 2.0, 0], [0, 0, 2.0]] @@ -245,6 +247,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, #dict, dict of class ModifyIncar with keywords in Workflow name. e.g. modify_incar_params = settings.get('modify_incar_params', {}) + """ #check if fworker_name is assigned powerups = settings.get('powerups', {}) if len(powerups)>0: @@ -252,6 +255,7 @@ def get_wf_crosscom(structure, metadata=None, settings=None, run_num = 0, override_default_vasp_params.update({'user_incar_settings':{}}) override_default_vasp_params['user_incar_settings'].update({'powerups':powerups}) modify_incar_params.update({'powerups':powerups}) + """ #dict, dict of class ModifyKpoints with keywords in Workflow name, similar with modify_incar_params modify_kpoints_params = settings.get('modify_kpoints_params', {}) @@ -334,7 +338,8 @@ def vol_in_volumes(vol, volumes): def get_wf_elastic(structure=None, metadata=None, tag=None, vasp_cmd=None, db_file=None, name="elastic", vasp_input_set=None, override_default_vasp_params=None, strain_states=None, stencils=None, - analysis=True, sym_reduce=False, order=2, conventional=False, **kwargs): + analysis=True, sym_reduce=False, order=2, conventional=False, + settings={}, **kwargs): ''' Parameter --------- @@ -366,6 +371,7 @@ def get_wf_elastic(structure=None, metadata=None, tag=None, vasp_cmd=None, db_fi db_file = db_file or DB_FILE override_default_vasp_params = override_default_vasp_params or {} + a_kwargs={'settings':settings} metadata = metadata or {} tag = metadata.get('tag', '{}'.format(str(uuid4()))) @@ -424,7 +430,7 @@ def get_wf_elastic(structure=None, metadata=None, tag=None, vasp_cmd=None, db_fi override_default_vasp_params['user_incar_settings'].update({'SIGMA': 0.05}) print(vasp_input_set.CONFIG['INCAR']) """ - vasp_input_set = vasp_input_set or ElasticSet(structure=_struct, **override_default_vasp_params) + vasp_input_set = vasp_input_set or ElasticSet(structure=_struct, a_kwargs=a_kwargs, **override_default_vasp_params) wf_elastic = get_wf_elastic_constant(struct, metadata, strain_states=strain_states, stencils=stencils, db_file=db_file, conventional=conventional, order=order, vasp_input_set=vasp_input_set, @@ -445,7 +451,8 @@ def get_wf_elastic(structure=None, metadata=None, tag=None, vasp_cmd=None, db_fi def get_wf_borncharge(structure=None, metadata=None, db_file=None, isif=2, name="born charge", vasp_input_set=None,vasp_cmd=None, override_default_vasp_params=None, - tag=None, modify_incar=None, **kwargs): + tag=None, modify_incar=None, + settings={}, **kwargs): ''' The born charge work flow @@ -506,7 +513,7 @@ def get_wf_borncharge(structure=None, metadata=None, db_file=None, isif=2, name= struct_energy_bandgap[0][0].composition.reduced_formula, " with tag:", tag, "\n") else: bandgap=False - + a_kwargs={'settings':settings} fws = [] if bandgap: if override_default_vasp_params is None: override_default_vasp_params = {} @@ -525,7 +532,7 @@ def get_wf_borncharge(structure=None, metadata=None, db_file=None, isif=2, name= fw = BornChargeFW(structure, isif=isif, name="{}-{:.3f}".format(name, structure.volume), vasp_cmd=vasp_cmd, metadata=metadata, modify_incar=modify_incar, override_default_vasp_params=override_default_vasp_params, tag=tag, - prev_calc_loc=False, db_file=db_file, **kwargs) + prev_calc_loc=False, db_file=db_file, a_kwargs=a_kwargs, **kwargs) fws.append(fw) else: if structure is None: @@ -534,7 +541,7 @@ def get_wf_borncharge(structure=None, metadata=None, db_file=None, isif=2, name= fw = BornChargeFW(structure, isif=isif, name="{}-{:.3f}".format(name, structure.volume), vasp_cmd=vasp_cmd, metadata=metadata, modify_incar=modify_incar, override_default_vasp_params=override_default_vasp_params, tag=tag, - prev_calc_loc=False, db_file=db_file, **kwargs) + prev_calc_loc=False, db_file=db_file, a_kwargs=a_kwargs, **kwargs) fws.append(fw) if not fws: raise ValueError('The system is metal or no static result under given metadata in the mongodb') @@ -563,6 +570,7 @@ def get_wf_gibbs_robust(structure, num_deformations=7, deformation_fraction=(-0. metadata=None, name='EV_QHA', override_default_vasp_params=None, modify_incar_params={}, modify_kpoints_params={}, verbose=False, level=1, phonon_supercell_matrix_min=60, phonon_supercell_matrix_max=120, optimize_sc=False, force_phonon=False, stable_tor=0.01, + settings={}, store_volumetric_data=False): """ E - V @@ -641,11 +649,12 @@ def get_wf_gibbs_robust(structure, num_deformations=7, deformation_fraction=(-0. vasp_kwargs = {'modify_incar_params': modify_incar_params, 'modify_kpoints_params': modify_kpoints_params} t_kwargs = {'t_min': t_min, 't_max': t_max, 't_step': t_step} eos_kwargs = {'deformations': deformations, 'vol_spacing': vol_spacing, 'eos_tolerance': eos_tolerance, 'threshold': 14} + a_kwargs = {'settings':settings} fws = [] robust_opt_fw = RobustOptimizeFW(structure, prev_calc_loc=False, name='Full relax', store_volumetric_data=store_volumetric_data, - **robust_opt_kwargs, **vasp_kwargs, **common_kwargs) + a_kwargs=a_kwargs, **robust_opt_kwargs, **vasp_kwargs, **common_kwargs) fws.append(robust_opt_fw) check_qha_parent = [] @@ -664,7 +673,7 @@ def get_wf_gibbs_robust(structure, num_deformations=7, deformation_fraction=(-0. raise ValueError('Current phonon_supercell_matrix({}) is not correct.'.format(phonon_supercell_matrix)) phonon_wf = PhononFW(structure, phonon_supercell_matrix, parents=robust_opt_fw, prev_calc_loc='static', name='structure_{:.3f}-phonon'.format(structure.volume), stable_tor=stable_tor, - **t_kwargs, **common_kwargs) + a_kwargs=a_kwargs, **t_kwargs, **common_kwargs) fws.append(phonon_wf) check_qha_parent.append(phonon_wf) @@ -675,7 +684,7 @@ def get_wf_gibbs_robust(structure, num_deformations=7, deformation_fraction=(-0. check_qha_fw = Firework(EVcheck_QHA(site_properties=site_properties,verbose=verbose, stable_tor=stable_tor, phonon=phonon, phonon_supercell_matrix=phonon_supercell_matrix, force_phonon=force_phonon, override_symmetry_tolerances=override_symmetry_tolerances, store_volumetric_data=store_volumetric_data, - **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), + a_kwargs=a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), parents=check_qha_parent, name='{}-EVcheck_QHA'.format(structure.composition.reduced_formula)) fws.append(check_qha_fw) @@ -692,6 +701,7 @@ def get_wf_gibbs(structure, num_deformations=7, deformation_fraction=(-0.1, 0.1) t_min=5, t_max=2000, t_step=5, tolerance = 0.01, volume_spacing_min = 0.03, vasp_cmd=None, db_file=None, metadata=None, name='EV_QHA', symmetry_tolerance = 0.05, passinitrun=False, relax_path='', modify_incar_params={}, + settings={}, modify_kpoints_params={}, verbose=False, store_volumetric_data=False): """ E - V @@ -812,6 +822,7 @@ def get_wf_gibbs_SQS(structure, num_deformations=7, deformation_fraction=(-0.1, t_min=5, t_max=2000, t_step=5, tolerance = 0.01, volume_spacing_min = 0.03, vasp_cmd=None, db_file=None, metadata=None, name='EV_QHA', symmetry_tolerance = 0.05, passinitrun=False, relax_path='', modify_incar_params={}, + settings={}, modify_kpoints_params={}, verbose=False, store_volumetric_data=False): """ E - V @@ -892,6 +903,7 @@ def get_wf_gibbs_SQS(structure, num_deformations=7, deformation_fraction=(-0.1, vis_PreStatic = PreStaticSet(structure1) prestatic = StaticFW(structure=structure1, scale_lattice=deformation, name='VR_%.3f-PreStatic' %deformation, prev_calc_loc=False, vasp_input_set=vis_PreStatic, vasp_cmd=vasp_cmd, db_file=db_file, + a_kwargs={'settings':settings}, metadata=metadata, Prestatic=True, store_volumetric_data=store_volumetric_data) fws.append(prestatic) @@ -901,6 +913,7 @@ def get_wf_gibbs_SQS(structure, num_deformations=7, deformation_fraction=(-0.1, tolerance = tolerance, threshold = 14, vol_spacing = vol_spacing, vasp_cmd = vasp_cmd, run_isif2=run_isif2, metadata = metadata, t_min=t_min, t_max=t_max, t_step=t_step, phonon = phonon, symmetry_tolerance = symmetry_tolerance, phonon_supercell_matrix = phonon_supercell_matrix, verbose = verbose, pass_isif4=pass_isif4, + a_kwargs={'settings':settings}, modify_incar_params=modify_incar_params, modify_kpoints_params = modify_kpoints_params), parents=prestatic_calcs, name='%s-PreEV_check' %structure.composition.reduced_formula) fws.append(check_result) From 3895aa711b225a88ab31f26bc243f261b71bffea Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 15 Oct 2021 22:50:15 -0400 Subject: [PATCH 049/111] up --- dfttk/input_sets.py | 75 +++++++++++++++++++++++++------------- dfttk/scripts/run_dfttk.py | 2 +- dfttk/wflows.py | 6 ++- 3 files changed, 54 insertions(+), 29 deletions(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index c73665ce..8b19a751 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -103,6 +103,7 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar self.kwargs = copy.deepcopy(kwargs) self.volume_relax = volume_relax self.isif = isif + self.a_kwargs = a_kwargs uis = copy.deepcopy(self.kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(RelaxSet.CONFIG) if self.volume_relax and self.isif is not None: @@ -125,20 +126,20 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar elif uis['ISPIN']==1: if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] - settings = a_kwargs.get('settings', {}) - relax = settings.get('Relax_settings', None) or uis.get('Relax_settings', None) - if relax: - for ff in relax: + settings = self.a_kwargs.get('settings', {}) + new_vasp_settings = settings.get('Relax_settings', None) or uis.get('Relax_settings', None) + if new_vasp_settings: + for ff in new_vasp_settings: if ff.lower()=='prec': if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') - new_config['INCAR'].update({ff:relax.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='KPAR': - new_config['INCAR'].update({ff:relax.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': - new_config['KPOINTS'].update({ff:relax.get(ff)}) + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': - kpoints = Kpoints(kpts=relax.get(ff)) + kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints #print (new_config) @@ -251,6 +252,8 @@ class ForceConstantsSet(DictSet): def __init__(self, structure, a_kwargs={}, **kwargs): self.kwargs = copy.deepcopy(kwargs) + self.a_kwargs = a_kwargs + uis = copy.deepcopy(self.kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(ForceConstantsSet.CONFIG) if 'ISPIN' not in uis: @@ -268,6 +271,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['INCAR'].update(uis) from pymatgen.io.vasp.inputs import Kpoints + """ user_kpoints_settings = kwargs.get('user_kpoints_settings', {}) grid_density = user_kpoints_settings.get('grid_density') or None if grid_density is not None: @@ -275,6 +279,22 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['INCAR'].update({'PREC': 'High'}) kpoints = Kpoints.automatic_gamma_density(structure, grid_density) new_config['KPOINTS'] = kpoints + """ + settings = self.a_kwargs.get('settings', {}) + new_vasp_settings = settings.get('Forceconstant_settings', None) or uis.get('Forceconstant_settings', None) + if new_vasp_settings: + for ff in new_vasp_settings: + if ff.lower()=='prec': + if 'ENCUT' in new_config['INCAR']: + new_config['INCAR'].pop('ENCUT') + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) + elif ff=='KPAR': + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) + elif ff=='grid_density': + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) + elif ff=='k_mesh': + kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) + new_config['KPOINTS'] = kpoints else: kpoints = Kpoints(kpts=[[3,3,3],]) new_config['KPOINTS'] = kpoints @@ -319,7 +339,8 @@ class StaticSet(DictSet): def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet self.isif = isif - + self.a_kwargs = a_kwargs + old_kwargs = ['prev_incar', 'prev_kpoints', 'grid_density', 'lepsilon', 'lcalcpol'] for k in old_kwargs: try: @@ -344,20 +365,20 @@ def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] - settings = a_kwargs.get('settings', {}) - static = settings.get('Static_settings', None) or uis.get('Static_settings', None) - if static: - for ff in static: + settings = self.a_kwargs.get('settings', {}) + new_vasp_settings = settings.get('Static_settings', None) or uis.get('Static_settings', None) + if new_vasp_settings: + for ff in new_vasp_settings: if ff.lower()=='prec': if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') - new_config['INCAR'].update({ff:static.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='KPAR': - new_config['INCAR'].update({ff:static.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': - new_config['KPOINTS'].update({ff:static.get(ff)}) + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': - kpoints = Kpoints(kpts=static.get(ff)) + kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints new_config['INCAR'].update(uis) @@ -571,7 +592,8 @@ class ElasticSet(DictSet): def __init__(self, structure, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet - + self.a_kwargs = a_kwargs + uis = copy.deepcopy(kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(ElasticSet.CONFIG) if metal_check(structure): grid_density = 15625 @@ -632,22 +654,23 @@ def __init__(self, structure, a_kwargs={}, **kwargs): kpoints = Kpoints(kpts=[[31,31,31],]) new_config['KPOINTS'] = kpoints - if 'Relax_settings' in uis: - relax = uis['Relax_settings'] - for ff in relax: + from pymatgen.io.vasp.inputs import Kpoints + settings = self.a_kwargs.get('settings', {}) + new_vasp_settings = settings.get('Elastic_settings', None) or uis.get('Elastic_settings', None) + if new_vasp_settings: + for ff in new_vasp_settings: if ff.lower()=='prec': if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') - new_config['INCAR'].update({ff:relax.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='KPAR': - new_config['INCAR'].update({ff:relax.get(ff)}) + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': - new_config['KPOINTS'].update({ff:relax.get(ff)}) + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) #kpoints = Kpoints.automatic_gamma_density(structure, grid_density) elif ff=='k_mesh': - kpoints = Kpoints(kpts=relax.get(ff)) + kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints - from pymatgen.io.vasp.inputs import Kpoints pot = self.kwargs.get('user_potcar_functional', None) if pot: diff --git a/dfttk/scripts/run_dfttk.py b/dfttk/scripts/run_dfttk.py index bc222372..c82a48d5 100644 --- a/dfttk/scripts/run_dfttk.py +++ b/dfttk/scripts/run_dfttk.py @@ -324,7 +324,7 @@ def get_wf_single(structure, WORKFLOW="get_wf_gibbs", settings={}, db_file=None) override_default_vasp_params=override_default_vasp_params, modify_incar_params=modify_incar_params, modify_kpoints_params=modify_kpoints_params, verbose=verbose, phonon_supercell_matrix_min=phonon_supercell_matrix_min, phonon_supercell_matrix_max=phonon_supercell_matrix_max, optimize_sc=optimize_sc, level=level, - force_phonon=force_phonon, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data' + force_phonon=force_phonon, stable_tor=stable_tor, store_volumetric_data=store_volumetric_data, settings=settings) elif WORKFLOW == "born": wf = get_wf_borncharge(structure=structure, metadata=metadata, db_file=db_file, isif=2, name="born charge", diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 96a16b4c..2da6aedc 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -306,6 +306,7 @@ def get_wf_crosscom(structure, metadata=None, settings={}, run_num = 0, axisa, axisb, axisc, new_deformations = get_constrain(deformation_scheme, new_deformation_fraction) fws = [] + parents_com = [] for defo in new_deformations: struct = scale_lattice_vector(structure, defo, axisa=axisa, axisb=axisb, axisc=axisc) full_relax_fw = OptimizeFW(struct, isif=isif, @@ -313,13 +314,14 @@ def get_wf_crosscom(structure, metadata=None, settings={}, run_num = 0, store_volumetric_data=store_volumetric_data, t_kwargs=t_kwargs, a_kwargs=a_kwargs, **common_kwargs, defo=defo) fws.append(full_relax_fw) - tmp = copy.deepcopy(fws) + parents_com.append(full_relax_fw) + if not single_volume: check_qha_fw = Firework(Crosscom_EVcheck_QHA(verbose=verbose, stable_tor=stable_tor, run_num = run_num, store_volumetric_data=store_volumetric_data, a_kwargs=a_kwargs, **eos_kwargs, **vasp_kwargs, **t_kwargs, **common_kwargs), - parents=tmp, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) + parents=parents_com, name='{}-Crosscom_EVcheck_QHA'.format(structure.composition.reduced_formula)) fws.append(check_qha_fw) wfname = "{}:{}".format(structure.composition.reduced_formula, 'EV_QHA_crosscom') From 81bbe9c8e0b2548ab33114fda87baf93a75f691a Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 19 Oct 2021 10:24:31 -0400 Subject: [PATCH 050/111] Update input_sets.py --- dfttk/input_sets.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 8b19a751..f42249d6 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -488,7 +488,7 @@ class BornChargeSet(DictSet): #"LCALCEPS": True, #For Born Effective Charge "LRPA": False, 'EDIFF_PER_ATOM': 1e-6, - 'ENCUT': 520, # MP compatibility + #'ENCUT': 520, # MP compatibility 'ISMEAR': 0, "NSW": 0, "LORBIT": 11, @@ -499,6 +499,7 @@ class BornChargeSet(DictSet): "LCHARG": False, "LWAVE": False, "ICHARG": 2, + "PREC": "High" }) CONFIG['POTCAR_FUNCTIONAL'] = 'PBE' @@ -540,6 +541,7 @@ def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] for key in uis.keys(): + if key == 'ENCUT': continue if key not in new_config['INCAR']: if key in {'NELM', 'EDIFF', 'NEDOS', 'KPOINT_BSE'} : continue new_config['INCAR'][key] = uis[key] @@ -568,7 +570,7 @@ class ElasticSet(DictSet): # 'EDIFF_PER_ATOM': 1e-6, CONFIG['INCAR'] = { 'EDIFF': 1e-6, - 'ENCUT': 520, # MP compatibility + #'ENCUT': 520, # MP compatibility 'ISMEAR': -5, "IBRION": 2, 'LREAL': False, @@ -600,10 +602,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): else: grid_density = 8000 user_kpoints_settings = kwargs.get('user_kpoints_settings', {}) grid_density = user_kpoints_settings.get('grid_density') or grid_density - """ - old_kwargs = ['prev_incar', 'prev_kpoints', 'grid_density', 'lepsilon', 'lcalcpol', \ - 'user_potcar_functional', 'user_incar_settings'] - """ + old_kwargs = ['prev_incar', 'prev_kpoints', 'grid_density', 'lepsilon', 'lcalcpol', \ 'user_incar_settings', 'user_kpoints_settings'] @@ -628,6 +627,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] for key in uis.keys(): + if key == 'ENCUT': continue if key not in new_config['INCAR']: if key in {'NELM', 'EDIFF', 'NEDOS', 'KPOINT_BSE'} : continue new_config['INCAR'][key] = uis[key] @@ -637,14 +637,15 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['INCAR'][key] = uis[key] elif key == 'SIGMA': new_config['INCAR'][key] = uis[key] - elif key == 'ENCUT': - new_config['INCAR'][key] = uis[key] + #avoid conflict betwwen HIHG and ENCUT + """ for key in uis.keys(): if key == 'PREC': new_config['INCAR'][key] = uis[key] if 'ENCUT' in new_config['INCAR'] : new_config['INCAR'].pop('ENCUT') + """ if 'SIGMA' in new_config['INCAR'] and 'ISMEAR' in new_config['INCAR'] : if new_config['INCAR']['ISMEAR'] == -5: From 3bc786b1d1f7b3940baf9945019e12bfc2b0caf9 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 22 Oct 2021 10:38:18 -0400 Subject: [PATCH 051/111] Update wflows.py --- dfttk/wflows.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dfttk/wflows.py b/dfttk/wflows.py index 2da6aedc..a237bafd 100644 --- a/dfttk/wflows.py +++ b/dfttk/wflows.py @@ -183,12 +183,7 @@ def get_wf_singleV(structure, store_volumetric_data=False, metadata=None, overri vasp_input_set=None, prev_calc_loc=True, parents=full_relax_fw, store_volumetric_data=store_volumetric_data, **common_kwargs) fws.append(static_fw) - if metadata is not None and all(x in metadata for x in ('phase_name', 'sublattice_configuration')): - # create a nicer name for the workflow - subl_config = ':'.join(','.join(subl_comps) for subl_comps in metadata['sublattice_configuration']) - wfname = f"{metadata['phase_name']}:{subl_config}:{structure.composition.reduced_formula}" - else: - wfname = f"unknown:{structure.composition.reduced_formula}:unknown" + wfname = "{}:{}".format(structure.composition.reduced_formula, 'singleV') wf = Workflow(fws, name=wfname, metadata=metadata) return wf From 95aa78aa94c5d0b50a987cb02383b51e0d734249 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 27 Oct 2021 11:50:15 -0400 Subject: [PATCH 052/111] Update input_sets.py --- dfttk/input_sets.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index f42249d6..dc700139 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -507,6 +507,7 @@ class BornChargeSet(DictSet): def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): # pop the old kwargs, backwards compatibility from the complex StaticSet + self.a_kwargs = a_kwargs self.isif = isif uis = copy.deepcopy(kwargs.get('user_incar_settings', {})) @@ -555,6 +556,25 @@ def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): if 'SIGMA' in new_config['INCAR'] and 'ISMEAR' in new_config['INCAR'] : if new_config['INCAR']['ISMEAR'] == -5: new_config['INCAR'].pop('SIGMA') + + from pymatgen.io.vasp.inputs import Kpoints + settings = self.a_kwargs.get('settings', {}) + new_vasp_settings = settings.get('Born_settings', None) or uis.get('Born_settings', None) + if new_vasp_settings: + for ff in new_vasp_settings: + if ff.lower()=='prec': + if 'ENCUT' in new_config['INCAR']: + new_config['INCAR'].pop('ENCUT') + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) + elif ff=='KPAR': + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) + elif ff=='grid_density': + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) + #kpoints = Kpoints.automatic_gamma_density(structure, grid_density) + elif ff=='k_mesh': + kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) + new_config['KPOINTS'] = kpoints + pot = self.kwargs.get('user_potcar_functional', None) if pot: new_config['POTCAR_FUNCTIONAL'] = pot From 3dead53186416eb42cb33b1547d28f52fbc7a9a5 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 4 Nov 2021 14:57:36 -0400 Subject: [PATCH 053/111] for get EV/Born data --- dfttk/analysis/ywplot.py | 9 +-- dfttk/pyEVfind.py | 122 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 6 deletions(-) diff --git a/dfttk/analysis/ywplot.py b/dfttk/analysis/ywplot.py index accfb047..8c8b0e63 100644 --- a/dfttk/analysis/ywplot.py +++ b/dfttk/analysis/ywplot.py @@ -642,10 +642,11 @@ def plot_EV(self): self.ax.plot(self.x, self.y, fillstyle='none', marker='o', markersize=12, color='k', linestyle='None', label=self._label) xnew = np.linspace(min(self.x)*0.95,max(self.x)*1.05, 300) - from dfttk.pythelec import BMvol4, BMvol, alt_curve_fit - f2, pcov = alt_curve_fit(BMvol4, self.x, self.y) - ynew = BMvol(xnew, f2) - self.ax.plot(xnew,ynew,'-',linewidth=1,color='b', label="BMvol4") + if len(self.x)>=4: + from dfttk.pythelec import BMvol4, BMvol, alt_curve_fit + f2, pcov = alt_curve_fit(BMvol4, self.x, self.y) + ynew = BMvol(xnew, f2) + self.ax.plot(xnew,ynew,'-',linewidth=1,color='b', label="BMvol4") def plot_Helmholtz_energy_v0(self): diff --git a/dfttk/pyEVfind.py b/dfttk/pyEVfind.py index 38312f6f..ef90fffd 100644 --- a/dfttk/pyEVfind.py +++ b/dfttk/pyEVfind.py @@ -187,10 +187,12 @@ def EV_find(self): else: phases[i] = pname[0]+potname[i]+EV['MagState'] if EV['natoms'] < self.natoms: continue - sys.stdout.write('{}, static: {:>2}, natoms: {:>3}, {}\n'.format(metadata, count[i], EV['natoms'], phases[i])) - folder = os.path.join(evdirhome,phases[i]) if not os.path.exists(folder): os.mkdir(folder) + self.num_Born = 0 + self.get_data(folder, EV, mm) + sys.stdout.write('{}, static: {:>2}, natoms: {:>3}, Born: {}, {}\n'.format(metadata, \ + count[i], EV['natoms'], self.num_Born, phases[i])) with open (os.path.join(folder,'POSCAR'), 'w') as fp: fp.write(POSCAR) readme = {} @@ -250,3 +252,119 @@ def EV_find(self): for j in range(len(i_volumes)): print(i_volumes[j], i_energies[j], file=fp_ev) thermoplot(folder,"0 K total energies (eV/atom)", i_volumes, i_energies) + + def get_data(self, phasename, EV, tag): + phdir = os.path.join(phasename,'Yphon') + if not os.path.exists(phdir): + os.mkdir(phdir) + + self.num_Born = self.get_dielecfij(phdir, tag) + for i in (self.vasp_db).db['phonon'].find({'metadata.tag': tag}): + try: + self.force_constant_factor = i['force_constant_factor'] + except: + if self.static_vasp_version[0:1] >= '6': + self.force_constant_factor = 0.004091649655126895 + + if i['volume'] not in EV['volumes']: continue + voldir = self.get_superfij(i, phdir, EV['volumes'], EV['energies']) + + + def get_superfij(self,i, phdir, volumes, energies): + try: + structure = Structure.from_dict(i['unitcell']) + except: + print("\nit seems phonon for", i['volume'],"is not finished yet and so it is discared\n") + return None + vol = 'V{:010.6f}'.format(float(i['volume'])) + voldir = os.path.join(phdir,vol) + if not os.path.exists(voldir): + os.mkdir(voldir) + elif os.path.exists(os.path.join(voldir,'superfij.out')): return voldir + + poscar = structure.to(fmt="poscar") + unitcell_l = str(poscar).split('\n') + natom = len(structure.sites) + + supercell_matrix = i['supercell_matrix'] + supercell_structure = copy.deepcopy(structure) + supercell_structure.make_supercell(supercell_matrix) + + sa = SpacegroupAnalyzer(supercell_structure) + #reduced_structure = supercell_structure.get_reduced_structure(reduction_algo='niggli') + #print ('niggli reduced structure', reduced_structure) + #poscar = reduced_structure.to(fmt="poscar") + primitive_unitcell_structure = sa.find_primitive() + poscar = primitive_unitcell_structure.to(fmt="poscar") + punitcell_l = str(poscar).split('\n') + + natoms = len(supercell_structure.sites) + ##print(supercell_structure.sites) + poscar = supercell_structure.to(fmt="poscar") + supercell_l = str(poscar).split('\n') + structure.to(filename=os.path.join(voldir,'POSCAR')) + + with open (os.path.join(voldir,'OSZICAR'),'w') as out: + out.write(' 1 F= xx E0= {}\n'.format(energies[(list(volumes)).index(i['volume'])])) + with open (os.path.join(voldir,'superfij.out'),'w') as out: + for line in range (2,5): + out.write('{}\n'.format(unitcell_l[line])) + for line in range (2,5): + out.write('{}\n'.format(supercell_l[line])) + out.write('{} {}\n'.format(natoms, natoms//natom)) + for line in range (7,natoms+8): + out.write('{}\n'.format(supercell_l[line])) + force_constant_matrix = np.array(i['force_constants']) + hessian_matrix = np.empty((natoms*3, natoms*3), dtype=float) + + for ii in range(natoms): + for jj in range(natoms): + for x in range(3): + for y in range(3): + hessian_matrix[ii*3+x, jj*3+y] = -force_constant_matrix[ii,jj,x,y] + + hessian_matrix *= self.force_constant_factor + if self.force_constant_factor!=1.0: + print ("\n force constant matrix has been rescaled by :", self.force_constant_factor) + + for xx in range(natoms*3): + for yy in range(natoms*3-1): + out.write('{} '.format(hessian_matrix[xx,yy])) + out.write('{}\n'.format(hessian_matrix[xx,natoms*3-1])) + return voldir + + def get_dielecfij(self, phdir, tag): + + volumes_b = (self.vasp_db).db['borncharge'].find({'metadata.tag': tag}, {'_id':0, 'volume':1}) + volumes_b = [i['volume'] for i in volumes_b] + num_Born = len(volumes_b) + if num_Born>0: + for i in (self.vasp_db).db['borncharge'].find({'metadata.tag': tag}): + vol = 'V{:010.6f}'.format(float(i['volume'])) + voldir = phdir+'/'+vol + if not os.path.exists(voldir): + os.mkdir(voldir) + + structure = Structure.from_dict(i['structure']) + poscar = structure.to(fmt="poscar") + poscar = str(poscar).split('\n') + natom = len(structure.sites) + with open (voldir+'/dielecfij.out','w') as out: + for line in range (2,5): + out.write('{}\n'.format(poscar[line])) + for line in range (8,natom+8): + out.write('{}\n'.format(poscar[line])) + dielectric_tensor = np.array(i['dielectric_tensor']) + for x in range(3): + for y in range(3): + out.write('{} '.format(dielectric_tensor[x,y])) + out.write('\n') + born_charge = np.array(i['born_charge']) + for ii in range(natom): + out.write(' ion {}\n'.format(ii+1)) + for x in range(3): + out.write(' {} '.format(x+1)) + for y in range(3): + out.write('{} '.format(born_charge[ii,x,y])) + out.write('\n') + return num_Born From 10d3d727861e7bb3d031f3721a76072ad24e792f Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 8 Nov 2021 16:09:20 -0500 Subject: [PATCH 054/111] minor update --- dfttk/pyEVfind.py | 24 ++++++++++++++++++++++-- dfttk/pythelec.py | 4 +++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dfttk/pyEVfind.py b/dfttk/pyEVfind.py index ef90fffd..96198589 100644 --- a/dfttk/pyEVfind.py +++ b/dfttk/pyEVfind.py @@ -191,8 +191,8 @@ def EV_find(self): if not os.path.exists(folder): os.mkdir(folder) self.num_Born = 0 self.get_data(folder, EV, mm) - sys.stdout.write('{}, static: {:>2}, natoms: {:>3}, Born: {}, {}\n'.format(metadata, \ - count[i], EV['natoms'], self.num_Born, phases[i])) + sys.stdout.write('{}, static: {:>2}, natoms: {:>3}, phonon: {:>2}, Born: {}, {}\n'.format(metadata, \ + count[i], EV['natoms'], self.num_phonon, self.num_Born, phases[i])) with open (os.path.join(folder,'POSCAR'), 'w') as fp: fp.write(POSCAR) readme = {} @@ -259,17 +259,37 @@ def get_data(self, phasename, EV, tag): os.mkdir(phdir) self.num_Born = self.get_dielecfij(phdir, tag) + vasp_version = list(self.vasp_db.db['tasks'].find({'$and':[ {'metadata.tag': tag}, { 'calcs_reversed': { '$exists': True } }]})) + self.static_vasp_version = None + for i in vasp_version: + v = i['calcs_reversed'][0]['vasp_version'] + #print ("xxxxxxxx", v) + if self.static_vasp_version is None: self.static_vasp_version = v + """ + elif v[0:3]!=self.static_vasp_version[0:3]: + print("\n***********FETAL messing up calculation! please remove:", tag, "\n") + """ + """ + if self.static_vasp_version is not None: + print("\nvasp version for the static calculation is:", self.static_vasp_version, " for ", tag, "\n") + """ + + self.num_phonon = 0 for i in (self.vasp_db).db['phonon'].find({'metadata.tag': tag}): try: self.force_constant_factor = i['force_constant_factor'] except: if self.static_vasp_version[0:1] >= '6': self.force_constant_factor = 0.004091649655126895 + else: + self.force_constant_factor = 1.0 if i['volume'] not in EV['volumes']: continue + self.num_phonon += 1 voldir = self.get_superfij(i, phdir, EV['volumes'], EV['energies']) + def get_superfij(self,i, phdir, volumes, energies): try: structure = Structure.from_dict(i['unitcell']) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 5912046f..7481b33a 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1436,6 +1436,8 @@ def toYphon(self, _T=None, for_plot=False): except: if self.static_vasp_version[0:1] >= '6': self.force_constant_factor = 0.004091649655126895 + else: + self.force_constant_factor = 1.0 if i['volume'] not in self.volumes: continue voldir = self.get_superfij(i, phdir) @@ -1658,7 +1660,7 @@ def find_static_calculations(self): for i in vasp_version: v = i['calcs_reversed'][0]['vasp_version'] if self.static_vasp_version is None: self.static_vasp_version = v - elif v[0:1]!=self.static_vasp_version[0:1]: + elif v[0:3]!=self.static_vasp_version[0:3]: print("\n***********FETAL messing up calculation! please remove:", self.tag, "\n") if self.static_vasp_version is not None: print("\nvasp version for the static calculation is:", self.static_vasp_version, " for ", self.tag, "\n") From 58d0a3c55202bc6928482ff246c81a32b2376f0e Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 9 Nov 2021 11:53:58 -0500 Subject: [PATCH 055/111] Update EVcheck_QHA.py --- dfttk/EVcheck_QHA.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/EVcheck_QHA.py b/dfttk/EVcheck_QHA.py index be827409..860dc3e9 100644 --- a/dfttk/EVcheck_QHA.py +++ b/dfttk/EVcheck_QHA.py @@ -577,7 +577,7 @@ def check_vol_coverage(self, volume, vol_spacing, vol_orig, run_num, energy, str vol_spacing = volumer[-1] - volumer[-2] for i in range(idx+1+nV_addR-nV): result.append(volumer[-1] + (i+1)*vol_spacing) - raise ValueError('************* {}'.format(results)) + #raise ValueError('************* {}'.format(results)) return(np.array(result)) def check_fit(self, volumes, energies): From 2e6e33c497a8d01c1da54c6fdfc917b175328c2e Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 11 Nov 2021 17:11:00 -0500 Subject: [PATCH 056/111] Update input_sets.py --- dfttk/input_sets.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index dc700139..02eee503 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -134,14 +134,13 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) - elif ff=='KPAR': - new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints - #print (new_config) + else: + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) new_config['INCAR'].update(uis) pot = self.kwargs.get('user_potcar_functional', None) @@ -288,13 +287,13 @@ def __init__(self, structure, a_kwargs={}, **kwargs): if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) - elif ff=='KPAR': - new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints + else: + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) else: kpoints = Kpoints(kpts=[[3,3,3],]) new_config['KPOINTS'] = kpoints @@ -373,13 +372,13 @@ def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) - elif ff=='KPAR': - new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints + else: + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) new_config['INCAR'].update(uis) pot = self.kwargs.get('user_potcar_functional', None) @@ -566,14 +565,13 @@ def __init__(self, structure, isif=2, a_kwargs={}, **kwargs): if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) - elif ff=='KPAR': - new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) - #kpoints = Kpoints.automatic_gamma_density(structure, grid_density) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints + else: + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) pot = self.kwargs.get('user_potcar_functional', None) if pot: @@ -684,14 +682,13 @@ def __init__(self, structure, a_kwargs={}, **kwargs): if 'ENCUT' in new_config['INCAR']: new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) - elif ff=='KPAR': - new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) - #kpoints = Kpoints.automatic_gamma_density(structure, grid_density) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints + else: + new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) pot = self.kwargs.get('user_potcar_functional', None) if pot: From 10355a831f770f19822e6969cdea03f3e2ca40ad Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 18 Nov 2021 16:40:43 -0500 Subject: [PATCH 057/111] Update index.rst --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 18445299..e5839685 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -161,7 +161,7 @@ The solution is to make the best use of `ISIF Date: Thu, 18 Nov 2021 16:43:54 -0500 Subject: [PATCH 058/111] Update index.rst --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index e5839685..18445299 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -161,7 +161,7 @@ The solution is to make the best use of `ISIF Date: Wed, 8 Dec 2021 17:42:17 -0500 Subject: [PATCH 059/111] Update pythelec.py --- dfttk/pythelec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 7481b33a..b1595f26 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1462,7 +1462,7 @@ def toYphon(self, _T=None, for_plot=False): if self.debug: _nqwave = "-nqwave "+ str(1.e4) #md = "Yphon -tranI 2 -DebCut 0.5 " +_nqwave+ " Date: Thu, 9 Dec 2021 17:51:18 -0500 Subject: [PATCH 060/111] updates for bug fix --- dfttk/input_sets.py | 2 +- docs/source/troubleshooting.rst | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 02eee503..ec057b2f 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -683,7 +683,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': - new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) + new_config['KPOINTS']={ff:new_vasp_settings.get(ff)} elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index fbd8869a..7c3fbc74 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -71,6 +71,23 @@ Following are the steps of adding API key number on DFTTK. a reason that was not caught and handled by Custodian. Check the output files in the launch directory and see if there are any errors in the VASP output or stdout/stderr. +atomate issue +============= + + atomate not compatible with pymongo >=4.0, you can sovle it by:: + + pip uninstall pymongo + + pip install pymongo==3.11.3 + + pip uninstall maggma + + pip install maggma==0.26.0 + +fireworks issue +=============== + + fireworks>=1.9.5 requires UTF-8 for for Windows, you should turn it on Windows setting (system locale) pymatgen 2021 issue =================== From 64527bdd0895438b9e521b3f6019a040b4794d14 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 10 Dec 2021 11:18:51 -0500 Subject: [PATCH 061/111] Update input_sets.py --- dfttk/input_sets.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index ec057b2f..56fba518 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -585,6 +585,12 @@ class ElasticSet(DictSet): Kpoints have a 6000 reciprocal density default. """ CONFIG = _load_yaml_config("MPRelaxSet") + + CONFIG['KPOINTS'].update({ + 'grid_density': 8000, + }) + CONFIG['KPOINTS'].pop('reciprocal_density') # to be explicit + # 'EDIFF_PER_ATOM': 1e-6, CONFIG['INCAR'] = { 'EDIFF': 1e-6, @@ -668,14 +674,15 @@ def __init__(self, structure, a_kwargs={}, **kwargs): if 'SIGMA' in new_config['INCAR'] and 'ISMEAR' in new_config['INCAR'] : if new_config['INCAR']['ISMEAR'] == -5: new_config['INCAR'].pop('SIGMA') - - from pymatgen.io.vasp.inputs import Kpoints - kpoints = Kpoints(kpts=[[31,31,31],]) - new_config['KPOINTS'] = kpoints from pymatgen.io.vasp.inputs import Kpoints settings = self.a_kwargs.get('settings', {}) new_vasp_settings = settings.get('Elastic_settings', None) or uis.get('Elastic_settings', None) + + if 'grid_density' not in new_vasp_settings: + kpoints = Kpoints(kpts=[[31,31,31],]) + new_config['KPOINTS'] = kpoints + if new_vasp_settings: for ff in new_vasp_settings: if ff.lower()=='prec': @@ -683,7 +690,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['INCAR'].pop('ENCUT') new_config['INCAR'].update({ff:new_vasp_settings.get(ff)}) elif ff=='grid_density': - new_config['KPOINTS']={ff:new_vasp_settings.get(ff)} + new_config['KPOINTS'].update({ff:new_vasp_settings.get(ff)}) elif ff=='k_mesh': kpoints = Kpoints(kpts=new_vasp_settings.get(ff)) new_config['KPOINTS'] = kpoints From 3ade2b326ed4150349a31176580b55157726070d Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 14 Dec 2021 09:49:06 -0500 Subject: [PATCH 062/111] elastic update --- dfttk/elasticity/parse_outputs.py | 9 +++++++-- dfttk/input_sets.py | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dfttk/elasticity/parse_outputs.py b/dfttk/elasticity/parse_outputs.py index 9883ccf1..2e54aacd 100644 --- a/dfttk/elasticity/parse_outputs.py +++ b/dfttk/elasticity/parse_outputs.py @@ -305,9 +305,14 @@ def run_task(self, fw_spec): } vasp_input_set = env_chk(self.get('vasp_input_set'), False) if vasp_input_set: + from pymatgen.io.vasp.inputs import Kpoints d['vasp_input_set_all'] = vasp_input_set.config - d['vasp_input_set'] = {'INCAR':vasp_input_set.config['INCAR'], \ - 'KPOINTS':vasp_input_set.config['KPOINTS'].as_dict()} + if isinstance(new_config['KPOINTS'], Kpoints): + d['vasp_input_set'] = {'INCAR':vasp_input_set.config['INCAR'], \ + 'KPOINTS':vasp_input_set.config['KPOINTS'].as_dict()} + else: + d['vasp_input_set'] = {'INCAR':vasp_input_set.config['INCAR'], \ + 'KPOINTS':vasp_input_set.config['KPOINTS']} # Get optimized structure calc_locs_opt = [cl for cl in fw_spec.get('calc_locs', []) if 'optimiz' in cl['name']] diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 56fba518..4ca93651 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -702,4 +702,3 @@ def __init__(self, structure, a_kwargs={}, **kwargs): new_config['POTCAR_FUNCTIONAL'] = pot super(ElasticSet, self).__init__(structure, new_config, sort_structure=False, **self.kwargs) self.config = new_config - From 18669259443b64f044c123d71b29b853fce76ac7 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 14 Dec 2021 11:13:50 -0500 Subject: [PATCH 063/111] Update parse_outputs.py --- dfttk/elasticity/parse_outputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/elasticity/parse_outputs.py b/dfttk/elasticity/parse_outputs.py index 2e54aacd..ec0fdfdc 100644 --- a/dfttk/elasticity/parse_outputs.py +++ b/dfttk/elasticity/parse_outputs.py @@ -307,7 +307,7 @@ def run_task(self, fw_spec): if vasp_input_set: from pymatgen.io.vasp.inputs import Kpoints d['vasp_input_set_all'] = vasp_input_set.config - if isinstance(new_config['KPOINTS'], Kpoints): + if isinstance(vasp_input_set.config['KPOINTS'], Kpoints): d['vasp_input_set'] = {'INCAR':vasp_input_set.config['INCAR'], \ 'KPOINTS':vasp_input_set.config['KPOINTS'].as_dict()} else: From 49da7da0fb70843b1984cc80389751287b80f093 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 15 Dec 2021 15:43:39 -0500 Subject: [PATCH 064/111] Update fworks.py --- dfttk/fworks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index 25705932..f8bbab33 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -76,10 +76,14 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole """ tmp = copy.deepcopy(override_default_vasp_params) - if isif!=4 and isif!=3: + if isif>4: + for _key in tmp: + if 'EDIFFG' in tmp[_key]: + tmp[_key].pop('EDIFFG') if 'user_incar_settings' in tmp: if 'EDIFFG' in tmp['user_incar_settings']: tmp['user_incar_settings'].pop('EDIFFG') + override_symmetry_tolerances = override_symmetry_tolerances or {} vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, From 5b4fc4df892c67230e154548101e3412433f97d3 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 15 Dec 2021 16:07:43 -0500 Subject: [PATCH 065/111] Update fworks.py --- dfttk/fworks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index f8bbab33..b8f85633 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -77,17 +77,21 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole tmp = copy.deepcopy(override_default_vasp_params) if isif>4: - for _key in tmp: - if 'EDIFFG' in tmp[_key]: - tmp[_key].pop('EDIFFG') if 'user_incar_settings' in tmp: if 'EDIFFG' in tmp['user_incar_settings']: tmp['user_incar_settings'].pop('EDIFFG') + tmp_a_kwargs = copy.deepcopy(a_kwargs) + if isif>4: + if 'settings' in tmp_a_kwargs: + for _key in tmp_a_kwargs['settings']: + if 'EDIFFG' in tmp_a_kwargs['settings'][_key]: + tmp_a_kwargs['settings'][_key].pop('EDIFFG') + override_symmetry_tolerances = override_symmetry_tolerances or {} vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, - a_kwargs=a_kwargs, **tmp) + a_kwargs=tmp_a_kwargs, **tmp) site_properties = deepcopy(structure).site_properties t = [] From ec5b83250396ce363a962d8d72ae9a91d82052d9 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 15 Dec 2021 16:58:25 -0500 Subject: [PATCH 066/111] bug fix for isif >4 --- dfttk/fworks.py | 15 +-------------- dfttk/input_sets.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dfttk/fworks.py b/dfttk/fworks.py index b8f85633..0552c00d 100644 --- a/dfttk/fworks.py +++ b/dfttk/fworks.py @@ -74,24 +74,11 @@ def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tole if len (override_default_vasp_params)==0: override_default_vasp_params = a_kwargs.get("override_default_vasp_params", {}) """ - - tmp = copy.deepcopy(override_default_vasp_params) - if isif>4: - if 'user_incar_settings' in tmp: - if 'EDIFFG' in tmp['user_incar_settings']: - tmp['user_incar_settings'].pop('EDIFFG') - - tmp_a_kwargs = copy.deepcopy(a_kwargs) - if isif>4: - if 'settings' in tmp_a_kwargs: - for _key in tmp_a_kwargs['settings']: - if 'EDIFFG' in tmp_a_kwargs['settings'][_key]: - tmp_a_kwargs['settings'][_key].pop('EDIFFG') override_symmetry_tolerances = override_symmetry_tolerances or {} vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma, - a_kwargs=tmp_a_kwargs, **tmp) + a_kwargs=a_kwargs, **override_default_vasp_params) site_properties = deepcopy(structure).site_properties t = [] diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 4ca93651..370de145 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -103,7 +103,21 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar self.kwargs = copy.deepcopy(kwargs) self.volume_relax = volume_relax self.isif = isif - self.a_kwargs = a_kwargs + self.a_kwargs = copy.deepcopy(a_kwargs) + + if isif>4: + if 'user_incar_settings' in self.kwargs: + if 'EDIFFG' in self.kwargs['user_incar_settings']: + self.kwargs['user_incar_settings'].pop('EDIFFG') + + if 'settings' in self.a_kwargs: + try: + for _key in self.a_kwargs['settings']: + if 'EDIFFG' in self.a_kwargs['settings'][_key]: + self.a_kwargs['settings'][_key].pop('EDIFFG') + except: + pass + uis = copy.deepcopy(self.kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(RelaxSet.CONFIG) if self.volume_relax and self.isif is not None: @@ -126,6 +140,7 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar elif uis['ISPIN']==1: if 'MAGMON' in uis.keys(): uis.pop['MAGMOM'] if 'MAGMON' in new_config['INCAR']: new_config['INCAR'].pop['MAGMOM'] + settings = self.a_kwargs.get('settings', {}) new_vasp_settings = settings.get('Relax_settings', None) or uis.get('Relax_settings', None) if new_vasp_settings: From eafb37f980ebe4545e9fc2c98e3742aeaafb1ecb Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 15 Dec 2021 17:41:37 -0500 Subject: [PATCH 067/111] Update input_sets.py --- dfttk/input_sets.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 370de145..934efd39 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -105,7 +105,11 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar self.isif = isif self.a_kwargs = copy.deepcopy(a_kwargs) - if isif>4: + if self.volume_relax and self.isif is not None: + raise ValueError("isif cannot have a value while volume_relax is True.") + + no_position_relax = self.isif is None or self.isif>4 + if self.volume_relax or no_position_relax: if 'user_incar_settings' in self.kwargs: if 'EDIFFG' in self.kwargs['user_incar_settings']: self.kwargs['user_incar_settings'].pop('EDIFFG') @@ -120,11 +124,9 @@ def __init__(self, structure, volume_relax=False, isif=None, a_kwargs={}, **kwar uis = copy.deepcopy(self.kwargs.get('user_incar_settings', {})) new_config = copy.deepcopy(RelaxSet.CONFIG) - if self.volume_relax and self.isif is not None: - raise ValueError("isif cannot have a value while volume_relax is True.") + if self.volume_relax: uis.update({'ISIF': 7}) - #uis['ISIF'] = 7 if self.isif is not None: uis.update({'ISIF': self.isif}) From 435ef1182acd5866168e6e24d86c54b1ffb8d9ff Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 10 Feb 2022 16:22:04 -0500 Subject: [PATCH 068/111] debug --- dfttk/analysis/ywplot.py | 23 +++++++++++++++++------ dfttk/input_sets.py | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dfttk/analysis/ywplot.py b/dfttk/analysis/ywplot.py index 8c8b0e63..67a094b2 100644 --- a/dfttk/analysis/ywplot.py +++ b/dfttk/analysis/ywplot.py @@ -2367,19 +2367,30 @@ def Plot298(folder, V298, volumes, debug=False, plottitle=None, local=None): ydir = os.path.join(folder,'..') vdict = {} + emin = 1.0e36 for root, dirs, files in os.walk(ydir): for dir in dirs: poscar = os.path.join(ydir,dir,'POSCAR') + if os.path.exists(poscar): structure = Structure.from_file(poscar) vol = 'V{:010.6f}'.format(structure.volume) vdict[vol]=dir - try: - natom = len(structure.sites) - sa = SpacegroupAnalyzer(structure) - ngroup = sa.get_space_group_number() - except: - return + oszicar = os.path.join(ydir,dir, 'OSZICAR') + if not os.path.exists(poscar): continue + with open(oszicar,"r") as fp: + lines = fp.readlines() + for line in lines: + dat = [s for s in line.split() if s!=""] + if len(dat) < 5: continue + if dat[1]!="F=" or dat[3]!="E0=": continue + e = float(dat[4]) + if e < emin: + emin = e + natom = len(structure.sites) + sa = SpacegroupAnalyzer(structure) + ngroup = sa.get_space_group_number() + print("xxxxxxxxxxxxx", ngroup) #print(natom,ngroup) i1 = 0 diff --git a/dfttk/input_sets.py b/dfttk/input_sets.py index 934efd39..6c8d59a5 100644 --- a/dfttk/input_sets.py +++ b/dfttk/input_sets.py @@ -695,7 +695,7 @@ def __init__(self, structure, a_kwargs={}, **kwargs): from pymatgen.io.vasp.inputs import Kpoints settings = self.a_kwargs.get('settings', {}) new_vasp_settings = settings.get('Elastic_settings', None) or uis.get('Elastic_settings', None) - + if 'grid_density' not in new_vasp_settings: kpoints = Kpoints(kpts=[[31,31,31],]) new_config['KPOINTS'] = kpoints From b6f8f99cb5f975390c2df01eacd91e7b9b6d8af2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 14 Nov 2022 09:13:36 -0500 Subject: [PATCH 069/111] more changes from local computers --- dfttk/analysis/debye.py | 4 +++- dfttk/analysis/ywplot.py | 3 +-- dfttk/pythelec.py | 31 ++++++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/dfttk/analysis/debye.py b/dfttk/analysis/debye.py index d865cbca..518ef989 100644 --- a/dfttk/analysis/debye.py +++ b/dfttk/analysis/debye.py @@ -202,8 +202,10 @@ def debye_temperature(self, volume): # Low temperature limit: 1 # take 0 K E-V curve properties dBdP = self.ev_eos_fit.b1 # bulk modulus/pressure derivative + debye = s*A * (self.ev_eos_fit.v0*1.e-30/self.natoms) ** (1. / 6.) * np.sqrt(self.bulk_modulus*1e9/self.avg_mass) gamma = (1+dBdP)/2 - self.bp2gru # 0K equilibrium Gruneisen parameter - return debye * (self.ev_eos_fit.v0 / volume) ** (gamma) + debye = debye*(self.ev_eos_fit.v0 / volume) ** (gamma) + return debye else: return debye diff --git a/dfttk/analysis/ywplot.py b/dfttk/analysis/ywplot.py index 67a094b2..8b5354be 100644 --- a/dfttk/analysis/ywplot.py +++ b/dfttk/analysis/ywplot.py @@ -617,7 +617,7 @@ def __init__(self, folder,thermodynamicproperty,x,y,reflin=None, yzero=None,fitt elif self.thermodynamicproperty.lower()!="heat capacities (J/mol-atom/K)".lower(): self.plot_default() else: self.plot_Heat_Capacity() - if self.plottitle!=None: plt.title(self.plottitle) + #if self.plottitle!=None: plt.title(self.plottitle) plt.xlabel(self._xlabel) plt.ylabel(self._ylabel) self.ax.legend(loc=0, prop={'size': 24}) @@ -2390,7 +2390,6 @@ def Plot298(folder, V298, volumes, debug=False, plottitle=None, local=None): natom = len(structure.sites) sa = SpacegroupAnalyzer(structure) ngroup = sa.get_space_group_number() - print("xxxxxxxxxxxxx", ngroup) #print(natom,ngroup) i1 = 0 diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index b1595f26..13d5c270 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1624,8 +1624,14 @@ def find_static_calculations(self): tmp = _calc['input']['pseudo_potential'] tmp['functional'] = potsoc key_comments['pseudo_potential'] = tmp - key_comments['ENCUT'] = _calc['input']['incar']['ENCUT'] - key_comments['NEDOS'] = _calc['input']['incar']['NEDOS'] + try: + key_comments['ENCUT'] = _calc['input']['incar']['ENCUT'] + except: + pass + try: + key_comments['NEDOS'] = _calc['input']['incar']['NEDOS'] + except: + pass try: key_comments['LSORBIT'] = _calc['input']['incar']['LSORBIT'] except: @@ -2339,6 +2345,7 @@ def calc_thermodynamics(self): def datasm(self, fname): data = np.loadtxt(fname, comments="#", dtype=float) + data_orig = copy.deepcopy(data) nT = data.shape[0] nF = data.shape[1] nSmooth = 11 @@ -2348,7 +2355,8 @@ def datasm(self, fname): for i in range(1,nF): #data[:,i]=np.convolve(data[:,i], box, mode='same') data[:,i]=savgol_filter(data[:,i], nSmooth, 3) - with open(fname+'_sm', 'w') as fout: + + with open(fname+'_sm.csv', 'w') as fout: with open(fname, 'r') as fin: lines = fin.readlines() for line in lines: @@ -2357,9 +2365,19 @@ def datasm(self, fname): for i in range(0,nT): for j in range(0,nF): if j==nF-1: fout.write('{}\n'.format(data[i,j])) - else: fout.write('{} '.format(data[i,j])) + else: fout.write('{}, '.format(data[i,j])) + + with open(fname+'.csv', 'w') as fout: + with open(fname, 'r') as fin: + lines = fin.readlines() + for line in lines: + if line.startswith('#'): print(line.strip(),file=fout) + for i in range(0,nT): + for j in range(0,nF): + if j==nF-1: fout.write('{}\n'.format(data_orig[i,j])) + else: fout.write('{}, '.format(data_orig[i,j])) def add_comput_inf(self): if self.vasp_db!=None: @@ -2759,7 +2777,10 @@ def calc_Cij_S(self): def run_console(self): - finished_tags = finished_calc() + try: + finished_tags = finished_calc() + except: + finished_tags = {} if not self.renew: if self.tag is not None: if self.tag in finished_tags: From de7cd4c57d2dbc3de5fbd9f23267c21e3d5b01ef Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 14 Nov 2022 10:12:03 -0500 Subject: [PATCH 070/111] Update pythelec.py --- dfttk/pythelec.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 13d5c270..3bdc46fa 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -893,6 +893,12 @@ def vol_within(vol, volumes, thr=0.001): return False +def vol_within_index(vol, volumes, thr=0.001): + for i,v in enumerate(volumes): + if (abs(vol-v) < thr): return i + return -1 + + def vol_closest(vol, volumes, thr=1.e-6): for i,v in enumerate(volumes): if (abs(vol-v) < thr*vol): return i @@ -1068,7 +1074,7 @@ def __init__(self, t0, t1, td, xdn, xup, dope, ndosmx, gaussian, natfactor, outf def get_superfij(self,i, phdir): - if vol_within(float(i['volume']), self.Vlat): + if vol_within(float(i['volume']), self.Vlat, thr=1.e-6): print("\nit seems a repeated phonon calculation for", i['volume'],"so it is discared\n") return None try: @@ -1105,6 +1111,9 @@ def get_superfij(self,i, phdir): structure.to(filename=os.path.join(voldir,'POSCAR')) with open (os.path.join(voldir,'metadata.json'),'w') as out: + idx = vol_within_index(i['volume'],self.volumes, thr=1.e-3) + #print("iiiiiiiiii idx=", idx, i['volume'],self.volumes) + if idx >=0: mm = i['metadata'] mm['volume'] = i['volume'] mm['energy'] = self.energies[(list(self.volumes)).index(i['volume'])] @@ -1121,7 +1130,8 @@ def get_superfij(self,i, phdir): with open (os.path.join(voldir,'OSZICAR'),'w') as out: - out.write(' 1 F= xx E0= {}\n'.format(self.energies[(list(self.volumes)).index(i['volume'])])) + idx = vol_within_index(i['volume'],self.volumes, thr=1.e-3) + if idx >0: out.write(' 1 F= xx E0= {}\n'.format(self.energies[idx])) with open (os.path.join(voldir,'superfij.out'),'w') as out: for line in range (2,5): out.write('{}\n'.format(unitcell_l[line])) @@ -1433,13 +1443,18 @@ def toYphon(self, _T=None, for_plot=False): for i in (self.vasp_db).db['phonon'].find({'metadata.tag': self.tag}): try: self.force_constant_factor = i['force_constant_factor'] + if self.static_vasp_version[0:1] >= '6' and self.static_vasp_version[0:3] < '6.2': + self.force_constant_factor /= 0.004091649655126895 except: if self.static_vasp_version[0:1] >= '6': self.force_constant_factor = 0.004091649655126895 else: self.force_constant_factor = 1.0 - if i['volume'] not in self.volumes: continue + #if i['volume'] not in self.volumes: + if not vol_within(i['volume'], self.volumes, thr=1.e-3): + print (i['volume'], "is not within", self.volumes) + continue voldir = self.get_superfij(i, phdir) if voldir is None: continue @@ -1558,7 +1573,7 @@ def check_vol(self): for i,v in enumerate (self.Vlat): fvol = False for j,vol in enumerate(self.volumes): - if abs(vol-v)<1.e-8: + if abs(vol-v)<1.e-6: print (v, self.energies[j]) fvol = True if not fvol: @@ -1571,7 +1586,8 @@ def check_vol(self): _e = [] _d = [] for i, vol in enumerate(list(self.volumes)): - if vol not in self.Vlat: + #if vol not in self.Vlat: + if not vol_within(vol,self.Vlat,thr=1.e-3): print ("data in static calculation with volume=", vol, "is discarded") continue _v.append(vol) @@ -2078,9 +2094,10 @@ def get_qha(self): Flat = [] Dlat = [] for i, vol in enumerate(_Vlat): - if vol_within(vol, Vlat): continue + if vol_within(vol, Vlat, thr=1.e-3): continue #if vol in Vlat: continue - if vol not in self.volumes: continue + if not vol_within(vol, self.volumes, thr=1.e-3): continue + #if vol not in self.volumes: continue Vlat.append(vol) Slat.append(_Slat[i]) Clat.append(_Clat[i]) From df3a5d71d1a4946d287ff523186699b6767ed65a Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 14 Nov 2022 14:43:22 -0500 Subject: [PATCH 071/111] 20221114 fix versions for pymatgen, automate, and fireworks --- dfttk/pythelec.py | 8 ++++---- dfttk/scripts/QHAAnalysis_renew.py | 11 +++++++---- setup.py | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 3bdc46fa..41850478 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1114,10 +1114,10 @@ def get_superfij(self,i, phdir): idx = vol_within_index(i['volume'],self.volumes, thr=1.e-3) #print("iiiiiiiiii idx=", idx, i['volume'],self.volumes) if idx >=0: - mm = i['metadata'] - mm['volume'] = i['volume'] - mm['energy'] = self.energies[(list(self.volumes)).index(i['volume'])] - out.write('{}\n'.format(mm)) + mm = i['metadata'] + mm['volume'] = i['volume'] + mm['energy'] = self.energies[idx] + out.write('{}\n'.format(mm)) if len(self.xmlvol)!=0: diff --git a/dfttk/scripts/QHAAnalysis_renew.py b/dfttk/scripts/QHAAnalysis_renew.py index 9feef576..ac7729f5 100644 --- a/dfttk/scripts/QHAAnalysis_renew.py +++ b/dfttk/scripts/QHAAnalysis_renew.py @@ -41,7 +41,7 @@ from fireworks import Firework from atomate.vasp.config import VASP_CMD, DB_FILE import os -from dfttk.pythelec import get_static_calculations +from dfttk.pythelec import get_static_calculations, vol_within head,tail = os.path.split(__file__) db_file = os.path.join(head,"db.json") @@ -131,8 +131,10 @@ def run_task(self): vol_s_vib = [] vol_c_vib = [] for calc in phonon_calculations: - if calc['volume'] in vol_vol: continue - if calc['volume'] not in volumes: continue + #if calc['volume'] in vol_vol: continue + #if calc['volume'] not in volumes: continue + if vol_within(calc['volume'], vol_vol): continue + if not vol_within(calc['volume'],volumes): continue vol_vol.append(calc['volume']) vol_f_vib.append(calc['F_vib']) vol_s_vib.append(calc['S_vib']) @@ -149,7 +151,8 @@ def run_task(self): _energies = [] _dos_objs = [] for iv,vol in enumerate(volumes): - if vol not in vol_vol: continue + #if vol not in vol_vol: continue + if not vol_within(vol, vol_vol): continue _volumes.append(vol) _energies.append(energies[iv]) _dos_objs.append(dos_objs[iv]) diff --git a/setup.py b/setup.py index 6df8657e..1aec3296 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate>=0.9.4', 'tinydb', 'phonopy', 'ase', 'pymatgen', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.0.16', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From e13c42fc5a5593902ab64c9401dc3589b0c2d9c9 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:07:24 -0500 Subject: [PATCH 072/111] 20221115 1. fix compatibility between phonopy and vasp 6.2 2. fix install_requires=['atomate==1.0.1', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'] --- dfttk/analysis/phonon.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/analysis/phonon.py b/dfttk/analysis/phonon.py index 3ed9e5f7..9e2d62d3 100644 --- a/dfttk/analysis/phonon.py +++ b/dfttk/analysis/phonon.py @@ -42,7 +42,7 @@ def get_f_vib_phonopy(structure, supercell_matrix, vasprun_path, # get codename and version from vasprun.xml file code_name, code_version = get_code_version(xml=vasprun_path) force_constant_factor = 1.0 - if code_version[0:1] >= '6': + if code_version[0:3] >= '6.2': force_constant_factor = 0.004091649655126895 # get the force constants from a vasprun.xml file diff --git a/setup.py b/setup.py index 1aec3296..c1a24835 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.0.16', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.1', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From d32fc87a23ed87701f8e1ad89325a7a08e132eaa Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:13:21 -0500 Subject: [PATCH 073/111] Update pythelec.py --- dfttk/pythelec.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 41850478..3dd404b2 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1444,9 +1444,10 @@ def toYphon(self, _T=None, for_plot=False): try: self.force_constant_factor = i['force_constant_factor'] if self.static_vasp_version[0:1] >= '6' and self.static_vasp_version[0:3] < '6.2': - self.force_constant_factor /= 0.004091649655126895 + if self.force_constant_factor == 0.004091649655126895: + self.force_constant_factor /= 0.004091649655126895 except: - if self.static_vasp_version[0:1] >= '6': + if self.static_vasp_version[0:3] >= '6.2': self.force_constant_factor = 0.004091649655126895 else: self.force_constant_factor = 1.0 From 60d18b4910e0801678f96b11cf4ec2f955a7aa94 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:19:33 -0500 Subject: [PATCH 074/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c1a24835..43f57cd1 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.1', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.3', 'phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From 3bf88b0f9cc581acb748c0a2bf7960ac7071db2b Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:32:32 -0500 Subject: [PATCH 075/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 43f57cd1..560dec66 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.3', 'phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==0.9.8', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From 2f8c76e0095d50720e25ff5c475ffd2fbf924645 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:36:08 -0500 Subject: [PATCH 076/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 560dec66..99382aee 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==0.9.8', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.1', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.0.15', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From 3e9e9a8078a78eeee46354e6ea4109c8c1295422 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:39:38 -0500 Subject: [PATCH 077/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 99382aee..1f1f5b86 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.1', 'phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.0.15', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.3', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From c64cd21fe8e3b5872827cfd4a9ee72bf7277795c Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:45:12 -0500 Subject: [PATCH 078/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1f1f5b86..055d7984 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.3', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.3', 'pymongo==4.2.0','phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From 0b4bef1922fd13cab87f084cc51f75cf86e3b749 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 14:03:08 -0500 Subject: [PATCH 079/111] Update pythelec.py --- dfttk/pythelec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 3dd404b2..c742a5ac 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1444,7 +1444,7 @@ def toYphon(self, _T=None, for_plot=False): try: self.force_constant_factor = i['force_constant_factor'] if self.static_vasp_version[0:1] >= '6' and self.static_vasp_version[0:3] < '6.2': - if self.force_constant_factor == 0.004091649655126895: + if self.force_constant_factor == 1.0: self.force_constant_factor /= 0.004091649655126895 except: if self.static_vasp_version[0:3] >= '6.2': From 55ba493c51cb3cc099c3d9d5461a9c012995133a Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 15 Nov 2022 14:56:53 -0500 Subject: [PATCH 080/111] Update ywplot.py --- dfttk/analysis/ywplot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dfttk/analysis/ywplot.py b/dfttk/analysis/ywplot.py index 8b5354be..2e3a4463 100644 --- a/dfttk/analysis/ywplot.py +++ b/dfttk/analysis/ywplot.py @@ -1433,7 +1433,7 @@ def mkDict(line): idx = 1 while True: if not os.path.exists(dir0): break - recordfile = dir0,"record.json" + recordfile = os.path.join(dir0,"record.json") newdir = False try: if os.path.exists(recordfile): @@ -1744,7 +1744,6 @@ def Phonon298(dir0, pvdos=False): copyfile(os.path.join(plotdatabase,dfile),os.path.join(phdir298,dfile)) cwd = os.getcwd() os.chdir( phdir298 ) - import platform if platform.system()=="Linux": cmd = 'timeout 6 pos2s Symmetry.pos -THR 3.e-4 >&symmetry.out' output = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -2446,7 +2445,6 @@ def Plot298(folder, V298, volumes, debug=False, plottitle=None, local=None): move("vdos.png", os.path.join(cwd,folder,'vdos298.15.png')) if not os.path.exists('symmetry.mode'): - import platform if platform.system()=="Linux": cmd = "pos2s Symmetry.pos -THR 0.001" output = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, From 94e555afd3499c0c19b5fe778f5d534445ae8870 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 17 Nov 2022 14:05:18 -0500 Subject: [PATCH 081/111] 20201117 fix static/phonon match bugs --- dfttk/analysis/ywutils.py | 4 ++-- dfttk/ftasks.py | 11 +++++++---- dfttk/pythelec.py | 12 ++++++------ dfttk/scripts/QHAAnalysis_renew.py | 6 +++--- setup.py | 2 +- tests/test_QHAAnalysis.py | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/dfttk/analysis/ywutils.py b/dfttk/analysis/ywutils.py index 46977942..6cad8845 100644 --- a/dfttk/analysis/ywutils.py +++ b/dfttk/analysis/ywutils.py @@ -271,7 +271,7 @@ def get_rec_from_metatag(vasp_db,m, test=False): for calc in static_calculations: vol = calc['output']['structure']['lattice']['volume'] if kpoints is None: kpoints = calc['orig_inputs']['kpoints']['kpoints'] - if vol_within(vol, volumes): continue + if vol_within(vol, volumes, thr=1.e-6): continue natoms = len(calc['output']['structure']['sites']) try: sites = calc['output']['structure']['sites'] @@ -306,7 +306,7 @@ def get_rec_from_metatag(vasp_db,m, test=False): for calc in all_static_calculations: if len(calc['metadata'])<=1:continue # only check constrained calculation vol = calc['output']['structure']['lattice']['volume'] - if vol_within(vol, volumes): continue + if vol_within(vol, volumes, thr=1.e-6): continue natoms = len(calc['output']['structure']['sites']) try: sites = calc['output']['structure']['sites'] diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 99ca8e09..31323235 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -32,7 +32,7 @@ from atomate import __version__ as atomate_ver from dfttk import __version__ as dfttk_ver from pymatgen.core import __version__ as pymatgen_ver -from dfttk.pythelec import get_static_calculations +from dfttk.pythelec import get_static_calculations, vol_within from dfttk.scripts.assign_fworker_name import Customizing_Workflows def extend_calc_locs(name, fw_spec): @@ -355,8 +355,10 @@ def run_task(self, fw_spec): vol_s_vib = [] vol_c_vib = [] for calc in phonon_calculations: - if calc['volume'] in vol_vol: continue - if calc['volume'] not in volumes: continue + #if calc['volume'] in vol_vol: continue + #if calc['volume'] not in volumes: continue + if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue + if not vol_within(calc['volume'],volumes, thr=1.e-6): continue vol_vol.append(calc['volume']) vol_f_vib.append(calc['F_vib'][::everyT]) vol_s_vib.append(calc['S_vib']) @@ -371,7 +373,8 @@ def run_task(self, fw_spec): _energies = [] _dos_objs = [] for iv,vol in enumerate(volumes): - if vol not in vol_vol: continue + #if vol not in vol_vol: continue + if not vol_within(vol,vol_vol, thr=1.e-6): continue _volumes.append(vol) _energies.append(energies[iv]) _dos_objs.append(dos_objs[iv]) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index c742a5ac..5f85a9c7 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -1111,7 +1111,7 @@ def get_superfij(self,i, phdir): structure.to(filename=os.path.join(voldir,'POSCAR')) with open (os.path.join(voldir,'metadata.json'),'w') as out: - idx = vol_within_index(i['volume'],self.volumes, thr=1.e-3) + idx = vol_within_index(i['volume'],self.volumes, thr=1.e-6) #print("iiiiiiiiii idx=", idx, i['volume'],self.volumes) if idx >=0: mm = i['metadata'] @@ -1130,7 +1130,7 @@ def get_superfij(self,i, phdir): with open (os.path.join(voldir,'OSZICAR'),'w') as out: - idx = vol_within_index(i['volume'],self.volumes, thr=1.e-3) + idx = vol_within_index(i['volume'],self.volumes, thr=1.e-6) if idx >0: out.write(' 1 F= xx E0= {}\n'.format(self.energies[idx])) with open (os.path.join(voldir,'superfij.out'),'w') as out: for line in range (2,5): @@ -1453,7 +1453,7 @@ def toYphon(self, _T=None, for_plot=False): self.force_constant_factor = 1.0 #if i['volume'] not in self.volumes: - if not vol_within(i['volume'], self.volumes, thr=1.e-3): + if not vol_within(i['volume'], self.volumes, thr=1.e-6): print (i['volume'], "is not within", self.volumes) continue voldir = self.get_superfij(i, phdir) @@ -1588,7 +1588,7 @@ def check_vol(self): _d = [] for i, vol in enumerate(list(self.volumes)): #if vol not in self.Vlat: - if not vol_within(vol,self.Vlat,thr=1.e-3): + if not vol_within(vol,self.Vlat,thr=1.e-6): print ("data in static calculation with volume=", vol, "is discarded") continue _v.append(vol) @@ -2095,9 +2095,9 @@ def get_qha(self): Flat = [] Dlat = [] for i, vol in enumerate(_Vlat): - if vol_within(vol, Vlat, thr=1.e-3): continue + if vol_within(vol, Vlat, thr=1.e-6): continue #if vol in Vlat: continue - if not vol_within(vol, self.volumes, thr=1.e-3): continue + if not vol_within(vol, self.volumes, thr=1.e-6): continue #if vol not in self.volumes: continue Vlat.append(vol) Slat.append(_Slat[i]) diff --git a/dfttk/scripts/QHAAnalysis_renew.py b/dfttk/scripts/QHAAnalysis_renew.py index ac7729f5..89ad7a07 100644 --- a/dfttk/scripts/QHAAnalysis_renew.py +++ b/dfttk/scripts/QHAAnalysis_renew.py @@ -133,8 +133,8 @@ def run_task(self): for calc in phonon_calculations: #if calc['volume'] in vol_vol: continue #if calc['volume'] not in volumes: continue - if vol_within(calc['volume'], vol_vol): continue - if not vol_within(calc['volume'],volumes): continue + if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue + if not vol_within(calc['volume'],volumes, the=1.e-6): continue vol_vol.append(calc['volume']) vol_f_vib.append(calc['F_vib']) vol_s_vib.append(calc['S_vib']) @@ -152,7 +152,7 @@ def run_task(self): _dos_objs = [] for iv,vol in enumerate(volumes): #if vol not in vol_vol: continue - if not vol_within(vol, vol_vol): continue + if not vol_within(vol, vol_vol, thr=1.e-6): continue _volumes.append(vol) _energies.append(energies[iv]) _dos_objs.append(dos_objs[iv]) diff --git a/setup.py b/setup.py index 055d7984..d6201836 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.3', 'pymongo==4.2.0','phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'phonopy', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==0.9.8', 'maggma==0.26.0', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index c73e7545..f8750d17 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -59,7 +59,7 @@ @pytest.mark.QHAAnalysis def test_QHAAnalysis(): - tags = ['5e8b5a18-b2b9-4dcd-81a7-0bd75ee361ec'] + tags = ['a9b209b5-2dd9-4e4a-890d-9c3387861f52'] print(db_file) for tag in tags: vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) From c7a12e10f2c501ae131a698bfbbff6b92bd6aca2 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Fri, 18 Nov 2022 11:35:45 -0500 Subject: [PATCH 082/111] Update pyphon.py --- dfttk/pyphon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dfttk/pyphon.py b/dfttk/pyphon.py index 00bc2c76..670865df 100644 --- a/dfttk/pyphon.py +++ b/dfttk/pyphon.py @@ -292,15 +292,15 @@ def vibrational_contributions(T, dos_input=sys.stdin, _dmu=0.0, energyunit='J'): sys.stderr.write ("\nThe phonon quality= {:08.6f}\n\n".format(quality)) - for i in range(T.size): + for i in range(1, T.size): tmp0 = 0.0 tmp1 = 0.0 if N_ph[i]!=0.: tmp0 = C_ph_mu[i]/N_ph[i] tmp1 = C_ph_n[i]/N_ph[i] - sys.stdout.write('{:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} \ - {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g}\n'.format(\ - T[i], F_ph[i]*unit, U_ph[i]*unit, S_ph[i]*unit, C_ph_mu[i]*unit, C_ph_n[i], \ + sys.stdout.write('{:10.7g} {:10.2f} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} \ + {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} {:10.7g} \n'.format(\ + T[i], debyeT[i], F_ph[i]*unit, U_ph[i]*unit, S_ph[i]*unit, C_ph_mu[i]*unit, C_ph_n[i], \ tmp0, tmp1, Sound_ph[i], Sound_nn[i], \ N_ph[i], NN_ph[i], debyeT[i])) From e66a050995df002500fbfa6da459e8d6286d7046 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 22 Nov 2022 08:38:40 -0500 Subject: [PATCH 083/111] 20201122 fix pymatgen/atomate bugs --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d6201836..1131b761 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==0.9.8', 'maggma==0.26.0', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.1', 'maggma==0.26.0', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From c0a55ffd57feddbc7e4a81a6c0cf03505bb08882 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:19:35 -0500 Subject: [PATCH 084/111] Update ftasks.py --- dfttk/ftasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 31323235..55096680 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -360,7 +360,7 @@ def run_task(self, fw_spec): if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue if not vol_within(calc['volume'],volumes, thr=1.e-6): continue vol_vol.append(calc['volume']) - vol_f_vib.append(calc['F_vib'][::everyT]) + vol_f_vib.append(calc['F_vib']) vol_s_vib.append(calc['S_vib']) vol_c_vib.append(calc['CV_vib']) # sort them order of the unit cell volumes From 88f45e4049038ab5287928aef9fec26f386e891a Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:48:23 -0500 Subject: [PATCH 085/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1131b761..68c80ebe 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate==1.0.1', 'maggma==0.26.0', 'pymongo==3.12.1','phonopy==2.9.1', 'fireworks==1.9.7', 'tinydb', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate>=1.0.1', 'maggma>=0.26.0', 'pymongo>=3.12.1','phonopy==2.9.1', 'fireworks>=1.9.7', 'tinydb', 'ase', 'pymatgen>=2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From 825d76014fed826f83d80089bfb33c255376cd9c Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:14:19 -0500 Subject: [PATCH 086/111] Update utils.py --- dfttk/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dfttk/utils.py b/dfttk/utils.py index 9910b1bc..0afa8cb3 100644 --- a/dfttk/utils.py +++ b/dfttk/utils.py @@ -519,9 +519,9 @@ def mark_adopted_TF(tag, db_file, adpoted, phonon=False): t_file = loadfn(config_to_dict()["FWORKER_LOC"])["env"]["db_file"] vasp_db = VaspCalcDb.from_db_file(t_file, admin=True) if vasp_db: - vasp_db.collection.update({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True, multi = True) + vasp_db.collection.update_many({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True) if phonon: - vasp_db.db['phonon'].update({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True, multi = True) + vasp_db.db['phonon'].update_many({'metadata.tag': tag}, {'$set': {'adopted': adpoted}}, upsert = True) def mark_adopted(tag, db_file, volumes, phonon=False): @@ -533,11 +533,11 @@ def mark_adopted(tag, db_file, volumes, phonon=False): t_file = loadfn(config_to_dict()["FWORKER_LOC"])["env"]["db_file"] vasp_db = VaspCalcDb.from_db_file(t_file, admin=True) for volume in volumes: - vasp_db.collection.update({'$and':[ {'metadata.tag': tag}, {'output.structure.lattice.volume': volume} ]}, - {'$set': {'adopted': True}}, upsert = True, multi = False) # Mark only one + vasp_db.collection.update_one({'$and':[ {'metadata.tag': tag}, {'output.structure.lattice.volume': volume} ]}, + {'$set': {'adopted': True}}, upsert = True) # Mark only one if phonon: - vasp_db.db['phonon'].update({'$and':[ {'metadata.tag': tag}, {'volume': volume} ]}, - {'$set': {'adopted': True}}, upsert = True, multi = False) + vasp_db.db['phonon'].update_one({'$and':[ {'metadata.tag': tag}, {'volume': volume} ]}, + {'$set': {'adopted': True}}, upsert = True) def consistent_check_db(db_file, tag): From 69335315fe93bcc1ddf83d4ead18573b15ea8d5b Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:42:17 -0500 Subject: [PATCH 087/111] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 68c80ebe..31532708 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def readme(): package_data = {'dfttk.structure_builders' : ["prototype_anrl.all", "aflow_prototype_db.json"]}, description='Density functional theory workflows for finite temperature thermodynamics based on atomate workflows. Created by the Phases Research Lab', long_description=readme(), - install_requires=['atomate>=1.0.1', 'maggma>=0.26.0', 'pymongo>=3.12.1','phonopy==2.9.1', 'fireworks>=1.9.7', 'tinydb', 'ase', 'pymatgen>=2022.11.1', 'numpy>=1.20.1'], + install_requires=['atomate==1.0.3', 'maggma==0.49.9', 'pymongo==4.3.3','phonopy==2.9.1', 'fireworks==2.0.3', 'tinydb', 'ase', 'pymatgen==2022.11.1', 'numpy>=1.20.1'], extras_require={ 'dev': [ 'sphinx', From c1d17479b722b121ab649b1cc3eae838f68d8e90 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:44:14 -0500 Subject: [PATCH 088/111] vasp6 compatibility update --- dfttk/ftasks.py | 11 +++++++---- dfttk/pythelec.py | 13 ++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index 55096680..ff7ca805 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -359,10 +359,13 @@ def run_task(self, fw_spec): #if calc['volume'] not in volumes: continue if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue if not vol_within(calc['volume'],volumes, thr=1.e-6): continue - vol_vol.append(calc['volume']) - vol_f_vib.append(calc['F_vib']) - vol_s_vib.append(calc['S_vib']) - vol_c_vib.append(calc['CV_vib']) + try: + vol_vol.append(calc['volume']) + vol_f_vib.append(calc['F_vib']) + vol_s_vib.append(calc['S_vib']) + vol_c_vib.append(calc['CV_vib']) + except: + pass # sort them order of the unit cell volumes vol_f_vib = sort_x_by_y(vol_f_vib, vol_vol) vol_s_vib = sort_x_by_y(vol_s_vib, vol_vol) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 5f85a9c7..fcb0469a 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -2035,7 +2035,7 @@ def find_vibrational(self): self.force_constant_factor = i['force_constant_factor'] except: if self.static_vasp_version[0:1] >= '6': - print("\n**************FETAL ERROR! force constant not compatible for :", self.tag, "by default phonopy with vasp6\n") + print("\n**************Warning! force constant may not compatible for :", self.tag, "by default phonopy with vasp6\n") try: @@ -2066,10 +2066,13 @@ def get_qha(self): _Flat = [] for i in self.qha_items: - _Vlat.append(i['volume']) - _Slat.append(i['S_vib'][::self.everyT]) - _Clat.append(i['CV_vib'][::self.everyT]) - _Flat.append(i['F_vib'][::self.everyT]) + try: + _Vlat.append(i['volume']) + _Slat.append(i['S_vib'][::self.everyT]) + _Clat.append(i['CV_vib'][::self.everyT]) + _Flat.append(i['F_vib'][::self.everyT]) + else: + pass self.volT = np.zeros(len(self.T_vib)) self.GibT = np.zeros(len(self.T_vib)) _Dlat = np.full((len(_Vlat)), 400.) From ace5f657e2084ba3a2854c4b040824ab4d0bffe9 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:47:08 -0500 Subject: [PATCH 089/111] Update pythelec.py --- dfttk/pythelec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index fcb0469a..6b69b77f 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -2071,7 +2071,7 @@ def get_qha(self): _Slat.append(i['S_vib'][::self.everyT]) _Clat.append(i['CV_vib'][::self.everyT]) _Flat.append(i['F_vib'][::self.everyT]) - else: + except: pass self.volT = np.zeros(len(self.T_vib)) self.GibT = np.zeros(len(self.T_vib)) From 9b009c07505df9bad43ce5c27467ce43e53db260 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:56:34 -0500 Subject: [PATCH 090/111] updates --- dfttk/ftasks.py | 2 +- dfttk/pythelec.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index ff7ca805..a51517c0 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -360,10 +360,10 @@ def run_task(self, fw_spec): if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue if not vol_within(calc['volume'],volumes, thr=1.e-6): continue try: - vol_vol.append(calc['volume']) vol_f_vib.append(calc['F_vib']) vol_s_vib.append(calc['S_vib']) vol_c_vib.append(calc['CV_vib']) + vol_vol.append(calc['volume']) except: pass # sort them order of the unit cell volumes diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 6b69b77f..83d5bfc1 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -2067,10 +2067,10 @@ def get_qha(self): for i in self.qha_items: try: - _Vlat.append(i['volume']) _Slat.append(i['S_vib'][::self.everyT]) _Clat.append(i['CV_vib'][::self.everyT]) _Flat.append(i['F_vib'][::self.everyT]) + _Vlat.append(i['volume']) except: pass self.volT = np.zeros(len(self.T_vib)) From 567ffccfd095a4f4f9e03cd5a4f6e345fe99d0e9 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 29 Nov 2022 10:39:38 -0500 Subject: [PATCH 091/111] fixes for crosscom --- dfttk/ftasks.py | 18 ++++++++++-------- dfttk/pythelec.py | 26 ++++++++++++-------------- tests/test_QHAAnalysis.py | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dfttk/ftasks.py b/dfttk/ftasks.py index a51517c0..edb024e4 100644 --- a/dfttk/ftasks.py +++ b/dfttk/ftasks.py @@ -340,9 +340,13 @@ def run_task(self, fw_spec): #always perform phonon calculations when when enough phonon calculations found #to perform a quasiharmonic phonon calculations, one needs at least phonon results five volumes #phonon_calculations= list(vasp_db.db['phonon'].find({'$and':[ {'metadata.tag': tag}, {'adopted': True} ]})) - phonon_calculations= list(vasp_db.db['phonon'].find({'$and':[ {'metadata': {'tag':tag}}, {'adopted': True} ]})) + phonon_calculations= list(vasp_db.db['phonon'].find({'$and':[ {'metadata': {'tag':tag}}, {'adopted': True}, {'S_vib': {'$exists': True}} ]})) num_phonon_finished = len(phonon_calculations) qha_result['has_phonon'] = num_phonon_finished >= 5 + if not qha_result['has_phonon']: + phonon_calculations= list(vasp_db.db['phonon'].find({'$and':[ {'metadata': {'tag':tag}}, {'S_vib': {'$exists': True}} ]})) + num_phonon_finished = len(phonon_calculations) + qha_result['has_phonon'] = num_phonon_finished >= 5 #if self['phonon']: if qha_result['has_phonon']: # get the vibrational properties from the FW spec @@ -359,13 +363,11 @@ def run_task(self, fw_spec): #if calc['volume'] not in volumes: continue if vol_within(calc['volume'], vol_vol, thr=1.e-6): continue if not vol_within(calc['volume'],volumes, thr=1.e-6): continue - try: - vol_f_vib.append(calc['F_vib']) - vol_s_vib.append(calc['S_vib']) - vol_c_vib.append(calc['CV_vib']) - vol_vol.append(calc['volume']) - except: - pass + vol_f_vib.append(calc['F_vib'][::everyT]) + vol_s_vib.append(calc['S_vib']) + vol_c_vib.append(calc['CV_vib']) + vol_vol.append(calc['volume']) + # sort them order of the unit cell volumes vol_f_vib = sort_x_by_y(vol_f_vib, vol_vol) vol_s_vib = sort_x_by_y(vol_s_vib, vol_vol) diff --git a/dfttk/pythelec.py b/dfttk/pythelec.py index 83d5bfc1..0d578f2e 100644 --- a/dfttk/pythelec.py +++ b/dfttk/pythelec.py @@ -2018,19 +2018,19 @@ def find_vibrational(self): return self.from_phonon_collection = False if self.qhamode=="debye": - self.qha_items = self.vasp_db.db['qha'].find({'metadata.tag': self.tag}) + self.qha_items = self.vasp_db.db['qha'].find({'$and':[ {'metadata': {'tag':self.tag}}, {'S_vib': {'$exists': True}} ]}) elif self.qhamode=="phonon": - self.qha_items = self.vasp_db.db['qha_phonon'].find({'metadata.tag': self.tag}) + self.qha_items = self.vasp_db.db['qha_phonon'].find({'$and':[ {'metadata': {'tag':self.tag}}, {'S_vib': {'$exists': True}} ]}) else: try: self.qhamode='phonon' - self.qha_items = self.vasp_db.db['qha_phonon'].find({'metadata.tag': self.tag}) + self.qha_items = self.vasp_db.db['qha_phonon'].find({'$and':[ {'metadata': {'tag':self.tag}}, {'S_vib': {'$exists': True}} ]}) except: self.qhamode='debye' - self.qha_items = self.vasp_db.db['qha'].find({'metadata.tag': self.tag}) + self.qha_items = self.vasp_db.db['qha'].find({'$and':[ {'metadata': {'tag':self.tag}}, {'S_vib': {'$exists': True}} ]}) # check compatibility with vasp6 if self.qhamode=='phonon': - for i in (self.vasp_db).db['phonon'].find({'metadata.tag': self.tag}): + for i in (self.vasp_db).db['phonon'].find({'$and':[ {'metadata.tag': self.tag}, {'S_vib': {'$exists': True}} ]}): try: self.force_constant_factor = i['force_constant_factor'] except: @@ -2044,12 +2044,12 @@ def find_vibrational(self): #print("xxxx=",self.T_vib) except: try: - self.qha_items = self.vasp_db.db['qha_phonon'].find({'metadata': self.tag}) + self.qha_items = self.vasp_db.db['qha_phonon'].find({'$and':[ {'metadata.tag': self.tag}, {'S_vib': {'$exists': True}} ]}) self.T_vib = self.qha_items[0][self.qhamode]['temperatures'][::self.everyT] except: try: self.qhamode = 'phonon' - self.qha_items = self.vasp_db.db[self.qhamode].find({'metadata.tag': self.tag}) + self.qha_items = self.vasp_db.db[self.qhamode].find({'$and':[ {'metadata.tag': self.tag}, {'S_vib': {'$exists': True}} ]}) self.T_vib = self.qha_items[0]['temperatures'][::self.everyT] self.from_phonon_collection = True except: @@ -2066,13 +2066,11 @@ def get_qha(self): _Flat = [] for i in self.qha_items: - try: - _Slat.append(i['S_vib'][::self.everyT]) - _Clat.append(i['CV_vib'][::self.everyT]) - _Flat.append(i['F_vib'][::self.everyT]) - _Vlat.append(i['volume']) - except: - pass + _Slat.append(i['S_vib'][::self.everyT]) + _Clat.append(i['CV_vib'][::self.everyT]) + _Flat.append(i['F_vib'][::self.everyT]) + _Vlat.append(i['volume']) + self.volT = np.zeros(len(self.T_vib)) self.GibT = np.zeros(len(self.T_vib)) _Dlat = np.full((len(_Vlat)), 400.) diff --git a/tests/test_QHAAnalysis.py b/tests/test_QHAAnalysis.py index f8750d17..e6dd60b8 100644 --- a/tests/test_QHAAnalysis.py +++ b/tests/test_QHAAnalysis.py @@ -59,7 +59,7 @@ @pytest.mark.QHAAnalysis def test_QHAAnalysis(): - tags = ['a9b209b5-2dd9-4e4a-890d-9c3387861f52'] + tags = ['700dd9c9-afb0-4a09-a39d-ad77622b3f08'] print(db_file) for tag in tags: vasp_db = VaspCalcDb.from_db_file(db_file, admin=False) From 586e15c862a86d66608332c1dbeb7d8098dc6770 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:34:08 -0500 Subject: [PATCH 092/111] Update config_dfttk.py --- dfttk/scripts/config_dfttk.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dfttk/scripts/config_dfttk.py b/dfttk/scripts/config_dfttk.py index b6ca21a5..890758e5 100644 --- a/dfttk/scripts/config_dfttk.py +++ b/dfttk/scripts/config_dfttk.py @@ -75,7 +75,8 @@ def get_machines(nodes=1, ppn=16, user_machines=None): "_fw_template_file": os.path.join(".", "config", "PBS_template_custom.txt"), "vasp_cmd": "mpirun vasp_std"} } - dumpfn(machines, "machines.yaml", default_flow_style=False, indent=4) + #dumpfn(machines, "machines.yaml", default_flow_style=False, indent=4) + dumpfn(machines, "machines.yaml", indent=4) return machines def replace_file(filename, old_str, new_str): @@ -600,7 +601,8 @@ def config_pymatgen(psp_dir=None, def_fun="PBE", mapi=None, path_to_store_psp="p shutil.copyfile(pmg_config_file, pmg_config_file + ".dfttk.bak") for key in keys_required: params[key] = keys_dict[key] - dumpfn(params, pmg_config_file, default_flow_style=False) + #dumpfn(params, pmg_config_file, default_flow_style=False) + dumpfn(params, pmg_config_file) if "PMG_MAPI_KEY" in keys_required and (not mapi): warnings.warn("'PMG_MAPI_KEY' is empty, some function will not work. " + "Please add your own Materials Project's API. " + @@ -639,7 +641,8 @@ def update_configfile(filename, base_file): if filename.endswith(".json"): dumpfn(ori_file, filename, indent=4) elif filename.endswith(".yaml"): - dumpfn(ori_file, filename, default_flow_style=False, indent=4) + #dumpfn(ori_file, filename, default_flow_style=False, indent=4) + dumpfn(ori_file, filename, indent=4) def config_atomate(path_to_store_config=".", config_folder="config", queue_script="vaspjob.pbs", queue_type="pbs", vasp_cmd_flag="vasp_std", machine="aci", machines=None, @@ -727,7 +730,8 @@ def write_file(self): dump(self.DATA, f, indent=4) elif filename.endswith(".yaml"): from yaml import dump - dump(self.DATA, f, default_flow_style=False, sort_keys=False, indent=4) + #dump(self.DATA, f, default_flow_style=False, sort_keys=False, indent=4) + dump(self.DATA, f, sort_keys=False, indent=4) class ConfigDb(ConfigTemplate): """docstring for ConfigDb""" From 43049caf466b58182db5de73cc91acef43643510 Mon Sep 17 00:00:00 2001 From: Yi Wang <19328318+yiwang62@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:36:55 -0500 Subject: [PATCH 093/111] Update config_dfttk.py --- dfttk/scripts/config_dfttk.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dfttk/scripts/config_dfttk.py b/dfttk/scripts/config_dfttk.py index 890758e5..5a22537b 100644 --- a/dfttk/scripts/config_dfttk.py +++ b/dfttk/scripts/config_dfttk.py @@ -76,7 +76,7 @@ def get_machines(nodes=1, ppn=16, user_machines=None): "vasp_cmd": "mpirun vasp_std"} } #dumpfn(machines, "machines.yaml", default_flow_style=False, indent=4) - dumpfn(machines, "machines.yaml", indent=4) + dumpfn(machines, "machines.yaml") return machines def replace_file(filename, old_str, new_str): @@ -639,10 +639,10 @@ def update_configfile(filename, base_file): ori_file[item] = base_file[item] """ if filename.endswith(".json"): - dumpfn(ori_file, filename, indent=4) + dumpfn(ori_file, filename) elif filename.endswith(".yaml"): #dumpfn(ori_file, filename, default_flow_style=False, indent=4) - dumpfn(ori_file, filename, indent=4) + dumpfn(ori_file, filename) def config_atomate(path_to_store_config=".", config_folder="config", queue_script="vaspjob.pbs", queue_type="pbs", vasp_cmd_flag="vasp_std", machine="aci", machines=None, @@ -727,11 +727,11 @@ def write_file(self): with open(filename, 'w') as f: if filename.endswith(".json"): from json import dump - dump(self.DATA, f, indent=4) + dump(self.DATA, f) elif filename.endswith(".yaml"): from yaml import dump #dump(self.DATA, f, default_flow_style=False, sort_keys=False, indent=4) - dump(self.DATA, f, sort_keys=False, indent=4) + dump(self.DATA, f, sort_keys=False) class ConfigDb(ConfigTemplate): """docstring for ConfigDb""" From 62865e420739ed04b5b263a300ec509d290c39bb Mon Sep 17 00:00:00 2001 From: YI WANG Date: Thu, 8 Dec 2022 09:37:33 -0500 Subject: [PATCH 094/111] update in 20221208 in ROARS clusters --- docs/source/troubleshooting.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 7c3fbc74..4b165274 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -71,6 +71,32 @@ Following are the steps of adding API key number on DFTTK. a reason that was not caught and handled by Custodian. Check the output files in the launch directory and see if there are any errors in the VASP output or stdout/stderr. +12. During the installation or running dfttk, it could report this or that packakge missing/VersionConflict errors. You may have many of them, esspecially when you have good years' experience using python and many of your packages are obselete. DO NOT blame me, ``it is due to pymatgen`` + + You can try to sovle them by + + .. code-block:: bash + pip install -U #where should be the name of missed package + + Sometimes, one may meet issue with ruamel_yaml due to ``conda`` bug on namespace of ruamel_yaml vs ruamel.yaml. One may Manually delete the files from site-packages. In my case, to delete ruamel.yaml the command was rm -rf ``your-path-to-anaconda3``/lib/python``your-version``/site-packages/ruamel*. Then + + .. code-block:: bash + pip install ruamel.yaml + +13. During the installation in Windows system, the latest fireworks package may give you trouble + + I solved by install the development version + + .. code-block:: bash + git clone https://github.com/materialsproject/fireworks + cd fireworks + + replace the \`\`\` in README.md by \` followed by + + .. code-block:: bash + pip install -e . + + atomate issue ============= From 02e07221c32eb8247ed5f04155b6bc72f27cb497 Mon Sep 17 00:00:00 2001 From: YI WANG Date: Thu, 8 Dec 2022 11:27:41 -0500 Subject: [PATCH 095/111] update in 20221208 in ROARS clusters --- docs/source/troubleshooting.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 4b165274..fa294ebc 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -61,8 +61,8 @@ Following are the steps of adding API key number on DFTTK. 10. How to find the reason for FIZZLED job. - .. code-block:: bash - lpad get_fws -i fw_id -d more +.. code-block:: bash + lpad get_fws -i fw_id -d more 11. VasprunXMLValidator found from the command "lpad get_fws -i fw_id -d more" @@ -75,26 +75,26 @@ Following are the steps of adding API key number on DFTTK. You can try to sovle them by - .. code-block:: bash - pip install -U #where should be the name of missed package +.. code-block:: bash + pip install -U #where should be the name of missed package Sometimes, one may meet issue with ruamel_yaml due to ``conda`` bug on namespace of ruamel_yaml vs ruamel.yaml. One may Manually delete the files from site-packages. In my case, to delete ruamel.yaml the command was rm -rf ``your-path-to-anaconda3``/lib/python``your-version``/site-packages/ruamel*. Then - .. code-block:: bash +.. code-block:: bash pip install ruamel.yaml -13. During the installation in Windows system, the latest fireworks package may give you trouble +13. During the installation in Windows system, the latest fireworks package may give you some troubles I solved by install the development version - .. code-block:: bash - git clone https://github.com/materialsproject/fireworks - cd fireworks +.. code-block:: bash + git clone https://github.com/materialsproject/fireworks + cd fireworks replace the \`\`\` in README.md by \` followed by - .. code-block:: bash - pip install -e . +.. code-block:: bash + pip install -e . atomate issue From a85354e76dfd117caece82181e3c5dd235e1bb16 Mon Sep 17 00:00:00 2001 From: YI WANG Date: Thu, 8 Dec 2022 11:42:51 -0500 Subject: [PATCH 096/111] update in 20221208 in ROARS clusters --- docs/source/troubleshooting.rst | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index fa294ebc..c1061f9b 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -62,6 +62,7 @@ Following are the steps of adding API key number on DFTTK. 10. How to find the reason for FIZZLED job. .. code-block:: bash + lpad get_fws -i fw_id -d more 11. VasprunXMLValidator found from the command "lpad get_fws -i fw_id -d more" @@ -75,26 +76,29 @@ Following are the steps of adding API key number on DFTTK. You can try to sovle them by -.. code-block:: bash - pip install -U #where should be the name of missed package + .. code-block:: bash + + pip install -U #where should be the name of missed package Sometimes, one may meet issue with ruamel_yaml due to ``conda`` bug on namespace of ruamel_yaml vs ruamel.yaml. One may Manually delete the files from site-packages. In my case, to delete ruamel.yaml the command was rm -rf ``your-path-to-anaconda3``/lib/python``your-version``/site-packages/ruamel*. Then -.. code-block:: bash - pip install ruamel.yaml + .. code-block:: bash + + pip install ruamel.yaml 13. During the installation in Windows system, the latest fireworks package may give you some troubles I solved by install the development version -.. code-block:: bash - git clone https://github.com/materialsproject/fireworks - cd fireworks + .. code-block:: bash + + git clone https://github.com/materialsproject/fireworks + cd fireworks replace the \`\`\` in README.md by \` followed by -.. code-block:: bash - pip install -e . + .. code-block:: bash + pip install -e . atomate issue From fa7787432d65ea4cb4e7500ec4dfb24c7052a56d Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 10:12:08 -0500 Subject: [PATCH 097/111] 20221209 --- dfttk/scripts/config_dfttk.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dfttk/scripts/config_dfttk.py b/dfttk/scripts/config_dfttk.py index b6ca21a5..641da632 100644 --- a/dfttk/scripts/config_dfttk.py +++ b/dfttk/scripts/config_dfttk.py @@ -75,7 +75,8 @@ def get_machines(nodes=1, ppn=16, user_machines=None): "_fw_template_file": os.path.join(".", "config", "PBS_template_custom.txt"), "vasp_cmd": "mpirun vasp_std"} } - dumpfn(machines, "machines.yaml", default_flow_style=False, indent=4) + #dumpfn(machines, "machines.yaml", default_flow_style=False, indent=4) + dumpfn(machines, "machines.yaml") return machines def replace_file(filename, old_str, new_str): @@ -639,7 +640,8 @@ def update_configfile(filename, base_file): if filename.endswith(".json"): dumpfn(ori_file, filename, indent=4) elif filename.endswith(".yaml"): - dumpfn(ori_file, filename, default_flow_style=False, indent=4) + #dumpfn(ori_file, filename, default_flow_style=False, indent=4) + dumpfn(ori_file, filename) def config_atomate(path_to_store_config=".", config_folder="config", queue_script="vaspjob.pbs", queue_type="pbs", vasp_cmd_flag="vasp_std", machine="aci", machines=None, From 21f88fa9b29d2ecfe06e00085a861e5f1d25ba59 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 10:54:40 -0500 Subject: [PATCH 098/111] docs --- docs/source/troubleshooting.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index c1061f9b..6de257f3 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -29,6 +29,7 @@ or equivalently in the ``.cshrc`` file setenv FW_CONFIG_FILE /storage/work/y/yuw3/dfttk/config/FW_config.yaml 5. git push issue for contributors, see https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account + 6. for batch run of the postprocessing modules, make sure compatibilities of non-ascii character by: .. code-block:: bash From f4cb1fbf1dfc8183115fc5085099e6d950ebbec9 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 10:58:36 -0500 Subject: [PATCH 099/111] docs --- docs/source/troubleshooting.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 6de257f3..118df49a 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -30,7 +30,7 @@ or equivalently in the ``.cshrc`` file 5. git push issue for contributors, see https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account -6. for batch run of the postprocessing modules, make sure compatibilities of non-ascii character by: +6. For batch run of the postprocessing modules, make sure compatibilities of non-ascii character by: .. code-block:: bash @@ -42,7 +42,7 @@ or equivalently in the ``.cshrc`` file 8. When you are interesting in revising the code, if have job running in the system before your changes, the codes in the batch system might not be updated and the results might be not as you assumed. It takes me two days to figure out this problem. The solution is to kill all the dfttk running job and resubmit them. Following are the steps of adding API key number on DFTTK. -9. How to solve the install warning of 'PMG_MAPI_KEY' is empty. +9. How to solve the install warning of 'PMG_MAPI_KEY' is empty. 1. Go to the materials project website, https://materialsproject.org/, under the API section, you will @@ -60,20 +60,20 @@ Following are the steps of adding API key number on DFTTK. PMG_MAPI_KEY: ######(your API key number) -10. How to find the reason for FIZZLED job. +10. How to find the reason for FIZZLED job. .. code-block:: bash lpad get_fws -i fw_id -d more -11. VasprunXMLValidator found from the command "lpad get_fws -i fw_id -d more" +11. VasprunXMLValidator found from the command "lpad get_fws -i fw_id -d more" If you get an error from the VasprunXMLValidator, that means that the vasprun.xml failed to be parsed and/or validated. Usually that means the VASP job did not run or failed for a reason that was not caught and handled by Custodian. Check the output files in the launch directory and see if there are any errors in the VASP output or stdout/stderr. -12. During the installation or running dfttk, it could report this or that packakge missing/VersionConflict errors. You may have many of them, esspecially when you have good years' experience using python and many of your packages are obselete. DO NOT blame me, ``it is due to pymatgen`` +12. During the installation or running dfttk, it could report this or that packakge missing/VersionConflict errors. You may have many of them, esspecially when you have good years' experience using python and many of your packages are obselete. DO NOT blame me, ``it is due to pymatgen`` You can try to sovle them by @@ -87,7 +87,7 @@ Following are the steps of adding API key number on DFTTK. pip install ruamel.yaml -13. During the installation in Windows system, the latest fireworks package may give you some troubles +13. During the installation in Windows system, the latest fireworks package may give you some troubles I solved by install the development version From dd1174b23879fe21e73918b84c67e86a32ea751f Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:02:53 -0500 Subject: [PATCH 100/111] docs --- docs/source/troubleshooting.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 118df49a..a7466559 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -37,13 +37,14 @@ or equivalently in the ``.cshrc`` file export LC_ALL='en_US.utf8' #for bsh; setenv LC_ALL en_US.utf8 #for csh -7. For phonon calculations, due to certain reasons (such as temperature range too high), one may not see results in the ``qha_phonon`` or ``qha`` MongoDB collections. In this case, the subcommand ``dfttk thfind`` will try to find results from the ``phonon`` collection and process the data by calling ``Yphon`` +7. For phonon calculations, due to certain reasons (such as temperature range too high), one may not see results in the ``qha_phonon`` or ``qha`` MongoDB collections. In this case, the subcommand ``dfttk thfind`` will try to find results from the ``phonon`` collection and process the data by calling ``Yphon``: 8. When you are interesting in revising the code, if have job running in the system before your changes, the codes in the batch system might not be updated and the results might be not as you assumed. It takes me two days to figure out this problem. The solution is to kill all the dfttk running job and resubmit them. -Following are the steps of adding API key number on DFTTK. 9. How to solve the install warning of 'PMG_MAPI_KEY' is empty. + Following are the steps of adding API key number on DFTTK. + 1. Go to the materials project website, https://materialsproject.org/, under the API section, you will easily find you API Keys number. From a737dc6b49ddc7d506890b19fdf66f1f22032ae8 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:04:46 -0500 Subject: [PATCH 101/111] docs --- docs/source/troubleshooting.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index a7466559..7a185bb9 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -41,13 +41,9 @@ or equivalently in the ``.cshrc`` file 8. When you are interesting in revising the code, if have job running in the system before your changes, the codes in the batch system might not be updated and the results might be not as you assumed. It takes me two days to figure out this problem. The solution is to kill all the dfttk running job and resubmit them. -9. How to solve the install warning of 'PMG_MAPI_KEY' is empty. +9. How to solve the install warning of 'PMG_MAPI_KEY' is empty. Following are the steps of adding API key number on DFTTK. - Following are the steps of adding API key number on DFTTK. - - 1. Go to the materials project website, - https://materialsproject.org/, under the API section, you will - easily find you API Keys number. + 1. Go to the materials project website, https://materialsproject.org/, under the API section, you will easily find you API Keys number. 2. Go to the .pmgrc.yaml file From e478f54ca6654b085bdf7df23ef47e052cfba1d2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:12:41 -0500 Subject: [PATCH 102/111] docs --- docs/source/troubleshooting.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 7a185bb9..ca4ba393 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -78,7 +78,7 @@ or equivalently in the ``.cshrc`` file pip install -U #where should be the name of missed package - Sometimes, one may meet issue with ruamel_yaml due to ``conda`` bug on namespace of ruamel_yaml vs ruamel.yaml. One may Manually delete the files from site-packages. In my case, to delete ruamel.yaml the command was rm -rf ``your-path-to-anaconda3``/lib/python``your-version``/site-packages/ruamel*. Then + Sometimes, one may meet issue with ruamel_yaml due to ``conda`` bug on namespace of ruamel_yaml vs ruamel.yaml. One may Manually delete the files from site-packages. What I learnt was to delete ruamel.yaml ``rm -rf your-path-to-anaconda3/lib/python-your-version/site-packages/ruamel*``. Then install ruamel.yaml by .. code-block:: bash @@ -86,14 +86,14 @@ or equivalently in the ``.cshrc`` file 13. During the installation in Windows system, the latest fireworks package may give you some troubles - I solved by install the development version + I solved the problem by installing the development version .. code-block:: bash git clone https://github.com/materialsproject/fireworks cd fireworks - replace the \`\`\` in README.md by \` followed by + The trouble is due to the line containing \`\`\` in README.md. You can delete/replace them followed by install it as .. code-block:: bash pip install -e . From cec9cc4cb3b943fc0f8b494296371417a1852810 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:14:03 -0500 Subject: [PATCH 103/111] docs --- docs/source/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index ca4ba393..32c6ce26 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -93,7 +93,7 @@ or equivalently in the ``.cshrc`` file git clone https://github.com/materialsproject/fireworks cd fireworks - The trouble is due to the line containing \`\`\` in README.md. You can delete/replace them followed by install it as + The trouble is due to the line containing "```" in README.md. You can delete/replace them followed by install it as .. code-block:: bash pip install -e . From ee2582b43e3a6e1c30804320dab460c4ce96d606 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:15:27 -0500 Subject: [PATCH 104/111] docs --- docs/source/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 32c6ce26..78b5c1c0 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -93,7 +93,7 @@ or equivalently in the ``.cshrc`` file git clone https://github.com/materialsproject/fireworks cd fireworks - The trouble is due to the line containing "```" in README.md. You can delete/replace them followed by install it as + The trouble is due to the line containing in README.md. You can delete/replace them followed by installing fireworks it as .. code-block:: bash pip install -e . From d25669677f0b8e2e0a1345d1b6c56ad39f0e9c31 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:16:32 -0500 Subject: [PATCH 105/111] docs --- docs/source/troubleshooting.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 78b5c1c0..d76808c8 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -92,8 +92,9 @@ or equivalently in the ``.cshrc`` file git clone https://github.com/materialsproject/fireworks cd fireworks + pip install -e . - The trouble is due to the line containing in README.md. You can delete/replace them followed by installing fireworks it as + The trouble is due to the line containing "```" in README.md. You can delete/replace them followed by installing fireworks it as .. code-block:: bash pip install -e . From bfc9de30e2958911d7963e456bd080d73c957ef2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:17:16 -0500 Subject: [PATCH 106/111] docs --- docs/source/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index d76808c8..cd7ba897 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -92,11 +92,11 @@ or equivalently in the ``.cshrc`` file git clone https://github.com/materialsproject/fireworks cd fireworks - pip install -e . The trouble is due to the line containing "```" in README.md. You can delete/replace them followed by installing fireworks it as .. code-block:: bash + pip install -e . From a516570a15ef10db3ce774493a96870ea92c4570 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:25:24 -0500 Subject: [PATCH 107/111] docs --- docs/source/troubleshooting.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index cd7ba897..7cf0f92b 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -99,6 +99,13 @@ or equivalently in the ``.cshrc`` file pip install -e . + 14. Sometimes, some VASP jobs may crash (showing as "F" or "FIZZLED") due to various reasons (Ram leakage, job time limitations etc) or even no reasons. + + These problems can mostly resovled by rerun the wflows using: + + .. code-block:: bash + + lapd rerun_fws -s FIZZLED atomate issue ============= From 9adc758d63fd9820a2045fa17d03f3c0f0092591 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 11:31:44 -0500 Subject: [PATCH 108/111] docs --- docs/source/troubleshooting.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 7cf0f92b..f73c70ce 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -99,18 +99,18 @@ or equivalently in the ``.cshrc`` file pip install -e . - 14. Sometimes, some VASP jobs may crash (showing as "F" or "FIZZLED") due to various reasons (Ram leakage, job time limitations etc) or even no reasons. + 14. Sometimes, some VASP jobs may crash (showing as "F" or "FIZZLED" when you use the command ``lpad get_wflows`` to check your job status) due to various reasons (Ram leakage, job time limitations etc) or even no reasons. These problems can mostly resovled by rerun the wflows using: .. code-block:: bash - lapd rerun_fws -s FIZZLED + lapd rerun_fws -s FIZZLED #you may ``qlaunch your VASP batch jobs if no jobs in queue`` -atomate issue -============= +atomate issue (This issue has been resolved by atomate 1.0.3) +============================================================= - atomate not compatible with pymongo >=4.0, you can sovle it by:: + if you use old version of atomate such as 0.9.7, atomate may not be compatible with pymongo >=4.0, you can sovle it by:: pip uninstall pymongo From 304239460144598f739841d48c87cb790ead1a53 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 12:33:15 -0500 Subject: [PATCH 109/111] docs --- docs/source/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index f73c70ce..72acc596 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -105,7 +105,7 @@ or equivalently in the ``.cshrc`` file .. code-block:: bash - lapd rerun_fws -s FIZZLED #you may ``qlaunch your VASP batch jobs if no jobs in queue`` + lapd rerun_fws -s FIZZLED #you may need ``qlaunch`` your VASP batch jobs if no jobs in queue atomate issue (This issue has been resolved by atomate 1.0.3) ============================================================= From 464c70c5e97b6ac8b3fb71f279d8dd34938f0a10 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 9 Dec 2022 18:12:06 -0500 Subject: [PATCH 110/111] docs --- docs/source/troubleshooting.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 72acc596..43f48ef8 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -86,6 +86,8 @@ or equivalently in the ``.cshrc`` file 13. During the installation in Windows system, the latest fireworks package may give you some troubles + See troubleshooting 6. If peoblem persists, do the following: + I solved the problem by installing the development version .. code-block:: bash From c84937edd123b57889c0457ca4e17d6302f48659 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sat, 10 Dec 2022 16:18:20 -0500 Subject: [PATCH 111/111] docs --- docs/source/troubleshooting.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 43f48ef8..ef2e5edc 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -86,7 +86,7 @@ or equivalently in the ``.cshrc`` file 13. During the installation in Windows system, the latest fireworks package may give you some troubles - See troubleshooting 6. If peoblem persists, do the following: + See troubleshooting 6. If the problem persists, do the following: I solved the problem by installing the development version @@ -103,10 +103,11 @@ or equivalently in the ``.cshrc`` file 14. Sometimes, some VASP jobs may crash (showing as "F" or "FIZZLED" when you use the command ``lpad get_wflows`` to check your job status) due to various reasons (Ram leakage, job time limitations etc) or even no reasons. - These problems can mostly resovled by rerun the wflows using: + These problems can mostly be resoleed by rerunning the wflows using: .. code-block:: bash + lapd detect_lostruns --rerun lapd rerun_fws -s FIZZLED #you may need ``qlaunch`` your VASP batch jobs if no jobs in queue atomate issue (This issue has been resolved by atomate 1.0.3)