Skip to content

Commit

Permalink
Init ecut in AbinitInput.__init__ if hints are available
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Dec 24, 2024
1 parent 21a47d3 commit 54edcc0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 33 deletions.
6 changes: 6 additions & 0 deletions abipy/abio/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion abipy/dfpt/qha_general_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
import os
import abc
#import abc
import math
import abipy.core.abinit_units as abu

Expand Down
15 changes: 4 additions & 11 deletions abipy/examples/flows/run_qha_2d.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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)
)
Expand Down
6 changes: 2 additions & 4 deletions abipy/examples/flows/run_qha_vzsisa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
)

Expand Down
20 changes: 5 additions & 15 deletions abipy/examples/flows/run_qha_zsisa.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions abipy/flowtk/vzsisa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 54edcc0

Please sign in to comment.