Numerical Solution for Coupled Differential Equations using Runge-Kutta Method

  • Context: Graduate 
  • Thread starter Thread starter choppu
  • Start date Start date
  • Tags Tags
    Runge kutta
Click For Summary

Discussion Overview

The discussion revolves around solving a set of coupled differential equations numerically using the Runge-Kutta method. Participants express their challenges with the method, share their experiences with alternative approaches like the Euler method, and seek guidance on implementing the Runge-Kutta technique.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants present coupled differential equations involving forces and masses, expressing a need to solve them using the Runge-Kutta method.
  • One participant mentions having solved the equations using the Euler algorithm and offers to share their code for review.
  • Another participant questions what specific help is needed, noting that the Runge-Kutta method is only slightly more complex than Euler's method.
  • There is a suggestion to convert the second-order equations into four first-order equations to apply the Runge-Kutta method effectively.
  • Some participants discuss the differences between the Euler method and the second-order Runge-Kutta method, emphasizing the latter's use of slopes from both sides of the function.
  • A participant expresses uncertainty about how to apply the second-order Runge-Kutta method and seeks clarification on its implementation.

Areas of Agreement / Disagreement

Participants generally agree on the need to use the Runge-Kutta method but express differing levels of understanding and familiarity with its application. There is no consensus on the best approach to transition from the Euler method to Runge-Kutta, and multiple viewpoints on how to proceed remain unresolved.

Contextual Notes

Participants mention various assumptions and dependencies, such as the specific form of the Runge-Kutta method to be used and the need to convert the equations into a suitable format for numerical integration. Some details about the implementation and mathematical steps remain unclear.

choppu
Messages
10
Reaction score
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] <br /> [/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
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] <br /> [/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.
 
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
 
What have you been taught about Runge-Kutta methods?

Which Runga-Kutta method (there are several) are you supposed to be using?
 
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.
 
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).
 
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.
 
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] <br /> [/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
 

Similar threads

  • · Replies 65 ·
3
Replies
65
Views
9K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 2 ·
Replies
2
Views
1K