-
Notifications
You must be signed in to change notification settings - Fork 2
/
slbw.py
371 lines (286 loc) · 14.3 KB
/
slbw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
import numpy as np
from data import ρ0
import scipy
import scipy.special
#def evaluate_Σγ(E, Γ): ## The most simple SLBW caputre resonance
# """
# Evaluate SLBW capture cross section
#
# Parameters
# ----------
# Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
#
# Returns
# -------
# float : capture cross section
# """
# return (np.pi*Γ[1]*Γ[2]/(ρ0**2*E**0.5*Γ[0]**0.5))/((E-Γ[0])**2+((Γ[1]*(E/Γ[0])**(1/2)+ Γ[2])/2)**2)
def exact_Σγ(E, Γ): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
float : capture cross section
"""
return (np.pi*Γ[1]*Γ[2]/(ρ0**2*Γ[0]**0.5*E**0.5))/((Γ[0]-E)**2+(Γ[1]+ Γ[2])**2/4)
def exact_Real_SLBW(E, Γ , α): ## The OK Real[•] version of E-space Breit-Wigner profile
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
float : capture cross section
"""
ελ = Γ[0] - 1j*(Γ[1]+ Γ[2])/2
return 1/(E**0.5)*np.real(α/(ελ - E))
def w_faddeeva(z): #this is only for integral representation purpose use only
if np.imag(z) > 0 :
return scipy.special.wofz(z)
else :
return - scipy.special.wofz(-z) # - np.conj(scipy.special.wofz(np.conj(z)))
def χ0(x): ## the antisymmetric χ function at 0 K
return x/(1 + x**2)
def χT_Faddeeva_approx(x,τ): ## the antisymmetric χ function approximated at T K
z = (x + 1j)/(2*(τ**0.5))
return (np.pi/(4*τ))**0.5*np.imag(w_faddeeva(z))
def ψ0(x): ## the symmetric ψ function at 0 K
return 1/(1 + x**2)
def ψT_Faddeeva_approx(x,τ): ## the symmetric ψ function approximated at T K
z = (x + 1j)/(2*(τ**0.5))
return (np.pi/(4*τ))**0.5*np.real(w_faddeeva(z))
def zeroK_exact_SLBW_χψ_Σγ(E, Γ, a , b): ## The OK Real[•] version of E-space Breit-Wigner profile
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
float : capture cross section
"""
Γtot = (Γ[1]+ Γ[2])
x = (Γ[0] - E)/(Γtot/2)
return (a/(Γtot/2))/(E**0.5)*χ0(x) + (b/(Γtot/2))/(E**0.5)*ψ0(x)
def TK_approx_SLBW_χψ_Σγ(E, Γ, a, b, T): ## The OK Real[•] version of E-space Breit-Wigner profile
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
float : capture cross section
"""
kB = 8.617333262145*10**(-5)
A = 238
β = (kB * T /A)**0.5
τ = 4*E*(β/(Γ[1]+ Γ[2]))**2
Γtot = (Γ[1]+ Γ[2])
x = (Γ[0] - E)/(Γtot/2)
z = (1 -1j*x)/(2*τ**0.5)
return (a/(Γtot/2))/(E**0.5)*χT_Faddeeva_approx(x,τ) + (b/(Γtot/2))/(E**0.5)*ψT_Faddeeva_approx(x,τ)
def TK_approx_SLBW_Faddeeva_Σγ(E, Γ, α, T ): ## The OK Real[•] version of E-space Breit-Wigner profile
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
float : capture cross section
"""
kB = 8.617333262145*10**(-5)
A = 238
β = (kB * T /A)**0.5
τ = 4*E*(β/(Γ[1]+ Γ[2]))**2
ελ = Γ[0] - 1j*(Γ[1]+ Γ[2])/2
x = (Γ[0] - E)/((Γ[1]+ Γ[2])/2)
Z0 = (np.conj(ελ) - E)/(2*β*E**0.5)
return (1/E**0.5)*np.imag( (np.conj(α)*np.pi**0.5)/(2*β*E**0.5) * w_faddeeva(Z0) )
# SLBW Derivative Equations
def exact_dΣγ_dΓ(E, Γ):
"""
Derivative of capture cross section with respect to resonance
parameters
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
np.array : [dΣγ_dEλ , dΣγ_dΓn , dΣγ_dΓγ]
"""
dΣγ_dEλ = exact_Σγ(E, Γ)*( (-1)/(2*Γ[0]) - 2*(Γ[0]-E)*exact_Σγ(E, Γ)*(ρ0**2*E**0.5*Γ[0]**(0.5))/(np.pi*Γ[1]*Γ[2]))
dΣγ_dΓn = exact_Σγ(E, Γ)*( 1/(Γ[1]) - 1/2*(Γ[1] + Γ[2])*exact_Σγ(E, Γ)*(ρ0**2*E**0.5*Γ[0]**(0.5))/(np.pi*Γ[1]*Γ[2]))
dΣγ_dΓγ = exact_Σγ(E, Γ)*( 1/(Γ[2]) - 1/2*(Γ[1] + Γ[2])*exact_Σγ(E, Γ)*(ρ0**2*E**0.5*Γ[0]**(0.5))/(np.pi*Γ[1]*Γ[2]))
return np.array([dΣγ_dEλ , dΣγ_dΓn , dΣγ_dΓγ])
# z-space Multipole representation of BS approximation of SLBW
def exact_poles_and_residues(Γ):
"""
Calcultes the exact poles and residues for the SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
"""
ελ = Γ[0] - 1j*(Γ[1]+Γ[2])/2
r1 = 1j*np.pi*Γ[1]*Γ[2]/(ρ0**2*Γ[0]**0.5*(Γ[1]+ Γ[2]))
p1 = np.sqrt(ελ)
return np.array([ [ p1, r1 ] , [-p1 , r1] ])
def exact_poles_and_residues_differentials_dΠ_dΓ(Γ):
"""
Calcultes the exact poles and residues for the SLBW capture cross section (with BS approximation)
Parameters
----------
Γ : Resonance Parameters [Eλ resonance energy, Γn neutron width, Γγ gamma width]
Returns
-------
dΠ_dΓ : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
"""
ελ = Γ[0] - 1j*(Γ[1]+Γ[2])/2
r1 = 1j*np.pi*Γ[1]*Γ[2]/(ρ0**2*Γ[0]**0.5*(Γ[1]+ Γ[2]))
p1 = np.sqrt(ελ)
dp1_dEλ = 1/(2*p1)
dr1_dEλ = - r1/(2*Γ[0])
dp1_dΓn = -1j/(4*p1)
dr1_dΓn = r1*( 1/Γ[1] - 1/(Γ[1]+Γ[2]) )
dp1_dΓγ = -1j/(4*p1)
dr1_dΓγ = r1*( 1/Γ[2] - 1/(Γ[1]+Γ[2]) )
dΠ_dΓ = np.array([ [[dp1_dEλ, dr1_dEλ] , [-dp1_dEλ , dr1_dEλ]] , [[dp1_dΓn, dr1_dΓn] , [-dp1_dΓn , dr1_dΓn]] , [[dp1_dΓγ, dr1_dΓγ] , [-dp1_dΓγ , dr1_dΓγ]] ])
# dp_dΓ = np.array([ [ dp1_dEλ , -dp1_dEλ] , [dp1_dΓn , -dp1_dΓn] , [dp1_dΓγ,-dp1_dΓγ] ])
# dr_dΓ = np.array([ [ dr1_dEλ , dr1_dEλ] , [dr1_dΓn , dr1_dΓn] , [dr1_dΓγ, dr1_dΓγ] ])
dp_dΓ = np.array([ [ dp1_dEλ , dp1_dΓn , dp1_dΓγ] , [ -dp1_dEλ , -dp1_dΓn , -dp1_dΓγ] ])
dr_dΓ = np.array([ [ dr1_dEλ , dr1_dΓn , dr1_dΓγ] , [ dr1_dEλ , dr1_dΓn , dr1_dΓγ] ])
return dp_dΓ , dr_dΓ
def multipole_Σ(z, Π): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
Returns
-------
float : capture cross section
"""
return (1/z**2) * np.real(sum( Π[j][1]/(z-Π[j][0]) for j in range(Π.shape[0]))) #+ np.conj(Π[j][1])/(z-np.conj(Π[j][0])) for j in range(Π.shape[0]) ) )
def approx_multipole_Doppler_Σ(z, Π, T): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
Returns
-------
float : capture cross section
"""
kB = 8.617333262145*10**(-5)
A = 238
β = (kB * T /A)**0.5
return (1/z**2) * np.real( (np.pi**0.5/(1j*β)) * sum( Π[j][1] * w_faddeeva( ((z-Π[j][0])/β) ) for j in range(Π.shape[0])))
def multipole_dΣ_dΓ(z, Π, dp_dΓ, dr_dΓ): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW (with BS approximation) capture cross section differential with respect to resonance parameters Γ
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
dΠ_dΓ : Jacobians of poles and residues with respect to all the resonance parameters Γ [{d_pole_dΓ, d_residue_dΓ}]
Returns
-------
array (size of resonance parameters) : differential capture cross sections in multipole representation
"""
return np.array([ (1/z**2) * np.real(sum( dr_dΓ[j][i]/(z-Π[j][0]) + Π[j][1]*dp_dΓ[j][i]/(z-Π[j][0])**2 for j in range(Π.shape[0]))) for i in range(dp_dΓ.shape[1])])
def multipole_dΣ_dΠ(z, Π): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW (with BS approximation) capture cross section differential with respect to multipoles (represented as a set of twice as much real parameters (the real and imaginary part of each multipole complex parameter))
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
Returns
-------
array (size of resonance multipoles times two) : differential capture cross sections (functions of z) [ dΣ_dRe[p] , dΣ_dIm[p] , dΣ_dRe[r] , dΣ_dIm[r] ]
"""
dΣ_dRe_p = np.array([ (1/z**2) * np.real( Π[j][1]/(z-Π[j][0])**2 ) for j in range(Π.shape[0]) ])
dΣ_dIm_p = np.array([ (1/z**2) * np.real( 1j*Π[j][1]/(z-Π[j][0])**2 ) for j in range(Π.shape[0]) ])
dΣ_dRe_r = np.array([ (1/z**2) * np.real( 1.0/(z-Π[j][0]) ) for j in range(Π.shape[0]) ])
dΣ_dIm_r = np.array([ (1/z**2) * np.real( 1j/(z-Π[j][0])) for j in range(Π.shape[0]) ])
return np.concatenate( ( dΣ_dRe_p, dΣ_dIm_p, dΣ_dRe_r, dΣ_dIm_r ) )
def multipoles_real_vector_Π(Π):
"""
Take a set of multipoles (p_j, r_j), and convert then into a vector of real parameters multipole: [Re[p_j] ; Im[p_j] ; Re[r_j] ; Im[r_j]]
inputs
----------
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
"""
N_p = Π.shape[0]
Π_real_vector = np.zeros(4*N_p)
for j in range(Π.shape[0]):
Π_real_vector[j] = np.real(Π[j][0])
Π_real_vector[N_p + j] = np.imag(Π[j][0])
Π_real_vector[2*N_p + j] = np.real(Π[j][1])
Π_real_vector[3*N_p + j] = np.imag(Π[j][1])
return Π_real_vector
def multipoles_set_Π(Π_real_vector):
"""
Take a set of multipoles (p_j, r_j), and convert then into a vector of real parameters multipole: [Re[p_j] ; Im[p_j] ; Re[r_j] ; Im[r_j]]
inputs
----------
Π : Multipole Parameters [{pole, residue}], for poles in the lower half of the complex plane (in the {E,+} sheet of the Rieman surface).
"""
N_p = np.int(Π_real_vector.shape[0]/4)
Π = complex(0.0)*np.zeros([N_p , 2])
for j in range(Π.shape[0]):
Π[j][0] = Π_real_vector[j] + 1j*Π_real_vector[N_p + j]
Π[j][1] = Π_real_vector[2*N_p + j] + 1j*Π_real_vector[3*N_p + j]
return Π
def z_space_Σγ(z, Γ): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
E : energy (eV)
Γ : Resonance Parameters [mean, neutron width, gamma width]
Returns
-------
float : capture cross section
"""
return (np.pi*Γ[1]*Γ[2]/(ρ0**2*Γ[0]**0.5*z))/((Γ[0]-z**2)**2+(Γ[1]+ Γ[2])**2/4)
def analytic_Σγ(z, Γ): ## The most simple SLBW caputre resonance, with BS approximation
"""
Evaluate SLBW capture cross section (with BS approximation)
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Γ : Resonance Parameters [mean, neutron width, gamma width]
Returns
-------
float : capture cross section
"""
ελ = Γ[0] - 1j*(Γ[1]+Γ[2])/2
b = (2*np.pi*Γ[1]*Γ[2])/(ρ0**2*Γ[0]**0.5*(Γ[1]+ Γ[2]))
return 1/z * ( (-1j*b)/(ελ - z**2) + np.conj((-1j*b))/(np.conj(ελ) - z**2) )/2
def analytic_dΣγ_dΓ(z, Γ):
"""
Derivative of SLBW (with BS approximation) capture cross section with respect to resonance parameters Γ
Parameters
----------
z : square-root-ofenergy (eV) (on {E,+} sheet of Riemann surface)
Γ : Resonance Parameters [mean, neutron width, gamma width]
Returns
-------
np.array : [dΣγ_dEλ , dΣγ_dΓn , dΣγ_dΓγ]
"""
ελ = Γ[0] - 1j*(Γ[1]+Γ[2])/2
dΣγ_dEλ = analytic_Σγ(z, Γ)*( (-1)/(2*Γ[0]) - (1j/(ελ - z**2)**2 + np.conj(1j)/(np.conj(ελ) - z**2)**2)/( 1j/(ελ - z**2) + np.conj(1j)/(np.conj(ελ) - z**2) ) )
dΣγ_dΓn = analytic_Σγ(z, Γ)*( 1/Γ[1] - 1/(Γ[1]+Γ[2]) - 1/2*(1/(ελ - z**2)**2 + 1/(np.conj(ελ) - z**2)**2)/( 1j/(ελ - z**2) + np.conj(1j)/(np.conj(ελ) - z**2) ) )
dΣγ_dΓγ = analytic_Σγ(z, Γ)*( 1/Γ[2] - 1/(Γ[1]+Γ[2]) - 1/2*(1/(ελ - z**2)**2 + 1/(np.conj(ελ) - z**2)**2)/( 1j/(ελ - z**2) + np.conj(1j)/(np.conj(ελ) - z**2) ) )
return np.array([dΣγ_dEλ , dΣγ_dΓn , dΣγ_dΓγ])