Numerical Solution for Coupled Differential Equations using Runge-Kutta Method

In summary, the author is unsure how to apply the Runge-Kutta method to solve a differential equation, and has found help from the user. They provide a programme to convert their code to the Runge-K
  • #1
choppu
10
0
Hi, I have got a coupled Differential equation :

[tex]
\ x_1''\ =\ \frac{F_1}{M_1}\ =\ \gamma\cdot{}\left[-\,\frac{M_S}{|\overrightarrow{x_1}|^3}\cdot{}\overrightarrow{x_2}+\frac{M_2}{|\overrightarrow{x_2-x_1}|^3}\cdot{}(\overrightarrow{x_2-x_1})\right]
[/tex]

[tex]
\ x_2''\ =\ \frac{F_2}{M_2}\ =\ \gamma\cdot{}\left[-\frac{M_S}{|\overrightarrow{x_2}|^3}\cdot{}\overrightarrow{x_1}+\frac{M_1}{|\overrightarrow{x_2-x_1}|^3}\cdot{}(\overrightarrow{x_2-x_1})\right]

[/tex]

and i need to solve it numerically using the RUNGE-KUTTA method, however I have no clue how to do that . Please save me!
 
Last edited:
Physics news on Phys.org
  • #2
choppu said:
Hi,


I have got a coupled Differential equation :

[tex]
\ x_1''\ =\ \frac{F_1}{M_1}\ =\ \gamma\cdot{}\left[-\,\frac{M_S}{|x_1|^3}\cdot{}x_1+\frac{M_2}{|x_2-x_1|^3}\cdot{}(x_2-x_1)\right]
[/tex]

[tex]
\ x_2''\ =\ \frac{F_1}{M_1}\ =\ \gamma\cdot{}\left[-\frac{M_S}{|x_2|^3}\cdot{}x_1+\frac{M_1}{|x_2-x_1|^3}\cdot{}(x_2-x_1)\right]

[/tex]

and i need to solve it numerically using the RUNGE-KUTTA method, however I have no clue how to do that .


Please save me!

What have you been taught? Certainly the instructor did not just say "here are some differential equations. Write a numerical integrator to solve them." (You will have to wait until you are an employee to have that kind of joy.)

Please remember that our role here is to students do their own homework. You need to show some work before we can start on that path.
 
  • #3
I have solved it with the Euler Algorithm. I have really never used/seen the Runge-Kutta before.

I wrote a programme . (using the Euler) Shall I send you the programme to proof my work?

Will you help me out then?

Thank you.

choppu
 
  • #4
What have you been taught about Runge-Kutta methods?

Which Runga-Kutta method (there are several) are you supposed to be using?
 
  • #5
We should use the Runge-Kutta of the Second Order...

We have been taught that they are an improvement to the Euler-Algorithm and that they use the slope of both sides instead of just one.

However I have no clue how to apply this.
 
  • #6
Ok,


I will post the Euler computation excerpt of my code. Maybe somebody will have mercy and tell me how to modify it to transform it to Runge-Kutta:

Code:
        int m1 = 6000;        
        int m2 = 8000;
        double gamma = 6.67;
        double r = 15;
        double r2 = 20;
        double vx = 0;
        double vx2 = 0;
        double alpha = 0;
        double alpha2 = 0;
        double alpha3 = 0;
        double alpha4 = 0;
        double x = r;
        double x2 = r2;
        double y = 0;
        double y2 = 0;
        double mittelpunktx = b/2;
        double mittelpunkty = h/2;
        double vy = 0.0001 * Math.sqrt(1000 * gamma * m / r);
        double vy2 = 0.0001 * Math.sqrt(1000* gamma * m / r2);
        //double tend = 500;
        double t = 0;
        double pi = 4*Math.atan(1);
        double deltat = 0.2;
        double result = 0;
 
        while (t <= tend) {
 
            t = t + deltat;
            r = Math.sqrt(x * x + y * y);
            r2 = Math.sqrt(x2 * x2 + y2 * y2);
 
            double posx = mittelpunktx + x;
            double posy = mittelpunkty + y;
            double posx2 = mittelpunktx + x2;
            double posy2 = mittelpunkty + y2;
            double poswechselx = posx2 - posx;
            double poswechsely = posy2 - posy;
            double rwechselq = poswechselx * poswechselx + poswechsely * poswechsely;
 
            double a = 0.00001 * gamma * ((m / r) / r);
            double a2 = 0.00001 * gamma * ((m / r2) / r2);
            double avon1auf2 = 0.00001 * gamma * (m2 / rwechselq);
            double avon2auf1 = 0.00001 * gamma * (m1 / rwechselq);
 
            alpha = winkel(x,y,alpha);
            alpha2 = winkel(x2, y2, alpha2);
            alpha3 = winkel(poswechselx, poswechsely, alpha3);
            alpha4 = alpha3 + pi;
 
            double ax = a * Math.cos(alpha);
            double ay = a * Math.sin(alpha);
            double ax2 = a2 * Math.cos(alpha2);
            double ay2 = a2 * Math.sin(alpha2);
            double ax3 = avon1auf2 * Math.cos(alpha4);
            double ay3 = avon1auf2 * Math.sin(alpha4);
            double ax4 = avon2auf1 * Math.cos(alpha3);
            double ay4 = avon2auf1 * Math.sin(alpha3);
 
            ax = ax + ax3;
            ay = ay + ay3;
            ax2 = ax2 + ax4;
            ay2 = ay2 + ay4;
            vx = vx - ax * deltat;
            vy = vy - ay * deltat;
            x = x + vx * deltat;
            y = y + vy * deltat;
            vx2 = vx2 - ax2 * deltat;
            vy2 = vy2 - ay2 * deltat;
            x2 = x2 + vx2 * deltat;
            y2 = y2 + vy2 * deltat;

the winkel() method is used to achieve the correct angle (like in the complex plane).
 
  • #7
The problem is that we don't know exactly what it is you want help with. You seem to understand what the Euler method is about, and the Runge-Kutta method is only infinitesimally more complicated, so what are you having trouble with? Here is a description of the second-order Runge-Kutta method:

http://www.swarthmore.edu/NatSci/echeeve1/Ref/NumericInt/RK2.html

If you have dv/dt=GM/r^2, then you calculate dv/dt and use it to predict r a timestep in advance, just like in the Euler method. You then use this predicted r to calculate dv/dt, average the two dv/dt's that you've calculated, and use that average to calculate that r that you're going to use.
 
  • #8
choppu said:
Hi,


I have got a coupled Differential equation :

[tex]
\ x_1''\ =\ \frac{F_1}{M_1}\ =\ \gamma\cdot{}\left[-\,\frac{M_S}{|x_1|^3}\cdot{}x_1+\frac{M_2}{|x_2-x_1|^3}\cdot{}(x_2-x_1)\right]
[/tex]

[tex]
\ x_2''\ =\ \frac{F_1}{M_1}\ =\ \gamma\cdot{}\left[-\frac{M_S}{|x_2|^3}\cdot{}x_1+\frac{M_1}{|x_2-x_1|^3}\cdot{}(x_2-x_1)\right]

[/tex]

and i need to solve it numerically using the RUNGE-KUTTA method, however I have no clue how to do that .


Please save me!
You'll need to convert this to four 1st-order equations in order to use Runge-Kutta methods.

So for example, define
x1' = x3
so that
x3' = γ · [...]
and similarly for x2
 

Related to Numerical Solution for Coupled Differential Equations using Runge-Kutta Method

1. What is Runge Kutta method?

Runge Kutta method is a numerical technique used for solving ordinary differential equations. It is an iterative method that approximates the solution at multiple points within an interval, resulting in a more accurate solution compared to other numerical methods.

2. How does Runge Kutta method work?

The method involves breaking down the interval into smaller sub-intervals and using a weighted average of different slopes to approximate the solution at each point. The size of the sub-intervals can be adjusted to achieve a more accurate solution.

3. What are the advantages of using Runge Kutta method?

Runge Kutta method is a highly versatile and accurate numerical technique for solving differential equations. It can handle a wide range of problems and produces more accurate results compared to other numerical methods. It is also relatively easy to implement and requires minimal computational resources.

4. Are there any limitations of Runge Kutta method?

One limitation of Runge Kutta method is that it requires the differential equation to be written in a specific form, known as the first-order system. It is also not suitable for stiff differential equations, which have rapidly changing solutions. In such cases, other numerical methods may be more appropriate.

5. How is Runge Kutta method used in real-world applications?

Runge Kutta method has various applications in different fields such as physics, engineering, and economics. It is commonly used to model and simulate dynamic systems, such as population growth, chemical reactions, and electrical circuits. It is also used in computational fluid dynamics to solve complex equations that describe the behavior of fluids.

Similar threads

Replies
1
Views
461
Replies
61
Views
1K
  • Differential Equations
Replies
6
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
234
  • Advanced Physics Homework Help
Replies
7
Views
1K
  • Differential Equations
Replies
16
Views
3K
  • Differential Equations
Replies
6
Views
3K
  • Special and General Relativity
Replies
4
Views
1K
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
7
Views
3K
Back
Top