forked from comp-phys-uniroma2/ode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.f90
92 lines (61 loc) · 1.67 KB
/
functions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module functions
use precision
implicit none
private
public :: ff
public :: pendolo
public :: harmonic
public :: func
real(dp), public :: k1
real(dp), public :: k2
real(dp), public :: Q
real(dp), public :: A
real(dp), public :: w
interface
function func(t,u) result(up)
use precision
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), allocatable :: up(:)
end function
end interface
contains
subroutine fsub(t,u,up)
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), intent(out) :: up(:)
up(1) = u(2)
up(2) = k1*u(1) + k2*u(2)
end subroutine fsub
function f1(t,u) result(up)
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), allocatable :: up(:)
allocate(up(size(u)))
up(1) = k1*u(1)
end function f1
function ff(t,u) result(up)
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), allocatable :: up(:)
allocate(up(size(u)))
up(1) = u(2)
up(2) = k1*u(1) + k2*u(2)
end function ff
function pendolo(t,u) result(up)
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), allocatable :: up(:)
allocate(up(size(u)))
up(1) = u(2)
up(2) = -sin(u(1)) - u(2)/Q + A*cos(w*t)
end function pendolo
function harmonic(t,u) result(up)
real(dp), intent(in) :: t
real(dp), intent(in) :: u(:)
real(dp), allocatable :: up(:)
allocate(up(size(u)))
up(1) = u(2)
up(2) = -u(1) - u(2)/Q + A*cos(w*t)
end function harmonic
end module functions