GCC Code Coverage Report


Directory: ./
File: src/field/field_can_test.f90
Date: 2026-10-22 05:02:02
Coverage Exec Excl Total
Lines: 100.0% 58 0 58
Functions: 100.0% 2 0 2
Branches: 100.0% 4 0 4

Line Branch Exec Source
1 module field_can_test
2
3 use, intrinsic :: iso_fortran_env, only: dp => real64
4 use field_can_base, only: count_field_evaluation, field_can_t
5
6 implicit none
7
8 contains
9
10 333541 subroutine evaluate_test(f, r, th_c, ph_c, mode_secders)
11 type(field_can_t), intent(inout) :: f
12
13 real(dp), intent(in) :: r, th_c, ph_c
14 integer, intent(in) :: mode_secders
15
16 333541 call eval_field_test(f, r, th_c, ph_c, mode_secders)
17
18 333541 call count_field_evaluation(mode_secders)
19 333541 end subroutine evaluate_test
20
21
22 ! for testing -> circular tokamak
23 333541 subroutine eval_field_test(f, r, th, ph, mode_secders)
24 type(field_can_t), intent(inout) :: f
25 double precision, intent(in) :: r, th, ph
26 integer, intent(in) :: mode_secders
27
28 double precision :: B0, iota0, a, R0, cth, sth
29
30 333541 B0 = 1.0 ! magnetic field modulus normalization
31 333541 iota0 = 1.0 ! constant part of rotational transform
32 333541 a = 0.5 ! (equivalent) minor radius
33 333541 R0 = 1.0 ! (equivalent) major radius
34
35 333541 cth = cos(th)
36 333541 sth = sin(th)
37
38 333541 f%Ath = B0*(r**2/2d0 - r**3/(3d0*R0)*cth)
39 333541 f%Aph = -B0*iota0*(r**2/2d0-r**4/(4d0*a**2))
40 333541 f%hth = iota0*(1d0-r**2/a**2)*r**2/R0
41 333541 f%hph = R0 + r*cth
42 333541 f%Bmod = B0*(1d0 - r/R0*cth)
43
44 333541 f%dAth(1) = B0*(r - r**2/R0*cth)
45 333541 f%dAth(2) = B0*r**3*sth/(3.0*R0)
46 333541 f%dAth(3) = 0d0
47
48 333541 f%dAph(1) = -B0*iota0*(r-r**3/a**2)
49 333541 f%dAph(2) = 0d0
50 333541 f%dAph(3) = 0d0
51
52 333541 f%dhth(1) = 2d0*iota0*r*(a**2-2d0*r**2)/(a**2*R0)
53 333541 f%dhth(2) = 0d0
54 333541 f%dhth(3) = 0d0
55
56 333541 f%dhph(1) = cth
57 333541 f%dhph(2) = -r*sth
58 333541 f%dhph(3) = 0d0
59
60 333541 f%dBmod(1) = -B0/R0*cth
61 333541 f%dBmod(2) = B0*r/R0*sth
62 333541 f%dBmod(3) = 0d0
63
64
2/2
✓ Branch 0 taken 86389 times.
✓ Branch 1 taken 247152 times.
333541 if (mode_secders <= 0) return
65
66 86389 f%d2Ath(1) = B0*(1d0 - 2d0*r/R0*cth)
67 86389 f%d2Ath(4) = B0*r**3*cth/(3d0*R0)
68 86389 f%d2Ath(3) = 0d0
69 86389 f%d2Ath(2) = B0*r**2/R0*sth
70 86389 f%d2Ath(5) = 0d0
71 86389 f%d2Ath(6) = 0d0
72
73 86389 f%d2Aph(1) = -B0*iota0*(1d0-3d0*r**2/a**2)
74 86389 f%d2Aph(4) = 0d0
75 86389 f%d2Aph(3) = 0d0
76 86389 f%d2Aph(2) = 0d0
77 86389 f%d2Aph(5) = 0d0
78 86389 f%d2Aph(6) = 0d0
79
80
2/2
✓ Branch 0 taken 518334 times.
✓ Branch 1 taken 86389 times.
604723 f%d2hth = 0d0
81 86389 f%d2hth(1) = 2d0*iota0*(a**2-6d0*r**2)/(a**2*R0)
82
83 86389 f%d2hph(1) = 0d0
84 86389 f%d2hph(4) = -r*cth
85 86389 f%d2hph(3) = 0d0
86 86389 f%d2hph(2) = -sth
87 86389 f%d2hph(5) = 0d0
88 86389 f%d2hph(6) = 0d0
89
90 86389 f%d2Bmod(1) = 0d0
91 86389 f%d2Bmod(4) = B0*r/R0*cth
92 86389 f%d2Bmod(3) = 0d0
93 86389 f%d2Bmod(2) = B0/R0*sth
94 86389 f%d2Bmod(5) = 0d0
95 86389 f%d2Bmod(6) = 0d0
96
97 end subroutine eval_field_test
98
99 end module field_can_test
100