Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion process/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class Vmcon(_Solver):
def solve(self) -> int:
"""Optimise using new VMCON.

:raises NotImplementedError: not currently implemented
:return: solver error code
:rtype: int
"""
Expand All @@ -179,6 +178,37 @@ def _solver_callback(i: int, _result, _x, convergence_param: float):
flush=True,
)

def _ineq_cons_satisfied(
result: Result,
_x: np.ndarray,
_delta: np.ndarray,
_lambda_eq: np.ndarray,
_lambda_in: np.ndarray,
) -> bool:
"""Check that inequality constraints are satisfied.

This additional convergence criterion ensures that solutions have
satisfied inequality constraints.

:param result: evaluation of current optimisation parameter vector
:type result: Result
:param _x: current optimisation parameter vector
:type _x: np.ndarray
:param _delta: search direction for line search
:type _delta: np.ndarray
:param _lambda_eq: equality Lagrange multipliers
:type _lambda_eq: np.ndarray
:param _lambda_in: inequality Lagrange multipliers
:type _lambda_in: np.ndarray
:return: True if inequality constraints satisfied
:rtype: bool
"""
# Check all ineqs positive, i.e. satisfied
if np.all(result.ie >= 0.0):
return True
else:
return False

try:
x, _, _, res = solve(
problem,
Expand All @@ -190,6 +220,7 @@ def _solver_callback(i: int, _result, _x, convergence_param: float):
qsp_options={"eps_rel": 1e-1, "adaptive_rho_interval": 25},
initial_B=B,
callback=_solver_callback,
additional_convergence=_ineq_cons_satisfied,
)
except VMCONConvergenceException as e:
if isinstance(e, LineSearchConvergenceException):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ numba>=0.57
pandas>=1.1.5
bokeh==2.4.0
mkdocstrings==0.18.0
PyVMCON>=2.1.0,<3.0.0
PyVMCON>=2.2.2,<3.0.0
CoolProp>=6.4
Jinja2>=3.0
cvxpy!=1.3.0,!=1.3.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"tables",
"SALib",
"numba>=0.57",
"PyVMCON>=2.1.0,<3.0.0",
"PyVMCON>=2.2.2,<3.0.0",
"CoolProp>=6.4",
"seaborn>=0.12.2",
],
Expand Down
5 changes: 5 additions & 0 deletions tests/regression/test_process_input_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ def test_input_file(
should be compared in the test.
:type opt_params_only: bool
"""
if input_file.name == "stellarator.IN.DAT":
pytest.skip(
reason="Stellarator currently doesn't converge with satisfied inequality constraints."
)

new_input_file = tmp_path / input_file.name
shutil.copy(input_file, new_input_file)

Expand Down