VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
functions.f
Go to the documentation of this file.
1
3
4 MODULE functions
5
6 USE stel_kinds
7
8 implicit none
9
10 PUBLIC :: two_power, two_power_gs
11 PRIVATE :: check
12
13 CONTAINS
14
20 REAL(rprec) function two_power(x, b)
21
22 REAL(rprec), INTENT(in) :: x
23 REAL(rprec), DIMENSION(0:20), INTENT(in) :: b
24
25 two_power = b(0)*((1 - x**b(1))**b(2))
26
27 END FUNCTION
28
34 REAL(rprec) function two_power_gs(x, b)
35
36 REAL(rprec), INTENT(in) :: x
37 REAL(rprec), DIMENSION(0:20), INTENT(in) :: b
38
39 INTEGER :: i
40
41 two_power_gs = 1.0
42 DO i = 3, 18, 3
44 & b(i)*exp(-((x - b(i+1))/b(i+2))**2.0_dp)
45 END DO
47
48 END FUNCTION
49
51 FUNCTION function_test()
52
53 LOGICAL :: function_test
54 REAL(rprec) :: result
55 REAL(rprec), DIMENSION(0:20) :: b(0:20) = 0
56
58 b(0:2) = (/ 1.0d+0, 10.0d+0, 2.0d+0 /)
59 result = two_power(0.0d+0, b)
60 function_test = check(1.0d+0,result,1,"two_power()")
61 IF (.not.function_test) RETURN
62
64 result = two_power(1.0d+0, b)
65 function_test = check(0.0d+0,result,2,"two_power()")
66 IF (.not.function_test) RETURN
67
69 b(0:2) = (/ 1.0d+0, 1.0d+0, 1.0d+0 /)
70 result = two_power(0.5d+0, b)
71 function_test = check(0.5d+0,result,3,"two_power()")
72 IF (.not.function_test) RETURN
73
75 b(0:2) = (/ 1.0d+0, 1.0d+0, 2.0d+0 /)
76 result = two_power(0.5d+0, b)
77 function_test = check(0.25d+0,result,4,"two_power()")
78 IF (.not.function_test) RETURN
79
81 b(0:5) = (/ 1.0d+0, 1.0d+0, 1.0d+0, 0.0d+0, 0.0d+0, 1.0d+0 /)
82 result = two_power_gs(0.4d+0, b)
83 function_test = check(two_power(0.4d+0, b), &
84 & result,1,"two_power_gs")
85 IF (.not.function_test) RETURN
86
88 b(0:5) = (/ 1.0d+0, 1.0d+0, 0.0d+0, 1.0d+0, 0.8d+0, 0.1d+0 /)
89 result = two_power_gs(0.8d+0, b)
90 function_test = check(2.0d+0,result,1,"two_power_gs")
91 IF (.not.function_test) RETURN
92
93 END FUNCTION
94
96 FUNCTION check(expected, recieved, testNum, name)
97
98 LOGICAL :: check
99 REAL(rprec), INTENT(in) :: expected, recieved
100 INTEGER, INTENT(in) :: testnum
101 CHARACTER (LEN=*), INTENT(in) :: name
102
103 check = expected .eq. recieved
104 IF (.not.check) THEN
105 write(*,*) "functions.f: ", name, " test", testnum, &
106 & "failed."
107 write(*,*) "Expected", expected, "Recieved", recieved
108 END IF
109
110 END FUNCTION
111
112 END MODULE
real(rprec) function, public two_power(x, b)
Profile function for the two_power profile. .
Definition functions.f:21
real(rprec) function, public two_power_gs(x, b)
Profile function for the two_power_gs profile. .
Definition functions.f:35
logical function function_test()
Main test function.
Definition functions.f:52
integer, parameter rprec