chore: sync project state and current artifacts

This commit is contained in:
Sepehr
2026-02-22 23:27:31 +01:00
parent 1b6415776e
commit dd77089b22
232 changed files with 37056 additions and 4296 deletions

View File

@@ -103,7 +103,7 @@ class TestExpansionValve:
def test_default(self):
v = entropyk.ExpansionValve()
assert v.fluid_name == "R134a"
assert v.opening_value is None
assert v.opening_value == pytest.approx(0.5)
def test_with_opening(self):
v = entropyk.ExpansionValve(opening=0.5)

View File

@@ -112,6 +112,100 @@ class TestSolverConfigs:
config = entropyk.FallbackConfig(newton=newton, picard=picard)
assert "50" in repr(config)
def test_newton_advanced_params(self):
config = entropyk.NewtonConfig(
initial_state=[1.0, 2.0, 3.0],
use_numerical_jacobian=True,
line_search_armijo_c=1e-3,
line_search_max_backtracks=10,
divergence_threshold=1e5
)
assert config is not None
def test_picard_advanced_params(self):
config = entropyk.PicardConfig(
initial_state=[1.0, 2.0],
timeout_ms=1000,
)
assert config is not None
def test_convergence_criteria(self):
cc = entropyk.ConvergenceCriteria(
pressure_tolerance_pa=2.0,
mass_balance_tolerance_kgs=1e-8,
energy_balance_tolerance_w=1e-2
)
assert "dP=2.0" in repr(cc)
assert "dM=1.0" in repr(cc)
assert "dE=1.0" in repr(cc)
assert cc.pressure_tolerance_pa == 2.0
config = entropyk.NewtonConfig(convergence_criteria=cc)
assert config is not None
def test_jacobian_freezing(self):
jf = entropyk.JacobianFreezingConfig(max_frozen_iters=5, threshold=0.5)
assert jf.max_frozen_iters == 5
assert jf.threshold == 0.5
config = entropyk.NewtonConfig(jacobian_freezing=jf)
assert config is not None
def test_timeout_config(self):
tc = entropyk.TimeoutConfig(return_best_state_on_timeout=False, zoh_fallback=True)
assert not tc.return_best_state_on_timeout
assert tc.zoh_fallback
config = entropyk.NewtonConfig(timeout_config=tc)
assert config is not None
def test_solver_strategy(self):
newton_strat = entropyk.SolverStrategy.newton(tolerance=1e-5)
picard_strat = entropyk.SolverStrategy.picard(relaxation=0.6)
default_strat = entropyk.SolverStrategy.default()
assert newton_strat is not None
assert picard_strat is not None
assert default_strat is not None
class TestSolverExecution:
"""Tests that the bindings actually call the Rust solver engine."""
@pytest.fixture
def simple_system(self):
system = entropyk.System()
# Use simple components to avoid complex physics crashes
i0 = system.add_component(entropyk.Pipe(length=10.0, diameter=0.1, fluid="Water"))
i1 = system.add_component(entropyk.Pipe(length=10.0, diameter=0.1, fluid="Water"))
system.add_edge(i0, i1)
system.add_edge(i1, i0)
system.finalize()
return system
def test_newton_solve(self, simple_system):
config = entropyk.NewtonConfig(max_iterations=2, timeout_ms=10)
try:
result = config.solve(simple_system)
assert result is not None
except entropyk.SolverError:
# We don't care if it fails to converge, only that it crossed the boundary
pass
def test_picard_solve(self, simple_system):
config = entropyk.PicardConfig(max_iterations=2, timeout_ms=10)
try:
result = config.solve(simple_system)
assert result is not None
except entropyk.SolverError:
pass
def test_strategy_solve(self, simple_system):
strategy = entropyk.SolverStrategy.newton(max_iterations=2, timeout_ms=10)
try:
result = strategy.solve(simple_system)
assert result is not None
except entropyk.SolverError:
pass
class TestConvergedState:
"""Tests for ConvergedState and ConvergenceStatus types."""