Created
September 9, 2023 11:23
-
-
Save Leowbattle/7ac27c971f2b9c982b10cbf1ebb87ab7 to your computer and use it in GitHub Desktop.
Simulation of a simple pendulum in Fortran using the semi-implicit Euler method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program pendulum | |
implicit none | |
real :: time, dt, g, l, y, v | |
integer :: n, i | |
read (*,*) time, dt, g, l, y, v | |
n = ceiling(time / dt) | |
do i=2,n | |
v = v - (g/l * sin(y)) * dt | |
y = y + v * dt | |
print *, y | |
end do | |
end program pendulum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment