完善 PNL00R 摩擦模型与八路回归

This commit is contained in:
huojiarong committed 2026-08-18 09:30:29 +00:00
1 parent 684d28752a
commit f725f038b6
10 files changed
+498 -98

No files matched your search

+42 -12
View File
@@ -241,8 +241,9 @@ class ResistancePnl0001SeriesBinding:
resistance_port: str
resistance_other_port: str
positive_flow_port: str
pipe: AmesimPnl0001
pipe: AmesimPnl00r | AmesimPnl0001
pipe_port: str
pipe_other_port: str | None
@dataclass(frozen=True)
@@ -2338,24 +2339,31 @@ class PressureFlowSolver:
) -> tuple[ResistancePnl0001SeriesBinding, ...]:
bindings: list[ResistancePnl0001SeriesBinding] = []
resistance_types = (AmesimPnor001, AmesimPnvo001FixedOpening)
pipe_types = (AmesimPnl00r, AmesimPnl0001)
for connection in self.network.connections:
first_endpoint, second_endpoint = connection.endpoints
first = self.network.components[first_endpoint.component]
second = self.network.components[second_endpoint.component]
if isinstance(first, resistance_types) and isinstance(
second, AmesimPnl0001
second, pipe_types
):
resistance, resistance_port = first, first_endpoint.port
pipe, pipe_port = second, second_endpoint.port
elif isinstance(second, resistance_types) and isinstance(
first, AmesimPnl0001
first, pipe_types
):
resistance, resistance_port = second, second_endpoint.port
pipe, pipe_port = first, first_endpoint.port
else:
continue
if isinstance(pipe, AmesimPnl0002) or pipe_port != "port_1":
continue
if isinstance(pipe, AmesimPnl0001):
if isinstance(pipe, AmesimPnl0002) or pipe_port != "port_1":
continue
pipe_other_port = None
else:
pipe_other_port = (
"port_2" if pipe_port == "port_1" else "port_1"
)
if isinstance(resistance, AmesimPnor001):
positive_flow_port, negative_flow_port = "port_1", "port_2"
else:
@@ -2374,12 +2382,13 @@ class PressureFlowSolver:
positive_flow_port=positive_flow_port,
pipe=pipe,
pipe_port=pipe_port,
pipe_other_port=pipe_other_port,
)
)
return tuple(bindings)
def _seed_resistance_pnl0001_series_pressures(self) -> None:
"""Causalize pressure between an orifice/valve and a PNL0001 R port."""
"""Causalize pressure between an orifice/valve and a PNL pipe."""
from scipy.optimize import brentq
@@ -2390,7 +2399,14 @@ class PressureFlowSolver:
pipe_port = binding.pipe_port
pressure_a = resistance.get_port(binding.resistance_other_port).p
pressure_b = pipe.properties().p
if isinstance(pipe, AmesimPnl00r):
assert binding.pipe_other_port is not None
pressure_b = pipe.get_port(binding.pipe_other_port).p
pipe_temperature = None
else:
pipe_properties = pipe.properties()
pressure_b = pipe_properties.p
pipe_temperature = pipe_properties.T
lower = min(pressure_a, pressure_b)
upper = max(pressure_a, pressure_b)
@@ -2405,11 +2421,25 @@ class PressureFlowSolver:
pressure_a,
intermediate_pressure,
)
pipe_flow_into_connection = pipe.mass_flow(
intermediate_pressure,
pressure_b,
pipe.properties().T,
)
if isinstance(pipe, AmesimPnl00r):
pipe.get_port(pipe_port).p = intermediate_pressure
if pipe_port == "port_1":
pipe_flow_into_connection = pipe.mass_flow(
intermediate_pressure,
pressure_b,
)
else:
pipe_flow_into_connection = -pipe.mass_flow(
pressure_b,
intermediate_pressure,
)
else:
assert pipe_temperature is not None
pipe_flow_into_connection = pipe.mass_flow(
intermediate_pressure,
pressure_b,
pipe_temperature,
)
return resistance_flow_into_connection + pipe_flow_into_connection
lower_value = mismatch(lower)