206206# ================================
207207def neutron_pairing_field (rho_n ):
208208 # Formula (5.12) from NeST.pdf
209- """
209+ r """
210210 Returns the pairing field for uniform pure neutron nuclear matter. For kF larger
211211 than 1.38 fm :sup:`-1` it returns (numerical) zero.
212212
@@ -225,17 +225,21 @@ def neutron_pairing_field(rho_n):
225225 :func:`.neutron_ref_pairing_field`
226226 :func:`.proton_ref_pairing_field`
227227 """
228- kF = rho2kf (rho_n )
228+ kF = np . asarray ( rho2kf (rho_n ), dtype = float )
229229 delta = 3.37968 * (kF ** 2 )* ((kF - 1.38236 )** 2 )/ (((kF ** 2 )+ (0.556092 ** 2 ))*
230230 ((kF - 1.38236 )** 2 + (0.327517 ** 2 )))
231231 i = np .where (kF > 1.38 )
232- if (i [0 ].size != 0 ):
233- delta [i ] = np .float64 (1.0 * NUMZERO )
232+ if delta .shape == ():
233+ if kF > 1.38 :
234+ return float (NUMZERO )
235+ else :
236+ return float (delta )
237+ delta [i ] = np .float64 (1.0 * NUMZERO )
234238 return delta
235239
236240def symmetric_pairing_field (rho_n , rho_p ):
237241 # Formula (5.11) from NeST.pdf
238- """
242+ r """
239243 Returns the pairing field for uniform symmetric matter. For kF larger than
240244 1.31 fm :sup:`-1` it returns (numerical) zero.
241245
@@ -256,17 +260,23 @@ def symmetric_pairing_field(rho_n, rho_p):
256260 :func:`.neutron_ref_pairing_field`
257261 :func:`.proton_ref_pairing_field`
258262 """
259- kF = rho2kf ((rho_n + rho_p ))
263+ rho_n = np .asarray (rho_n , dtype = float )
264+ rho_p = np .asarray (rho_p , dtype = float )
265+ kF = np .asarray (rho2kf ((rho_n + rho_p )), dtype = float )
260266 delta = 11.5586 * (kF ** 2 )* ((kF - 1.3142 )** 2 )/ (((kF ** 2 )+ (0.489932 ** 2 ))*
261267 (((kF - 1.3142 )** 2 )+ (0.906146 ** 2 )))
262- # 11.5586*(x**2)*((x-1.3142)**2)/(((x**2)+(0.489932**2))*(((x-1.3142)**2)+(0.906146**2)))
263268 i = np .where (kF > 1.31 )
269+ if delta .shape == ():
270+ if kF > 1.31 :
271+ return float (NUMZERO )
272+ else :
273+ return float (delta )
264274 delta [i ] = NUMZERO
265275 return delta
266276
267277def neutron_ref_pairing_field (rho_n , rho_p ):
268278 # Formula (5.10) from NeST.pdf
269- """
279+ r """
270280 Returns the reference pairing field for neutrons in uniform matter.
271281 This is an extrapolation between :math:`\Delta_{\\mathrm{SM}}` and
272282 :math:`\Delta_{\\mathrm{NeuM}}`. In limits :math:`\\eta \\rightarrow 0` reproduces
@@ -292,14 +302,16 @@ def neutron_ref_pairing_field(rho_n, rho_p):
292302 :func:`.symmetric_pairing_field`
293303 :func:`.proton_ref_pairing_field`
294304 """
295- rho , eta = rhoEta (rho_n , rho_p )
296- rho = rho + DENSEPSILON
297- return (symmetric_pairing_field (rho_n , rho_p )* (1 - abs (eta / rho ))
305+ rho_n = np .asarray (rho_n , dtype = float )
306+ rho_p = np .asarray (rho_p , dtype = float )
307+ rho , eta = rhoEta (rho_n , rho_p )
308+ rho = np .asarray (rho + DENSEPSILON , dtype = float )
309+ return (symmetric_pairing_field (rho_n , rho_p )* (1 - np .abs (eta / rho ))
298310 + neutron_pairing_field (rho_n )* rho_n / rho * eta / rho )
299311
300312def proton_ref_pairing_field (rho_n , rho_p ):
301313 # Formula (5.10) from NeST.pdf
302- """
314+ r """
303315 Returns the reference pairing field for protons in uniform matter.
304316 This is an extrapolation between :math:`\Delta_{\\mathrm{SM}}` and
305317 :math:`\Delta_{\\mathrm{NeuM}}`. In limits :math:`\\eta \\rightarrow 0` reproduces
@@ -325,9 +337,11 @@ def proton_ref_pairing_field(rho_n, rho_p):
325337 :func:`.symmetric_pairing_field`
326338 :func:`.neutron_ref_pairing_field`
327339 """
328- rho , eta = rhoEta (rho_n , rho_p ) #eta = rho_n - rho_p
329- rho = rho + DENSEPSILON
330- return (symmetric_pairing_field (rho_n , rho_p )* (1 - abs (eta / rho ))
340+ rho_n = np .asarray (rho_n , dtype = float )
341+ rho_p = np .asarray (rho_p , dtype = float )
342+ rho , eta = rhoEta (rho_n , rho_p ) #eta = rho_n - rho_p
343+ rho = np .asarray (rho + DENSEPSILON , dtype = float )
344+ return (symmetric_pairing_field (rho_n , rho_p )* (1 - np .abs (eta / rho ))
331345 - neutron_pairing_field (rho_n )* rho_p / rho * eta / rho )
332346
333347
@@ -895,6 +909,8 @@ def epsilon_rho_np(rho_n, rho_p):
895909 Returns:
896910 float: energy functional :math:`\\ epsilon_{\\ rho}`
897911 """
912+ rho_n = np .asarray (rho_n )
913+ rho_p = np .asarray (rho_p )
898914 rho = rho_n + rho_p + DENSEPSILON
899915 return C0_rho (rho_n , rho_p ) * np .power (rho , 2 ) + C1_rho (rho_n , rho_p ) * np .power (rho_n - rho_p , 2 )
900916
@@ -923,6 +939,12 @@ def epsilon_tau_np(rho_n, rho_p, tau_n, tau_p, jsum2, jdiff2):
923939 Returns:
924940 float: energy functional :math:`\\ epsilon_{\\ tau}`
925941 """
942+ rho_n = np .asarray (rho_n )
943+ rho_p = np .asarray (rho_p )
944+ tau_n = np .asarray (tau_n )
945+ tau_p = np .asarray (tau_p )
946+ jsum2 = np .asarray (jsum2 )
947+ jdiff2 = np .asarray (jdiff2 )
926948 return C0_tau (rho_n , rho_p ) * ((rho_n + rho_p ) * (tau_n + tau_p ) - jsum2 ) + C1_tau (rho_n , rho_p ) * ((rho_n - rho_p ) * (tau_n - tau_p ) - jdiff2 )
927949
928950
@@ -970,8 +992,13 @@ def epsilon_delta_rho_np(rho_n, rho_p, rho_grad_n_square, rho_grad_p_square, rho
970992 Returns:
971993 float: energy functional :math:`\\ epsilon_{\\ Delta \\ rho}`
972994 """
995+ rho_n = np .asarray (rho_n )
996+ rho_p = np .asarray (rho_p )
997+ rho_grad_n_square = np .asarray (rho_grad_n_square )
998+ rho_grad_p_square = np .asarray (rho_grad_p_square )
999+ rho_grad_square = np .asarray (rho_grad_square )
9731000 rho = rho_n + rho_p + DENSEPSILON
974- grad_rho_n_rho_p = 0.5 * (rho_grad_p_square - rho_grad_n_square - rho_grad_p_square )
1001+ grad_rho_n_rho_p = 0.5 * (rho_grad_p_square - rho_grad_n_square - rho_grad_p_square )
9751002
9761003 return (3. / 16. * T1 * ((1. + 0.5 * X1 )* rho_grad_square - (0.5 + X1 )* (rho_grad_n_square + rho_grad_p_square ))
9771004 - 1. / 16. * T2X2 * (0.5 * rho_grad_square + rho_grad_n_square + rho_grad_p_square )
@@ -1016,6 +1043,18 @@ def epsilon_np(rho_n, rho_p, rho_grad_n, rho_grad_p, tau_n, tau_p, jsum2, jdiff2
10161043 Returns
10171044 float: nergy functional :math:`\\ epsilon`
10181045 """
1046+ rho_n = np .asarray (rho_n )
1047+ rho_p = np .asarray (rho_p )
1048+ rho_grad_n = np .asarray (rho_grad_n )
1049+ rho_grad_p = np .asarray (rho_grad_p )
1050+ tau_n = np .asarray (tau_n )
1051+ tau_p = np .asarray (tau_p )
1052+ jsum2 = np .asarray (jsum2 )
1053+ jdiff2 = np .asarray (jdiff2 )
1054+ nu_n = np .asarray (nu_n )
1055+ nu_p = np .asarray (nu_p )
1056+ kappa_n = np .asarray (kappa_n )
1057+ kappa_p = np .asarray (kappa_p )
10191058 rho_grad_n_square = (rho_grad_n )** 2
10201059 rho_grad_p_square = (rho_grad_p )** 2
10211060 rho_grad_square = rho_grad_n_square + rho_grad_p_square
0 commit comments