Calling time step and values of Previous time step in a component file of simscape
6 次查看(过去 30 天)
显示 更早的评论
There is a PEMFC model for system modeling of polymer electrolyte membrane fuel cells, which can be opened using the command : "ssc_fuel_cell".
Here, you can find some more details about it.
The membrane electrode assembly (MEA) has a source code which has been written in simscape language.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1194678/image.png)
I am trying to couple our 1D multiphase model with this code. now, I have some questions:
1- How is this "fuelcell.ssc" component file used in this simulink model? is it called in each time step?
2- My numerical model needs the values of some paprameters from previous time step. how can I call them? is there any way to store some parameters in workspace and call them again in the following time step?
3- how can I call the time step itself? I mean the length of each time step.
This is an example for updating a parameter in each time step. as it can be seen I need value of previous time step and length of each time step for finding the new one.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1194683/image.png)
4- is there any way I can run the whole simulink model in steady state mode? I need some preliminary results in steady state but the main and final objective is constructing a transient model. So, in the end I need to find the way I can call values of previous time steps and length of each time step.
0 个评论
采纳的回答
David John
2022-11-21
(1) I'm not 100% sure what you mean with this question, but fuelcell.ssc defines the Simscape model for one block of the overall model. All of the Simscape blocks that are connected to the Solver Configuration block are analyzed together as a system of equations.
(2)-(3) Your equation looks like a forward Euler discretization of a differential equation. In general, I would say that you could consider using eta_a.der = (eta_a_new - eta_a_old)/dt and then you don't need to try and get old and new values everywhere, and you can just let Simscape discretize things. This would then work for both variable- and fixed-step solvers. If you really need to sample old values of variables, then you probably need an asynchronous sample-and-hold or an event that stores an old value. For your case, I would recommend just writing the equations as differential equations instead of as finite-difference equations.
(4) See Find Steady-State Operating Points for Simscape Models - MATLAB & Simulink (mathworks.com) for information on steady-state solutions.
4 个评论
David John
2022-12-16
If you have a valid license, please feel free to reach out to our Tech Support organization for more interactive help: Contact Us - MATLAB & Simulink (mathworks.com).
In general, if you have an equation that looks like:
eta_new == dt * f + eta_old
where f is some arbitrary function and dt is the timestep, then you can try replacing it with a continuous-time differential form of the equation:
eta.der == f
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Composite Components 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!