Skip to content

Commit 7972b83

Browse files
committed
check parameters validity
1 parent c864049 commit 7972b83

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/dcore/anacont/pade.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ def parameters_from_ini(inifile):
5959
parser = create_parser(["post.anacont.pade"])
6060
parser.read(inifile)
6161
params = parser.as_dict()
62+
parse_parameters(params)
6263
return params["post.anacont.pade"]

src/dcore/anacont/spm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from scipy.sparse.linalg import svds
2525

2626
from dcore._dispatcher import MeshImFreq, GfImFreq, GfReFreq
27-
from dcore.program_options import create_parser
27+
from dcore.program_options import create_parser, parse_parameters
2828

2929
def set_default_values(dictionary, default_values_dict):
3030
for key, value in default_values_dict.items():
@@ -285,6 +285,7 @@ def parameters_from_ini(inifile):
285285
parser = create_parser(["post.anacont.spm"])
286286
parser.read(inifile)
287287
params = parser.as_dict()
288+
parse_parameters(params)
288289
return params["post.anacont.spm"]
289290

290291
def anacont(sigma_iw_npz, beta, mesh_w, params_spm):

src/dcore/program_options.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,33 @@ def parse_parameters(params):
268268
if 'tool' in params:
269269
if params['tool']['n_pade_max'] < 0:
270270
params['tool']['n_pade_max'] = params['system']['n_iw']
271-
271+
272+
if 'post' in params:
273+
if params['post']['omega_min'] >= params['post']['omega_max']:
274+
sys.exit(f"ERROR: omega_min={params['post']['omega_min']} must be less than omega_max={params['post']['omega_max']}.")
275+
if params['post']['Nomega'] <= 0:
276+
sys.exit(f"ERROR: Nomega={params['post']['Nomega']} must be a positive integer.")
277+
278+
if 'post.anacont.pade' in params:
279+
if params['post.anacont.pade']['iomega_max'] < 0:
280+
sys.exit(f"ERROR: iomega_max={params['post.anacont.pade']['iomega_max']} must be a positive float.")
281+
if params['post.anacont.pade']['n_min'] < 0:
282+
sys.exit(f"ERROR: n_min={params['post.anacont.pade']['n_min']} must be a positive integer.")
283+
if params['post.anacont.pade']['n_max'] < params['post.anacont.pade']['n_min']:
284+
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']}.")
285+
286+
if 'post.anacont.spm' in params:
287+
if params['post.anacont.spm']['n_matsubara'] <= 0:
288+
sys.exit(f"ERROR: n_matsubara={params['post.anacont.spm']['n_matsubara']} must be a positive integer.")
289+
if params['post.anacont.spm']['n_tail'] <= 0:
290+
sys.exit(f"ERROR: n_tail={params['post.anacont.spm']['n_tail']} must be a positive integer.")
291+
if params['post.anacont.spm']['n_sv'] <= 0:
292+
sys.exit(f"ERROR: n_sv={params['post.anacont.spm']['n_sv']} must be a positive integer.")
293+
if params['post.anacont.spm']['lambda'] < 0:
294+
sys.exit(f"ERROR: lambda={params['post.anacont.spm']['lambda']} must be a non-negative float.")
295+
if params['post.anacont.spm']['max_iters_opt'] <= 0:
296+
sys.exit(f"ERROR: max_iters_opt={params['post.anacont.spm']['max_iters_opt']} must be a positive integer.")
297+
272298

273299
def parse_knode(knode_string):
274300
"""

0 commit comments

Comments
 (0)