- 按文件哈希区分当前八路工程和历史 Amesim 基准,修复测试与清单中的旧路径。 - 四路审计从 JSON 按需生成 XML,八路新增只核对模式,并显式使用 UTF-8 与 LF。 - 将缺失高刚度夹具的测试替换为当前八路完整 BDF 运行,明确未恢复原 RK45 专项覆盖。 - 更新前端大型工程测试、历史活动回放入口、数据说明、现行规范和相关报告。 验证:全量后台 374 项通过、1 项条件跳过;前端 11 项通过、历史独立服务用例 1 项跳过;四路八路 AME 审计通过。 环境、缓存和运行产物保持忽略;本次未实施工程 JSON 字段精简。
141 lines
6.1 KiB
Markdown
141 lines
6.1 KiB
Markdown
# test_mql
|
||
|
||
本目录记录 AMESim 模型 `test_mql.ame` 向 `app.simulation` 迁移时使用的源模型信息、结果对齐约定和当前进度。
|
||
|
||
## 目标
|
||
|
||
迁移目标不是复制 AMESim `.results` 中的观测值,而是建立真实的 Python 仿真链路:
|
||
|
||
`组件方程 -> SimulationNetwork/系统装配 -> closure -> snapshot/端口写回 -> RHS -> solver -> reporting/comparison`
|
||
|
||
Python 输出只有通过 AMESim baseline 对比后才能作为数值一致性依据。duplicate、反号或派生观测可以用于验证端口方向,但不能替代组件方程和网络闭合。
|
||
|
||
## 模型与源数据
|
||
|
||
- AMESim 源模型:`tests/data/AmesimModels/test_mql.ame`
|
||
- Python 系统类:`app.simulation.examples.test_mql.system.TestMqlSystem`
|
||
- 结构运行入口:`app.simulation.examples.test_mql.run`
|
||
- 132 状态比较入口:`app.simulation.examples.test_mql.run_full_state_comparison`
|
||
- 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 拆解。
|
||
|
||
主要实现位置:
|
||
|
||
- `app/simulation/examples/test_mql/system.py`
|
||
- `app/simulation/examples/test_mql/closure.py`
|
||
- `app/simulation/examples/test_mql/pneumatic.py`
|
||
- `app/simulation/examples/test_mql/mechanical.py`
|
||
- `app/simulation/examples/test_mql/lines.py`
|
||
- `app/simulation/examples/test_mql/primitives/`
|
||
- `app/simulation/examples/test_mql/structural_network.py`
|
||
- `app/simulation/reporting/amesim_results.py`
|
||
- `app/simulation/reporting/test_mql_comparison.py`
|
||
- `app/simulation/examples/test_mql/run_full_state_comparison.py`
|
||
|
||
## 当前对比结果
|
||
|
||
默认 comparison 已从区间内插值的 `t=1e-5 s` 改为与 AMESim
|
||
首个保存时刻精确对齐的 `t=0.01 s`,当前比较 13 个关键信号,并
|
||
新增 `xv@pn_morifice_1`、`dm2@pn_morifice_1` 的结构化 PNVO 诊断。
|
||
|
||
事件前 `t=0.01 s` 对比:
|
||
|
||
- `press@pn_c1_8`:Python `-1286.601221 Pa`,AMESim
|
||
`-1288.253185 Pa`,绝对误差约 `1.651964 Pa`。
|
||
- `dm1@pneumatic_69`:Python `-0.002485112 g/s`,AMESim
|
||
`-0.002054255 g/s`;换算后的 canonical 流量绝对误差约
|
||
`4.30857e-7 kg/s`。
|
||
- `xv@pn_morifice_1` 和 `dm2@pn_morifice_1` 在两侧均为 0,确认
|
||
STEP0 事件前 PNVO 保持关闭。
|
||
- `vol1@pn_brp2_8` 绝对误差约 `8.76e-5`,机械位移、速度和加速度
|
||
仍保持较小误差;当前较明显的累计差异集中在 PNL0001 流量和
|
||
PNCH012 压力/能量链路。
|
||
|
||
新增 `--pnvo-event-boundary` 诊断:先积分到 `0.04 s` 的左极限,
|
||
再按 STEP0 的右连续语义在事件时刻读取开度和流量。结果为:
|
||
|
||
- `xv@pn_morifice_1`:Python/AMESim 均为 `1`。
|
||
- `dm2@pn_morifice_1`:Python `502.945005 g/s`,AMESim
|
||
`497.823823 g/s`,绝对误差约 `5.121182 g/s`,相对约 `1.03%`。
|
||
- `press@pn_c1_8` 绝对误差约 `55.4815 Pa`;
|
||
`dm1@pneumatic_69` 绝对误差约 `0.00281880 g/s`。
|
||
|
||
这说明 PNVO 开启瞬间的开度语义和主流量量级已经对齐,但事件前
|
||
累积压力/支路流量仍有偏差。常规积分直接跨越事件到 `0.05 s` 时,
|
||
当前进程会被系统终止,尚未形成可信的事件后结果;不能据此声明
|
||
完整 `0.04 -> 0.05 s` 窗口已经可运行。
|
||
|
||
## 下一步
|
||
|
||
1. 优先定位 `0 -> 0.04 s` 累积的 `pneumatic_69` 流量与
|
||
`pn_c1_8` 压力偏差,区分 PNL0001 阻力和 PNCH012 能量方程。
|
||
2. 采用显式事件分段或针对事件后的局部数值策略,解决跨越
|
||
`t=0.04 s` 后积分进程被终止的问题,再验证 `t=0.05 s` 保存点。
|
||
3. 保留 `press@pn_c1_8`、`dm1@pneumatic_69`、PNVO `xv/dm2`
|
||
和 chamber RHS breakdown 作为同一条诊断链。
|
||
4. 在完整开启窗口稳定后,再判断是否需要校准 PNVO 流量系数。
|
||
|
||
`pn_c1_8` 的直接主线是 `pneumatic_69`;`pneumatic_96`
|
||
属于另一条固定气室支路,不是该诊断对象。
|
||
|
||
## 运行与验证
|
||
|
||
运行默认短时域 comparison:
|
||
|
||
```bash
|
||
python3 -m app.simulation.examples.test_mql.run_full_state_comparison
|
||
```
|
||
|
||
运行 PNVO 事件边界诊断:
|
||
|
||
```bash
|
||
python3 -m app.simulation.examples.test_mql.run_full_state_comparison --pnvo-event-boundary
|
||
```
|
||
|
||
运行相关测试:
|
||
|
||
```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 完全一致”之类结论。
|