同步仿真框架并接入AMESim气动组件

This commit is contained in:
huojiarong committed 2026-07-30 03:53:10 +00:00
1 parent 420bafeb4e
commit db4bdb4b70
109 files changed
+26920 -420

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
from __future__ import annotations
import tempfile
import unittest
from pathlib import Path
from app.main import ReactFlowProjectPayload, run_reactflow_test_mql
from app.simulation.examples.test_mql.run import prepare_test_mql_run, run_test_mql
from app.simulation.paths import PROJECT_ROOT, SIMULATION_RUNS_DIR
from PythonModels.systems.test_mql import TestMqlRunConfig
class TestMqlExampleRunnerTests(unittest.TestCase):
def test_default_run_paths_use_app_simulation_runs_dir(self) -> None:
prepared = prepare_test_mql_run()
self.assertEqual(prepared.repo_root, PROJECT_ROOT)
self.assertEqual(prepared.output_dir.parent, SIMULATION_RUNS_DIR)
def test_zero_duration_run_writes_summary(self) -> None:
with tempfile.TemporaryDirectory() as directory:
output_dir = Path(directory) / "test_mql"
result = run_test_mql(
run_config=TestMqlRunConfig(t_start=0.0, t_stop=0.0),
output_dir=output_dir,
)
self.assertEqual(result.result.t, [0.0])
self.assertEqual(result.summary_path, output_dir / "test_mql_model_summary.txt")
self.assertIn(
"Model: test_mql",
result.summary_path.read_text(encoding="utf-8"),
)
def test_reactflow_helper_runs_fixed_topology_test_mql(self) -> None:
payload = ReactFlowProjectPayload(
name="test-mql-fixed",
simulation={
"t_start": 0.0,
"t_stop": 0.2,
"step": 0.1,
"max_step": 0.001,
"method": "BDF",
},
)
result = run_reactflow_test_mql(payload)
self.assertTrue(result["success"])
self.assertEqual(result["model"]["name"], "test_mql")
self.assertEqual(result["model"]["componentCount"], 117)
self.assertEqual(result["series"]["time"], [0.0, 0.1, 0.2])
self.assertIn("summary", result["artifacts"])
if __name__ == "__main__":
unittest.main()