Files
ljz 1aac220084 优化 Jacobian 确定性复用并补充性能剖析与平台依赖文档
在单次 Jacobian 构建内按完整输入精确复用储气物性、PH 反算、密度和管路求根结果,保持原有求值副作用、差分政策与失败回退。八路模型求解 CPU 中位数减少 19.27%,循环和不循环的完整原始采样均与恢复基线一致。

增加独立的跨平台时间剖析工具,记录互斥阶段耗时、Newton/LU 统计、矩阵复用与内核复用,保存 UD00 两种工况的调查报告和机器可读汇总。

补充 Windows/Linux 运行、测试、原生编译和剖析所需依赖文档及索引,不修改依赖清单、版本锁或安装环境。

验证:8 项新增专项回归通过;2270 次完整 Jacobian 核对零差异;16 次剖析配对及预热运行保持完整数值一致。既有固定样本哈希失败和 Linux 实机验收限制见报告。
2026-09-16 13:39:53 +08:00

37 lines
1.9 KiB
Python

"""Reviewed native component module exports and their compilation dependencies."""
from __future__ import annotations
import re
EXPORTS = {
"properties": frozenset({
"native_properties_init", "native_temperature_ph_context", "native_density_context",
"native_gas_init", "native_gas", "native_gas_context", "native_medium_init",
"native_density", "native_temperature_ph", "native_viscosity",
"native_medium_gas", "native_medium_gas_context", "native_polytropic_gas_context",
"native_jacobian_gas",
"native_jacobian_scalar_get", "native_jacobian_scalar_put",
}),
"orifice": frozenset({"native_orifice", "native_orifice_context", "native_medium_orifice", "native_medium_orifice_context"}),
"pipe": frozenset({"native_pipe_resistance", "native_pipe_flow", "native_pipe_flow_context",
"native_pipe_flow_cached", "native_pipe_flow_cached_context",
"native_pipe_diagnostics", "native_pipe_diagnostics_context"}),
"mechanics": frozenset({"native_contact", "native_stop_motion", "native_limit_force", "native_dry_friction"}),
"signal": frozenset({"native_signal", "native_signal_break"}),
}
DEPENDENCIES = {"orifice": ("properties",), "pipe": ("properties",)}
def component_modules(source: str) -> tuple[str, ...]:
# Generated C refers to these functions directly. Include identifier uses
# (also function pointers), conservatively including any comments/strings.
identifiers = set(re.findall(r"\bnative_[A-Za-z0-9_]+\b", source))
selected = {name for name, exports in EXPORTS.items() if identifiers & exports}
pending = list(selected)
while pending:
for dependency in DEPENDENCIES.get(pending.pop(), ()):
if dependency not in selected:
selected.add(dependency)
pending.append(dependency)
return tuple(name for name in EXPORTS if name in selected)