Recurring Error in Simulation
이전 댓글 표시
So, I have a fairly complicated Simulink Model which run again and again, to generate different outputs. This has worked fine for several weeks, and now suddenly I have this Error. I didn't change anything in the model, only a random variable definition in the matlab script which initiates the simulation. The variable is not used in the model.
I was able to get the Model to run once by closing the window, reopening it and reloading some variables, but upon a second unaltered simulation it crashed again. The Error message I get is the following:
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
['My Model/Solver Configuration3']: Transient initialization at time 3.116414621485137e-05, solving for consistent states and modes, failed to converge.
Nonlinear solver: failed to converge, residual norm too large.
Here is the set of components with unconverged equations:
'My Model/Transmission Line3' % an ideal transmission line
Equation location is:
'C:\Program Files\MATLAB\R2023b\toolbox\physmod\elec\library\m\+ee\+passive\+lines\ideal_transmission_line.sscp'(no line number info)
'My Model/Simscape Component1' % this is a component I made myself by copying the Capacitor component and allowing negative capacitances
Equation location is:
'\\My Path\+NegativeCapacitor\NegativeCapacitor.ssc' (line 29)
Equation location is:
'\\My Path\+NegativeCapacitor\NegativeCapacitor.ssc' (line 29)
'My Model/Simscape Component' % same negative Capacitor
Equation location is:
'\\My Path\+NegativeCapacitor\NegativeCapacitor.ssc' (line 29)
Equation location is:
'\\My Path\+NegativeCapacitor\NegativeCapacitor.ssc' (line 29)
'My Model/Resistor3' % random resistor 1 Ohm
Equation location is:
'C:\Program Files\MATLAB\R2023b\toolbox\physmod\simscape\library\m\+foundation\+electrical\branch.ssc' (line 23)
'My Model/Resistor5' % random resistor ca 120 Ohm
Equation location is:
'C:\Program Files\MATLAB\R2023b\toolbox\physmod\simscape\library\m\+foundation\+electrical\branch.ssc' (line 23)
I've encountered this error several times before, the last time several months ago, but could so far avoid it by reloading previous versions of the file, or closing and opening again. My usual strategies aren't working this time and I'd like to know why this error occurs so I can fix it once and for all.
A similar question suggested checking for algebraic loops, but the Code
Simulink.BlockDiagram.getAlgebraicLoops('My Model')
did not find any algebraic loops.
I'm using Automatic Solver Selection with Variable Step. My model is pretty idealized, so abrupt jumps occur, however this has not been an issue in the past and I don't understand why it would be now, if this is why the error occurs (this has been suggested in another answer to a similar question). I have found that after a few microseconds the current in my circuit jumps to about 10^300, which is where the simulation stops, understandably. I just don't understand why the current would suddenly jump so high and why at that moment.
If anyone has any ideas on what is causing this error and how to fix it, I would greatly appreciate the help.
채택된 답변
추가 답변 (2개)
Umar
2024년 7월 1일
0 개 추천
Hi Annika,
No problem, so I will try to tackle your questions by providing solutions to them to best of my knowledge. So, your first question was
What settings would you recommend? I have tried lowering the max step time, however this didn't fix the issue and the simulation got of course much slower. I don't know the Solvers well enough to know how they differ, so if you can recommend one that is better than the auto selection, I would be glad to know.
In my opinion, default solver selection is usually reliable, but for specific cases, manual selection might be beneficial. Here are some common solvers and their characteristics:
ode45: A good general-purpose solver for non-stiff problems. ode15s: Ideal for stiff systems where fast transients are present. ode23: Balances efficiency and accuracy for medium-sized problems. You can manually select a solver using the odeset function. For instance:
options = odeset('RelTol',1e-5,'AbsTol',1e-8); [t,y] = ode45(@odefun,tspan,y0,options);
As for the variables in the block parameters: Those all check out. I've checked them, and again, this exact simulation ran like this for months with these exact parameters. I don't know where you see a capacitance defined as 1F, in my model all capacitances are of the order 1e-8F or lower. My custom component is of course a bit of a wildcard, but since I literally changed only "C>0" to "abs(C>0)" in the capacitor for this I don't think it is the source of the issue. Again, I have been using this simulation in this form for months and never had an issue.
If you suspect a custom component might be causing the issue, it's essential to scrutinize its implementation. Verify the changes made, especially the alteration from "C>0" to "abs(C>0)" in the capacitor. Ensure that this modification aligns with the expected behavior and doesn't introduce unintended consequences.
I may try upgrading to 2024a and see if that helps, if you have any specific advice beyond "check everything again" I'd be glad to hear it.
That is a valid option because newer versions often come with bug fixes and performance enhancements. Before upgrading, ensure compatibility with your existing codebase and any specific features you rely on.
While you have validated the parameters and settings, a systematic troubleshooting approach can help pinpoint the root cause. Check for any recent changes, unexpected interactions, or boundary conditions that might have been overlooked.
Let me know if I can assist further.
Umar
2024년 7월 1일
0 개 추천
Hi Annika,
Glad to help out. People make mistakes but when we work as a team together, problems get resolved. I am glad that you are happy and problem is resolved. Good luck with your future endeavors.
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!