Simulink simulation doesn't end

조회 수: 25 (최근 30일)
Tobia De Benedictis
Tobia De Benedictis 2024년 7월 18일
편집: Kautuk Raj 2024년 9월 11일
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
Umar
Umar 2024년 7월 18일
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 2024년 7월 24일
It smells like initial condition issue to me. Any chance you could share the model here for diagnostics?

댓글을 달려면 로그인하십시오.

답변 (1개)

Kautuk Raj
Kautuk Raj 2024년 8월 23일
편집: Kautuk Raj 2024년 9월 11일
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.

카테고리

Help CenterFile Exchange에서 Creating Custom Components and Libraries에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by