Go to the documentation of this file.
38 real(
r_kind),
dimension(:),
allocatable,
public ::
pf
39 real(
r_kind),
dimension(:),
allocatable,
private ::
gg
40 real(
r_kind),
dimension(:),
allocatable,
private ::
be
45 integer,
dimension(:),
allocatable,
public ::
aa
46 integer,
dimension(:),
allocatable,
public ::
zz
47 integer,
dimension(:),
allocatable,
public ::
nn
80 real(
r_kind),
parameter :: nem = 8.071323d0
81 real(
r_kind),
parameter :: pem = 7.288969d0
120 real(
r_kind),
intent(in) :: t9
121 real(
r_kind),
intent(in) :: rho
122 real(
r_kind),
intent(in) :: ye
123 real(
r_kind),
intent(in) :: yn_guess
124 real(
r_kind),
intent(in) :: yp_guess
125 real(
r_kind),
dimension(net_size),
intent(inout) :: ysol
131 info_entry(
"winnse_guess")
142 if ((kit .ge. 1) .and. (kit .le.
nse_max_it))
then
156 if(
ynse(i).lt.1.d-25)
ynse(i) = 0.d0
161 info_exit(
"winnse_guess")
183 real(
r_kind),
intent(in) :: t9strt
184 real(
r_kind),
intent(in) :: t9fnl
185 real(
r_kind),
intent(in) :: rho
186 real(
r_kind),
intent(in) :: ye
187 real(
r_kind),
intent(in) :: yni
188 real(
r_kind),
intent(in) :: ypi
189 real(
r_kind),
dimension(net_size),
intent(inout) :: ysol
191 real(
r_kind) :: t9,delt9,t9hi
192 real(
r_kind) :: yn,yn0,yp0,yp
195 info_entry(
"winnse_descend")
201 delt9 = sign(10.d0,(t9fnl-t9strt))
203 delt9 = 5.d-1*(t9fnl-t9hi)
217 if ((kit .ge. 1) .and. (kit .le.
nse_max_it))
then
219 if(kit.lt.4) delt9 = 2.d0*delt9
224 if((t9.eq.t9fnl).and.(delt9.eq.0.d0))
then
226 trim(adjustl(
int_to_str(kit)))//
") when calculating NSE.",&
227 "winnse_descend",450003)
234 delt9 = sign(min(2.d1,abs(delt9)),delt9)
235 delt9 = sign(min(abs(t9-t9fnl),abs(delt9)),delt9)
238 call raise_exception(
"Temperature difference was too small when calculating"//new_line(
"A")//&
239 "NSE composition (T9= "//trim(adjustl(
num_to_str(dabs(t9))))//
", delt9="//trim(adjustl(
num_to_str(dabs(delt9))))//
")."//new_line(
"A")//&
240 'Try to set "nse_descend_t9start", "nse_nr_tol", or "nse_max_it" to a higher value.',&
241 "winnse_descend",450004)
245 if(t9.le.t9fnl) t9 = t9fnl
250 if(
ynse(i).lt.1.d-25)
ynse(i) = 0.d0
255 info_exit(
"winnse_descend")
279 real(
r_kind),
intent(in) :: t9
280 real(
r_kind),
intent(in) :: rho
281 real(
r_kind),
intent(in) :: ye
282 real(
r_kind),
intent(inout) :: yn
283 real(
r_kind),
intent(inout) :: yp
284 integer,
intent(in) :: imax
285 integer,
intent(out) :: kit
287 info_entry(
"winnse_calc")
302 "winnse_calc",450006)
305 info_exit(
"winnse_calc")
326 real(
r_kind),
intent(in) :: t9
327 real(
r_kind),
intent(in) :: rho
328 real(
r_kind),
intent(in) :: ye
329 real(
r_kind),
intent(inout) :: yn
330 real(
r_kind),
intent(inout) :: yp
331 integer,
intent(in) :: imax
332 integer,
intent(out) :: kit
336 real(
r_kind),
dimension(2) :: x
337 real(
r_kind),
dimension(2) :: fvec
356 if (info .ne. 1)
then
360 if (maxval(abs(fvec)) .gt. tol)
then
407 real(
r_kind),
intent(in) :: t9
408 real(
r_kind),
intent(in) :: rho
409 real(
r_kind),
intent(in) :: ye
410 real(
r_kind),
intent(inout) :: yn
411 real(
r_kind),
intent(inout) :: yp
412 integer,
intent(in) :: imax
413 integer,
intent(out) :: kit
415 real(
r_kind) :: yn0,ynl,ynr,delyn,testyn
416 real(
r_kind) :: yp0,ypl,ypr,delyp,testyp
417 real(
r_kind) :: f,dfdn,dfdp
418 real(
r_kind) :: g,dgdn,dgdp
421 real(
r_kind) :: atst,ztst,ytst,abar,zbar
458 if (maxval(
ynse) .ge. dlog(infty)-5)
then
485 if ((dfdp .gt. 0) .and. (dgdn .gt. 0) .and.&
486 (dfdn .gt. 0) .and. (dgdp .gt. 0))
then
489 if ((dlog(dfdp)+dlog(dgdn) .ge. dlog(infty)) .or. &
490 (dlog(dfdn)+dlog(dgdp) .ge. dlog(infty)))
then
492 det = dlog(dfdn)+dlog(dfdp)+dlog(dgdn/dfdn - dgdp/dfdp)
494 if (det .ge. dlog(infty))
then
501 det = dfdp*dgdn - dfdn*dgdp
503 elseif (((dfdp .gt. infty/10.) .and. (dgdn .gt. infty/10.)) .or.&
504 ((dfdn .gt. infty/10.) .and. (dgdp .gt. infty/10.)))
then
508 det = dfdp*dgdn - dfdn*dgdp
516 delyp = (dgdn*f - dfdn*g)*detr
517 delyn = (dfdp*g - dgdp*f)*detr
519 call raise_exception(
'Did not converge when trying to calculate NSE. '//new_line(
"A")//&
520 'Found zero determinant.',&
521 "winnse_calc",450005)
528 if ((testyp.gt.0.d0).and.(testyn.gt.0.d0))
then
539 testk = sqrt(testyp**2 + testyn**2 + f**2 + g**2)
541 if (testk .lt. tol)
exit
587 real(
r_kind),
intent(in) :: t9
588 real(
r_kind),
intent(in) :: rho
589 real(
r_kind),
intent(in) :: ye
590 real(
r_kind) :: hp, ht, hh
591 integer :: i,z1,z2,a1,a2
601 call screening (t9,rho,z1,z2,a1,a2,ye,0,hh,ht,hp)
633 real(
r_kind),
intent(in) :: t9
634 real(
r_kind),
intent(in) :: rho
645 bkt = 1.d9*t9*
unit%k_mev
649 ronath = dlog(
unit%n_a*rho)+1.5d0*dlog((2.d0*
unit%pi*
unit%hbar_mev**2)/ &
696 real (r_kind),
dimension(n) :: fvec
697 real (r_kind),
dimension(n) :: x
711 if (maxval(
ynse) .ge. dlog(huge(ynl))-5)
then
720 fvec(2) = sum(
aa*
ynse) -1.d0
724 end subroutine mass_and_charge_conservation
subroutine, private winnse_calc_nr(t9, rho, ye, yn, yp, imax, kit)
Solves the nse-equations using a 2-dimensional newton-raphson scheme.
real(r_kind), dimension(:), allocatable, public pf
Partition function for a given temperature.
integer, dimension(:), allocatable, public aa
Mass number.
Module to calculate electron screening.
real(r_kind) nse_descend_t9start
high initial temperature in GK for winnse_descend subroutine
subroutine, public winnse_guess(t9, rho, ye, yn_guess, yp_guess, ysol)
Calculate NSE composition with an initial guess.
real(r_kind), dimension(:), allocatable, private scrn
Screening correction (details see nse_screen)
real(r_kind), dimension(:), allocatable, private be
Binding energy, calculated using mass excesses.
subroutine, private winnse_calc(t9, rho, ye, yn, yp, imax, kit)
Solves the nse-equations.
integer nse_solver
Solver for calculating NSE. 0: Newton-Raphson, 1: Powell's hybrid method.
subroutine, private wincnse_calc(t9, rho)
Calculates the nse coefficients C, as given in Hix,Thielemann '99, Eq.25.
character(:) function, allocatable, public int_to_str(num)
Converts a given integer to a string.
integer, dimension(:), allocatable, public zz
Proton number.
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
subroutine, public nse_init()
Allocates and initialises various arrays needed for the nse calculation.
type(isotope_type), dimension(:), allocatable, public isotope
all nuclides used in the network
Module with helper functions such as rate tabulation, partition functions, and theoretical weak rates...
real(r_kind), dimension(:), allocatable, public ynse
NSE abundances.
integer, private zmax
Highest proton number occuring in network.
subroutine, public winnse_descend(t9strt, t9fnl, rho, ye, yni, ypi, ysol)
This routine descends from an initially high temperature, at which the NSE abudances can be accuratel...
integer, public net_size
total number of isotopes (network size)
type(unit_type), public unit
constants and unit conversion factors
character(:) function, allocatable, public num_to_str(num)
Converts a given real to a string with format "(1pE10.2)".
real(r_kind), dimension(:), allocatable, public cnse
NSE coefficients (details see cnsecalc)
subroutine, private nse_screen(t9, rho, ye)
Calls screening subroutine and adds subsequent proton capture screening corrections in scrn(1:zmax).
subroutine fsolve(fcn, n, x, fvec, tol, info)
real(r_kind), public ye_ext
Electron fraction to pass to external function.
subroutine, private winnse_calc_hybrid_powell(t9, rho, ye, yn, yp, imax, kit)
Solves the nse-equations using the Powell hybrid method.
real(r_kind), dimension(:), allocatable, private gg
where is the spin of the ground state
integer, dimension(:), allocatable, public nn
Neutron number.
subroutine, public inter_partf(temp, interpol)
Calculates partition function.
Contains types and objects shared between multiple modules.
subroutine mass_and_charge_conservation(n, x, fvec)
Determines the mass and charge conservation for the NSE calculation.
real(r_kind) nse_delt_t9min
Minimum temperature [GK] when descending to desired temperature in NSE.
real(r_kind) nse_nr_tol
Tolerance for the NR loop in the NSE calculation.
logical, public iscreen
Flag whether screening is enabled or not.
integer nse_max_it
Maximum amount of NSE iterations.
Contains all runtime parameters as well as phys and math constants.