ERICCa 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ERICCA/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .cross_sections import CrossSection
2
+ from .profile_function import ProfileFunction
3
+ from .density import Density
4
+
5
+ __all__ = ["CrossSection", "ProfileFunction", "Density"]
ERICCA/__version__.py ADDED
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.1.0'
22
+ __version_tuple__ = version_tuple = (0, 1, 0)
23
+
24
+ __commit_id__ = commit_id = None
ERICCA/baseline.py ADDED
@@ -0,0 +1,648 @@
1
+ """
2
+ Reference implementation of ERICCa in procedural style.
3
+
4
+ This module exists for validation purposes. The production API is in
5
+ cross_sections.py, Density.py, and Profile_function.py. Do not use this
6
+ module directly in user code.
7
+ """
8
+
9
+
10
+ import importlib.resources
11
+
12
+ import numpy as np
13
+ from numpy.polynomial import legendre
14
+ from scipy.interpolate import Rbf, CubicSpline, interp1d
15
+ from scipy.optimize import curve_fit, minimize
16
+ import scipy as sp
17
+
18
+ #_Constants and meshs
19
+
20
+ #
21
+ A = 12
22
+
23
+ #Constants for rho
24
+ A_p = 0
25
+ C_m_p = 0
26
+ a_m_p = 0
27
+ rho_0_p = 0
28
+
29
+ A_t = 0
30
+ C_m_t = 0
31
+ a_m_t = 0
32
+ rho_0_t = 0
33
+
34
+ #constant for C
35
+ sigma_R_measured = 218
36
+
37
+ #Constants for gamma
38
+
39
+ alpha = 1.808
40
+ beta = .268
41
+ sigma_n = 3.16
42
+
43
+ alphapp = 1.808
44
+ betapp = .268
45
+ sigma_pp =3.16
46
+
47
+ alphapn = 0
48
+ betapn = 0
49
+ sigma_pn = 0
50
+
51
+ #max values for our mesh
52
+ rmax = 25
53
+ bmax = 20
54
+ zmax = 5
55
+ st_max = 15
56
+
57
+ #Number of points for the mesh
58
+ numpoints = 30 # What numpoints does this go to?
59
+ numpoints_theta = 30
60
+
61
+ r_numpoints = 20
62
+ b_numpoints = 35
63
+ z_numpoints =20
64
+
65
+ #r mesh
66
+ ra = 0 #fm
67
+ rb = rmax #fm
68
+
69
+ r_roots, r_weights = legendre.leggauss(r_numpoints)
70
+ r_weights = r_weights* 0.5 * (rb - ra)
71
+ # Map the roots from [-1, 1] to the interval [a, b]
72
+ r_mapped_roots = 0.5 * (r_roots + 1) * (rb - ra) + ra
73
+
74
+ #r mesh
75
+ ba = 0 #fm
76
+ bb = bmax #fm
77
+
78
+ b_roots, b_weights = legendre.leggauss(b_numpoints)
79
+ b_weights = b_weights* 0.5 * (bb - ba)
80
+ # Map the roots from [-1, 1] to the interval [a, b]
81
+ b_mapped_roots = 0.5 * (b_roots + 1) * (bb - ba) + ba
82
+
83
+ #z mesh
84
+ za = - zmax#fm
85
+ zb = zmax#fm
86
+ z_roots, z_weights = legendre.leggauss(z_numpoints)
87
+
88
+ z_weights = z_weights * 0.5 * (zb - za)
89
+
90
+ # Map the roots from [-1, 1] to the interval [a, b]
91
+ z_mapped_roots = 0.5 * (z_roots + 1) * (zb - za) + za
92
+
93
+
94
+ #horrible 4d s and t vector mesh
95
+
96
+ # Get Legendre roots and weights for the specified number of points in each dimension
97
+
98
+ #s mesh
99
+ sa = 0 #fm
100
+ sb = st_max #fm
101
+ s_numpoints = numpoints
102
+ s_roots, s_weights = legendre.leggauss(s_numpoints)
103
+
104
+ s_weights = s_weights * 0.5 * (sb - sa)
105
+
106
+ # Map the roots from [-1, 1] to the interval [a, b]
107
+ s_mapped_roots = 0.5 * (s_roots + 1) * (sb - sa) + sa
108
+
109
+ #s theta mesh
110
+ s_theta_a = 0 #fm
111
+ s_theta_b = 2*np.pi #fm
112
+ s_theta_numpoints = numpoints_theta
113
+ s_theta_roots, s_theta_weights = legendre.leggauss(s_theta_numpoints)
114
+
115
+ s_theta_weights = s_theta_weights * 0.5 * (s_theta_b - s_theta_a)
116
+
117
+ # Map the roots from [-1, 1] to the interval [a, b]
118
+ s_theta_mapped_roots = 0.5 * (s_theta_roots + 1) * (s_theta_b - s_theta_a) + s_theta_a
119
+
120
+ #t mesh
121
+ ta =0 #fm
122
+ tb = st_max #fm
123
+ t_numpoints = numpoints
124
+ t_roots, t_weights = legendre.leggauss(t_numpoints)
125
+
126
+ t_weights = t_weights * 0.5 * (tb - ta)
127
+ # Map the roots from [-1, 1] to the interval [a, b]
128
+ t_mapped_roots = 0.5 * (t_roots + 1) * (tb - ta) + ta
129
+
130
+ #t theta mesh
131
+ t_theta_a = 0 #fm
132
+ t_theta_b = 2 * np.pi#fm
133
+ t_theta_numpoints = numpoints_theta
134
+ t_theta_roots, t_theta_weights = legendre.leggauss(t_theta_numpoints)
135
+
136
+ t_theta_weights = t_theta_weights* 0.5 * (t_theta_b - t_theta_a)
137
+
138
+ # Map the roots from [-1, 1] to the interval [a, b]
139
+ t_theta_mapped_roots = 0.5 * (t_theta_roots + 1) * (t_theta_b - t_theta_a) + t_theta_a
140
+
141
+
142
+
143
+
144
+ #_ Vector operations____________________________________________________________________________________________________________________________
145
+
146
+ def add_sub_vec_mag(a, theta_a, b, theta_b, c, theta_c):
147
+ arg_x = a * np.cos(theta_a) + b * np.cos(theta_b) - c * np.cos(theta_c)
148
+ arg_y = a * np.sin(theta_a) + b * np.sin(theta_b) - c * np.sin(theta_c)
149
+
150
+ return np.sqrt(arg_x**2 + arg_y**2)
151
+
152
+ #__functions_____________________________________________________________________________________________________________________________
153
+
154
+
155
+
156
+ def C( E):
157
+
158
+ global sigma_R_measured
159
+ #Defining our variables needed for the function
160
+
161
+ #Caluation of neutron grazing distance
162
+ B_c = np. sqrt(sigma_R_measured / np.pi )
163
+ output = 1.0 + (B_c/E)
164
+ return output
165
+
166
+ def rho_m(r):
167
+ # calcualating the projectile/target density
168
+
169
+ global A_p, C_m_p, a_m_p, rho_0_p
170
+
171
+ #C_m = 1.2 * A**(1/3) # half-density radius
172
+ #a_m = 0.5 # fm diffuseness
173
+
174
+ #the saturation density
175
+ #rho_0 = .176 * (1 + np.exp(( - C_m * A**(1/3))/a_m)) #fm^-3
176
+
177
+
178
+ arg = (1 + np.exp((r - C_m_p)/a_m_p))
179
+
180
+ return rho_0_p / arg
181
+
182
+
183
+ def Gamma(b):
184
+ # calculating the profile function
185
+
186
+ global alpha, beta, sigma_n
187
+
188
+ # alpha : real and imaginary part of the scattering NN scattering amplitude
189
+ # beta : finite range parameter
190
+ # sigma_N: does not need to be calculated
191
+
192
+ arg1 = (1 - 1j * alpha)/( 4 * np.pi * beta)
193
+ arg2 = sigma_n * np.exp( - b**2/(2 *beta) )
194
+
195
+ #arg1 = (1 - 1j * alpha)/(4 * np.pi)
196
+ #arg2 = (sigma_n)* np.exp( - (beta * b**2)/2 )
197
+
198
+ return arg1 * arg2
199
+
200
+ def Gammap(b ):
201
+ # calculating the profile function
202
+
203
+ global alphapp, betapp, sigma_pp
204
+ global alphapn, betapn, sigma_pn
205
+
206
+ # alpha : real and imaginary part of the scattering NN scattering amplitude
207
+ # beta : finite range parameter
208
+ # sigma_N: does not need to be calculated
209
+
210
+ arg1 = (1 - 1j * alphapp)/( 4 * np.pi * betapp)
211
+ arg2 = sigma_pp * np.exp( - b**2/(2 *betapp) )
212
+
213
+ arg3 = (1 - 1j * alphapn)/( 4 * np.pi * betapn)
214
+ arg4 = sigma_pn * np.exp( - b**2/(2 *betapn) )
215
+
216
+ return arg1 * arg2
217
+
218
+
219
+ def Gamman(b ):
220
+ # calculating the profile function
221
+
222
+ global alphapp, betapp, sigma_pp
223
+ global alphapn, betapn, sigma_pn
224
+
225
+ # alpha : real and imaginary part of the scattering NN scattering amplitude
226
+ # beta : finite range parameter
227
+ # sigma_N: does not need to be calculated
228
+
229
+ arg1 = (1 - 1j * alphapp)/( 4 * np.pi * betapp)
230
+ arg2 = sigma_pp * np.exp( - b**2/(2 *betapp) )
231
+
232
+ arg3 = (1 - 1j * alphapn)/( 4 * np.pi * betapn)
233
+ arg4 = sigma_pn * np.exp( - b**2/(2 *betapn) )
234
+
235
+ return arg3 * arg4
236
+
237
+ def profile_funct_param(E, interaction_type = "matter"):
238
+
239
+ global alphapp, betapp, sigma_pp
240
+ global alphapn, betapn, sigma_pn
241
+ global Gamma
242
+ """Given an energy outputs parameters to the profile function
243
+ alpha_nn, a, and sigma_nn"""
244
+
245
+
246
+ if (interaction_type == "np"):# and ( E < 1000 and E > 40) :
247
+
248
+ with importlib.resources.as_file(
249
+ importlib.resources.files("ERICCA").joinpath("new_profile_funct_params.txt")
250
+ ) as path:
251
+ profile_funct_table = np.genfromtxt(path, unpack=True, skip_header=2)
252
+
253
+
254
+ sigma_pp_fun = CubicSpline(profile_funct_table[0],profile_funct_table[1])
255
+ alphapp_fun = CubicSpline(profile_funct_table[0],profile_funct_table[2])
256
+ betapp_fun = CubicSpline(profile_funct_table[0],profile_funct_table[3])
257
+
258
+ sigma_pn_fun = CubicSpline(profile_funct_table[0],profile_funct_table[4])
259
+ alphapn_fun = CubicSpline(profile_funct_table[0],profile_funct_table[5])
260
+ betapn_fun = CubicSpline(profile_funct_table[0],profile_funct_table[6])
261
+
262
+ sigma_pp = sigma_pp_fun(E)
263
+ alphapp = alphapp_fun(E)
264
+ betapp = betapp_fun(E)
265
+
266
+ sigma_pn = sigma_pn_fun(E)
267
+ alphapn = alphapn_fun(E)
268
+ betapn = betapn_fun(E)
269
+
270
+ Gamma = lambda b : Gamman(b) + Gammap(b)
271
+ return
272
+
273
+ elif (interaction_type == "matter"):# and ( E < 1000 and E > 40) :
274
+
275
+ with importlib.resources.as_file(
276
+ importlib.resources.files("ERICCA").joinpath("profile_funct_param_matter.txt")
277
+ ) as path:
278
+ profile_funct_table = np.genfromtxt(path, unpack=True, skip_header=2)
279
+
280
+
281
+ sigma_NN_fun = CubicSpline(profile_funct_table[0],profile_funct_table[1])
282
+ alpha_fun = CubicSpline(profile_funct_table[0],profile_funct_table[2])
283
+ beta_fun = CubicSpline(profile_funct_table[0],profile_funct_table[3])
284
+
285
+ sigma_n = sigma_NN_fun(E)
286
+ alpha = alpha_fun(E)
287
+ beta = beta_fun(E)
288
+
289
+ mGamma = lambda b : ((1 - 1j * alpha)/( 4 * np.pi * beta) ) * sigma_n * np.exp( - b**2/(2 *beta) )
290
+ Gamma = lambda b: mGamma(b)
291
+ return
292
+ else:
293
+ raise ValueError(
294
+ f"Unknown interaction_type '{interaction_type}'. "
295
+ "Choose 'np' or 'matter'."
296
+ )
297
+
298
+
299
+
300
+ def dens_b_interpolator(array_r, array_rho):
301
+ """"""
302
+ #rho_funct = Rbf(array_r, array_rho)
303
+ def rho_funct(r):
304
+ if r <= (array_r[-1]) :
305
+ den_rho_f = Rbf(array_r, array_rho)
306
+ return den_rho_f(r)
307
+
308
+ else:
309
+ return 0
310
+
311
+ def rho_z_funct(b):
312
+ integrand = lambda z: rho_funct(np.sqrt(b**2 + z**2))
313
+ funct_values = np.array([integrand(i) for i in z_mapped_roots.tolist()])
314
+ results_b = np.sum(z_weights * funct_values)
315
+ return results_b
316
+
317
+ results_z = np.array( [rho_z_funct(i) for i in t_mapped_roots.tolist()])
318
+ return results_z
319
+
320
+
321
+
322
+
323
+ #_____________________________________________________________________________________________________________________________________
324
+
325
+ def rhoz_p(b):
326
+ # calcualating the projectile/target density
327
+
328
+ global A_p
329
+
330
+ global za, zb, z_numpoints, z_roots, z_weights, z_mapped_roots
331
+
332
+ integrand = lambda z : rho_m( np.sqrt(z**2 + b**2 ))
333
+ #the saturation density
334
+
335
+ #func_values = np.array( [integrand(i) for i in z_mapped_roots.tolist()])
336
+ func_values = integrand(z_mapped_roots)
337
+
338
+ #print(func_values)
339
+ # Perform Gaussian Legendre integration
340
+ result = np.sum(z_weights * func_values)
341
+
342
+ return result
343
+
344
+
345
+ # Functions that require integrals____________________________________________________________________________________________________
346
+
347
+ def Chi_mol_1(b, rho_t, rho_p, Gamma):
348
+
349
+ # import s mesh
350
+ global sa, sb, s_weights, s_mapped_roots
351
+ global ta, tb, t_weights, t_mapped_roots
352
+
353
+ global t_theta_a, t_theta_b, t_theta_weights, t_theta_mapped_roots
354
+
355
+ #defining integrand
356
+
357
+ def chi_t(b,s, theta_s, theta_t):
358
+
359
+ t_integrand = lambda t : t * Gamma(add_sub_vec_mag(b, 0, s, theta_s, t, theta_t))
360
+
361
+
362
+ #func_values = np.array( [t_integrand(i) for i in t_mapped_roots.tolist()]) * rho_t
363
+ func_values =t_integrand(t_mapped_roots[:, np.newaxis, np.newaxis, np.newaxis])*rho_t[:, np.newaxis, np.newaxis, np.newaxis]
364
+
365
+ # Perform Gaussian Legendre integration
366
+ t_result = np.sum(t_weights[:, np.newaxis, np.newaxis, np.newaxis] * func_values, axis= 0)
367
+
368
+ return t_result
369
+
370
+ def chi_theta_t(b,s, theta_s):
371
+
372
+ t_theta_integrand = lambda theta_t : chi_t(b,s, theta_s, theta_t)
373
+
374
+ #func_values = np.array( [t_theta_integrand(i) for i in t_theta_mapped_roots.tolist()])
375
+ func_values = t_theta_integrand(t_theta_mapped_roots[:, np.newaxis, np.newaxis])
376
+
377
+ # Perform Gaussian Legendre integration
378
+ t_theta_result = np.sum(t_theta_weights[:, np.newaxis, np.newaxis] * func_values, axis= 0)
379
+
380
+ return t_theta_result
381
+
382
+ def chi_s(b, theta_s):
383
+
384
+ s_integrand = lambda s: s * (1 - np.exp(-chi_theta_t(b,s, theta_s)) )
385
+
386
+ #func_values = np.array( [s_integrand(i) for i in s_mapped_roots.tolist()]) * rho_p
387
+ func_values = s_integrand(s_mapped_roots[:, np.newaxis])* rho_p[:, np.newaxis]
388
+
389
+ # Perform Gaussian Legendre integration
390
+ s_result = np.sum(s_weights[:, np.newaxis] * func_values, axis = 0)
391
+
392
+ return s_result
393
+
394
+ integrand = lambda theta_s: .5j * chi_s(b, theta_s)
395
+
396
+ #func_values = np.array( [integrand(i) for i in s_theta_mapped_roots.tolist()])
397
+ func_values = integrand(s_theta_mapped_roots)
398
+
399
+ # Perform Gaussian Legendre integration
400
+ result = np.sum(s_theta_weights * func_values, axis = 0)
401
+
402
+
403
+ return result
404
+
405
+
406
+
407
+ def Chi_mol(b, rho_t, rho_p, Gamma):
408
+ #print(Chi_mol_1(b, rho_t, rho_p, Gamma) + Chi_mol_1(b, rho_p, rho_t, Gamma))
409
+ return Chi_mol_1(b, rho_t, rho_p, Gamma) + Chi_mol_1(b, rho_p, rho_t, Gamma)
410
+
411
+
412
+ #_____________________________________________________________________________________________________________________________________
413
+ def chi(b, rho_t, rho_p, Gamma):
414
+
415
+ # import s mesh
416
+ global sa, sb, s_weights, s_mapped_roots
417
+ global ta, tb, t_weights, t_mapped_roots
418
+
419
+ global t_theta_a, t_theta_b, t_theta_weights, t_theta_mapped_roots
420
+
421
+ #defining integrand
422
+
423
+ #array_rho_t = np.array( [rho_t(i) for i in t_mapped_roots.tolist()])
424
+ #array_rho_p = np.array( [rho_p(i) for i in s_mapped_roots.tolist()])
425
+
426
+ def chi_t(b,s, theta_s, theta_t):
427
+
428
+ #t_integrand = lambda t : s**2 + theta_s**2 + t**2 + theta_t**2
429
+
430
+ t_integrand = lambda t : 1j* s * t * Gamma(add_sub_vec_mag(b, 0, s, theta_s, t, theta_t))
431
+
432
+
433
+ #func_values = np.array( [t_integrand(i) for i in t_mapped_roots.tolist()]) * rho_t
434
+ func_values = t_integrand(t_mapped_roots[:, np.newaxis, np.newaxis, np.newaxis]) * rho_t[:, np.newaxis, np.newaxis, np.newaxis]
435
+
436
+ # Perform Gaussian Legendre integration
437
+ t_result = np.sum(t_weights[:, np.newaxis, np.newaxis, np.newaxis] * func_values, axis = 0)
438
+
439
+ return t_result
440
+
441
+ def chi_theta_t(b,s, theta_s):
442
+
443
+ t_theta_integrand = lambda theta_t : chi_t(b,s, theta_s, theta_t)
444
+
445
+ #func_values = np.array( [t_theta_integrand(i) for i in t_theta_mapped_roots.tolist()])
446
+
447
+ func_values =t_theta_integrand(t_theta_mapped_roots[:, np.newaxis, np.newaxis])
448
+
449
+ # Perform Gaussian Legendre integration
450
+ t_theta_result = np.sum(t_theta_weights[:, np.newaxis, np.newaxis] * func_values, axis = 0)
451
+
452
+ return t_theta_result
453
+
454
+ def chi_s(b, theta_s):
455
+
456
+ s_integrand = lambda s: chi_theta_t(b,s, theta_s)
457
+
458
+ #func_values = np.array( [s_integrand(i) for i in s_mapped_roots.tolist()]) * rho_p
459
+ func_values =s_integrand(s_mapped_roots[:, np.newaxis])* rho_p [:, np.newaxis]
460
+
461
+ # Perform Gaussian Legendre integration
462
+ s_result = np.sum(s_weights[:, np.newaxis] * func_values, axis = 0)
463
+
464
+ return s_result
465
+
466
+ integrand = lambda theta_s: chi_s(b, theta_s)
467
+
468
+ #func_values = np.array( [integrand(i) for i in s_theta_mapped_roots.tolist()])
469
+ func_values =integrand(s_theta_mapped_roots)
470
+
471
+ # Perform Gaussian Legendre integration
472
+ result = np.sum(s_theta_weights * func_values, axis = 0)
473
+
474
+ return result
475
+
476
+ def chi_no_dens(b , rho, Gamma):
477
+
478
+ # import s mesh
479
+ global sa, sb, s_weights, s_mapped_roots
480
+ global ta, tb, t_weights, t_mapped_roots
481
+
482
+ global t_theta_a, t_theta_b, t_theta_weights, t_theta_mapped_roots
483
+
484
+ #defining integrand
485
+
486
+ #array_rho_t = np.array( [rho_t(i) for i in t_mapped_roots.tolist()])
487
+ #array_rho_p = np.array( [rho_p(i) for i in s_mapped_roots.tolist()])
488
+
489
+ def chi_s(b, theta_s):
490
+
491
+ s_integrand = lambda s, : 1j * s * (Gamma(add_sub_vec_mag(b,0,s,theta_s,0,0)))
492
+
493
+ #func_values = np.array( [s_integrand(i) for i in s_mapped_roots.tolist()]) * rho
494
+ func_values =s_integrand(s_mapped_roots[:, np.newaxis])* rho[:, np.newaxis]
495
+ # Perform Gaussian Legendre integration
496
+ s_result = np.sum(s_weights[:, np.newaxis] * func_values, axis = 0)
497
+
498
+ return s_result
499
+
500
+ integrand = lambda theta_s: chi_s(b, theta_s)
501
+
502
+ #func_values = np.array( [integrand(i) for i in s_theta_mapped_roots.tolist()])
503
+ func_values =integrand(s_theta_mapped_roots)
504
+ # Perform Gaussian Legendre integration
505
+ result = np.sum(s_theta_weights * func_values, axis = 0)
506
+
507
+ return result
508
+
509
+ def sigma_R( rho_t, rho_p = 0, Gamma = lambda b: np.exp(-b), Model = "OLA"):
510
+
511
+ global ba, bb, b_numpoints, b_roots, b_weights, b_mapped_roots
512
+
513
+ if (Model == "OLA p-n"):
514
+
515
+ #if only the target/projectile are composite particles
516
+ sigma_R_nd_int =lambda b: 2 * np.pi * b * (1 - np.exp(- 2 * chi_no_dens(b, rho_t, Gamma ).imag ) )
517
+
518
+ func_values = np.array( [sigma_R_nd_int(i) for i in b_mapped_roots.tolist()])
519
+
520
+ elif (Model == "MOL"):
521
+ sigma_R_int= lambda b: 2 * np.pi * b * (1 - np.exp(- 2 * Chi_mol(b, rho_t, rho_p, Gamma ).imag ) )
522
+ func_values = np.array( [sigma_R_int(i) for i in b_mapped_roots.tolist()])
523
+ #func_values =sigma_R_int(b_mapped_roots)
524
+
525
+ else:
526
+ #if both target and projectiles are composite particles
527
+ sigma_R_int= lambda b: 2 * np.pi * b * (1 - np.exp(- 2 * chi(b, rho_t, rho_p, Gamma ).imag ) )
528
+
529
+ func_values = np.array( [sigma_R_int(i) for i in b_mapped_roots.tolist()])
530
+
531
+
532
+
533
+ #plt.plot(r_mapped_roots,func_values)
534
+
535
+ #print(func_values)
536
+ #print(r_mapped_roots , sigma_R_int(r_mapped_roots) #*r_weights *0.5 * (rb - ra))
537
+
538
+ # Perform Gaussian Legendre integration
539
+ result = np.sum(b_weights * func_values)
540
+
541
+ return result * 10
542
+
543
+ def chi_mol_micro(b, rho_t_p, rho_t_n, rho_p_p ,rho_p_n, Gamma_pp, Gamma_pn, Gamma_nn ):
544
+ chi_pp = Chi_mol(b, rho_t_p, rho_p_p, Gamma_pp )
545
+ chi_pn = Chi_mol(b, rho_t_p, rho_p_n, Gamma_pn ) + Chi_mol(b, rho_t_n, rho_p_p, Gamma_pn )
546
+ chi_nn = Chi_mol(b, rho_t_n, rho_p_n, Gamma_nn )
547
+ return (chi_pp + chi_pn + chi_nn)
548
+
549
+ def chi_ola_micro(b, rho_t_p, rho_t_n, rho_p_p, rho_p_n, Gamma_pp, Gamma_pn, Gamma_nn ):
550
+ chi_pp = chi(b, rho_t_p, rho_p_p, Gamma_pp )
551
+ chi_pn = chi(b, rho_t_p, rho_p_n, Gamma_pn) + chi(b, rho_t_n, rho_p_p, Gamma_pn)
552
+ chi_nn = chi(b, rho_t_n, rho_p_n, Gamma_nn )
553
+ return (chi_pp + chi_pn + chi_nn)
554
+
555
+
556
+ def sigma_R_micro(rho_t_p, rho_t_n, rho_p_p, rho_p_n, Gamma_pp, Gamma_pn, Gamma_nn , Model = "OLA"):
557
+
558
+ global ba, bb, b_numpoints, b_roots, b_weights, b_mapped_roots
559
+
560
+ if (Model == "MOL"):
561
+ sigma_R_int= lambda b: 2 * np.pi * b * (1 - np.exp(- 2 * chi_mol_micro(b, rho_t_p, rho_t_n, rho_p_p, rho_p_n, Gamma_pp, Gamma_pn, Gamma_nn).imag ) )
562
+ func_values = np.array( [sigma_R_int(i) for i in b_mapped_roots.tolist()])
563
+ #func_values =sigma_R_int(b_mapped_roots)
564
+
565
+
566
+ else:
567
+ #if both target and projectiles are composite particles
568
+ sigma_R_int= lambda b: 2 * np.pi * b * (1 - np.exp(- 2 * chi_ola_micro(b, rho_t_p, rho_t_n, rho_p_p, rho_p_n,Gamma_pp, Gamma_pn, Gamma_nn).imag ) )
569
+ func_values = np.array( [sigma_R_int(i) for i in b_mapped_roots.tolist()])
570
+
571
+ # Perform Gaussian Legendre integration
572
+ result = np.sum(b_weights * func_values)
573
+
574
+ return result * 10
575
+
576
+ #________________________________________________________________________________________________________________________________________
577
+
578
+ def rm_rms(rho):
579
+
580
+ global A
581
+
582
+ #defining integrand
583
+
584
+ integrand = lambda r: 4 * np.pi* (r**4) * rho(r)/A
585
+
586
+ #bounds for the integral
587
+
588
+ global ra, rb, r_numpoints, r_roots, r_weights, r_mapped_roots
589
+
590
+ func_values = integrand(r_mapped_roots)
591
+
592
+ # Perform Gaussian Legendre integration
593
+ result = np.sum(r_weights * func_values)
594
+
595
+ return np.sqrt(result)
596
+
597
+ def A_return(rho):
598
+
599
+ global A
600
+
601
+ #defining integrand
602
+
603
+ integrand = lambda r : 4 * np.pi* (r**2) * rho(r)
604
+
605
+ #bounds for the integral
606
+
607
+ global ra, rb, r_numpoints, r_roots, r_weights, r_mapped_roots
608
+
609
+ func_values = integrand(r_mapped_roots)
610
+ #func_values = np.array( [integrand(i) for i in r_mapped_roots.tolist()])
611
+
612
+ # Perform Gaussian Legendre integration
613
+ result = np.sum(r_weights * func_values)
614
+
615
+ return result
616
+
617
+
618
+ def A_min(params):
619
+ global A
620
+ global C_m_p, a_m_p, rho_0_p
621
+ C_m_p, a_m_p, rho_0_p = params
622
+ rhom = rho_m
623
+
624
+ return abs(A_return(rhom) - A)
625
+
626
+ def sat_min(params):
627
+ global C_m_p, a_m_p, rho_0_p
628
+ C_m_p, a_m_p, rho_0_p = params
629
+ rhom = rho_m
630
+ return abs(rhom(0) - 0.176)
631
+
632
+ def rho_param_finder(E, array_rho_t, sigma_R_measured, dsigma, guess_param = [ 4.1, .5, .176] ):
633
+
634
+ def sigma_min(params):
635
+ global C_m_p, a_m_p, rho_0_p
636
+ C_m_p, a_m_p, rho_0_p = params
637
+
638
+
639
+ array_rho_p = np.array( [rhoz_p(i) for i in s_mapped_roots.tolist()])
640
+
641
+ return (sigma_R( E, array_rho_t , array_rho_p, Model = "MOL" )*10 - sigma_R_measured)**2/ ((dsigma))
642
+
643
+
644
+
645
+ constraints= [{'type': 'eq', 'fun': A_min},
646
+ {'type': 'eq', 'fun': sat_min}]
647
+
648
+ return minimize(sigma_min, guess_param, constraints=constraints)