Xmod Co-simulation May 2026

def set_state(self, state: Dict): pass xmod co-simulation master ---------------------------------------------------------------------- class XModCoSimulation: """Orchestrates coupled xmod models."""

def __init__(self, dt: float): self.dt = dt self.models: Dict[str, XModModel] = {} self.connections: List[tuple] = [] # (from_model, from_port, to_model, to_port) xmod co-simulation

def add_model(self, model: XModModel): self.models[model.name] = model to_port) def add_model(self

def get_state(self): return {} # stateless outputs): x = outputs["mass_spring"].get("x"

@abstractmethod def step(self, t: float, dt: float, inputs: Dict[str, np.ndarray]) -> XModStep: """Advance model by dt from t with given inputs.""" pass

# Log results history = [] def log(t, outputs): x = outputs["mass_spring"].get("x", [0])[0] history.append((t, x)) print(f"t={t:.3f}, x={x:.4f}")