So I'm trying to model a hydrodynamic system that introduces a sudden "jump" in the value of a function at a specific time. The system is solved with a Runge-Kutta fourth order method.
I have a hydrodynamic system where there is a phase transition modelled by a sudden increase in pressure that I'm modelling with a heavyside function. The problem is that this step-function introduces a lot of stiffness.
In other words, after temperature is less than T, pressure goes from
$P\rightarrow P+A$
where $A$ is the extra factor that suddenly increases the pressure.
I was wondering if it's possible to "approximate" the step-function as a linear function into a continous function to reduce the stiffness. I was thinking of multiplying $A$ by a linear function that increases linearly with time until the linear function reaches $1$.
Thanks!
No, it will not help. Either the approximation is too far away and thus introduces a similar error, or the approximation is close which gives you still a stiff equation.
The best course is to integrate to exactly (within the given tolerance) the time of the switching condition and continue with a practically new differential equation with the last point of the old system as initial condition.
A small model equation to play with different mitigation strategies is $$ \ddot x +\text{sign}(\dot x)+x=0. $$