1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran 90 Euler Scheme for Radioactive Decay

  1. Nov 28, 2009 #1
    1. The problem statement, all variables and given/known data

    in fortran 90 write a program to using the euler scheme to solve the differential equation for decay of a radioactive substance

    dx/dt = -j*x

    solving the equation we get

    x = e^(-j*t)

    following info is given

    2. Relevant equations and values

    t0 = 0.0
    tF = 10.0
    tStep = 0.1
    x(0) = 1+0i
    j = 3.0

    3. The attempt at a solution

    Code (Text):

    PROGRAM EULER
    !
    INTEGER :: I,N
    REAL :: t, x
    REAL, PARAMETER :: t0 = 0.0, tF = 10.0, tStep = 0.1, j = 3.0
    !
    !Calc N
    !
    N = INT((tF-t0)/tStep + SPACING((tF-t0)/tStep)) + 1 ! trip count
    !
    !set initial values
    !
    t = t0
    x = 0.0
    !
    !Calculate x with time
    !
    DO I + 1, N+1
          PRINT *, t, x
          x = x + tStep * f(x,t)
          t = t + tStep
    ENDDO
    !
    END PROGRAM EULER
    !
    FUNCTION f(x,t)
    !
    REAL :: t, x
    REAL, PARAMETER :: j = 3.0
    !
    f = EXP( -1.0 * j * t)
    !
    END FUNCTION f(x,t)
     
    no errors upon compiling

    my x value ends up being 2*t

    i think the problem is in the DO loop
     
  2. jcsd
  3. Nov 29, 2009 #2

    dlgoff

    User Avatar
    Science Advisor
    Gold Member

    Shouldn't DO I + 1, N+1
    be Do I=1,N+1
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran 90 Euler Scheme for Radioactive Decay
  1. Fortran 90 Question (Replies: 1)

  2. FOrtran 90 stucked (Replies: 4)

  3. Fortran 90 (Replies: 1)

Loading...