Skip to content

Commit

Permalink
check parameters validity
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed May 10, 2024
1 parent c864049 commit 7972b83
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/dcore/anacont/pade.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ def parameters_from_ini(inifile):
parser = create_parser(["post.anacont.pade"])
parser.read(inifile)
params = parser.as_dict()
parse_parameters(params)
return params["post.anacont.pade"]
3 changes: 2 additions & 1 deletion src/dcore/anacont/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from scipy.sparse.linalg import svds

from dcore._dispatcher import MeshImFreq, GfImFreq, GfReFreq
from dcore.program_options import create_parser
from dcore.program_options import create_parser, parse_parameters

def set_default_values(dictionary, default_values_dict):
for key, value in default_values_dict.items():
Expand Down Expand Up @@ -285,6 +285,7 @@ def parameters_from_ini(inifile):
parser = create_parser(["post.anacont.spm"])
parser.read(inifile)
params = parser.as_dict()
parse_parameters(params)
return params["post.anacont.spm"]

def anacont(sigma_iw_npz, beta, mesh_w, params_spm):
Expand Down
28 changes: 27 additions & 1 deletion src/dcore/program_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,33 @@ def parse_parameters(params):
if 'tool' in params:
if params['tool']['n_pade_max'] < 0:
params['tool']['n_pade_max'] = params['system']['n_iw']


if 'post' in params:
if params['post']['omega_min'] >= params['post']['omega_max']:
sys.exit(f"ERROR: omega_min={params['post']['omega_min']} must be less than omega_max={params['post']['omega_max']}.")
if params['post']['Nomega'] <= 0:
sys.exit(f"ERROR: Nomega={params['post']['Nomega']} must be a positive integer.")

if 'post.anacont.pade' in params:
if params['post.anacont.pade']['iomega_max'] < 0:
sys.exit(f"ERROR: iomega_max={params['post.anacont.pade']['iomega_max']} must be a positive float.")
if params['post.anacont.pade']['n_min'] < 0:
sys.exit(f"ERROR: n_min={params['post.anacont.pade']['n_min']} must be a positive integer.")
if params['post.anacont.pade']['n_max'] < params['post.anacont.pade']['n_min']:
sys.exit(f"ERROR: n_max={params['post.anacont.pade']['n_max']} must be greater than or equals to n_min={params['post.anacont.pade']['n_min']}.")

if 'post.anacont.spm' in params:
if params['post.anacont.spm']['n_matsubara'] <= 0:
sys.exit(f"ERROR: n_matsubara={params['post.anacont.spm']['n_matsubara']} must be a positive integer.")
if params['post.anacont.spm']['n_tail'] <= 0:
sys.exit(f"ERROR: n_tail={params['post.anacont.spm']['n_tail']} must be a positive integer.")
if params['post.anacont.spm']['n_sv'] <= 0:
sys.exit(f"ERROR: n_sv={params['post.anacont.spm']['n_sv']} must be a positive integer.")
if params['post.anacont.spm']['lambda'] < 0:
sys.exit(f"ERROR: lambda={params['post.anacont.spm']['lambda']} must be a non-negative float.")
if params['post.anacont.spm']['max_iters_opt'] <= 0:
sys.exit(f"ERROR: max_iters_opt={params['post.anacont.spm']['max_iters_opt']} must be a positive integer.")


def parse_knode(knode_string):
"""
Expand Down

0 comments on commit 7972b83

Please sign in to comment.