132 lines
5.6 KiB
Markdown
132 lines
5.6 KiB
Markdown
# test_mql
|
||
|
||
本目录记录 AMESim 模型 `test_mql.ame` 向 `PythonModels` 迁移时使用的源模型信息、结果对齐约定和当前进度。
|
||
|
||
## 目标
|
||
|
||
迁移目标不是复制 AMESim `.results` 中的观测值,而是建立真实的 Python 仿真链路:
|
||
|
||
`组件方程 -> SimulationNetwork/系统装配 -> closure -> snapshot/端口写回 -> RHS -> solver -> reporting/comparison`
|
||
|
||
Python 输出只有通过 AMESim baseline 对比后才能作为数值一致性依据。duplicate、反号或派生观测可以用于验证端口方向,但不能替代组件方程和网络闭合。
|
||
|
||
## 模型与源数据
|
||
|
||
- AMESim 源模型:`AmesimModels/test_mql.ame`
|
||
- Python 系统类:`PythonModels.systems.test_mql.TestMqlSystem`
|
||
- 结构运行入口:`PythonModels/scripts/run_test_mql.py`
|
||
- 132 状态比较入口:`PythonModels/scripts/run_test_mql_full_state_comparison.py`
|
||
- AMESim 组件数:117
|
||
- LINE 连接数:84
|
||
- 连续状态数:132
|
||
- 离散状态数:24
|
||
- 全局参数:`D1=20`、`D2=20`、`D3=14`、`P0=153`、`Pdq=1`、`V=15`、`cf=0.45`
|
||
|
||
`.ame` 文件是 tar 包,迁移和校验主要使用其中的:
|
||
|
||
- `test_mql_.cir`:组件、连接、参数表达式和生成代码线索。
|
||
- `test_mql_.param` / `test_mql_.data`:参数和结果配套数据。
|
||
- `test_mql_.modelinfo` / `test_mql_.sim`:状态数和仿真设置。
|
||
- `test_mql_.var` / `test_mql_.results`:AMESim `Data_Path` 目录和 baseline 时序。
|
||
|
||
当前结果解析器可读取 1002 个时间点和 1116 个保存变量,无需先转换成 CSV。
|
||
|
||
## 当前实现
|
||
|
||
当前已经完成:
|
||
|
||
- AMESim 组件、LINE 连接、直接组件接触、全局参数和变量目录解析。
|
||
- 氦气 Peng-Robinson 物性;内部使用绝对压力,AMESim `press` 按相对 `101300 Pa` 的表压输出。
|
||
- `PNCH023 / PNCH012 / PNOR001 / PNVO001` 气动组件。
|
||
- `PNL0001 / PNL0002 / PNL0003 / PNL00R` 管路动态或阻性关系。
|
||
- `PN3NODE2 / P4NODE2` 代数节点、真实邻接拓扑、canonical flow 和端口写回。
|
||
- `PNRP17 / MECMAS21 / LSTP00A / LMECHN1 / UD00 / FORC` 当前工况可确认的机械行为。
|
||
- 112 个气动状态和 20 个机械状态组成的 132 状态总闭包。
|
||
- 活塞运动学、变容气室机械反馈、气动力、外力、端止动和质量约束耦合。
|
||
- 关键 `Data_Path` 序列导出、schema validation、AMESim 插值 comparison、误差排序、端点诊断和变容气室 RHS 拆解。
|
||
|
||
主要实现位置:
|
||
|
||
- `PythonModels/systems/test_mql.py`
|
||
- `PythonModels/systems/test_mql_closure.py`
|
||
- `PythonModels/systems/test_mql_pneumatic.py`
|
||
- `PythonModels/systems/test_mql_mechanical.py`
|
||
- `PythonModels/systems/test_mql_lines.py`
|
||
- `PythonModels/components/amesim_pneumatic.py`
|
||
- `PythonModels/components/amesim_mechanical.py`
|
||
- `PythonModels/reporting/amesim_results.py`
|
||
- `PythonModels/reporting/test_mql_comparison.py`
|
||
- `PythonModels/scripts/run_test_mql_full_state_comparison.py`
|
||
|
||
## 当前对比结果
|
||
|
||
默认 comparison 仍使用 `0 -> 1e-5 s` 的短时域,并已新增
|
||
`dm1@pneumatic_69` 流量诊断。
|
||
|
||
本轮确认原最大偏差的主因不是 PNL0001 Darcy 阻力,而是 8 个
|
||
`PNVO001` 在 Python 中被固定为 `opening=1`,忽略了各自的
|
||
`STEP0` 控制。AMESim baseline 显示 `step_8..15` 均在
|
||
`t=0.04 s` 从 0 跳到 1,对应 PNVO 在此前保持关闭。
|
||
|
||
接入 STEP0 控制后的默认短时对比:
|
||
|
||
- `press@pn_c1_8` 末值误差从约 `9.22849 Pa` 降为
|
||
`0.0117249 Pa`。
|
||
- Python `dm1@pneumatic_69` 末值约
|
||
`-4.97737e-7 g/s`,AMESim 线性插值约
|
||
`-2.05425e-6 g/s`。
|
||
- canonical chamber-to-line flow 定义为
|
||
`-dm1 * 1e-3`,因此两者分别约为
|
||
`4.97737e-10 kg/s` 和 `2.05425e-9 kg/s`,绝对误差约
|
||
`1.55652e-9 kg/s`。
|
||
- AMESim 首个 `0.01 s` 区间的 `mgas1@pn_c1_8` 有限差分约
|
||
`-9.86349e-7 kg/s`;用该区间首末 `dm1` 做梯形平均得到的
|
||
chamber 质量变化率约 `-1.02713e-6 kg/s`,符号和量级一致。
|
||
|
||
当前剩余 `1e-5 s` 误差不能直接解释为物理方程误差:AMESim
|
||
baseline 只按 `0.01 s` 保存,而 comparison 在首个保存区间内做
|
||
线性插值;位移、体积和压力的初始响应并不一定是线性的。
|
||
|
||
## 下一步
|
||
|
||
1. 增加 AMESim 保存时刻对齐的诊断,优先比较事件前的
|
||
`t=0.01 s`,避免把 `1e-5 s` 线性插值误差当成物理偏差。
|
||
2. 导出 `xv@pn_morifice_1` 和 `dm2@pn_morifice_1`,检查
|
||
`t=0.04 -> 0.05 s` 开启窗口的 PNVO 流量及事件传播。
|
||
3. 在控制时序对齐后,再判断是否需要校准 PNVO 流量系数、
|
||
`pneumatic_69` 的 PNL0001 阻力或 PNCH012 能量方程。
|
||
4. 继续保留 `press@pn_c1_8`、`dm1@pneumatic_69` 和 chamber
|
||
RHS breakdown 作为同一条诊断链。
|
||
|
||
`pn_c1_8` 的直接主线是 `pneumatic_69`;`pneumatic_96`
|
||
属于另一条固定气室支路,不是该诊断对象。
|
||
|
||
## 运行与验证
|
||
|
||
运行默认短时域 comparison:
|
||
|
||
```bash
|
||
python3 -m PythonModels.scripts.run_test_mql_full_state_comparison
|
||
```
|
||
|
||
运行相关测试:
|
||
|
||
```bash
|
||
python3 -m unittest tests.test_run_test_mql_full_state_comparison tests.test_test_mql_pnl0001_segment
|
||
```
|
||
|
||
运行全量测试:
|
||
|
||
```bash
|
||
python3 -m unittest discover -s tests -t .
|
||
```
|
||
|
||
## 对齐约定
|
||
|
||
- 组件 alias 和输出名优先保持 AMESim 原名及 `Data_Path`。
|
||
- `PortState.m_flow > 0` 表示流入当前组件。
|
||
- closure 先定义 canonical flow,再按各组件端口方向写回 `m_flow`。
|
||
- AMESim 管路质量流量通常以 `g/s` 保存,Python 内部统一使用 `kg/s`。
|
||
- CSV 是人工检查和交换格式,不是读取 AMESim baseline 的前置条件。
|
||
- 未完成真实 Python 输出对比前,不使用“与 AMESim 完全一致”之类结论。
|