完善建模交互、组件图标与系统协议
This commit is contained in:
1 parent
456c29b3b6
commit
6572defaa4
66 files changed
+10067
-4163
No files matched your search
@@ -6,6 +6,7 @@ from app.main import (
|
||||
ReactFlowProjectPayload,
|
||||
build_reactflow_system_xml,
|
||||
compile_reactflow_network,
|
||||
compile_system_xml_network,
|
||||
)
|
||||
from app.system_xml import validate_system_xml_document
|
||||
from app.simulation.components.amesim.gases import (
|
||||
@@ -176,6 +177,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
registry.resolve(2, component_name="pipe_1")
|
||||
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="undefined-gas",
|
||||
nodes=[pneumatic_pipe_node("pipe_1", gi=2.0)],
|
||||
)
|
||||
@@ -221,6 +223,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="project-air-slot",
|
||||
nodes=[
|
||||
pneumatic_pipe_node("pipe_1", gi=1.0),
|
||||
@@ -267,6 +270,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
|
||||
def test_project_medium_definition_may_appear_after_its_references(self) -> None:
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="two-phase-medium-resolution",
|
||||
nodes=[
|
||||
pneumatic_chamber_node("chamber_1", gi=7.0),
|
||||
@@ -285,6 +289,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
self,
|
||||
) -> None:
|
||||
original = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="medium-xml-round-trip",
|
||||
nodes=[
|
||||
ideal_air_medium_node(
|
||||
@@ -302,7 +307,6 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
self.assertTrue(report.valid, report.issues)
|
||||
self.assertIsNotNone(report.document)
|
||||
assert report.document is not None
|
||||
self.assertEqual(report.document.medium_reference_version, "1")
|
||||
components = {
|
||||
component.id: component for component in report.document.components
|
||||
}
|
||||
@@ -310,6 +314,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
components["air_properties"].model_type,
|
||||
"amesim_ideal_air_medium",
|
||||
)
|
||||
self.assertEqual(components["air_properties"].model_version, "0.2.0")
|
||||
self.assertEqual(
|
||||
{item.name: item.value for item in components["air_properties"].parameters},
|
||||
{"gi": 4.0, "property_model": 0.0},
|
||||
@@ -320,11 +325,17 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
],
|
||||
4.0,
|
||||
)
|
||||
|
||||
parsed_project = ReactFlowProjectPayload(
|
||||
**report.document.as_project_data()
|
||||
model_components = {
|
||||
component["id"]: component
|
||||
for component in report.document.as_model_data()["components"]
|
||||
}
|
||||
self.assertEqual(
|
||||
model_components["air_properties"]["parameters"],
|
||||
{"gi": 4.0, "property_model": 0.0},
|
||||
)
|
||||
network = compile_reactflow_network(parsed_project)
|
||||
self.assertEqual(model_components["pipe_1"]["parameters"]["gi"], 4.0)
|
||||
|
||||
network = compile_system_xml_network(report.document)
|
||||
|
||||
self.assertNotIn("air_properties", network.components)
|
||||
self.assertIsInstance(
|
||||
@@ -334,6 +345,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
|
||||
def test_duplicate_project_medium_indices_are_rejected(self) -> None:
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="duplicate-medium-index",
|
||||
nodes=[
|
||||
ideal_air_medium_node("air_properties_1", gi=1.0),
|
||||
@@ -349,6 +361,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
|
||||
def test_medium_definition_cannot_claim_builtin_slot_zero(self) -> None:
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="reserved-medium-index",
|
||||
nodes=[ideal_air_medium_node("air_properties", gi=0.0)],
|
||||
)
|
||||
@@ -358,6 +371,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
|
||||
def test_default_compile_uses_air_before_state_initialization(self) -> None:
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="default-air",
|
||||
nodes=[pneumatic_chamber_node("chamber_1")],
|
||||
)
|
||||
@@ -374,6 +388,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
def test_gi_is_resolved_before_dynamic_state_initialization(self) -> None:
|
||||
registry, _, future_helium = two_slot_registry()
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="selected-medium-initialization",
|
||||
nodes=[pneumatic_chamber_node("chamber_1", gi=2.0)],
|
||||
)
|
||||
@@ -399,6 +414,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
) -> None:
|
||||
registry, _, future_helium = two_slot_registry()
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="future-helium-circuit",
|
||||
nodes=[
|
||||
pneumatic_pipe_node("pnl_1", gi=2.0),
|
||||
@@ -425,6 +441,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
def test_connected_circuit_rejects_conflicting_gas_indices(self) -> None:
|
||||
registry, _, _ = two_slot_registry()
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="conflicting-gases",
|
||||
nodes=[
|
||||
pneumatic_pipe_node("air_pipe", gi=0.0),
|
||||
@@ -453,6 +470,7 @@ class AmesimGasRegistryTests(unittest.TestCase):
|
||||
def test_disconnected_circuits_may_use_different_gas_indices(self) -> None:
|
||||
registry, air, future_helium = two_slot_registry()
|
||||
project = ReactFlowProjectPayload(
|
||||
projectSchemaVersion=1,
|
||||
name="separate-gases",
|
||||
nodes=[
|
||||
pneumatic_pipe_node("air_pipe", gi=0.0),
|
||||
|
||||
Reference in new issue
Block a user