公开更多 AMESim 组件并接入信号机械闭环
This commit is contained in:
1 parent
db4bdb4b70
commit
3f51a124d6
28 files changed
+3397
-58
No files matched your search
@@ -9,10 +9,12 @@ ResultVariableScope = Literal["component", "port"]
|
||||
|
||||
|
||||
SI_UNIT_BY_QUANTITY: dict[str, str] = {
|
||||
"acceleration": "m/s2",
|
||||
"area": "m2",
|
||||
"dimensionless": "",
|
||||
"density": "kg/m³",
|
||||
"flow_coefficient": "kg/(s*Pa^0.5)",
|
||||
"force": "N",
|
||||
"heat_transfer_coefficient": "W/(m2*K)",
|
||||
"internal_energy": "J",
|
||||
"length": "m",
|
||||
@@ -22,8 +24,13 @@ SI_UNIT_BY_QUANTITY: dict[str, str] = {
|
||||
"specific_enthalpy": "J/kg",
|
||||
"specific_internal_energy": "J/kg",
|
||||
"temperature": "K",
|
||||
"translational_damping": "N/(m/s)",
|
||||
"translational_stiffness": "N/m",
|
||||
"time": "s",
|
||||
"velocity": "m/s",
|
||||
"volume": "m3",
|
||||
"volume_flow": "m3/s",
|
||||
"windage": "N/(m/s)^2",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,6 +90,76 @@ class PortDefinition:
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def mechanical_translational(
|
||||
cls,
|
||||
name: str,
|
||||
*,
|
||||
nominal_role: Literal["inlet", "outlet", "bidirectional"] = "bidirectional",
|
||||
) -> PortDefinition:
|
||||
return cls(
|
||||
name=name,
|
||||
kind="physical",
|
||||
domain="mechanical",
|
||||
nominal_role=nominal_role,
|
||||
positive_flow_direction="intoComponent",
|
||||
variables=(
|
||||
PortVariableDefinition(
|
||||
"x",
|
||||
"effort",
|
||||
"equal",
|
||||
label="位移",
|
||||
quantity="length",
|
||||
unit="m",
|
||||
order=10,
|
||||
),
|
||||
PortVariableDefinition(
|
||||
"v",
|
||||
"effort",
|
||||
"equal",
|
||||
label="速度",
|
||||
quantity="velocity",
|
||||
unit="m/s",
|
||||
order=20,
|
||||
),
|
||||
PortVariableDefinition(
|
||||
"f",
|
||||
"flow",
|
||||
"sumToZero",
|
||||
label="力",
|
||||
quantity="force",
|
||||
unit="N",
|
||||
order=30,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def signal(
|
||||
cls,
|
||||
name: str,
|
||||
*,
|
||||
nominal_role: Literal["input", "output"],
|
||||
domain: str = "signal",
|
||||
) -> PortDefinition:
|
||||
return cls(
|
||||
name=name,
|
||||
kind="signal",
|
||||
domain=domain,
|
||||
nominal_role=nominal_role,
|
||||
variables=(
|
||||
PortVariableDefinition(
|
||||
"signal",
|
||||
"signal",
|
||||
"directed",
|
||||
label="信号值",
|
||||
quantity="dimensionless",
|
||||
unit="",
|
||||
order=10,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
def as_interface_dict(self) -> dict[str, object]:
|
||||
return {
|
||||
"name": self.name,
|
||||
@@ -108,6 +178,10 @@ class PortState:
|
||||
p: float = 0.0
|
||||
m_flow: float = 0.0
|
||||
h_outflow: float = 0.0
|
||||
signal: float = 0.0
|
||||
x: float = 0.0
|
||||
v: float = 0.0
|
||||
f: float = 0.0
|
||||
definition: PortDefinition | None = field(default=None, repr=False, compare=False)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in new issue
Block a user