-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExercise_03.f90
33 lines (32 loc) · 1.14 KB
/
Exercise_03.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
! Created by EverLookNeverSee@GitHub on 5/29/20
! For more information see FCS/img/Exercise_03.png
program main
implicit none
! n --> rod length
! r --> crank radius
! w --> angular Velocity(rpm)
! theta --> crank angle
! x --> displaceemnt
! v --> velocity
! declaring variables
integer :: i,theta, j = 1
real :: n, r, w, radian_theta
real, dimension(37) :: x, v
! initializing variables
n = 4; r = 4; w = 2000; theta = 360
! making variation of theta
do i = 0, theta, 10
! the argument of trigonometric functions must be in radians
radian_theta = i * 3.141593 / 180.0
! storing results in two arrays
x(j) = r * (1 + n - cos(radian_theta) - sqrt((n ** 2) - (sin(radian_theta)) ** 2))
v(j) = (w * r) * (sin(radian_theta) + &
sin(2 * radian_theta) / 2 * (sqrt(n ** 2 - sin(radian_theta) ** 2)))
! increasing counter of arrays blocks
j = j + 1
end do
! do loop for formated print
do i = 1, 37, 1
print "(a2,i2,a3,f15.10,10x,a2,i2,a3,f17.10)", "x(", i, "): ", x(i), "v(", i, "): ", v(i)
end do
end program main