From 54edcc0645b7729f6354a5fa954f804079797612 Mon Sep 17 00:00:00 2001 From: Matteo Giantomassi Date: Tue, 24 Dec 2024 16:29:11 +0100 Subject: [PATCH] Init ecut in AbinitInput.__init__ if hints are available --- abipy/abio/inputs.py | 6 ++++++ abipy/dfpt/qha_general_stress.py | 2 +- abipy/examples/flows/run_qha_2d.py | 15 ++++----------- abipy/examples/flows/run_qha_vzsisa.py | 6 ++---- abipy/examples/flows/run_qha_zsisa.py | 20 +++++--------------- abipy/flowtk/vzsisa.py | 4 ++-- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/abipy/abio/inputs.py b/abipy/abio/inputs.py index 53400e4a8..7924e1934 100644 --- a/abipy/abio/inputs.py +++ b/abipy/abio/inputs.py @@ -455,6 +455,12 @@ def __init__(self, structure, pseudos, self._pseudos = ord_pseudos + # Init ecut from hints if available. + try: + self.set_cutoffs_for_accuracy("normal") + except self.Error: + pass + def enforce_znucl_and_typat(self, znucl, typat): """ These arrays are used to enforce a particular value of `znucl` and `typat` when writing the Abinit input file diff --git a/abipy/dfpt/qha_general_stress.py b/abipy/dfpt/qha_general_stress.py index 2dc208999..b24e1666b 100644 --- a/abipy/dfpt/qha_general_stress.py +++ b/abipy/dfpt/qha_general_stress.py @@ -6,7 +6,7 @@ import numpy as np import os -import abc +#import abc import math import abipy.core.abinit_units as abu diff --git a/abipy/examples/flows/run_qha_2d.py b/abipy/examples/flows/run_qha_2d.py index b4168762c..f178f4fd1 100755 --- a/abipy/examples/flows/run_qha_2d.py +++ b/abipy/examples/flows/run_qha_2d.py @@ -1,7 +1,7 @@ #!/usr/bin/env python r""" Flow for quasi-harmonic calculations under development -===================================================== +====================================================== Warning: This code is still under development. """ import sys @@ -45,10 +45,7 @@ def build_flow(options): # Use NC PBE pseudos from pseudodojo v0.4 from abipy.flowtk.psrepos import get_oncvpsp_pseudos - pseudos = get_oncvpsp_pseudos(xc_name="PBE", version="0.4", accuracy="standard").get_pseudos_for_structure(structure) - - #ecut = max(p.hint_for_accuracy("normal").ecut for p in pseudos) - #print(ecut) + pseudos = get_oncvpsp_pseudos(xc_name="PBEsol", version="0.4") # Select k-mesh for electrons and q-mesh for phonons. #ngkpt = [6, 6, 4]; ngqpt = [1, 1, 1] @@ -59,18 +56,14 @@ def build_flow(options): #with_quad = not structure.has_zero_dynamical_quadrupoles scf_input = abilab.AbinitInput(structure, pseudos) - #scf_input.set_cutoffs_for_accuracy("standard") - # Set other important variables (consistent with tutorial) - # All the other DFPT runs will inherit these parameters. + # Set other important variables scf_input.set_vars( + nband=scf_input.num_valence_electrons // 2, nline=10, nbdbuf=0, nstep=100, - ecut=42.0, ecutsm=1.0, - occopt=1, - nband=26, #tolvrs=1.0e-18, # SCF stopping criterion (modify default) tolvrs=1.0e-6, # SCF stopping criterion (modify default) ) diff --git a/abipy/examples/flows/run_qha_vzsisa.py b/abipy/examples/flows/run_qha_vzsisa.py index 446c7bec2..d7dd0d939 100755 --- a/abipy/examples/flows/run_qha_vzsisa.py +++ b/abipy/examples/flows/run_qha_vzsisa.py @@ -28,7 +28,7 @@ def build_flow(options): # Get NC pseudos from pseudodojo. from abipy.flowtk.psrepos import get_oncvpsp_pseudos - pseudos = get_oncvpsp_pseudos(xc_name="PBE", version="0.4") + pseudos = get_oncvpsp_pseudos(xc_name="PBEsol", version="0.4") # Select k-mesh for electrons and q-mesh for phonons. ngkpt = [2, 2, 2]; ngqpt = [1, 1, 1] @@ -48,13 +48,11 @@ def build_flow(options): # Set other important variables # All the other DFPT runs will inherit these parameters. scf_input.set_vars( - nband=4, + nband=scf_input.num_valence_electrons // 2, nline=10, nbdbuf=0, nstep=100, - ecut=8.0, ecutsm=1.0, - occopt=1, tolvrs=1.0e-18, # SCF stopping criterion (modify default) ) diff --git a/abipy/examples/flows/run_qha_zsisa.py b/abipy/examples/flows/run_qha_zsisa.py index ba326f93e..320c7e00c 100755 --- a/abipy/examples/flows/run_qha_zsisa.py +++ b/abipy/examples/flows/run_qha_zsisa.py @@ -1,7 +1,7 @@ #!/usr/bin/env python r""" Flow for quasi-harmonic calculations under development -===================================================== +====================================================== Warning: This code is still under development. """ import sys @@ -47,10 +47,7 @@ def build_flow(options): # Use NC PBE pseudos from pseudodojo v0.4 from abipy.flowtk.psrepos import get_oncvpsp_pseudos - pseudos = get_oncvpsp_pseudos(xc_name="PBE", version="0.4", accuracy="standard").get_pseudos_for_structure(structure) - - #ecut = max(p.hint_for_accuracy("normal").ecut for p in pseudos) - #print(ecut) + pseudos = get_oncvpsp_pseudos(xc_name="PBEsol", version="0.4") # Select k-mesh for electrons and q-mesh for phonons. #ngkpt = [6, 6, 4]; ngqpt = [1, 1, 1] @@ -59,30 +56,23 @@ def build_flow(options): with_becs = False with_quad = False #with_quad = not structure.has_zero_dynamical_quadrupoles - eps = 0.005 scf_input = abilab.AbinitInput(structure, pseudos) - #scf_input.set_cutoffs_for_accuracy("standard") - # Set other important variables (consistent with tutorial) - # All the other DFPT runs will inherit these parameters. + # Set other important variables scf_input.set_vars( + nband=scf_input.num_valence_electrons // 2, nline=10, nbdbuf=0, nstep=100, - #ecut=42.0, - ecut=12.0, ecutsm=1.0, - occopt=1, - #nband=26, - nband=4, #tolvrs=1.0e-18, # SCF stopping criterion (modify default) tolvrs=1.0e-6, # SCF stopping criterion (modify default) ) - #scf_input.set_scf_nband_semicond() scf_input.set_kmesh(ngkpt=ngkpt, shiftk=[0, 0, 0]) + eps = 0.005 return ZsisaFlow.from_scf_input(options.workdir, scf_input, eps, ngqpt, with_becs, with_quad, edos_ngkpt=None) diff --git a/abipy/flowtk/vzsisa.py b/abipy/flowtk/vzsisa.py index b01f1d298..95ac019f5 100644 --- a/abipy/flowtk/vzsisa.py +++ b/abipy/flowtk/vzsisa.py @@ -41,8 +41,8 @@ def from_scf_input(cls, Args: workdir: Working directory of the flow. scf_input: |AbinitInput| for GS-SCF run used as template to generate other inputs. - bo_vol_scales: List of scaling factors for the BO volumes. - ph_vol_scales: List of scaling factors for the BO volumes. + bo_vol_scales: List of volumetric scaling factors for the BO terms + ph_vol_scales: List of volumetric scaling factors for phonons. ngqpt: Three integers defining the q-mesh for phonon calculation. with_becs: Activate calculation of Electric field and Born effective charges. with_quad: Activate calculation of dynamical quadrupoles. Require `with_becs`