| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module field_can_base | ||
| 2 | |||
| 3 | use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
| 4 | implicit none | ||
| 5 | |||
| 6 | real(dp), parameter :: twopi = atan(1.d0)*8.d0 | ||
| 7 | |||
| 8 | integer(8) :: n_field_evaluations = 0 | ||
| 9 | real(dp) :: radial_electric_potential_slope = 0.0_dp | ||
| 10 | |||
| 11 | ! Field evaluations split by derivative depth. The total above does not | ||
| 12 | ! distinguish them, but the two cost very different amounts and are consumed by | ||
| 13 | ! different integrator families: explicit Runge-Kutta paths only ever need first | ||
| 14 | ! derivatives (mode_secders = 0), while the implicit symplectic schemes need | ||
| 15 | ! second derivatives (mode_secders = 2) for their analytic Jacobians. Any | ||
| 16 | ! comparison of cost per unit accuracy between those families has to weight the | ||
| 17 | ! two separately, so they are counted separately. | ||
| 18 | integer(8) :: n_field_evaluations_d1 = 0 | ||
| 19 | integer(8) :: n_field_evaluations_d2 = 0 | ||
| 20 | |||
| 21 | !$omp threadprivate(n_field_evaluations) | ||
| 22 | !$omp threadprivate(n_field_evaluations_d1, n_field_evaluations_d2) | ||
| 23 | |||
| 24 | type :: field_can_t | ||
| 25 | real(dp) :: Ath, Aph | ||
| 26 | real(dp) :: hth, hph | ||
| 27 | real(dp) :: Bmod | ||
| 28 | real(dp) :: Phie = 0.0_dp | ||
| 29 | |||
| 30 | real(dp), dimension(3) :: dAth, dAph | ||
| 31 | real(dp), dimension(3) :: dhth, dhph | ||
| 32 | real(dp), dimension(3) :: dBmod | ||
| 33 | real(dp), dimension(3) :: dPhie = 0.0_dp | ||
| 34 | |||
| 35 | ! second derivatives: drdr, drdth, drdph, dthdth, dthdph, dphdph | ||
| 36 | real(dp), dimension(6) :: d2Ath, d2Aph | ||
| 37 | real(dp), dimension(6) :: d2hth, d2hph | ||
| 38 | real(dp), dimension(6) :: d2Bmod | ||
| 39 | real(dp), dimension(6) :: d2Phie = 0.0_dp | ||
| 40 | |||
| 41 | real(dp) :: H, pth, vpar | ||
| 42 | real(dp), dimension(4) :: dvpar, dH, dpth | ||
| 43 | |||
| 44 | ! order of second derivatives: | ||
| 45 | ! d2dr2, d2drdth, d2drph, d2dth2, d2dthdph, d2dph2, | ||
| 46 | ! d2dpphdr, d2dpphdth, d2dpphdph, d2dpph2 | ||
| 47 | real(dp), dimension(10) :: d2vpar, d2H, d2pth | ||
| 48 | |||
| 49 | real(dp) :: mu, ro0 | ||
| 50 | end type field_can_t | ||
| 51 | |||
| 52 | |||
| 53 | abstract interface | ||
| 54 | subroutine evaluate(f, r, th_c, ph_c, mode_secders) | ||
| 55 | import field_can_t, dp | ||
| 56 | type(field_can_t), intent(inout) :: f | ||
| 57 | real(dp), intent(in) :: r, th_c, ph_c | ||
| 58 | integer, intent(in) :: mode_secders | ||
| 59 | end subroutine evaluate | ||
| 60 | end interface | ||
| 61 | |||
| 62 | |||
| 63 | abstract interface | ||
| 64 | subroutine coordinate_transform(xfrom, xto) | ||
| 65 | import dp | ||
| 66 | real(dp), intent(in) :: xfrom(3) | ||
| 67 | real(dp), intent(out) :: xto(3) | ||
| 68 | end subroutine coordinate_transform | ||
| 69 | end interface | ||
| 70 | |||
| 71 | contains | ||
| 72 | |||
| 73 | 80 | subroutine set_radial_electric_potential_slope(slope) | |
| 74 | real(dp), intent(in) :: slope | ||
| 75 | 80 | radial_electric_potential_slope = slope | |
| 76 | 80 | end subroutine set_radial_electric_potential_slope | |
| 77 | |||
| 78 | 20335298 | subroutine apply_radial_electric_potential(f, s) | |
| 79 | type(field_can_t), intent(inout) :: f | ||
| 80 | real(dp), intent(in) :: s | ||
| 81 | |||
| 82 | 20335298 | f%Phie = radial_electric_potential_slope*s | |
| 83 |
2/2✓ Branch 0 taken 61005894 times.
✓ Branch 1 taken 20335298 times.
|
81341192 | f%dPhie = 0.0_dp |
| 84 | 20335298 | f%dPhie(1) = radial_electric_potential_slope | |
| 85 |
2/2✓ Branch 0 taken 122011788 times.
✓ Branch 1 taken 20335298 times.
|
142347086 | f%d2Phie = 0.0_dp |
| 86 | 20335298 | end subroutine apply_radial_electric_potential | |
| 87 | |||
| 88 | ! Record one field evaluation, split by derivative depth. Every field backend | ||
| 89 | ! calls this instead of bumping n_field_evaluations directly, so the split can | ||
| 90 | ! never drift out of step with the total. | ||
| 91 | 62633495 | subroutine count_field_evaluation(mode_secders) | |
| 92 | integer, intent(in) :: mode_secders | ||
| 93 | |||
| 94 | 62633495 | n_field_evaluations = n_field_evaluations + 1 | |
| 95 |
2/2✓ Branch 0 taken 19840861 times.
✓ Branch 1 taken 42792634 times.
|
62633495 | if (mode_secders > 0) then |
| 96 | 19840861 | n_field_evaluations_d2 = n_field_evaluations_d2 + 1 | |
| 97 | else | ||
| 98 | 42792634 | n_field_evaluations_d1 = n_field_evaluations_d1 + 1 | |
| 99 | end if | ||
| 100 | 62633495 | end subroutine count_field_evaluation | |
| 101 | |||
| 102 | 3082 | subroutine identity_transform(xfrom, xto) | |
| 103 | real(dp), intent(in) :: xfrom(3) | ||
| 104 | real(dp), intent(out) :: xto(3) | ||
| 105 | |||
| 106 | 3082 | xto = xfrom | |
| 107 | 3082 | end subroutine identity_transform | |
| 108 | |||
| 109 | ✗ | end module field_can_base | |
| 110 |