Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function returning incorrect value

Status
Not open for further replies.

teplotaxl

Programmer
Jan 7, 2009
1
MX
Hi all!

I'm trying to model a differential equation having to do with free fall, using RK4 and Fortran 90. The equation is:

[tex]\ddots{y}(t)=-g \frac{R^2}{y^2}[/tex]

The code is attached in caidalibre.f90

The big problem is that function f(y,v,t) returns an unexpected value within the main program. Moreover, the program yields results which would indicate the object is ascending, and not descending. Any insight will be greatly appreciated.

Cheers!

PS: I am using

gfortran
Using built-in specs.
Target: powerpc-apple-darwin8.9.0
Configured with: ../gcc-4.3-20070810/configure --enable-threads=posix --enable-languages=fortran
Thread model: posix
gcc version 4.3.0 20070810 (experimental)
 
Simply proove if you don't have an error in the Runge-Kutta formula you use.

But the strange behaviour can be caused by the nature of numerical treatment of differential equations:
In most cases you need to use the step control algorithm, which automatically decreases the integration step on critical intervals or increases it where it's possible.
The other special class are so called stiff differential equations. These equations cannot be integrated either with explicit RK methods like you use here, nor using step control helps. Here you need to use implicit Runge-Kutta Methods, like backward Euler method or from higher order Radau methods,..etc. ...and naturally all with the step control.

But this thema is off topic in this forum
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top