完善AMESim可配置参数交互
补充气动孔口、动态管路、UD00 与弹性接触组件的离散选项、条件显示和折叠分组。 增加目录协议、非法选项和前端参数表交互回归测试,不修改现有求解公式。
This commit is contained in:
1 parent
be54070855
commit
df1d676131
12 files changed
+1262
-69
No files matched your search
@@ -8,10 +8,16 @@ from app.simulation.components.amesim.gases import (
|
||||
normalize_amesim_gas_index,
|
||||
)
|
||||
from app.simulation.core.base import AlgebraicComponent, DynamicComponent, ThermodynamicVolumeComponent
|
||||
from app.simulation.core.catalog import ComponentDisplaySpec, PortDisplaySpec
|
||||
from app.simulation.core.catalog import (
|
||||
ComponentDisplaySpec,
|
||||
ParameterGroupDisplaySpec,
|
||||
PortDisplaySpec,
|
||||
)
|
||||
from app.simulation.core.equations import EquationResidual
|
||||
from app.simulation.core.metadata import (
|
||||
ParameterCondition,
|
||||
ParameterDefinition,
|
||||
ParameterOption,
|
||||
ResultVariableDefinition,
|
||||
THERMODYNAMIC_VOLUME_RESULT_VARIABLES,
|
||||
)
|
||||
@@ -20,6 +26,18 @@ from app.simulation.core.ports import PortDefinition
|
||||
from app.simulation.core.state import VolumeState
|
||||
|
||||
|
||||
_DYNAMIC_PIPE_POLYTROPIC_MODE = ParameterCondition("mode", (1.0,))
|
||||
_DYNAMIC_PIPE_HEAT_EXCHANGE_MODE = ParameterCondition("mode", (2.0,))
|
||||
_DYNAMIC_PIPE_PARAMETER_GROUPS = (
|
||||
ParameterGroupDisplaySpec(
|
||||
id="thermodynamics",
|
||||
label="热力学",
|
||||
parameters=("k", "kth", "extemp"),
|
||||
order=10,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class AmesimPnl00r(AlgebraicComponent):
|
||||
"""AMESim PNL00R pneumatic pipe friction resistance.
|
||||
|
||||
@@ -308,7 +326,7 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
"""AMESim PNL0001 C-R pneumatic pipe with compressibility and friction."""
|
||||
|
||||
MODEL_TYPE = "amesim_pnl0001"
|
||||
MODEL_VERSION = "0.1.0"
|
||||
MODEL_VERSION = "0.2.0"
|
||||
PORTS = (
|
||||
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
|
||||
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
|
||||
@@ -354,7 +372,11 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
minimum=0.0,
|
||||
minimum_exclusive=True,
|
||||
maximum=2.0,
|
||||
description="AMESim 管路热力学配置使用的多方指数。",
|
||||
description=(
|
||||
"mode=1 多方过程使用的指数;当前公开求解器保留该 AMESim "
|
||||
"配置,尚未实现多方指数对状态方程的修正。"
|
||||
),
|
||||
visible_when=(_DYNAMIC_PIPE_POLYTROPIC_MODE,),
|
||||
),
|
||||
ParameterDefinition(
|
||||
"kth",
|
||||
@@ -363,7 +385,8 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
quantity="heat_transfer_coefficient",
|
||||
unit="W/(m2*K)",
|
||||
minimum=0.0,
|
||||
description="管内气体与外部环境之间的对流换热系数。",
|
||||
description="mode=2 带换热过程使用的气体与外部环境对流换热系数。",
|
||||
visible_when=(_DYNAMIC_PIPE_HEAT_EXCHANGE_MODE,),
|
||||
),
|
||||
ParameterDefinition(
|
||||
"extemp",
|
||||
@@ -373,7 +396,8 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
unit="K",
|
||||
minimum=0.0,
|
||||
minimum_exclusive=True,
|
||||
description="管路外部环境的绝对温度,用于计算换热功率。",
|
||||
description="mode=2 带换热过程使用的外部环境绝对温度。",
|
||||
visible_when=(_DYNAMIC_PIPE_HEAT_EXCHANGE_MODE,),
|
||||
),
|
||||
ParameterDefinition(
|
||||
"mode",
|
||||
@@ -383,7 +407,16 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
unit="",
|
||||
minimum=1.0,
|
||||
maximum=2.0,
|
||||
description="热模型选择:1 为绝热,2 为按换热系数计算环境换热。",
|
||||
editor="choice",
|
||||
options=(
|
||||
ParameterOption(1.0, "多方过程"),
|
||||
ParameterOption(2.0, "带换热"),
|
||||
),
|
||||
description=(
|
||||
"AMESim 原始编码:1 为多方过程,2 为带换热。当前公开求解器在"
|
||||
"多方模式下关闭环境换热,在带换热模式下按换热系数和外部温度"
|
||||
"计算环境换热。"
|
||||
),
|
||||
),
|
||||
ParameterDefinition(
|
||||
"p0",
|
||||
@@ -450,6 +483,7 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
PortDisplaySpec("port_2", "right", order=20),
|
||||
),
|
||||
order=30,
|
||||
parameter_groups=_DYNAMIC_PIPE_PARAMETER_GROUPS,
|
||||
)
|
||||
|
||||
def __init__(
|
||||
@@ -513,7 +547,10 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
|
||||
rounded = round(value)
|
||||
if not isclose(value, rounded, rel_tol=0.0, abs_tol=1.0e-12):
|
||||
raise ValueError(f"PNL0001 parameter {name} must be an integer value.")
|
||||
return int(rounded)
|
||||
integer = int(rounded)
|
||||
if name == "mode" and integer not in {1, 2}:
|
||||
raise ValueError("PNL0001 parameter mode must be one of 1, 2.")
|
||||
return integer
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
@@ -713,7 +750,7 @@ class AmesimPnl0002(AmesimPnl0001):
|
||||
"""AMESim PNL0002 R-C-R pneumatic pipe with one center compliance."""
|
||||
|
||||
MODEL_TYPE = "amesim_pnl0002"
|
||||
MODEL_VERSION = "0.1.0"
|
||||
MODEL_VERSION = "0.2.0"
|
||||
PORTS = (
|
||||
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
|
||||
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
|
||||
@@ -730,6 +767,7 @@ class AmesimPnl0002(AmesimPnl0001):
|
||||
PortDisplaySpec("port_2", "right", order=20),
|
||||
),
|
||||
order=40,
|
||||
parameter_groups=_DYNAMIC_PIPE_PARAMETER_GROUPS,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -856,7 +894,7 @@ class AmesimPnl0003(DynamicComponent):
|
||||
|
||||
state_size = 4
|
||||
MODEL_TYPE = "amesim_pnl0003"
|
||||
MODEL_VERSION = "0.1.0"
|
||||
MODEL_VERSION = "0.2.0"
|
||||
PORTS = (
|
||||
PortDefinition.pneumatic("port_1", nominal_role="bidirectional"),
|
||||
PortDefinition.pneumatic("port_2", nominal_role="bidirectional"),
|
||||
@@ -930,6 +968,7 @@ class AmesimPnl0003(DynamicComponent):
|
||||
PortDisplaySpec("port_2", "right", order=20),
|
||||
),
|
||||
order=50,
|
||||
parameter_groups=_DYNAMIC_PIPE_PARAMETER_GROUPS,
|
||||
)
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in new issue
Block a user