验收四路模型并优化拓扑求解性能

This commit is contained in:
huojiarong committed 2026-08-12 11:57:42 +00:00
1 parent caca32a513
commit 456c29b3b6
20 files changed
+1085 -137

No files matched your search

+11 -5
View File
@@ -1,6 +1,7 @@
from __future__ import annotations
from collections.abc import Mapping
from functools import lru_cache
from math import isclose, log, log10, pi, sqrt, tanh
from app.simulation.components.amesim.gases import (
@@ -47,7 +48,7 @@ class AmesimPnl00r(AlgebraicComponent):
"""
MODEL_TYPE = "amesim_pnl00r"
MODEL_VERSION = "0.2.0"
MODEL_VERSION = "0.3.0"
PORTS = (
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
@@ -217,8 +218,12 @@ class AmesimPnl00r(AlgebraicComponent):
if self.rr <= 0.0:
turbulent = smooth_turbulent
else:
# Nikuradse's fully rough asymptote is the Re-independent limit
# of Colebrook. Haaland's rounded all-regime approximation is
# about 0.2003% high at the test_mql roughness values, enough to
# bias its long high-Re PNL0001 filling transient.
fully_rough = 1.0 / (
-1.8 * log10((self.rr / 3.7) ** 1.11)
-2.0 * log10(self.rr / 3.7)
) ** 2
roughness_reynolds = reynolds_number * self.rr
roughness_weight = roughness_reynolds * roughness_reynolds / (
@@ -351,7 +356,7 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
"""AMESim PNL0001 C-R pneumatic pipe with compressibility and friction."""
MODEL_TYPE = "amesim_pnl0001"
MODEL_VERSION = "0.3.0"
MODEL_VERSION = "0.4.0"
PORTS = (
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
@@ -685,6 +690,7 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
upper = middle
return 0.5 * (lower + upper)
@lru_cache(maxsize=32768)
def _one_way_pn2pipefr_mass_flow(
self,
*,
@@ -890,7 +896,7 @@ class AmesimPnl0002(AmesimPnl0001):
"""AMESim PNL0002 R-C-R pneumatic pipe with one center compliance."""
MODEL_TYPE = "amesim_pnl0002"
MODEL_VERSION = "0.5.0"
MODEL_VERSION = "0.6.0"
PORTS = (
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
@@ -1123,7 +1129,7 @@ class AmesimPnl0003(DynamicComponent):
state_size = 4
MODEL_TYPE = "amesim_pnl0003"
MODEL_VERSION = "0.3.0"
MODEL_VERSION = "0.4.0"
PORTS = (
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),