Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2014-2021 Josiah Schwab & The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module coulomb
21 :
22 : use const_def, only: dp, one_third
23 : use rates_def
24 : use math_lib
25 : use utils_lib, only: is_bad
26 : use auto_diff
27 :
28 : implicit none
29 :
30 : contains
31 :
32 178232 : subroutine do_coulomb_set_context( &
33 : cc, temp_in, den_in, logT_in, logRho_in, zbar, abar, z2bar)
34 : type (Coulomb_Info), pointer :: cc
35 : real(dp), intent(in) :: &
36 : temp_in, den_in, logT_in, logRho_in, zbar, abar, z2bar
37 : real(dp) :: ye
38 : type(auto_diff_real_2var_order1) :: temp, den
39 :
40 : include 'formats'
41 :
42 : ! auto_diff variables have
43 : ! var1: lnT
44 : ! var2: lnRho
45 :
46 89116 : temp = temp_in
47 89116 : temp% d1val1 = temp_in
48 89116 : temp% d1val2 = 0d0
49 :
50 89116 : den = den_in
51 89116 : den% d1val1 = 0d0
52 89116 : den% d1val2 = den_in
53 :
54 89116 : cc% temp = temp_in
55 89116 : cc% den = den_in
56 89116 : cc% logT = logT_in
57 89116 : cc% logRho = logRho_in
58 89116 : cc% zbar = zbar
59 89116 : cc% abar = abar
60 89116 : cc% z2bar = z2bar
61 :
62 89116 : ye = zbar / abar
63 :
64 : ! calculate key plasma parameters
65 89116 : cc% gamma_e = 2.275d5 * pow(ye * den, one_third) / temp
66 89116 : cc% rs = 1.388_dp * pow(ye * den, -one_third)
67 :
68 89116 : end subroutine do_coulomb_set_context
69 :
70 : end module coulomb
71 :
|