Xmod Co-simulation !!exclusive!! Direct

I'll write it as a with a small demo. """ xmod co-simulation — a lightweight modular co-simulation framework. Models exchange data via ports and advance with their own solvers. Master coordinates time steps and data exchange. """ import numpy as np from dataclasses import dataclass from typing import Dict, List, Callable from abc import ABC, abstractmethod ---------------------------------------------------------------------- Core xmod types ---------------------------------------------------------------------- @dataclass class XModPort: """Defines a data port for a model.""" name: str shape: tuple = () dtype: type = float

sim = XModCoSimulation(dt=0.01) sim.add_model(plant) sim.add_model(ctrl) sim.connect("controller", "F_cmd", "mass_spring", "F_ext") sim.connect("mass_spring", "x", "controller", "x_measured") xmod co-simulation

def get_state(self): return {"x": self.x, "v": self.v} I'll write it as a with a small demo

def __init__(self, name: str): self.name = name self.input_ports: List[XModPort] = [] self.output_ports: List[XModPort] = [] Callable from abc import ABC