From ff70078a567a0c271990e83ab9bccadd42076c67 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 16 Aug 2023 15:36:14 +0100 Subject: [PATCH 1/2] Print solver iteration and convergence param --- process/solver.py | 4 ++++ requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/process/solver.py b/process/solver.py index 799c9f06..aa4f5618 100644 --- a/process/solver.py +++ b/process/solver.py @@ -168,6 +168,9 @@ def solve(self) -> int: if self.b is not None: B = np.identity(numerics.nvar) * self.b + def _solver_callback(i: int, _x, _result, convergence_param: float): + print(f"{i+1} | Convergence Parameter: {convergence_param}") + try: x, _, _, res = solve( problem, @@ -178,6 +181,7 @@ def solve(self) -> int: epsilon=self.tolerance, qsp_options={"eps_rel": 1e-1, "adaptive_rho_interval": 25}, initial_B=B, + callback=_solver_callback, ) except VMCONConvergenceException as e: if isinstance(e, LineSearchConvergenceException): diff --git a/requirements.txt b/requirements.txt index 8d864079..96bba206 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,6 @@ pandas>=1.1.5 bokeh==2.4.0 mkdocstrings==0.18.0 flinter==0.3.0 -PyVMCON>=2.0.0,<3.0.0 +PyVMCON>=2.1.0,<3.0.0 CoolProp>=6.4 Jinja2>=3.0 diff --git a/setup.py b/setup.py index ad7c5048..5596c283 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ "tables", "SALib", "numba>=0.55.2", - "PyVMCON>=2.0.0,<3.0.0", + "PyVMCON>=2.1.0,<3.0.0", "CoolProp>=6.4", ], "extras_require": {"test": ["pytest"]}, From 461070b1d355aefb34a695fd9cb313dba049473e Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Wed, 16 Aug 2023 16:09:32 +0100 Subject: [PATCH 2/2] Write convergence param in scientific notation and overwrite previous line --- process/solver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/process/solver.py b/process/solver.py index aa4f5618..69aec2c4 100644 --- a/process/solver.py +++ b/process/solver.py @@ -169,7 +169,7 @@ def solve(self) -> int: B = np.identity(numerics.nvar) * self.b def _solver_callback(i: int, _x, _result, convergence_param: float): - print(f"{i+1} | Convergence Parameter: {convergence_param}") + print(f"{i+1} | Convergence Parameter: {convergence_param:.3E}", end="\r") try: x, _, _, res = solve( @@ -205,6 +205,10 @@ def _solver_callback(i: int, _x, _result, convergence_param: float): else: self.info = 1 + # print a blank line because of the carridge return + # in the callback + print() + self.x = x self.objf = res.f self.conf = np.hstack((res.eq, res.ie))