Generic CoSimulation block #212
DavidMStraub
started this conversation in
General
Replies: 2 comments 5 replies
-
|
@DavidMStraub exactly right. We already have a block in pathsim exactly for that purpose. Its the It has an internal scheduled event that periodically triggers the user defined function. Maybe naming is a bit ambiguous here.. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
And yes, DAE blocks are currently not supported. But they might be in the future. Do you know what kind of DAE we would need for pybamm? Semi-explicit? Fully implicit? Mass matrix? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
when initially designing pathsim-batt, I tried to override
DynamicalSystem'sstepmethod to step PyBaMM's internal solver. As correctly pointed out by @milanofthe in pathsim/pathsim-batt#2 (comment), this doesn't work as it is based on a misunderstanding ofstep: it's not a macro time step, but an ODE solver step.pathsim-batt is now implemented by extracting the ODE RHS and using pathsim's internal solver, which is way more elegant and integrated.
However, there is a fundamental limitation: the most accurate electrochemical model, the Doyle-Fuller-Newman (DFN) model, is not pure ODE but also contains algebraic equations (DAEs). As far as I know, this is not currently supported by pathsim.
Since PyBaMM already includes powerful solvers tuned for this use case, I tried to wrap my head around how to make this work. This was also triggered by this article: Running PyBaMM from MATLAB: Expanding Battery Simulation Capabilities, which discusses putting PyBaMM into a Simulink Python code block.
I think the answer is: this would not be a full integration, but a cosimulation.
PathSim already supports cosimulation via FMUs, but creating an FMU would be overkill here: we already have the PyBaMM Python objects.
So, here is my suggestion: let's introduce a new block
CoSimulation, which uses event hooks like the FMU cosimulation block and provides an abstract methodmacro_step(or whatever is a good name) that can be overridden by child classes.This would allow us to add DFN models to pathsimm-batt, choose between full integration and cosimulation for SPM models, and also allow integrating other Python-based simulation tools in PathSim via cosimulation.
Beta Was this translation helpful? Give feedback.
All reactions