Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft]: auto diff net rates #715

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion auto_diff/private/auto_diff_real_1var_order1_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ module auto_diff_real_1var_order1_module
max, &
min, &
dim, &
differentiate_1
differentiate_1, &
fill_with_NaNs_ad
type :: auto_diff_real_1var_order1
real(dp) :: val
real(dp) :: d1val1
Expand Down Expand Up @@ -358,6 +359,10 @@ module auto_diff_real_1var_order1_module
interface differentiate_1
module procedure differentiate_auto_diff_real_1var_order1_1
end interface differentiate_1

interface fill_with_NaNs_ad
module procedure fill_with_NaNs_self
end interface fill_with_NaNs_ad

contains

Expand Down Expand Up @@ -1297,4 +1302,10 @@ function differentiate_auto_diff_real_1var_order1_1(this) result(derivative)
derivative%d1val1 = 0_dp
end function differentiate_auto_diff_real_1var_order1_1

subroutine fill_with_NaNs_self(ptr)
type(auto_diff_real_1var_order1) :: ptr(:)
call set_nan(ptr%val)
call set_nan(ptr%d1val1)
end subroutine fill_with_NaNs_self

end module auto_diff_real_1var_order1_module
14 changes: 13 additions & 1 deletion auto_diff/private/auto_diff_real_2var_order1_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ module auto_diff_real_2var_order1_module
min, &
dim, &
differentiate_1, &
differentiate_2
differentiate_2, &
fill_with_NaNs_ad
type :: auto_diff_real_2var_order1
real(dp) :: val
real(dp) :: d1val1
Expand Down Expand Up @@ -364,6 +365,10 @@ module auto_diff_real_2var_order1_module
interface differentiate_2
module procedure differentiate_auto_diff_real_2var_order1_2
end interface differentiate_2

interface fill_with_NaNs_ad
module procedure fill_with_NaNs_self
end interface fill_with_NaNs_ad

contains

Expand Down Expand Up @@ -1523,4 +1528,11 @@ function differentiate_auto_diff_real_2var_order1_2(this) result(derivative)
derivative%d1val2 = 0_dp
end function differentiate_auto_diff_real_2var_order1_2

subroutine fill_with_NaNs_self(ptr)
type(auto_diff_real_2var_order1) :: ptr(:)
call set_nan(ptr%val)
call set_nan(ptr%d1val1)
call set_nan(ptr%d1val2)
end subroutine fill_with_NaNs_self

end module auto_diff_real_2var_order1_module
17 changes: 16 additions & 1 deletion auto_diff/private/auto_diff_real_2var_order2_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ module auto_diff_real_2var_order2_module
min, &
dim, &
differentiate_1, &
differentiate_2
differentiate_2, &
fill_with_NaNs_ad
type :: auto_diff_real_2var_order2
real(dp) :: val
real(dp) :: d1val1
Expand Down Expand Up @@ -368,6 +369,10 @@ module auto_diff_real_2var_order2_module
module procedure differentiate_auto_diff_real_2var_order2_2
end interface differentiate_2

interface fill_with_NaNs_ad
module procedure fill_with_NaNs_self
end interface fill_with_NaNs_ad

contains

subroutine assign_from_self(this, other)
Expand Down Expand Up @@ -1985,4 +1990,14 @@ function differentiate_auto_diff_real_2var_order2_2(this) result(derivative)
derivative%d2val2 = 0_dp
end function differentiate_auto_diff_real_2var_order2_2

subroutine fill_with_NaNs_self(ptr)
type(auto_diff_real_2var_order2) :: ptr(:)
call set_nan(ptr%val)
call set_nan(ptr%d1val1)
call set_nan(ptr%d1val2)
call set_nan(ptr%d2val1)
call set_nan(ptr%d1val1_d1val2)
call set_nan(ptr%d2val2)
end subroutine fill_with_NaNs_self

end module auto_diff_real_2var_order2_module
23 changes: 21 additions & 2 deletions auto_diff/private/auto_diff_real_2var_order3_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ module auto_diff_real_2var_order3_module
min, &
dim, &
differentiate_1, &
differentiate_2
differentiate_2, &
fill_with_NaNs_ad
type :: auto_diff_real_2var_order3
real(dp) :: val
real(dp) :: d1val1
Expand Down Expand Up @@ -372,6 +373,10 @@ module auto_diff_real_2var_order3_module
module procedure differentiate_auto_diff_real_2var_order3_2
end interface differentiate_2

interface fill_with_NaNs_ad
module procedure fill_with_NaNs_self
end interface fill_with_NaNs_ad

contains

subroutine assign_from_self(this, other)
Expand Down Expand Up @@ -3337,5 +3342,19 @@ function differentiate_auto_diff_real_2var_order3_2(this) result(derivative)
derivative%d1val1_d2val2 = 0_dp
derivative%d3val2 = 0_dp
end function differentiate_auto_diff_real_2var_order3_2


subroutine fill_with_NaNs_self(ptr)
type(auto_diff_real_2var_order3) :: ptr(:)
call set_nan(ptr%val)
call set_nan(ptr%d1val1)
call set_nan(ptr%d1val2)
call set_nan(ptr%d2val1)
call set_nan(ptr%d1val1_d1val2)
call set_nan(ptr%d2val2)
call set_nan(ptr%d3val1)
call set_nan(ptr%d2val1_d1val2)
call set_nan(ptr%d1val1_d2val2)
call set_nan(ptr%d3val2)
end subroutine fill_with_NaNs_self

end module auto_diff_real_2var_order3_module
20 changes: 17 additions & 3 deletions auto_diff/private/auto_diff_real_4var_order1_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ module auto_diff_real_4var_order1_module
differentiate_1, &
differentiate_2, &
differentiate_3, &
differentiate_4
differentiate_4, &
fill_with_NaNs_ad
type :: auto_diff_real_4var_order1
real(dp) :: val
real(dp) :: d1val1
Expand Down Expand Up @@ -376,7 +377,11 @@ module auto_diff_real_4var_order1_module
interface differentiate_4
module procedure differentiate_auto_diff_real_4var_order1_4
end interface differentiate_4


interface fill_with_NaNs_ad
module procedure fill_with_NaNs_self
end interface fill_with_NaNs_ad

contains

subroutine assign_from_self(this, other)
Expand Down Expand Up @@ -1728,5 +1733,14 @@ function differentiate_auto_diff_real_4var_order1_4(this) result(derivative)
derivative%d1val3 = 0_dp
derivative%d1val4 = 0_dp
end function differentiate_auto_diff_real_4var_order1_4


subroutine fill_with_NaNs_self(ptr)
type(auto_diff_real_4var_order1) :: ptr(:)
call set_nan(ptr%val)
call set_nan(ptr%d1val1)
call set_nan(ptr%d1val2)
call set_nan(ptr%d1val3)
call set_nan(ptr%d1val4)
end subroutine fill_with_NaNs_self

end module auto_diff_real_4var_order1_module
20 changes: 20 additions & 0 deletions chem/public/chem_lib.f90
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,26 @@ function get_mass_excess(nuclides,chem_id) result (mass_excess)
end if

end function

! returns mass excess in MeV
function get_mass_excess_each_component(nuclides,chem_id) result (mass_excess)
use chem_def
type(nuclide_data), intent(in) :: nuclides
integer, intent(in) :: chem_id
real(dp) :: mass_excess
logical :: use_nuclides_mass_excess=.false.

! These should be identical but can have slight ~ulp difference
! due to floating point maths
if(use_nuclides_mass_excess)then
mass_excess = nuclides% mass_excess(chem_id)
else
mass_excess = nuclides% Z(chem_id)*del_Mp + nuclides% N(chem_id)*del_Mn -&
nuclides% binding_energy(chem_id)
end if

end function


function get_Q(nuclides,chem_id) result (q)
use chem_def
Expand Down
Loading