Replace Python numerical kernels with native C execution

This commit is contained in:
ljz committed 2026-09-10 01:12:18 +08:00
1 parent 48da6be21c
commit 3b38f73fe0
227 files changed
+16801 -75499

No files matched your search

-53
View File
@@ -35,61 +35,8 @@ class AmesimPnch023ComponentTests(unittest.TestCase):
{"gi": 1.5},
)
def test_initial_state_matches_requested_pressure_temperature(self) -> None:
chamber = AmesimPnch023(
"chamber_1",
self.medium,
cvol=0.057,
p0=15300000.0,
T0=293.15,
)
props = chamber.properties()
self.assertAlmostEqual(props.p, 15300000.0)
self.assertAlmostEqual(props.T, 293.15)
self.assertAlmostEqual(chamber.port_1.p, props.p)
self.assertAlmostEqual(chamber.port_2.p, props.p)
def test_two_port_derivative_conserves_mass_and_adds_heat_transfer(self) -> None:
chamber = AmesimPnch023(
"chamber_1",
self.medium,
kth=10.0,
sth=2.0,
extemp=310.0,
T0=300.0,
)
props = chamber.properties()
chamber.port_1.m_flow = 0.2
chamber.port_2.m_flow = -0.1
derivative = chamber.state_derivative_from_ports(
{
"port_1": props.h + 1000.0,
"port_2": props.h - 1000.0,
}
)
self.assertAlmostEqual(derivative[0], 0.1)
self.assertAlmostEqual(
derivative[1],
0.2 * (props.h + 1000.0) - 0.1 * props.h + 10.0 * 2.0 * 10.0,
)
def test_pressure_residuals_bind_both_ports_to_state(self) -> None:
chamber = AmesimPnch023("chamber_1", self.medium, p0=200000.0, T0=300.0)
chamber.port_1.p = 200100.0
chamber.port_2.p = 199900.0
residuals = {
residual.id.rsplit(":", 1)[1]: residual
for residual in chamber.pressure_flow_equation_residuals()
}
self.assertEqual(set(residuals), {"port_1_pressure_state", "port_2_pressure_state"})
self.assertAlmostEqual(residuals["port_1_pressure_state"].value, 100.0)
self.assertAlmostEqual(residuals["port_2_pressure_state"].value, -100.0)
if __name__ == "__main__":