Matlab/Simulink Build error: Unable to honor user-specified priorities - matlab

I try to generate code with the embedded matlab coder from a Simulink model.
Then this error occurs: Unable to honor user-specified priorities.
It seems to me that this algebraic loop triggers this error. As you can see in the picture below, there are a higher execution-order at the sum as at the integrator.
I changed the continuous block integrator to an discrete, I put a memory block in the back-path, also an unit-delay-block. But nothing lead to success.
I hope you can give me some approaches to find out a workaround.
Regards
Alex

Related

Error in All sample times for this block must be discrete. No continuous or constant sample times are allowed

I'm designing DSS System, the problems is when I execute it this error occurs:
Error in 'DSS_System_withANFIS/Synchronization Unit/Acquisition/Integrate and Dump1': All sample times for this block must be discrete. No continuous or constant sample times are allowed.
Here is my overall system design:
and this is my acquisition subsystem of Synchronization unit:
The error occurred at integrate and dump unit.
Any help?
I found the solution.
I just changed the solver to discrete in configuration parameters in simulink UI

Non-liner solver couldn't converge during the initialization in Dymola

I met an error during initialization when using ThermoSysPro library.
It seems like the Turbine5.Pe is larger than Turbine2.Pe, so the result is negative. but I checked my parameters, there shouldn't be such a problem.
Is this because the nonlinear solver couldn't solve the equation in the following picture?
There is not enough information and I would recommend to set Details and/or Nonlinear iterations in Simulation setup>Debug>Nonlinear solver diagnostics to get more information.
The full expression causing the problem is sqrt((Turbine2.Pe^2-Turbine5.Pe^2)/(Turbine2.Cst*Turbine2.proe.T))
Since the two Pe-values have fixed=true it seems unlikely that they are wrong, but it is impossible to see without the complete model.
However, it is also possible that either Cst or proe.T is negative, or computed to a negative value based on other values.
Without a complete model that is impossible to tell.
According to the comparison between ThermoSysPro(Open source library from EDF https://github.com/alex19941215/ThermoSysPro ) and ThermalPower(Commercial library from Modelon https://www.modelon.com/library/thermal-power-library ), there should be some inspiration for people faced with the same situation.
Here is the code form ThermoSysPro library:
Connectors.FluidInlet Ce
Connectors.FluidOutlet Cs
Here is a type code from Thermal Power library:
Interfaces.FlowPort feed(
h_outflow(start=hstartin))
Interfaces.FlowPort drain(
p(start=pstart),
h_outflow(start=hstartout))
From the code, we can see that in the Thermal Power library each connector's attribute is assigned values according to the parameters, but in the ThermoSysPro library, the connector is using default values, probably zero. So that's why the Thermal Power library has better performance in the term of initialization convergence

Why does my Simulink-Model rebuild at every iteration?

I'am trying to speedup my simulink project and want to use the Accelerator-Simulation mode.
The aim of my project is to control a cyclic process and is structured as followes:
matlab-script, where all parameters and a feedforward control with
parameter estimation is implemented. Also it starts simulating the
simulink model for each iteration.
simulink model, where the dynamic system and the feedforward control (basically a lookup-table) together with a feedback control
is implemented. Parameters of all blocks are set by workspace variables/structs generated by the script.
The feedforward control variable is calculated and parameter are estimated from the simulated data after every simulation pass. Then the model is simulated again. The model is not changing during the iterations, but still it is compiling at every cycle. From the first: Is this solution appropriate for using the Accelerator mode?
I tried to follow theses proposed steps to determine, why it is built at every iteration: mathworks
If i run it with the Accelerator-Mode (referring to the documentation of this function, it now compiles for simulation), I still cannot reproduce why it is compiled at every iteration.
csdet1.ContentsChecksum.Value ~= csdet2.ContentsChecksum.Value
is true, but the proposed code does not find any details.
csdet1.InterfaceChecksum.Value ~= csdet2.InterfaceChecksum.Value
is also true, the proposed code outputs that
UserDefinedTypesChecksum
is different. What does that mean and how can I resolve this?
Sidefact: When I run Simulink.BlockDiagram.getChecksum() with the Model opened in Simulink and Normal-Mode chosen, I get this error:
Continuous update specified for this chart chartname This is not
supported for RTW."
But this chart is a Matlab-Function block, not a stateflow chart?!

More verbose error messages with recursive algorithms in Matlab?

BUG: I used cell-arrays in the underlying functions, bad!
I cannot understand why restarting Matlab result sometimes into more verbose error messages that help me to actually solve problems. Now I am trying to find a command that makes Matlab showing as much information as possible. For example the below index-exceed-dimension error is totally useless with my recursive algorithm -- this is the specific algorithm where Matlab have once revealed the specific line but now for some reason only telling the vacuously the name of the algorithm
Index exceeds matrix dimensions.
Error in Dij (line 65)
Dij_=Dij(ii,jj,[II,k],[r,q_(k)]);
where you can see that I am running the algorithm Dij failing on the line running the algorithm Dij again.
How can I get more information about the error? Or how can I get inside any point in the recursive algorithm? -Linebreak and trying to get inside that point just fires the error.
Add a try catch block on your recursive algorithm, print the information you think it would be valid and then rethrow an error that will terminate your other callbacks silently.
You may use the keyboard matlab function to check the matlab workspace as the recursive function goes on. You can choose to add it just before your error message, so it will be called every time it goes deeper in the recursive level, so that you can check what is going on, or you can add it when the error occurs (on the catch).
This is just a draft, it may contain errors, adapt it into your needs:
try
% recursive routine
catch ext
if strcmp(ext.identifier,'MyPackage:MyRecursiveRoutine:TerminateSilently'))
% Do nothing
else
% Display useful information, you edit it to add information you think would be valid, i.e.:
disp(ext.getReport)
disp(yourVariable)
% get dbstack size, to see how many recursive functions, i.e:
theStack = dbstack;
recursiveCalls=sum(strcmp({theStack.name},'MyRecursiveFcnName'))
% You may even add the keyboard function here, so that you can inspect your workspace:
keyboard
throw(MExcept('MyPackage:MyRecursiveRoutine:TerminateSilently',''));
end
end
Run dbstop if error before running your code to drop to the debugger exactly at the point of error. From there you can inspect the variables, including whatever variable you've carried along to ID the level. You can also run dbstack to see the full call stack.
It is not evident in the description where the bug is because it does not show with which tools I programmed the underlying functions: I used cellarrays and for some reason Matlab returns far worse error messages with cellarrays than with Matrices so:
my genuine recommendation is avoid cellarrays and use matrices -- and if you need to play with a lot of zero cases, use the ready sparse functionalities because they have far better debugging verbosity!
Instead of wasting too much time to debugging, choose the right tools and Matlab is excellent with Matrices and you can see it in the quality of error messages.

Input connector problems in custom modelica models with custom media

I am currently working with a Modelica model in Dymola to simulate a chemical process. The reactor modeling itself is done to a satisfying extent, but I'm having a hard time implementing these models into Modelica, especially with respect to getting the various Media definitions to interconnect and communicate, so to speak. This is also the key achievement of the Modelica implementation of the model.
At the moment I'm struggling with a specific type of error which, even though it appears quite obvious and straight-forward, I find relatively hard to solve. The errors are of the type:
Note: The input connector p of coopolReactor_2706_1.medium is not connected from the outside.
It is likely that it should have been connected, and recursive check will assume this.
The missing connection is a likely cause of errors in the model.
Note: The input connector h of coopolReactor_2706_1.medium is not connected from the outside.
It is likely that it should have been connected, and recursive check will assume this.
The missing connection is a likely cause of errors in the model.
The model has the same number of unknowns and equations.
The model has the same number of unknowns and equations.
The model EmulsionPolymerizationToolbox.Test.Test_2706 component coopolReactor_2706_1 is structurally singular.
when assuming the most generic outside couplings to all the flow variables of its connectors.
In the specific code which gave this error message, I've mimic'ed a simple lumped volume extending base classes from the Modelica Standard Library, but the error is still the same as for my complete reactor models. That's why understanding and solving this problem is vital to the progress of my assignment.
I've been searching a bit online to find out more about what could cause this problem, without much luck. Could someone please elaborate a bit on these kind of errors, and maybe even suggest solutions? Any inputs from this board will be useful to me.
Thanks in advance.
Regards, Fredrik.
It's possible this is actually a Red Herring. It appears as though this message is generated because of an imbalance in equations. Dymola then searches for the source. It may be that when it seems an imbalance in your component, it also notices that you have an unconnected input and reports that, even if that may not be your problem.
Another thing to keep in mind is that one of the new features in Modelica 3.x was the addition of rules about local balancing of equations and unknowns. One impact of these rules was that for medium models to be balanced, it was necessary to mark some of the variables as inputs (implying they would be specified from the outside). This use of the input qualifier isn't meant to indicate that these variables need to be connected to (or even specified via equations or modifications). Instead, it is really just a way of indicating how many equations are provided by the media model and how many are provided outside.
So where does this leave you. Well, I could be completely wrong (let's not overlook that possibility). But if I'm right, this indicates that you have an imbalance that has nothing to do "unconnected inputs". I suppose the only real help my answer gives is to encourage you to look for other "missing" equations.
If you actually posted code of your simple case, someone might be able to spot the missing equation.