优化压力流量求解并达到四路性能门槛

This commit is contained in:
huojiarong committed 2026-08-15 11:45:22 +00:00
1 parent 6572defaa4
commit 6a064892e2
20 files changed
+711 -175

No files matched your search

+23 -3
View File
@@ -44,13 +44,19 @@ class Component(ABC):
if port.definition is not None
)
@property
def active_port_definitions(self) -> tuple[PortDefinition, ...]:
"""Instance ports that participate in execution and result reporting."""
return self.port_definitions
@property
def required_connection_ports(self) -> tuple[str, ...]:
"""Physical ports that must have an external connection before simulation."""
return tuple(
definition.name
for definition in self.port_definitions
for definition in self.active_port_definitions
if definition.kind == "physical"
)
@@ -134,7 +140,7 @@ class Component(ABC):
)
values[name] = float(component_values[name])
for port_definition in self.port_definitions:
for port_definition in self.active_port_definitions:
port = self.get_port(port_definition.name)
for variable in port_definition.variables:
if not variable.result_visible:
@@ -161,7 +167,7 @@ class Component(ABC):
for definition in self.RESULT_VARIABLES
if definition.visible
]
for port_definition in self.port_definitions:
for port_definition in self.active_port_definitions:
for variable in port_definition.variables:
if not variable.result_visible:
continue
@@ -209,6 +215,20 @@ class Component(ABC):
return ()
def pressure_flow_equation_values(self) -> tuple[float, ...]:
"""Return live residual values in the declared equation order.
Components with frequently evaluated equations can override this
method to avoid rebuilding immutable equation metadata during closure.
The default keeps third-party components compatible with the public
residual API.
"""
return tuple(
float(equation.value)
for equation in self.pressure_flow_equation_residuals()
)
def update_stream_outflows(self, connected_h: Mapping[str, float]) -> None:
"""Update connector outflow properties from current flow directions."""