Find consistent initial conditions for DAE system [MATLAB - ODE solver]

Matlab can be used to solve DAE systems. Generally speaking a DAE system is a set of differential and algebraic equations that need to be solved simoultaneosly. Matlab provides different tools able to deal with these types of equations; those solvers are named ODE solvers. Even if the name itself would suggest the capability of the solvers to solve only ODEs, also DAEs can be easily managed.

For a complete overview of the different solvers, please visit the following link where all the available builtin solvers and their properties are described in detail.

One of the most important part to get a DAE system to work is to feed it a set of consistent initial conditions. Matlab provides also a tool able to support the user in this process (the function is called decic) but here I would like to explain a more DIY method.

Using the above function (decic) you will be able to find the set of variables which satisfy the consistent initial condition, such that

f(y',y,t0 ) = 0

where f(y',y,t ) describes the set of algebraic and differential equations that you're trying to solve.

Let's suppose to have your DAE system composed of N differential equations and M algebraic equations.

A way to boost the decic function is to fix the initial values for the differential variabless and use those guesses to solve the only set of M algebraic equations.

To do this you can easily use the fsolve Matlab's function. This script will try to find the root of a set of equations; Once you get the result from the fsolve you can just use it, with the guess of the differential states, to build the array of consistent initial conditions for the ODE solver.

Please note that in order to be considered consistent, the result coming from the fsolve should have a low residual from its run.


Change EASILY the default program (and other actions) when opening a file

This is a quick post in which I will simply describe my problem and the wonderful solution I found: -I needed to open two .tex files, and I use TexStudio as my default editor (so far it's the best editor I know).
However, TexStudio's default behavior is to open just ONE INSTANCE of the program and load all the files I open on that same instance.
If I want to open a new instance, I found a I nice solution here:

Simply go to my direct link access to TexStudio's link icon and add at the end of the target field (i.e. after "(path)\texstudio.exe" to:

" --start-always "%1"
That way, everytime you open Texstudio from this link, you'll open a new instance.
However, if you want to open a new instance everytime you open a .tex file, apparently the best solution is to download this beautiful program:

which allows you to easily change the behavior of your default opening programs. For example:

(I learned this trick from here:

And that's all for today.