@abstractmethod def get_state(self) -> Dict: """For checkpoint/rollback.""" pass
print(f"t=t:.3f, iter=_iter+1, converged=converged") t += self.dt
""" 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. """ xmod co-simulation
Are you using co-simulation in your current workflow? Let us know in the comments how it has saved your project timeline.
return XModStep( outputs="x": np.array([self.x]), "v": np.array([self.v]), new_time=t + dt ) """ Are you using co-simulation in your current workflow
I'll write it as a with a small demo.
On a PC, a complex calculation might take milliseconds. On a microcontroller running at 80MHz, it might take microseconds—or it might cause a timeout. Co-simulation forces the hardware to calculate within the allotted time step. If the hardware can't keep up with the Simulink solver, the simulation will error out, saving you from discovering latency issues months later in the field. On a PC, a complex calculation might take milliseconds
class PController(XModModel): """Outputs F = Kp * (x_ref - x_measured)."""
One of the biggest headaches in embedded design is the transition from double-precision floating-point (standard in Simulink) to fixed-point integers (standard in cheap microcontrollers). XMOD Co-Simulation reveals precision loss and overflow errors immediately. If the simulation works but the co-simulation fails, you know you have a quantization issue to solve.