diff --git a/.gitignore b/.gitignore index 5edd93e3..17e56120 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ # Directories /build*/ /_*/ + +# Outputs +.EDISP +.CPC diff --git a/test/validation/16-db-d3-bj.json b/test/validation/16-db-d3-bj.json index 23086980..815ec91f 100644 --- a/test/validation/16-db-d3-bj.json +++ b/test/validation/16-db-d3-bj.json @@ -1,4 +1,13 @@ { - "version": "0.4.2", - "energy": -7.5851998023687944E-02 + "version": "1.2.1", + "energy": -7.5474602132487828E-02, + "damping parameters": { + "damping": "rational", + "s6": 1.0000000000000000E+00, + "s8": 2.1166999999999998E+00, + "s9": 1.0000000000000000E+00, + "a1": 1.9860000000000000E-01, + "a2": 5.3875000000000002E+00, + "alp": 1.4000000000000000E+01 + } } diff --git a/test/validation/18-db-d3-bjm.json b/test/validation/18-db-d3-bjm.json index 93dcfb17..61de8153 100644 --- a/test/validation/18-db-d3-bjm.json +++ b/test/validation/18-db-d3-bjm.json @@ -1,4 +1,13 @@ { - "version": "0.4.2", - "energy": -7.0590046232372944E-02 + "version": "1.2.1", + "energy": -7.0407406164846739E-02, + "damping parameters": { + "damping": "rational", + "s6": 1.0000000000000000E+00, + "s8": 1.8750070000000001E+00, + "s9": 1.0000000000000000E+00, + "a1": 4.4848600000000000E-01, + "a2": 3.6106790000000002E+00, + "alp": 1.4000000000000000E+01 + } } diff --git a/test/validation/19-db-d3-zerom.json b/test/validation/19-db-d3-zerom.json index eb4fc1c3..22869d2f 100644 --- a/test/validation/19-db-d3-zerom.json +++ b/test/validation/19-db-d3-zerom.json @@ -1,4 +1,14 @@ { - "version": "0.4.2", - "energy": -1.8797304944424987E-02 + "version": "1.2.1", + "energy": -1.8667013017417262E-02, + "damping parameters": { + "damping": "mzero", + "s6": 6.4000000000000001E-01, + "s8": 7.1754300000000004E-01, + "s9": 1.0000000000000000E+00, + "rs6": 1.3131340000000000E+00, + "rs8": 1.0000000000000000E+00, + "alp": 1.4000000000000000E+01, + "bet": 1.6035000000000001E-02 + } } diff --git a/test/validation/20-db-d3-op.json b/test/validation/20-db-d3-op.json index 81e3ec29..a4d6cc80 100644 --- a/test/validation/20-db-d3-op.json +++ b/test/validation/20-db-d3-op.json @@ -1,4 +1,14 @@ { - "version": "0.4.2", - "energy": -1.5747159263772851E-02 + "version": "1.2.1", + "energy": -1.5521531426306081E-02, + "damping parameters": { + "damping": "optimizedpower", + "s6": 1.0000000000000000E+00, + "s8": 9.0742999999999996E-01, + "s9": 1.0000000000000000E+00, + "a1": 6.9999999999999996E-01, + "a2": 4.0000000000000000E+00, + "alp": 1.4000000000000000E+01, + "bet": 2.0000000000000000E+00 + } } diff --git a/test/validation/tester.py b/test/validation/tester.py index 762b8118..cf5980fb 100644 --- a/test/validation/tester.py +++ b/test/validation/tester.py @@ -8,14 +8,51 @@ """ try: - import subprocess, sys, json, os, pytest + import subprocess, sys, json, os except ImportError: exit(77) if len(sys.argv) < 4: raise RuntimeError("Requires at least four arguments") -thr = 1.0e-9 + +class approx: + def __init__(self, value, abs): + self.value = value + self.abs = abs + self.log = [] + + def __eq__(self, other): + def compare(a, b, ctx): + if isinstance(a, list) and isinstance(b, list): + return all(compare(x, y, f"{ctx}[{idx}]") for idx, (x, y) in enumerate(zip(a, b))) + + if isinstance(a, dict) and isinstance(b, dict): + try: + return all(compare(a[k], b[k], f"{ctx}[{k}]") for k in a.keys()) + except KeyError as e: + self.log.append(f"{ctx}: Missing key {e} in dictionary") + return False + + if isinstance(a, (int, float)) and isinstance(b, (int, float)): + stat = abs(a - b) < self.abs + if not stat: + self.log.append(f"{ctx}: {a} != {b} (diff: {abs(a - b)})") + return stat + + stat = a == b + if not stat: + self.log.append(f"{ctx}: {a} != {b}") + return stat + + stat = compare(self.value, other, "") + if not stat: + print("\n".join(self.log)) + + return stat + + +thr = 1.0e-6 prog = sys.argv[1] outp = sys.argv[2] with open(sys.argv[3]) as fd: @@ -38,7 +75,4 @@ with open(os.path.basename(outp)) as f: res = json.load(f) -for key in ref: - if key not in res: - raise RuntimeError("Missing '" + key + "' entry in results") - assert pytest.approx(res[key], abs=thr) == ref[key] +assert approx(ref, abs=thr) == res