How to input First Order Non Linear ODE that are dependent on each other into Runge-Kutta

102 Views Asked by At

I am working on ODE's that are highly non linear (even at only their first order expressions). The governing equations of motion describes a complex phenomenon of bubbles underwater. Runge Kutta 4 methodology was suggested by a colleague in solving the system of ODE's. I'm having trouble experessing them into RK4 format such that

$$y'=f(x)$$

I have sampled a simple similar problem below to describe the complex nonlinearity. Suppose that I have this system of Linear ODE'S (derivatives with respect to $t$ )

$$x' + y'= 3xy + x'y'- 4t$$

$$y'=y^2 - xt - (x')^2$$

with Initial Conditions $x(0)=x_0$ and $y(0)=y_0$.

How can I input these 2 equations into Runge-Kutta 4th Order. I know how to treat second order ODE, by converting into first order for Runge-Kutta formulation but I don't know how to resolve the above first order ODEs for multivariable.

Any help on this is really appreciated.

Thanks

1

There are 1 best solutions below

5
On BEST ANSWER

You can treat the equation as a DAE system, differential-algebraic equations, and use and DAE solver. This means to introduce an additional state variable $v=y'$, which is then also the new second differential equation, and transform the difference of the equations into an algebraic, which means here derivative-free, equation.

A second variant is to take the derivative of both equations and solve the resulting system of second-order DE.

In this special case the difference of both equations is quadratic in $y'$, which can be solved by the usual formula. However, one has to take care of the double-root case where the solution may cease to exist, or branches cross over, possibly generating a discontinuity in the second derivative.


Specific to get a system for RK4: Solve the linear system $$ u+v-uv=3xy-4t\\ u^2+v=y^2-xt $$ for $u$ and $v$ for given $t_0,x_0,y_0$, select one of the 4 solutions.

Apply RK4 in the vector version. Manually or via a solver routine solve in the ODE function the system $$ \pmatrix{1-v& 1-u\\2u&1}\pmatrix{u'\\v'} = \pmatrix{3uy+3xv-4\\2yv-ut-x} $$ input $[x,y,u,v]$, output $[u,v,u',v']$. Check for sign changes in the determinant, avoid division by zero.