How to get the Structure Jacobian in Dymola? - modelica

I notice there is a chapter about "Structure Jacobian" in Dymola Manual 2C, but I am not sure if I could also get the "Structure Jacobian" of my own model in Dymola. I have checked the Dymola manual but didn't find how to do it.
So my question is:
Could I get the "Structure Jacobian" of my own model in Dymola?
If it is possible, how should I do it?

There is no direct support for getting the incidence structure/structure Jacobian in Dymola 2021 and earlier.
You can some of the incidence structure of the manipulated system from the dependencies ("ModelStructure"-node) in the modelDescription.xml for FMI-export.

Related

The process of solving DAE in Dymola

I am trying to understand the process of solving DAEs in Dymola. According to Chapter 13.8 of Dymola's help document, Dymola would first use an index reduction algorithm to transform the original DAE into ODE, then get a BLT form after partitioning and tearing, so Dymola could solve ODE with BDF method like DASSL.
Here is the screenshot of Dymola's help document.
I also found some material about how to solve DAE from Wolfram mathematica, as shown in the following screenshot, there could be different strategies in different phases, I marked the method I think adopted in Dymola. My question is:
Does Dymola just adopt the method as I marked?
Or Dymola also adopt the method as Wolfram Mathematica, which is using different methods in different phases? If so, how does Dymola determine using which method?
Dymola does something resembling that red line, and ignoring many of the choices in that flow-chart as they are not relevant and there many equally important choices hidden.
E.g.,
The index reduction algorithm will work even if the index is 1 or 0 - it will just not do anything.
The dummy derivatives method can be seen as a projection method. (I did my master's thesis on implementing it a long time ago.)
IDAS is one of the solvers in the sundials suite. Dymola can use sundials solvers for integration, as well as a number of other solvers; and both have the model as ODE or as index 1 DAE for suitable solvers - but that's handled in the generated C-code, and doesn't influence other parts.

How can I find numerical solutions of discrete SIR model in MATLAB?

I was looking to simulate the discrete sir model in MATLAB and also to find stability and bifurcation graph. can anyone help me solve these problems?
A great source for Matlab scripts is the Mathworks file exchange. A search for the SIR model found:
https://www.mathworks.com/matlabcentral/fileexchange/75100-sir-epidemic-spread-model?s_tid=srchtitle
This should have what you're looking for (unfortunately don't have Matlab on this computer to check).
For the discrete sir equations a for loop as described in:
https://www.mathworks.com/matlabcentral/answers/325773-solving-difference-equation-with-its-initial-conditions
should be able to solve your system for fixed parameters. You're going have to do a bit of work to get the bifurcation diagram and stability. This answer:
Generate bifurcation diagram for 2D system
should get you going.

In Dymola, How to find which component that the wrong equations belong to?

If I build a model in Dymola, but in translation, there is a warning about incompatible units of equations, but just according to the warning message, I can't find which components that the wrong equations belong to. So how could I find it in Dymola?
I agree that Dymola should include more information about equations in unit-checking.
However, we can see that:
It doesn't seem to be in a function, as it is an equation for a derivative.
It doesn't seem to be in heatExchangerFixedTemperature as all variables do not start with that prefix (unless T_amb is a package constant). It would thus seem that the equation is directly in the current model, or in one of its base-classes.

Issues with the "Chattering" example in Chapter 2 of Modelica by example

Here is the link of the model:https://mbe.modelica.university/behavior/discrete/decay/#chattering
The simulation result for the following result in Dymola 2021 would be:
model WithChatter(stopTime=1.001s)
model WithChatter(stopTime=1.5s)
As we could see, noEvent operator does decrease the CPUTime, but it also causes the system stiff, it would be easier to understand with more explanation about why noEvent would cause the system stiff.
Based on the event logging of model WithChatter, the simulation process actually uses the minimum time step because the der(x) is not a continuous function. But why doesn't this approach suit the model WithNoEvents?(https://mbe.modelica.university/behavior/discrete/decay/#speed-vs-accuracy)
If noEvent operator means using the integrator directly, it might require the functions in the equation system have to be continuous? So Does this mean that the model used in the Chattering example(https://mbe.modelica.university/behavior/discrete/decay/#chattering) isn't appropriate, since the function in this model is not continuous?
The model used in the chattering example isn't appropriate since it is not continuous, and the error message from dassl is just a boiler-plate message, so the model isn't stiff but discontinuous as you found.
Markus A has a good point in the related question When to use noEvent operator in Modelica language? that using noEvent to avoid chattering is in general not a good idea, and one should normally try to rewrite the model instead of adding noEvent.
This specific model is sort of similar to a friction model where you would have
der(v)=(if v>=0 then -1 else 1)+f_other/m;
The solution for friction is not to introduce noEvent, but to add a stuck mode as in Modelica.Mechanics.Rotational.Components.BearingFriction.

Managing of Navier-Stokes PDEs by means of SBF in Dymola

Has anyone tried to implement the Navier Stokes Partial Differential Equations (PDE) in Modelica?
I found the method of the spatial basis functions (SBF) which by means of numerical modifications gets Ordinary Differential Equations (ODE) that could be handled by Dymola.
Regards,
Victor
The aim of the method I was saying before is to convert PDEs in ODEs, so the issues with the CFL coefficient would disappear, the problem is that the Modelica.Fluids elements just define the equations in function of the variables in both ends of each component.
i.e dp=port_a.p-port_b.p
but with that sort of methodology, the variables such as pressure, density, mass flow... would be function also of the surrounding components... it would be a kind of massive interaction between all the components,
I would like to see an example in Modelica, because I hardly haven't found information about that topic linked to Modelica.
Modelica is a language for modeling behavior described by DAEs. As such, as long as you can create a system of ODEs, you should be able to express your problem in Modelica.
However, if your PDEs are hyperbolic, the wave dynamics in the equations might cause some issues with simulation. This is because the CFL condition imposes limits on time steps that an ordinary differential equation solver will be unaware of. If the solver includes error control, it will probably manage to get a solutions but may run quite slow because it won't know how to explicitly limit the simulation step size. If it doesn't include error control and it violates the CFL condition, the system will go unstable. Note, this only applies to systems where the CFL condition applies.