完善仿真交互、结果展示与模型元数据
This commit is contained in:
1 parent
f1256a121d
commit
f7f1078911
26 files changed
+9042
-575
No files matched your search
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
||||
|
||||
from PythonModels.core.base import Component, DynamicComponent
|
||||
from PythonModels.core.equations import EquationResidual
|
||||
from PythonModels.core.metadata import ResultVariableMetadata
|
||||
from PythonModels.core.ports import PortState
|
||||
|
||||
|
||||
@@ -257,6 +258,13 @@ class SimulationNetwork:
|
||||
if cursor != len(values):
|
||||
raise ValueError("State vector length does not match dynamic components.")
|
||||
|
||||
def result_variable_metadata(self) -> tuple[ResultVariableMetadata, ...]:
|
||||
return tuple(
|
||||
variable
|
||||
for component in self.components.values()
|
||||
for variable in component.result_variable_metadata()
|
||||
)
|
||||
|
||||
def summary(self) -> str:
|
||||
lines = [f"Network: {self.name}", "Components:"]
|
||||
for name, component in self.components.items():
|
||||
@@ -281,10 +289,15 @@ class SimulationNetwork:
|
||||
{
|
||||
"id": component.name,
|
||||
"type": component.model_type,
|
||||
"parameters": component.parameter_interface_dicts(),
|
||||
"ports": [
|
||||
definition.as_interface_dict()
|
||||
for definition in component.port_definitions
|
||||
],
|
||||
"resultVariables": [
|
||||
variable.as_dict()
|
||||
for variable in component.result_variable_metadata()
|
||||
],
|
||||
}
|
||||
for component in self.components.values()
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user