Numerical modelling of a step function in time in a hydrodynamic system. (Runge Kutta fourth order) 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→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.
 A: Don't do it that way.
You have what is called a "Change Point".
Run it up until the time when the change should occur.
Then stop the solver.
Perform the instantaneous state change.
Then restart the solver.
So much silliness happens when people try to run ODE solvers over discontinuities.
A: RK 4th order is a good numerical approach - but it is only accurate up to fourth order terms in the Taylor expansion of your series.  As long as the fifth (and higher) order derivatives of the function are small, you are fine. But when you introduce a step function, or even a piecewise linear approximation, that assumption is violated.
I would recommend, as Kyle Kanos suggested in his comment, to find a suitable smooth function (the hyperbolic tangent works well with the right scaling) in order to turn your sudden transition into a smooth one. If that doesn't result in a stable solution, you are doing something wrong (hard to guess what - but it should be stable as you decrease the step size). 
As an aside, even phase transitions tend not to happen "all at once" but somewhat gradually - so a smoothly varying function isn't such a bad thing to use in your simulation.
