Simulink simulation doesn't end

10 visualizzazioni (ultimi 30 giorni)
Tobia De Benedictis
Tobia De Benedictis il 18 Lug 2024
Modificato: Kautuk Raj il 11 Set 2024
Hello, I'm simulating a Fuel Cell system with the fuel cell simscape's block. Is a simple system, constant in input for fuel and air pressures, stoichioimetric rate for "qair" and "qfuel", in the outport "p" and "n" i connected a power sensor and then a scope connected to the latter. I use a probe to read the value of "iFC" that is a result of the simulation to input it into a MatLab Function block to calculate the rate of production of water as a function of the current generated by the cell because I need it as an output as well. The problem I encounter is that during the simulation the little loading bar stays at 0% and it appears a writing next to it that says "T = a very little number". I am fairly new to simscape that i'm using for my bachel thesis. Is there someone that knows what is happening? Thanks so much in advance, i will attach an image of the model and write the code inside the matlab function block.
code:
function H2Opr = H2O_produced(area_cell,i_cell,Ncell)
MW_H2O = 18.01528; %g/mol
F = 9.64853321233100184*10^4; %C/mol
H2Opr = (Ncell * MW_H2O * area_cell * i_cell)/(2*F);
end
  2 Commenti
Umar
Umar il 18 Lug 2024
Hi Tobia,
I don’t have access to simulink but I will do my best to help you out. Your MATLAB function for calculating water production seems correct. The message "T = a very little number" indicates a numerical issue in the simulation. Review the simulation time and step size to ensure numerical stability. Check for any singularities or discontinuities in the system that could affect the simulation progress. Add disp statements within the MATLAB function to print intermediate values for debugging.Check if any variables become NaN (Not a Number) during the calculation. Ensure that the input arguments passed to the function are valid.
By following these steps and carefully reviewing your simulation setup and MATLAB function block, you should be able to identify and resolve the issue causing the simulation progress bar to stay at 0% and the "T = a very little number" message.
Yifeng Tang
Yifeng Tang il 24 Lug 2024
It smells like initial condition issue to me. Any chance you could share the model here for diagnostics?

Accedi per commentare.

Risposte (1)

Kautuk Raj
Kautuk Raj il 23 Ago 2024
Modificato: Kautuk Raj il 11 Set 2024
It sounds like you are encountering a simulation issue where the solver is struggling to progress, indicated by the simulation time ‘T’ not advancing. This can happen in Simscape models due to several reasons, such as stiff equations, incorrect initial conditions, or solver configuration issues.
You can go through some steps below to troubleshoot and resolve this issue:
(1) Check Initial Conditions:
Ensure that all initial conditions for your Simscape components are set appropriately. Incorrect or inconsistent initial conditions can cause the solver to have difficulty starting the simulation. More about specifying initial conditions can be found on this documentation page here: https://www.mathworks.com/help/releases/R2023b/sps/powersys/ug/specifying-initial-conditions.html
(2) Solver Configuration:
Go to theSolver Configuration” block in your Simulink model. Ensure that the solver is set to handle stiff systems if your model is complex or involves rapid dynamics. Consider using a solver likeode15s’ or ‘ode23t. Adjust the solver settings such as the maximum step size and relative/absolute tolerances. Sometimes, reducing the maximum step size can help the solver progress. More details about the choice of the solver can be accessed here: https://www.mathworks.com/help/releases/R2023b/simulink/ug/choose-a-solver.html
(3) Check for Algebraic Loops:
Ensure there are no algebraic loops in your model, as these can cause simulation issues. Simscape blocks can sometimes create implicit algebraic loops, so check your connections. To learn more about algebraic loops and their resolution, refer to this documentation page: https://www.mathworks.com/help/releases/R2023b/simulink/ug/algebraic-loops.html
By following these steps, you should be able to diagnose and resolve the issue with your Simscape simulation.

Categorie

Scopri di più su Creating Custom Components and Libraries in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by