Replace Python numerical kernels with native C execution

This commit is contained in:
ljz committed 2026-09-10 01:12:18 +08:00
1 parent 48da6be21c
commit 3b38f73fe0
227 files changed
+16801 -75499

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
"""Rebuild networks from the Python baseline captured before its retirement."""
import json
from pathlib import Path
from app.simulation.core.medium import IdealGasMedium
from app.simulation.components.amesim.media.mediums import AmesimHeliumPengRobinsonMedium, AmesimIdealAirMedium
from app.simulation.native_codegen.extended import catalog_contracts
from app.simulation.systems.network import SimulationNetwork
def reference_data():
return json.loads((Path(__file__).parent / 'data/native-python-reference.json').read_text(encoding='utf-8'))
def reference_network(case):
net = SimulationNetwork('frozen_reference')
media = {}
medium_types = {cls.__name__: cls for cls in (IdealGasMedium, AmesimHeliumPengRobinsonMedium, AmesimIdealAirMedium)}
for item in case['components']:
spec = item['medium']
key = json.dumps(spec, sort_keys=True)
if key not in media:
media[key] = medium_types[spec['type']](**spec['parameters']) if spec else IdealGasMedium()
component = catalog_contracts()[item['type']].create(name=item['name'], medium=media[key], parameters=item['parameters'])
for name, value in item['overrides'].items():
setattr(component, name, value)
net.add_component(component)
for left, right in case['connections']:
net.connect(*left, *right)
return net