现有组件功能与Amesim组件比较对齐,补全功能;仿真服务启动环境检测,旧版json工程文件适配读取
This commit is contained in:
1 parent
b6c22a54f8
commit
6fc9afe41d
119 files changed
+260114
-351
No files matched your search
@@ -74,11 +74,16 @@ def compile_native_program(network: SimulationNetwork) -> NativeProgram:
|
||||
network.validate_port_supplies()
|
||||
from .extended import catalog_contracts
|
||||
contracts = catalog_contracts()
|
||||
from app.simulation.components.amesim.semantics import validate_numerical_semantics
|
||||
for component in network.components.values():
|
||||
if type(component) is not contracts.get(component.model_type):
|
||||
raise NativeCapabilityError(f'{component.name}: no native contract for {component.model_type}')
|
||||
if component.MODEL_VERSION != SUPPORTED_VERSIONS.get(component.model_type):
|
||||
raise NativeCapabilityError(f'{component.name}: native kernel version does not match the component contract')
|
||||
try:
|
||||
validate_numerical_semantics(component)
|
||||
except ValueError as exc:
|
||||
raise NativeCapabilityError(str(exc)) from exc
|
||||
# Preserve the compact, verified schedule for its supported topology.
|
||||
# Both paths emit C; this never falls back to Python numerical execution.
|
||||
try:
|
||||
@@ -258,9 +263,11 @@ def _compile_storage_anchored_program(network: SimulationNetwork) -> NativeProgr
|
||||
put(c, "dvol", f"{get(c, 'vol')} <= {_number(c.cvol0 / 100)} ? 0.0 : ({rate})")
|
||||
volume, rate = get(c, "vol"), get(c, "dvol")
|
||||
volume_expressions[c.name] = (volume, rate)
|
||||
# Match the Python constructor: m/U use configured storage volume;
|
||||
# connected moving volumes subsequently change recovered p/T.
|
||||
initial_volume = max(base, c.cvol0 / 100) if c.model_type == "amesim_pnch012" else base
|
||||
# p0/T0 refer to the complete connected volume at the initial positions.
|
||||
initial_volume = base
|
||||
if c.model_type == "amesim_pnch012":
|
||||
initial_volume += sum(p.effective_area * (p.x0 + mass_at(p, "port_5").x0 - mass_at(p, "port_4").x0) for p in connected)
|
||||
initial_volume = max(initial_volume, c.cvol0 / 100)
|
||||
init.append(f"if (!native_gas_init({_number(c.p0)}, {_number(c.T0)}, {_number(initial_volume)}, &y[{si(c, 'm')}])) return 0;")
|
||||
lines.append(f"NativeGas gas_{gi};")
|
||||
lines.append(f"if (!native_gas_context(properties, y[{si(c, 'm')}], y[{si(c, 'U')}], {volume}, &gas_{gi})) return 0;")
|
||||
|
||||
Reference in new issue
Block a user