Fortran 90 Euler Scheme for Radioactive Decay

Click For Summary
SUMMARY

The discussion focuses on implementing the Euler scheme in Fortran 90 to solve the differential equation for radioactive decay, represented as dx/dt = -j*x. The provided program initializes parameters such as t0 = 0.0, tF = 10.0, tStep = 0.1, and j = 3.0, but the user identifies an issue with the DO loop syntax. The correct syntax should be "DO I=1,N+1" instead of "DO I + 1, N+1" to ensure proper iteration and calculation of the decay function.

PREREQUISITES
  • Understanding of Fortran 90 programming language
  • Familiarity with numerical methods, specifically the Euler method
  • Knowledge of differential equations, particularly exponential decay
  • Basic concepts of complex numbers in programming
NEXT STEPS
  • Review Fortran 90 syntax and control structures
  • Study numerical methods for solving differential equations
  • Explore the implementation of complex numbers in Fortran 90
  • Learn about debugging techniques in Fortran to identify and fix loop errors
USEFUL FOR

Students and educators in computational physics, software developers working with numerical simulations, and anyone interested in learning about the Euler method for solving differential equations in Fortran 90.

ksx2098
Messages
1
Reaction score
0

Homework Statement



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. Homework Equations and values

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

The Attempt at a Solution



Code:
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
 
Physics news on Phys.org
Shouldn't DO I + 1, N+1
be Do I=1,N+1
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K