接入test_mql真实气动组件
This commit is contained in:
1 parent
94badfb56f
commit
314b65872e
2 files changed
+149
-1
No files matched your search
@@ -2,6 +2,11 @@ from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from PythonModels.components.amesim_pneumatic import (
|
||||
AmesimPneumaticOrifice,
|
||||
AmesimPneumaticVolume,
|
||||
AmesimVariablePneumaticVolume,
|
||||
)
|
||||
from PythonModels.systems.test_mql import GLOBAL_PARAMETERS, SUBMODEL_COUNTS, TestMqlSystem
|
||||
|
||||
|
||||
@@ -25,6 +30,72 @@ class TestMqlStructuralTest(unittest.TestCase):
|
||||
self.assertIn("pn_brp2_8", system.network.components)
|
||||
self.assertIn("pn_gas_data", system.network.components)
|
||||
|
||||
def test_network_uses_typed_pneumatic_components_where_available(self) -> None:
|
||||
system = TestMqlSystem()
|
||||
|
||||
self.assertEqual(system.typed_pneumatic_component_count, 28)
|
||||
self.assertIsInstance(
|
||||
system.network.components["pn_general_chamber"],
|
||||
AmesimPneumaticVolume,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
system.network.components["pn_c1_8"],
|
||||
AmesimVariablePneumaticVolume,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
system.network.components["pn_orifice_18"],
|
||||
AmesimPneumaticOrifice,
|
||||
)
|
||||
self.assertIsInstance(
|
||||
system.network.components["pn_morifice_11"],
|
||||
AmesimPneumaticOrifice,
|
||||
)
|
||||
self.assertEqual(len(system.pneumatic_state_vector()), 24)
|
||||
|
||||
def test_can_build_pneumatic_branch_closure_from_typed_components(self) -> None:
|
||||
system = TestMqlSystem()
|
||||
|
||||
closure = system.pneumatic_branch_closure(
|
||||
name="typed_branch",
|
||||
upstream_volume_alias="pn_general_chamber",
|
||||
orifice_alias="pn_orifice_18",
|
||||
downstream_volume_alias="pn_c1_8",
|
||||
)
|
||||
snapshot = closure.snapshot()
|
||||
|
||||
self.assertGreater(snapshot.flow, 0.0)
|
||||
self.assertIs(
|
||||
closure.components.upstream_volume,
|
||||
system.network.components["pn_general_chamber"],
|
||||
)
|
||||
self.assertIs(
|
||||
closure.components.orifice,
|
||||
system.network.components["pn_orifice_18"],
|
||||
)
|
||||
self.assertIs(
|
||||
closure.components.downstream_volume,
|
||||
system.network.components["pn_c1_8"],
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
closure.components.upstream_volume.port_a.m_flow,
|
||||
-snapshot.flow,
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
closure.components.downstream_volume.port_a.m_flow,
|
||||
snapshot.flow,
|
||||
)
|
||||
|
||||
def test_pneumatic_branch_closure_rejects_structural_components(self) -> None:
|
||||
system = TestMqlSystem()
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
system.pneumatic_branch_closure(
|
||||
name="invalid_branch",
|
||||
upstream_volume_alias="pn_brp2_8",
|
||||
orifice_alias="pn_orifice_18",
|
||||
downstream_volume_alias="pn_c1_8",
|
||||
)
|
||||
|
||||
def test_submodel_counts_keep_key_amesim_families(self) -> None:
|
||||
self.assertEqual(SUBMODEL_COUNTS["PNRP17"], 8)
|
||||
self.assertEqual(SUBMODEL_COUNTS["PNCH012"], 8)
|
||||
|
||||
Reference in new issue
Block a user