| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module field_coils | ||
| 2 | !> Biot-Savart coil field evaluation in Cartesian coordinates. | ||
| 3 | !> Single responsibility: evaluate A and B from coil geometry. | ||
| 4 | |||
| 5 | use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
| 6 | use neo_biotsavart, only: coils_t, load_coils_from_file, & | ||
| 7 | compute_vector_potential, compute_magnetic_field | ||
| 8 | use field_base, only: magnetic_field_t | ||
| 9 | use cartesian_coordinates, only: cartesian_coordinate_system_t | ||
| 10 | |||
| 11 | implicit none | ||
| 12 | |||
| 13 | type, extends(magnetic_field_t) :: coils_field_t | ||
| 14 | type(coils_t) :: coils | ||
| 15 | contains | ||
| 16 | procedure :: evaluate => coils_evaluate | ||
| 17 | end type coils_field_t | ||
| 18 | |||
| 19 | contains | ||
| 20 | |||
| 21 | 71301 | subroutine coils_evaluate(self, x, Acov, hcov, Bmod, sqgBctr) | |
| 22 | !> Evaluate Biot-Savart field at Cartesian position x. | ||
| 23 | !> Returns A and h = B/|B| as Cartesian vectors (covariant = contravariant). | ||
| 24 | class(coils_field_t), intent(in) :: self | ||
| 25 | real(dp), intent(in) :: x(3) | ||
| 26 | real(dp), intent(out) :: Acov(3), hcov(3), Bmod | ||
| 27 | real(dp), intent(out), optional :: sqgBctr(3) | ||
| 28 | |||
| 29 | real(dp) :: Bcart(3) | ||
| 30 | |||
| 31 | 71301 | Acov = compute_vector_potential(self%coils, x) | |
| 32 | 71301 | Bcart = compute_magnetic_field(self%coils, x) | |
| 33 | |||
| 34 | 71301 | Bmod = sqrt(Bcart(1)**2 + Bcart(2)**2 + Bcart(3)**2) | |
| 35 |
2/2✓ Branch 0 taken 213903 times.
✓ Branch 1 taken 71301 times.
|
285204 | hcov = Bcart / Bmod |
| 36 | |||
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 71301 times.
|
71301 | if (present(sqgBctr)) then |
| 38 | ✗ | sqgBctr = Bcart | |
| 39 | end if | ||
| 40 | 71301 | end subroutine coils_evaluate | |
| 41 | |||
| 42 | |||
| 43 |
6/14✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
|
5 | subroutine create_coils_field(coils_file, field) |
| 44 | !> Load coils from file and create field with Cartesian coordinates. | ||
| 45 | character(*), intent(in) :: coils_file | ||
| 46 | type(coils_field_t), intent(out) :: field | ||
| 47 | |||
| 48 | real(dp), parameter :: M_TO_CM = 100.0d0 | ||
| 49 | real(dp), parameter :: A_TO_STATA = 2997924536.8431d0 | ||
| 50 | |||
| 51 | 5 | call load_coils_from_file(coils_file, field%coils) | |
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 93450 times.
✓ Branch 1 taken 5 times.
|
93455 | field%coils%x = field%coils%x * M_TO_CM |
| 54 |
2/2✓ Branch 0 taken 93450 times.
✓ Branch 1 taken 5 times.
|
93455 | field%coils%y = field%coils%y * M_TO_CM |
| 55 |
2/2✓ Branch 0 taken 93450 times.
✓ Branch 1 taken 5 times.
|
93455 | field%coils%z = field%coils%z * M_TO_CM |
| 56 |
2/2✓ Branch 0 taken 93450 times.
✓ Branch 1 taken 5 times.
|
93455 | field%coils%current = field%coils%current * A_TO_STATA |
| 57 | |||
| 58 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
|
5 | allocate(cartesian_coordinate_system_t :: field%coords) |
| 59 | 5 | end subroutine create_coils_field | |
| 60 | |||
| 61 | ✗ | end module field_coils | |
| 62 |