补充test_mql管路反号观测输出

This commit is contained in:
huojiarong committed 2026-07-16 08:54:59 +00:00
1 parent 0cd4359964
commit a1870f2789
2 files changed
+107

No files matched your search

+69
View File
@@ -67,6 +67,23 @@ class TestMqlComputedGeometryRun:
return len(self.output.data_paths)
@dataclass(frozen=True)
class TestMqlComputedLineRelationsRun:
amesim_results: AmesimResults
observation_catalog: TestMqlObservationCatalog
output_schema: TestMqlOutputSchema
output: TestMqlValidatedOutput
comparison: TestMqlComparisonResult
@property
def sample_count(self) -> int:
return len(self.output.times)
@property
def signal_count(self) -> int:
return len(self.output.data_paths)
@dataclass(frozen=True)
class TestMqlComputedPneumaticRelationsRun:
amesim_results: AmesimResults
@@ -189,6 +206,39 @@ def run_test_mql_computed_geometry(
)
def run_test_mql_computed_line_relations(
archive_path: Path,
) -> TestMqlComputedLineRelationsRun:
amesim_results = load_test_mql_amesim_results(archive_path)
observation_catalog = build_test_mql_observation_catalog(amesim_results)
output_schema = build_test_mql_output_schema(
amesim_results,
observation_catalog=observation_catalog,
)
output_series = _compute_line_reversed_series(amesim_results, observation_catalog)
output_data_paths = tuple(output_series)
output = validate_test_mql_output(
times=amesim_results.times,
series_by_data_path=output_series,
schema=output_schema,
data_paths=output_data_paths,
)
comparison = compare_validated_test_mql_output(
times=output.times,
series_by_data_path=output.series_by_data_path,
schema=output_schema,
amesim_results=amesim_results,
data_paths=output.data_paths,
)
return TestMqlComputedLineRelationsRun(
amesim_results=amesim_results,
observation_catalog=observation_catalog,
output_schema=output_schema,
output=output,
comparison=comparison,
)
def run_test_mql_computed_pneumatic_relations(
archive_path: Path,
) -> TestMqlComputedPneumaticRelationsRun:
@@ -397,3 +447,22 @@ def _compute_orifice_reversed_series(
)
return series_by_data_path
def _compute_line_reversed_series(
amesim_results: AmesimResults,
observation_catalog: TestMqlObservationCatalog,
) -> dict[str, tuple[float, ...]]:
series_by_data_path: dict[str, tuple[float, ...]] = {}
for binding in observation_catalog.lines.by_submodel("PNL00R"):
if len(binding.mass_flow_paths) != 2 or len(binding.enthalpy_flow_paths) != 2:
raise ValueError(f"Expected two PNL00R flow paths for {binding.alias}.")
primary_mass_path, reversed_mass_path = binding.mass_flow_paths
primary_enthalpy_path, reversed_enthalpy_path = binding.enthalpy_flow_paths
series_by_data_path[reversed_mass_path] = tuple(
-value for value in amesim_results.series(primary_mass_path)
)
series_by_data_path[reversed_enthalpy_path] = tuple(
-value for value in amesim_results.series(primary_enthalpy_path)
)
return series_by_data_path