前端进度条性能优化、仿真结束后后处理优化;后端C代码生成流程优化:先识别来源,再按照已知未知量需求排序,最后局部求解
This commit is contained in:
1 parent
0dcb465d84
commit
91bd9fb252
77 files changed
+11223
-551
No files matched your search
@@ -6,6 +6,9 @@ from app.simulation.core.base import Component, DynamicComponent
|
||||
from app.simulation.core.equations import EquationDefinition
|
||||
from app.simulation.core.metadata import ResultVariableMetadata
|
||||
from app.simulation.core.ports import PortState
|
||||
from app.simulation.core.port_computation import (
|
||||
PortSupplyError, port_supply_issue, reference_supply_issues,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -110,6 +113,10 @@ class SimulationNetwork:
|
||||
raise ValueError(
|
||||
f"Connection variable contracts do not match: {endpoint_a}, {endpoint_b}."
|
||||
)
|
||||
supply_issue = port_supply_issue(first_definition, second_definition,
|
||||
str(endpoint_a), str(endpoint_b))
|
||||
if supply_issue:
|
||||
raise PortSupplyError(supply_issue)
|
||||
if first_definition.kind == "signal" and {
|
||||
first_definition.nominal_role,
|
||||
second_definition.nominal_role,
|
||||
@@ -161,6 +168,22 @@ class SimulationNetwork:
|
||||
self.connections.append(connection)
|
||||
return connection
|
||||
|
||||
def validate_port_supplies(self) -> None:
|
||||
"""Validate again at compile time, including manually assembled networks."""
|
||||
ports = {(c.name, p.name): p for c in self.components.values()
|
||||
for p in c.active_port_definitions}
|
||||
adjacency = {}
|
||||
for edge in self.connections:
|
||||
a, b = (endpoint.key for endpoint in edge.endpoints)
|
||||
issue = port_supply_issue(ports[a], ports[b], '.'.join(a), '.'.join(b))
|
||||
if issue:
|
||||
raise PortSupplyError(issue)
|
||||
if edge.kind == 'physical':
|
||||
adjacency[a], adjacency[b] = b, a
|
||||
issues = reference_supply_issues(ports, adjacency)
|
||||
if issues:
|
||||
raise PortSupplyError(issues[0])
|
||||
|
||||
def _port_for(self, endpoint: Endpoint) -> PortState:
|
||||
try:
|
||||
component = self.components[endpoint.component]
|
||||
|
||||
Reference in new issue
Block a user