Skip to content

Commit

Permalink
derived ef dB1
Browse files Browse the repository at this point in the history
  • Loading branch information
jordidj committed Dec 8, 2023
1 parent 5f8c87a commit 84acde1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/eigenfunctions/mod_derived_ef_names.f08
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module mod_derived_ef_names
character(len=str_len_arr), parameter, public :: v_perp_name = "v_perp"
character(len=str_len_arr), parameter, public :: curl_v_para_name = "(curl v)_para"
character(len=str_len_arr), parameter, public :: curl_v_perp_name = "(curl v)_perp"
character(len=str_len_arr), parameter, public :: dB1_name = "dB1"

character(len=:), allocatable :: state_vector(:)
logical :: can_get_pp
Expand Down Expand Up @@ -64,7 +65,8 @@ function create_and_set_derived_state_vector(settings, background) &
v_para_name, &
v_perp_name, &
curl_v_para_name, &
curl_v_perp_name &
curl_v_perp_name, &
dB1_name &
]
derived_state_vector_mask = [ &
can_get_entropy(), &
Expand All @@ -86,7 +88,8 @@ function create_and_set_derived_state_vector(settings, background) &
can_get_v_pp(), &
can_get_v_pp(), &
can_get_curl_v_pp(), &
can_get_curl_v_pp() &
can_get_curl_v_pp(), &
can_get_dB1() &
]
derived_state_vector = pack(derived_state_vector, mask=derived_state_vector_mask)

Expand Down Expand Up @@ -189,6 +192,14 @@ pure logical function can_get_curl_v_pp()
end function can_get_curl_v_pp


pure logical function can_get_dB1()
can_get_dB1 = ( &
is_in_state_vector("a2") &
.and. is_in_state_vector("a3") &
)
end function can_get_dB1


logical function can_calculate_pp_quantities(background)
use mod_function_utils, only: zero_func
use mod_logging, only: logger
Expand Down
22 changes: 22 additions & 0 deletions src/eigenfunctions/mod_derived_efs.f08
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ subroutine set_function_pointer(this)
this%get_derived_ef => get_curl_v_para
case(curl_v_perp_name)
this%get_derived_ef => get_curl_v_perp
case(dB1_name)
this%get_derived_ef => get_dB1
case default
call logger%error( &
"derived ef assembly -- unknown eigenfunction name: "// trim(this%name) &
Expand Down Expand Up @@ -508,6 +510,26 @@ function get_curl_v_perp(settings, grid, eigenvector) result(curl_v_perp)
end function get_curl_v_perp


function get_dB1(settings, grid, eigenvector) result(dB1)
type(settings_t), intent(in) :: settings
type(grid_t), intent(in) :: grid
complex(dp), intent(in) :: eigenvector(:)
complex(dp) :: dB1(size(grid%ef_grid))
complex(dp) :: da2(size(grid%ef_grid))
complex(dp) :: a3(size(grid%ef_grid))
complex(dp) :: da3(size(grid%ef_grid))
real(dp) :: ef_eps(size(grid%ef_grid)), ef_deps

da2 = get_base_eigenfunction(sv_a2, settings, grid, eigenvector, diff_order=1)
a3 = get_base_eigenfunction(sv_a3, settings, grid, eigenvector)
da3 = get_base_eigenfunction(sv_a3, settings, grid, eigenvector, diff_order=1)
ef_eps = grid%get_eps(grid%ef_grid)
ef_deps = grid%get_deps()

dB1 = ic * (k2 * da3 / ef_eps - k3 * da2) - ic * k2 * ef_deps * a3 / ef_eps**2
end function get_dB1


function get_base_eigenfunction( &
sv_component, settings, grid, eigenvector, diff_order &
) result(base_ef)
Expand Down

0 comments on commit 84acde1

Please sign in to comment.