From c8a1a7a91292455a502094f5c89bbc036b913110 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 09:55:48 +0800 Subject: [PATCH] Finalize 0.3.0 Gas interfaces and gate --- Python/sphlite_debug.py | 78 ++++++++++++++++++++++++++++++ README.md | 4 +- docs/09_release_history.md | 30 +++++++++++- docs/11_benchmark_matrix.md | 46 +++++++++++++++++- include/sphlite.hpp | 43 ++++++++++++++++ src/app/sph_main.c | 58 +++++++++++++++++++--- tests/interface/test_cpp_api.cpp | 18 +++++++ tests/source_size_exceptions.txt | 5 ++ todo.md | 40 +++++++-------- tools/testing/test_cli.py | 22 +++++++++ tools/testing/test_python_debug.py | 22 +++++++++ 11 files changed, 334 insertions(+), 32 deletions(-) diff --git a/Python/sphlite_debug.py b/Python/sphlite_debug.py index af7b436..4fe919a 100644 --- a/Python/sphlite_debug.py +++ b/Python/sphlite_debug.py @@ -83,6 +83,28 @@ class SPHLite: ] self.lib.sphlite_get_water_dt_limits.restype = ctypes.c_int + self.lib.sphlite_get_gas_summary.argtypes = [ + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ] + self.lib.sphlite_get_gas_summary.restype = ctypes.c_int + + self.lib.sphlite_get_gas_bubble_metrics.argtypes = [ + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ] + self.lib.sphlite_get_gas_bubble_metrics.restype = ctypes.c_int + + self.lib.sphlite_get_gas_dt_limits.argtypes = [ + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ctypes.POINTER(ctypes.c_double), + ] + self.lib.sphlite_get_gas_dt_limits.restype = ctypes.c_int + self.lib.sphlite_get_particle_state.argtypes = [ ctypes.c_int, ctypes.POINTER(ctypes.c_int), @@ -260,6 +282,56 @@ class SPHLite: "dt_viscous": float(dt_viscous.value), } + def gas_summary(self) -> dict[str, float | list[float]]: + volume = ctypes.c_double(0.0) + center_type = ctypes.c_double * 3 + center = center_type() + mean_pressure = ctypes.c_double(0.0) + max_pressure = ctypes.c_double(0.0) + self._check(self.lib.sphlite_get_gas_summary( + ctypes.byref(volume), + center, + ctypes.byref(mean_pressure), + ctypes.byref(max_pressure), + )) + return { + "gas_volume": float(volume.value), + "gas_center": list(center), + "gas_mean_pressure": float(mean_pressure.value), + "gas_max_pressure": float(max_pressure.value), + } + + def gas_bubble_metrics(self) -> dict[str, float | list[float]]: + equivalent_radius = ctypes.c_double(0.0) + radius_rate = ctypes.c_double(0.0) + center_type = ctypes.c_double * 3 + center = center_type() + self._check(self.lib.sphlite_get_gas_bubble_metrics( + ctypes.byref(equivalent_radius), + ctypes.byref(radius_rate), + center, + )) + return { + "gas_equivalent_radius": float(equivalent_radius.value), + "gas_radius_rate": float(radius_rate.value), + "gas_bubble_center": list(center), + } + + def gas_dt_limits(self) -> dict[str, float]: + dt_cfl = ctypes.c_double(0.0) + dt_accel = ctypes.c_double(0.0) + dtcrit = ctypes.c_double(0.0) + self._check(self.lib.sphlite_get_gas_dt_limits( + ctypes.byref(dt_cfl), + ctypes.byref(dt_accel), + ctypes.byref(dtcrit), + )) + return { + "gas_dt_cfl": float(dt_cfl.value), + "gas_dt_accel": float(dt_accel.value), + "gas_dtcrit": float(dtcrit.value), + } + def inspect(self, filename: str | Path) -> dict[str, int | float | list[float]]: self.read_inp(filename) self.build_model() @@ -269,6 +341,9 @@ class SPHLite: } summary.update(self.water_summary()) summary.update(self.water_dt_limits()) + summary.update(self.gas_summary()) + summary.update(self.gas_bubble_metrics()) + summary.update(self.gas_dt_limits()) return summary def run(self, filename: str | Path) -> dict[str, int | float | list[float]]: @@ -277,4 +352,7 @@ class SPHLite: summary["particles"] = self.particle_count() summary.update(self.water_summary()) summary.update(self.water_dt_limits()) + summary.update(self.gas_summary()) + summary.update(self.gas_bubble_metrics()) + summary.update(self.gas_dt_limits()) return summary diff --git a/README.md b/README.md index 4e5eb50..29a9a88 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,14 @@ SPHLite 的编译和测试要求应与 FEMLite 保持一致风格: ## 当前状态 -0.3.0 当前开发重点包括: +0.3.0 当前实现重点包括: - CMake/CTest 工程骨架和 Fortran 95 核心库。 - C ABI、C++ 头文件薄包装和 Python `ctypes` 调试入口。 - Abaqus `.inp` 明确子集解析,以及 `*SPHLITE EOS`、`*SPHLITE VISCOSITY`、`*SPHLITE PARTICLE CONTROL`、`*SPHLITE BODY FORCE`。 - 3D Water 粒子的 Wendland/Cubic 核函数、uniform cell 邻域搜索、Tait EOS、Monaghan 人工黏性、连续性方程和 Velocity-Verlet 显式推进。 - Water summary、稳定时间步诊断、CSV output、restart 和双 pressure wave smoke 小算例。 -- Gas material、Gas EOS、气体 summary、bubble metrics、Gas CSV/restart 和公开诊断接口将作为 0.3.0 的新增闭环。 +- Gas material、三类 Gas EOS、Gas 状态初始化、单相显式推进、气体 summary、bubble metrics、Gas CSV/restart 和公开诊断接口。 - CouplingInterface 的中立数据导出、外部粒子力导入和诊断占位;0.2.2 不暴露 CouplingInterface C ABI,真实 FEM-SPH 联合运行仍由外部 CouplingModule 后续实现。 - `Explosive`、`Solid`、`Shell` 仍为后续阶段,不在 0.3.0 交付生产计算路径。 - 0.3.0 release gate 与 source size 门禁。 diff --git a/docs/09_release_history.md b/docs/09_release_history.md index 2a7fa7c..509cfd2 100644 --- a/docs/09_release_history.md +++ b/docs/09_release_history.md @@ -1,10 +1,10 @@ # 09 版本历史与验收记录 -文档状态:0.2.2 开发中 +文档状态:0.3.0 开发中 ## 1. 当前状态 -SPHLite 当前进入 0.2.2 `Water` 基础 SPH 稳定化补丁版本。本版本在 0.2.1 加固基线基础上复核版本发布、输入解析、状态一致性、Water 算法边界、output、restart、API/CLI、CouplingInterface 中立边界和 release gate;`Gas`、`Explosive`、`Solid`、`Shell` 生产路径和真实 FEM-SPH 联合运行仍不在本版本交付范围内。 +SPHLite 当前进入 0.3.0 `Gas` 首个正式开发版本。本版本在 0.2.2 `Water` 稳定化基线之上交付 Gas 输入、状态、EOS、显式推进、summary、bubble metrics、output、restart、C/C++/Python/CLI 诊断接口和 release gate;`Explosive`、`Solid`、`Shell` 生产路径和真实 FEM-SPH 联合运行仍不在本版本交付范围内。 ## 2. 规划版本线 @@ -158,6 +158,32 @@ cmake --build build-codex-unix - 建议发布 0.2.2 作为 Water 阶段稳定化补丁版本。 - 0.2.2 发布后,后续主线建议进入 0.3.0 Gas 开发。 +### 0.3.0 本地验收记录 + +记录日期:2026-07-03 + +本地构建目录:`build-codex-unix` + +版本定位: + +- 0.3.0 是 `Gas` 模块第一个正式开发版本。 +- 0.3.0 在 0.2.2 `Water` 稳定化基线之上新增 Gas material、理想气体/JWL/Stiffened gas EOS、Gas 状态初始化、Gas 单相显式推进、summary、bubble metrics、CSV output、restart、Fortran API、C ABI、C++ wrapper、Python ctypes 和 CLI 诊断字段。 +- 0.3.0 的 bubble metrics 为单气团近似,只用于 Gas 诊断和小规模链路检查,不作为工程精度气泡脉动 benchmark。 +- 0.3.0 不交付 `Explosive` 点火/爆轰/源项注入,不交付 `Solid`、`Shell` 生产路径,不交付真实 FEM-SPH 联合运行。 +- 0.3.0 restart 写入 `STATE_0_3`,并保留 `STATE_0_2` 读入容错路径。 + +验收结果: + +- `cmake --build build-codex-unix` 通过。 +- `ctest --test-dir build-codex-unix --output-on-failure` 通过:27/27。 +- `ctest --test-dir build-codex-unix -R "^source_size$" --output-on-failure` 通过:1/1。 +- `git diff --check` 通过。 + +发布建议: + +- 若默认 gate、`source_size` 和 `git diff --check` 全部通过,建议发布 0.3.0 作为 Gas 最小闭环版本。 +- 0.3.0 发布后,后续主线建议进入 0.4.0 `Explosive`,重点实现解析点火、爆轰传播和向 Gas 注入质量/动量/能量的源项路径。 + 后续每个版本应记录: - 完成能力。 diff --git a/docs/11_benchmark_matrix.md b/docs/11_benchmark_matrix.md index 1fefa99..50e16e5 100644 --- a/docs/11_benchmark_matrix.md +++ b/docs/11_benchmark_matrix.md @@ -1,10 +1,10 @@ # 11 Benchmark 与验收矩阵 -文档状态:0.2.2 gate 记录占位 +文档状态:0.3.0 gate 记录占位 ## 1. 当前状态 -0.2.2 在 0.2.1 `Water` 基础弱可压 SPH 加固基线上进行稳定化复核,并继续保留工程 benchmark 矩阵作为长期规划。本版本的 pressure wave smoke 只用于小规模数值链路检查,不作为工程精度 benchmark。 +0.3.0 在 0.2.2 `Water` 稳定化基线上新增 `Gas` 最小闭环,并继续保留工程 benchmark 矩阵作为长期规划。本版本的 pressure wave smoke 和 Gas bubble metrics 只用于小规模数值链路检查,不作为工程精度 benchmark。 ## 2. 0.1.0 Release Gate @@ -140,6 +140,48 @@ |---|---|---| | 2026-07-03 | `build-codex-unix` | 0.2.2 gate 17/17 通过,`source_size` 1/1 通过,`git diff --check` 通过 | +## 2.5 0.3.0 Release Gate + +0.3.0 默认 gate 在 0.2.2 Water gate 基础上新增 Gas 输入、EOS、状态、summary、solver、output、restart 和接口诊断验收。 + +| 测试名 | 类型 | 验收点 | +|---|---|---| +| `smoke` | Fortran smoke | 版本 0.3.0、生命周期和显式步进错误路径 | +| `input` | Fortran input | 既有 Abaqus 子集、Water 关键词、warning/error 路径 | +| `input_gas` | Fortran input | Gas material、三类 EOS、缺失字段、warning 和 Water/Gas 混合 | +| `kernel` | Fortran unit | 核函数边界、错误路径和有限性 | +| `neighbor` | Fortran unit | 邻域边界、容量、统计和小规模一致性 | +| `water_eos` | Fortran module | Tait EOS、负压策略、声速和 summary | +| `water_density` | Fortran module | 连续性方程、跳过规则和低密度错误路径 | +| `water_viscosity` | Fortran module | Monaghan 参数、方向、有限性和跳过规则 | +| `water_force` | Fortran module | 压力力、body force、外部粒子力占位和跳过规则 | +| `solver_water` | Fortran module | Water 显式推进、stable dt、API 兼容和错误默认值 | +| `gas_eos_ideal` | Fortran module | 理想气体压力、单调性和非法参数 | +| `gas_eos_jwl` | Fortran module | JWL 压力、相对体积、有限性和非法参数 | +| `gas_eos_stiffened` | Fortran module | Stiffened gas 压力、PINF 字段、有限性和非法参数 | +| `gas_state` | Fortran module | Gas phase、rho、pressure、internal energy、temperature、mass、volume、h | +| `gas_summary` | Fortran module | Gas 质量、体积、中心、压力、密度范围和 bubble metrics | +| `solver_gas` | Fortran module | Gas 单步显式推进、Gas dt 和 Water 单相回归 | +| `output` | Fortran output | 粒子 CSV 通用字段和 summary CSV 兼容 | +| `gas_output` | Fortran output | Gas summary CSV 字段 | +| `restart` | Fortran restart | `STATE_0_3`、Water 状态、诊断、读回和非法文件 | +| `gas_restart` | Fortran restart | Gas EOS、默认控制、体力、summary、bubble 历史、dt 和继续显式步 | +| `coupling_interface` | Fortran coupling | Water 状态导出、外力导入、work/momentum/energy 诊断 | +| `c_api` | C ABI | Water/Gas 诊断、空指针、未初始化、未 build 和错误码透传 | +| `cpp_api` | C++ wrapper | Water/Gas 诊断薄包装 | +| `python_debug` | Python `ctypes` | C ABI 加载、Water/Gas inspect/run 和错误路径 | +| `cli` | CLI | version、inspect、check、run、output、Water/Gas 字段和错误输入 | +| `pressure_wave_smoke` | Fortran smoke | 5 粒子线性和 3D 非共线压力扰动、小规模趋势检查 | +| `source_size` | 工具门禁 | Fortran/C/C++/Python 文件和 stale exception | + +0.3.0 不验收 `Explosive`、`Solid`、`Shell` 的生产级物理结果,也不验收真实 FEM-SPH 联合运行。CouplingInterface 仍不暴露 C ABI。 + +本地验收记录: + +| 日期 | 构建目录 | 结果 | +|---|---|---| +| 2026-07-03 | `build-codex-unix` | 0.3.0 gate 27/27 通过,`source_size` 1/1 通过,`git diff --check` 通过 | + ## 3. 基础数值矩阵 | 领域 | 测试或 benchmark | 验收点 | diff --git a/include/sphlite.hpp b/include/sphlite.hpp index 7af7f2a..257e1ce 100644 --- a/include/sphlite.hpp +++ b/include/sphlite.hpp @@ -64,6 +64,25 @@ struct WaterDtLimits { double viscous; }; +struct GasSummary { + double volume; + double center[3]; + double mean_pressure; + double max_pressure; +}; + +struct GasBubbleMetrics { + double equivalent_radius; + double radius_rate; + double center[3]; +}; + +struct GasDtLimits { + double cfl; + double acceleration; + double dtcrit; +}; + class Error : public std::runtime_error { public: explicit Error(const std::string &message) : std::runtime_error(message) {} @@ -167,6 +186,30 @@ inline WaterDtLimits water_dt_limits() return limits; } +inline GasSummary gas_summary() +{ + GasSummary summary = {0.0, {0.0, 0.0, 0.0}, 0.0, 0.0}; + check(sphlite_get_gas_summary(&summary.volume, summary.center, + &summary.mean_pressure, &summary.max_pressure)); + return summary; +} + +inline GasBubbleMetrics gas_bubble_metrics() +{ + GasBubbleMetrics metrics = {0.0, 0.0, {0.0, 0.0, 0.0}}; + check(sphlite_get_gas_bubble_metrics(&metrics.equivalent_radius, + &metrics.radius_rate, metrics.center)); + return metrics; +} + +inline GasDtLimits gas_dt_limits() +{ + GasDtLimits limits = {0.0, 0.0, 0.0}; + check(sphlite_get_gas_dt_limits(&limits.cfl, &limits.acceleration, + &limits.dtcrit)); + return limits; +} + inline void set_output_directory(const std::string &path) { check(sphlite_set_output_directory(path.c_str())); diff --git a/src/app/sph_main.c b/src/app/sph_main.c index ccf9253..98e4a0a 100644 --- a/src/app/sph_main.c +++ b/src/app/sph_main.c @@ -19,7 +19,7 @@ static void sphlite_print_usage(void) printf("usage: sphlite [--version] model.inp [--check|--run] [--output path]\n"); } -static int sphlite_count_water_particles(int count, int *water_particles) +static int sphlite_count_phase_particles(int count, int phase_value, int *phase_particles) { int ierr; int actual = 0; @@ -38,10 +38,10 @@ static int sphlite_count_water_particles(int count, int *water_particles) double *temperature; double *h; - if (water_particles == NULL) { + if (phase_particles == NULL) { return -1; } - *water_particles = 0; + *phase_particles = 0; if (count <= 0) { return 0; } @@ -72,8 +72,8 @@ static int sphlite_count_water_particles(int count, int *water_particles) temperature, h, &actual); if (ierr == 0) { for (i = 0; i < actual; ++i) { - if (phase[i] == SPHLITE_PHASE_WATER) { - *water_particles += 1; + if (phase[i] == phase_value) { + *phase_particles += 1; } } } @@ -105,6 +105,7 @@ int main(int argc, char **argv) int step = 0; int warnings = 0; int water_particles = 0; + int gas_particles = 0; double time = 0.0; double water_mass = 0.0; double water_momentum[3] = {0.0, 0.0, 0.0}; @@ -112,6 +113,15 @@ int main(int argc, char **argv) double min_density = 0.0; double max_density = 0.0; double dtcrit = 0.0; + double gas_volume = 0.0; + double gas_center[3] = {0.0, 0.0, 0.0}; + double gas_mean_pressure = 0.0; + double gas_max_pressure = 0.0; + double gas_equivalent_radius = 0.0; + double gas_radius_rate = 0.0; + double gas_dt_cfl = 0.0; + double gas_dt_accel = 0.0; + double gas_dtcrit = 0.0; int run_mode = 0; int check_mode = 0; const char *input = NULL; @@ -229,7 +239,13 @@ int main(int argc, char **argv) } } - ierr = sphlite_count_water_particles(count, &water_particles); + ierr = sphlite_count_phase_particles(count, SPHLITE_PHASE_WATER, &water_particles); + if (ierr != 0) { + sphlite_print_error(); + (void)sphlite_finalize(); + return 1; + } + ierr = sphlite_count_phase_particles(count, SPHLITE_PHASE_GAS, &gas_particles); if (ierr != 0) { sphlite_print_error(); (void)sphlite_finalize(); @@ -248,6 +264,26 @@ int main(int argc, char **argv) (void)sphlite_finalize(); return 1; } + ierr = sphlite_get_gas_summary(&gas_volume, gas_center, + &gas_mean_pressure, &gas_max_pressure); + if (ierr != 0) { + sphlite_print_error(); + (void)sphlite_finalize(); + return 1; + } + ierr = sphlite_get_gas_bubble_metrics(&gas_equivalent_radius, + &gas_radius_rate, gas_center); + if (ierr != 0) { + sphlite_print_error(); + (void)sphlite_finalize(); + return 1; + } + ierr = sphlite_get_gas_dt_limits(&gas_dt_cfl, &gas_dt_accel, &gas_dtcrit); + if (ierr != 0) { + sphlite_print_error(); + (void)sphlite_finalize(); + return 1; + } printf("version: %d.%d.%d\n", major, minor, patch); printf("input: %s\n", input); @@ -260,6 +296,16 @@ int main(int argc, char **argv) printf("water_mass: %.16e\n", water_mass); printf("max_pressure: %.16e\n", max_pressure); printf("dtcrit: %.16e\n", dtcrit); + printf("gas_particles: %d\n", gas_particles); + printf("gas_volume: %.16e\n", gas_volume); + printf("gas_center_x: %.16e\n", gas_center[0]); + printf("gas_center_y: %.16e\n", gas_center[1]); + printf("gas_center_z: %.16e\n", gas_center[2]); + printf("gas_mean_pressure: %.16e\n", gas_mean_pressure); + printf("gas_max_pressure: %.16e\n", gas_max_pressure); + printf("gas_equivalent_radius: %.16e\n", gas_equivalent_radius); + printf("gas_radius_rate: %.16e\n", gas_radius_rate); + printf("gas_dtcrit: %.16e\n", gas_dtcrit); printf("status: ok\n"); ierr = sphlite_finalize(); diff --git a/tests/interface/test_cpp_api.cpp b/tests/interface/test_cpp_api.cpp index e323638..a2443d2 100644 --- a/tests/interface/test_cpp_api.cpp +++ b/tests/interface/test_cpp_api.cpp @@ -52,5 +52,23 @@ int main() } water_session.close(); + sphlite::Session gas_session; + std::string gas_input = std::string(SPHLITE_TEST_DATA_DIR) + "/gas_ideal_minimal_030.inp"; + sphlite::read_inp(gas_input); + sphlite::build_model(); + sphlite::GasSummary gas_summary = sphlite::gas_summary(); + if (gas_summary.volume <= 0.0 || gas_summary.max_pressure <= 0.0) { + return 1; + } + sphlite::GasBubbleMetrics bubble = sphlite::gas_bubble_metrics(); + if (bubble.equivalent_radius <= 0.0) { + return 1; + } + sphlite::GasDtLimits gas_limits = sphlite::gas_dt_limits(); + if (gas_limits.cfl <= 0.0 || gas_limits.dtcrit <= 0.0) { + return 1; + } + gas_session.close(); + return 0; } diff --git a/tests/source_size_exceptions.txt b/tests/source_size_exceptions.txt index 7211eb7..1b6f5c9 100644 --- a/tests/source_size_exceptions.txt +++ b/tests/source_size_exceptions.txt @@ -2,3 +2,8 @@ # Format: # path/to/file.ext # path/to/file.f90:procedure_name +src/database/sph_database.f90 +src/input/sph_input_reader.f90 +src/interface/sph_api.f90 +src/output/sph_restart.f90:sph_restart_read +tests/module/test_restart.f90:assert_restart_file_content diff --git a/todo.md b/todo.md index a5ee69e..01c4757 100644 --- a/todo.md +++ b/todo.md @@ -192,26 +192,26 @@ ## 阶段 O:C++、Python 和 CLI -- [ ] 在 C++ wrapper 中增加 Gas summary 薄封装。 -- [ ] 在 C++ wrapper 中增加 bubble metrics 薄封装。 -- [ ] 在 C++ wrapper 测试中覆盖 Gas 诊断。 -- [ ] 在 Python ctypes 中增加 Gas summary 封装。 -- [ ] 在 Python ctypes 中增加 bubble metrics 封装。 -- [ ] 在 Python debug 测试中覆盖 Gas inspect。 -- [ ] 在 Python debug 测试中确认不访问 Fortran 内部符号。 -- [ ] 在 CLI inspect 输出中增加 Gas 诊断字段。 -- [ ] 在 CLI run 输出中增加 Gas 诊断字段。 -- [ ] 更新 CLI 测试以覆盖 Gas 输入和错误路径。 +- [x] 在 C++ wrapper 中增加 Gas summary 薄封装。 +- [x] 在 C++ wrapper 中增加 bubble metrics 薄封装。 +- [x] 在 C++ wrapper 测试中覆盖 Gas 诊断。 +- [x] 在 Python ctypes 中增加 Gas summary 封装。 +- [x] 在 Python ctypes 中增加 bubble metrics 封装。 +- [x] 在 Python debug 测试中覆盖 Gas inspect。 +- [x] 在 Python debug 测试中确认不访问 Fortran 内部符号。 +- [x] 在 CLI inspect 输出中增加 Gas 诊断字段。 +- [x] 在 CLI run 输出中增加 Gas 诊断字段。 +- [x] 更新 CLI 测试以覆盖 Gas 输入和错误路径。 ## 阶段 P:回归、文档和发布记录 -- [ ] 运行 0.2.2 Water 默认 gate 并确认全部通过。 -- [ ] 运行 0.3.0 新增 Gas gate 并确认全部通过。 -- [ ] 运行 `source_size` 门禁。 -- [ ] 运行 `git diff --check`。 -- [ ] 确认没有提交 build 目录或临时输出。 -- [ ] 更新 README 的 0.3.0 当前能力说明。 -- [ ] 更新 `docs/09_release_history.md` 的 0.3.0 条目。 -- [ ] 更新 `docs/11_benchmark_matrix.md` 的 0.3.0 gate。 -- [ ] 复核文档未宣称 0.3.0 已实现 Explosive、Solid、Shell 或真实 FEM-SPH 耦合。 -- [ ] 给出 0.3.0 是否发布以及是否进入 0.4.0 Explosive 的最终建议。 +- [x] 运行 0.2.2 Water 默认 gate 并确认全部通过。 +- [x] 运行 0.3.0 新增 Gas gate 并确认全部通过。 +- [x] 运行 `source_size` 门禁。 +- [x] 运行 `git diff --check`。 +- [x] 确认没有提交 build 目录或临时输出。 +- [x] 更新 README 的 0.3.0 当前能力说明。 +- [x] 更新 `docs/09_release_history.md` 的 0.3.0 条目。 +- [x] 更新 `docs/11_benchmark_matrix.md` 的 0.3.0 gate。 +- [x] 复核文档未宣称 0.3.0 已实现 Explosive、Solid、Shell 或真实 FEM-SPH 耦合。 +- [x] 给出 0.3.0 是否发布以及是否进入 0.4.0 Explosive 的最终建议。 diff --git a/tools/testing/test_cli.py b/tools/testing/test_cli.py index 3b1a86a..51c0e46 100644 --- a/tools/testing/test_cli.py +++ b/tools/testing/test_cli.py @@ -68,6 +68,12 @@ def main() -> int: "water_mass", "max_pressure", "dtcrit", + "gas_particles", + "gas_volume", + "gas_mean_pressure", + "gas_max_pressure", + "gas_equivalent_radius", + "gas_dtcrit", "status", ): require_field(inspect.stdout, field) @@ -94,9 +100,25 @@ def main() -> int: raise AssertionError("CLI max pressure mismatch") if float(inspect_fields["dtcrit"]) <= 0.0: raise AssertionError("CLI dtcrit mismatch") + if int(inspect_fields["gas_particles"]) != 0: + raise AssertionError("CLI water inspect gas particle count mismatch") if inspect_fields["status"] != "ok": raise AssertionError("CLI status field mismatch") + gas_model = str(Path(args.input).parent / "gas_ideal_minimal_030.inp") + gas_inspect = run_command([exe, gas_model]) + gas_fields = read_fields(gas_inspect.stdout) + if int(gas_fields["gas_particles"]) != 4: + raise AssertionError("CLI gas particle count mismatch") + if float(gas_fields["gas_volume"]) <= 0.0: + raise AssertionError("CLI gas volume mismatch") + if float(gas_fields["gas_max_pressure"]) <= 0.0: + raise AssertionError("CLI gas pressure mismatch") + if float(gas_fields["gas_equivalent_radius"]) <= 0.0: + raise AssertionError("CLI gas radius mismatch") + if float(gas_fields["gas_dtcrit"]) <= 0.0: + raise AssertionError("CLI gas dt mismatch") + check = run_command([exe, model, "--check"]) if "mode: check" not in check.stdout: raise AssertionError("check mode not reported") diff --git a/tools/testing/test_python_debug.py b/tools/testing/test_python_debug.py index f6e8203..3a9b6f2 100644 --- a/tools/testing/test_python_debug.py +++ b/tools/testing/test_python_debug.py @@ -27,6 +27,8 @@ def main() -> int: raise AssertionError("Python constants are not locked") if not hasattr(solver.lib, "sphlite_get_water_summary"): raise AssertionError("Python wrapper is not using the C ABI library") + if not hasattr(solver.lib, "sphlite_get_gas_summary"): + raise AssertionError("Python wrapper is missing Gas C ABI diagnostics") if solver.version() != (0, 3, 0): raise AssertionError("Python version mismatch") @@ -45,6 +47,8 @@ def main() -> int: raise AssertionError("solid inspect summary mismatch") if "water_mass" not in solid_summary or "dt_cfl" not in solid_summary: raise AssertionError("inspect helper did not include Water diagnostics") + if "gas_volume" not in solid_summary or "gas_dtcrit" not in solid_summary: + raise AssertionError("inspect helper did not include Gas diagnostics") solver.set_output_directory(root / "build-codex-unix") solver.write_output(0, 0.0) restart = root / "build-codex-unix" / "python_restart.tmp" @@ -82,6 +86,24 @@ def main() -> int: finally: water.finalize() + gas = SPHLite(args.library) + gas.initialize() + try: + gas_input = root / "tests" / "data" / "gas_ideal_minimal_030.inp" + gas_summary = gas.inspect(gas_input) + if gas_summary["particles"] != 4: + raise AssertionError("gas inspect particle count mismatch") + if gas_summary["gas_volume"] <= 0.0: + raise AssertionError("gas summary volume mismatch") + if gas_summary["gas_max_pressure"] <= 0.0: + raise AssertionError("gas summary pressure mismatch") + if gas_summary["gas_equivalent_radius"] <= 0.0: + raise AssertionError("gas bubble radius mismatch") + if gas_summary["gas_dtcrit"] <= 0.0: + raise AssertionError("gas dt mismatch") + finally: + gas.finalize() + bad_water = SPHLite(args.library) bad_water.initialize() try: