Documentation for the neutron-rich-bmm code
GP BMM structure and helper functions
SigmoidChangepoint(ls1, ls2, cbar1, cbar2, changepoint=1.0, changepoint_bounds=(1e-05, 100000.0), width=1.0, width_bounds=(1e-05, 100000.0))
Designs a non-stationary changepoint kernel that inherits from the sklearn RBF Kernel class.
The kernel is given by: .. math:: k(x_i, x_j) = (1 - \sigma(x_i)) * K1(x_i,x_j) * (1 - \sigma(x_j)) + \sigma(x_i) * K2(x_i,x_j) * \sigma(x_j)
where K1 is the first kernel and K2 is the second kernel, with the changepoint defined by a chosen switching function. The current options are 'linear' and 'sigmoid'.
Source code in src/neutron_rich_bmm/custom_kernels.py
TanhChangepoint(ls1, ls2, cbar1, cbar2, changepoint=1.0, changepoint_bounds=(1e-05, 100000.0), width=1.0, width_bounds=(1e-05, 100000.0))
Designs a non-stationary changepoint kernel that inherits from the sklearn RBF Kernel class.
The kernel is given by: .. math:: k(x_i, x_j) = (1 - \sigma(x_i)) * K1(x_i,x_j) * (1 - \sigma(x_j)) + \sigma(x_i) * K2(x_i,x_j) * \sigma(x_j)
where K1 is the first kernel and K2 is the second kernel, with the changepoint defined by a chosen switching function. The current option is 'tanh'.
Source code in src/neutron_rich_bmm/custom_kernels.py
boundary_conditions(dens, pres_dict, index=0)
Helper function to find boundary conditions from the pQCD results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dens
|
ndarray
|
The density array as input to find the BCs. |
required |
pres_dict
|
dict
|
The dictionary of pressure values corresponding to the input density array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
mu_FG |
ndarray
|
The 1-d array of chemical potentials corresponding to the values of density that were input. |
mU_FG |
ndarray
|
The array of shape [:,None] that is used in the gsum truncation error analysis. |
edens_dict |
dict
|
The energy density values at the chosen density index, used as the BCs for the speed of sound calculation. |
Source code in src/neutron_rich_bmm/eos_utils.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
get_closest_mask(array, values)
Returns a mask corresponding to the locations in array that are closest to values.
array and values must be sorted
Taken from gsum, originally written by J. A. Melendez
Source code in src/neutron_rich_bmm/eos_utils.py
get_linear_mask_in_log_space(x, x_min, x_max, log_x_step, base=np.e)
Mask for getting linear data in the log space. Written by J. A. Melendez.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Array of x values. |
required |
x_min float)
|
Min x value. |
required | |
x_max
|
float
|
Max x value. |
required |
log_x_step
|
float
|
The step size. |
required |
base
|
float
|
The base of the log we are using. Default is natural log (np.e). |
e
|
Returns:
| Type | Description |
|---|---|
|
The linear mask in the logarithmic space. |
Source code in src/neutron_rich_bmm/eos_utils.py
gp_data(data_xeft, data_pqcd, cutoff=40, all_orders=True, matter='SNM', kernel='rbf')
Helper function for determining training data from the Chiral EFT and pQCD full training sets. Used for the BMM when a GP is the method of choice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_xeft
|
dict
|
The dictionary of densities, means, and variances of the Chiral EFT data. |
required |
data_pqcd
|
dict
|
The dictionary of densities, means, and variances of the pQCD data. |
required |
cutoff
|
int
|
The scaled density cutoff we are using for pQCD data. |
40
|
all_orders
|
bool
|
Toggle if data is more than one-dimensional. Default is True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
training_set |
dict
|
The dictionary of selected training data |
|
concatenated from both EOSs. |
Source code in src/neutron_rich_bmm/eos_utils.py
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 | |
pal_eos(kf)
Python version of PAL (Prakash, Ainsworth, Lattimer) EOS. Coupling constants found via the FORTRAN code paleoscc.f90, not included in this function. This function is designed to be used as a mean function in the GP for chiral EFT.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kf
|
ndarray
|
The Fermi momentum to be used to calculate PAL for the energy per particle. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
enperpart_kf |
ndarray
|
The energy per particle, in terms of the Fermi momentum. |
Source code in src/neutron_rich_bmm/eos_utils.py
pressure_pal_eos(kf)
The PAL EOS pressure calculation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kf
|
ndarray
|
The Fermi momentum . |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pressure_kf |
ndarray
|
The pressure in terms of the Fermi momentum. |
Source code in src/neutron_rich_bmm/eos_utils.py
speed_of_sound(dens, pressure, edens=None, sat=False, bounds=68, integrate='forward', sampled=False)
Function to evaluate the speed of sound of a system given the pressure, number density, and initial parameters for the energy density integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dens
|
numpy 1d array
|
The number density of the system. |
required |
pressure
|
dict
|
The dictonary of pressure means and standard deviations from the system. |
required |
edens
|
dict
|
The dictionary of energy density means and standard deviations for a specific starting point in density. |
None
|
sat
|
bool
|
Starting at saturation density (0.16 fm^-3) or not. Default is False. |
False
|
integrate
|
str
|
Decision to integrate forward or backward. Default is 'forward'. |
'forward'
|
sampled
|
bool
|
If using samples from the speed of sound, run the std and mean using nanmean and nanstd from numpy instead of computing envelopes. Default is 'False'. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
cs2 |
dict
|
The dictonary of results for the speed of sound (calculated using 1\mu dP/dn) and the lower and upper bounds of it at one sigma, returned when sampled is True. |
edens_full |
dict
|
The energy density dictionary of means and variances returned when sampled is True. |
dens_arr |
ndarray
|
The densities corresponding to the speed of sound calculation (if sat is True, this will reflect from saturation up), returned when sampled is False. |
cs2_log |
dict
|
The dict of speed of sound values from using the n * dlog(mu)/dn method. Returned when sampled is False. |
edens_int |
dict
|
The dict of energy densities, returned when sampled is False. |
mu_dict |
dict
|
The dict of chemical potential values, returned when sampled is False. |
Source code in src/neutron_rich_bmm/eos_utils.py
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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
causality_stability(cs2, edens, pressure)
Function to eliminate any draws from the EOS that are unstable or acausal.
Example
causality_stability(cs2=array, edens=array, pressure=array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cs2
|
array
|
The array of speed of sound draws. Shape should be [density, draw]. |
required |
edens
|
array
|
The array of corresponding energy densities, in the shape [density, draw]. |
required |
pressure
|
array
|
The array of corresponding pressures in the shape of [density, draw]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cs2_reduced |
array
|
The 2D array of reduced samples for the speed of sound. |
edens_reduced |
array
|
The 2D array of reduced samples for the energy density. |
pres_reduced |
array
|
The 2D array of reduced samples for the pressure. |
Source code in src/neutron_rich_bmm/tov_utils.py
tov_data(edens_full, pres_dict, cs2_data=None, save=False, filepath=None)
Function to collect the data needed for the TOV input and to organize it such that it can be read correctly by the TOV solver we are using. It also attaches the low-density EOS information up to 0.5n0 from Bethe, Pethick, and Sutherland, and Negele and Vautherin's work.
Example
tov_data(edens_full=array, pres_dict=dict, cs2_data=array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edens_full
|
array
|
The array of energy densities in MeV/fm^3. |
required |
pres_dict
|
dict
|
The dictionary of pressures and their standard deviations in MeV/fm^3, as well as the number density in fm^-3. |
required |
cs2_data
|
array
|
The array of corresponding speed of sound values in dimensionless units. This is optional, as these values are only needed if the TOV solver is selected to calculate tidal deformability. |
None
|
save
|
bool
|
If the user wishes to save the data file, supply 'True'. |
False
|
filepath
|
str
|
If the user wishes to save the data file, supply a proper file path, including any external folders. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tov_dict |
dict
|
The full dictionary of dens, edens, pres, and cs2 (optionally) to be used in the TOV solver. |
Source code in src/neutron_rich_bmm/tov_utils.py
Chiral EFT EOS code
Chiral_model(density=None, Lambda=500, high_density=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
density
|
array
|
The density specified for calculation of the chiral EOS. Default is None, which will make the chiral EOS default to the original data density range. |
None
|
Lambda
|
int
|
The value of the cutoff chosen. Can be either 450 MeV or 500 MeV. |
500
|
high_density
|
bool
|
Whether we want to use high-density data or not. Default is True. Sets up the data for interpolation in the chiral EOS class. |
True
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/chiral_model.py
evaluate(input_space=None, N3LO=True, scaled=True, extend=False)
Returns the mean and standard deviation of the chiral EFT EOS in terms of pressure wrt baryon chemical potential. The mean is calculated from the chiral EFT EOS formalism of C. Drischler et al. (2021). The standard deviation is calculated via the truncation error models in the gsum package, used in the chiral EOS paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_space
|
array
|
The input space array. Not actually necessary for this function but necessary for Taweret. |
None
|
N3LO
|
bool
|
If True, returns only the N3LO results for mean and std_dev. Otherwise will return all results up to and through N3LO. |
True
|
scaled
|
bool
|
If the data is scaled, then this is True. Else, it is False. Default is True. |
True
|
extend
|
bool
|
Extends the data to higher truncation values. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
mean |
numpy.1darray
|
The mean of the pressure. |
std_dev |
numpy.1darray
|
The standard deviation of the pressure. |
Source code in src/neutron_rich_bmm/chiral_model.py
log_likelihood_elementwise()
Chiral(density_input=None, Lambda=500, high_density=True)
function imports the necessary data to begin the calculation, and sets up the density and data for interpolation. Choice of Lambda (450, 500) is also made here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
density_input
|
linspace
|
The density regime for the chiral EOS. Default is set below in the code. |
None
|
Lambda
|
int
|
The desired cutoff to use. Default is 500; either 450 or 500 MeV may currently be chosen. |
500
|
high_density
|
bool
|
Decision to use high density data or not. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/chiral.py
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 | |
chemical_potential(method=1, add_rest_mass=False)
Calculation of the chemical potential depending on which type is desired: either type=1 ((P+eps)/n) or type=2 (deps/dn). Both should be equivalent if thermodynamic consistency is preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
int
|
The type of calculation to obtain the chemical potential. Possibilities include: 1 = (P+eps)/n and 2 = d(eps)/dn. Default is 1. |
1
|
add_rest_mass
|
bool
|
Adds the rest mass to the energy per particle if desired. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
|
self.mu_s, self.mu_s_stds (numpy.ndarray): The chemical potential and std dev for the chiral EOS, wrt n. |
Source code in src/neutron_rich_bmm/chiral.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
data_interpolation(density_int=None, kf_s_int=None, extend=False)
The interpolation of the data using the observable containers from nuclear-matter-convergence for neutron matter, symmetric nuclear matter, and the symmetry energy calculation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
density_int
|
numpy.1darray
|
The interpolated number density values from the mu(n) inversion. Default is None; this will leave the container to use the original interpolated density_all. |
None
|
kf_s_int
|
numpy.1darray
|
The interpolated Fermi momenta for SNM. This will be replaced when calculating the inverted density and chemical potential. Default is None; this will leave the container to use the original interpolated kf_s. |
None
|
extend
|
bool
|
Whether or not to extend the data using the mean function estimation and extending the truncation error. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
|
self.obs_neutron, self.obs_nuclear, self.obs_sym_energy (objects): The objects that contain the important interpolation information for the chiral EFT EOS for PNM, SNM, and the symmetry energy. |
Source code in src/neutron_rich_bmm/chiral.py
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 | |
energy_dens(add_rest_mass=False, orders='all')
Computes the energy density and standard deviation of the energy density of the chiral EOS. Adds rest mass if desired.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
add_rest_mass
|
bool
|
The option to include the rest mass in the E/A (and in the energy density). |
False
|
orders
|
str
|
Option to either calculate all orders ('all') or only N3LO ('N3LO'). Default is 'all'. |
'all'
|
Returns:
| Type | Description |
|---|---|
|
self.energy_density, self.energy_density_s_stds (numpy.ndarray): The energy density and standard deviation of the energy density. |
Source code in src/neutron_rich_bmm/chiral.py
energy_per_particle(add_rest_mass=False, case='SNM', orders='all')
A function that ouputs the energy per particle with truncation errors from gsum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
add_rest_mass
|
bool
|
If desired, will add the rest mass to the energy per particle. |
False
|
orders
|
str
|
Command to determine whether we use all orders for the EFT or just one of them. Default is 'all', but 'N3LO' will convert to only one EFT at N3LO. |
'all'
|
Returns:
| Type | Description |
|---|---|
|
self.energies_s, self.energy_s_stds (numpy.ndarray): The energy per particle (E/A) and standard deviation of E/A. |
|
|
self.energies_s_mn, self.energy_s_stds (numpy.ndarray): E/A (inclusive of |
|
|
the rest mass) and the standard deviation of E/A. This is returned if |
|
|
add_rest_mass is True. |
Source code in src/neutron_rich_bmm/chiral.py
f_n(mu, mu_func, guess=0.33)
fsolve function to invert mu(n) to n(mu).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
float
|
The current value in the chemical potential to be inverted. |
required |
mu_func
|
function
|
The function from interp1d that is to be solved for n. |
required |
guess
|
float
|
The guess for fsolve to find a root. Default is 0.33. |
0.33
|
Returns:
| Type | Description |
|---|---|
|
The value of n with respect to the given values of the |
|
|
chemical potential. |
Source code in src/neutron_rich_bmm/chiral.py
inversion(guess=0.33)
Inverts the function mu(n) in favour of n(mu). For Lambda = 500 MeV, able to use the fsolve function to do this. For Lambda = 450 MeV, must manually invert. ***Note: because of this, the range of mu is not the same for both cases of Lambda.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guess
|
float
|
The guess for the fsolve function to invert for Lambda = 500 MeV. If using Lambda = 450 MeV, this argument is ignored. Default is 0.33. |
0.33
|
Returns:
| Type | Description |
|---|---|
|
self.density_mu_N3LO (numpy.ndarray): The array in density that we obtain from inversion. |
|
|
self.mu_array_N3LO (numpy.ndarray): The inverted chemical potential array. |
|
|
self.kf_N3LO (numpy.ndarray): The new array in kf for the observable container once mu has been inverted. |
Source code in src/neutron_rich_bmm/chiral.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | |
invert(n, mu, guess=0.33, nnew=None)
Inversion function that uses fsolve. At present, only used for Lambda = 500 MeV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
ndarray
|
The array of densities that we currently possess. |
required |
mu
|
ndarray
|
The array of chemical potential values for the range of densities in n. |
required |
guess
|
float
|
The guess for fsolve. Default is 0.33. |
0.33
|
nnew
|
ndarray
|
The values for the new array in density. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
mu_new |
ndarray
|
Array of mu results at new points in density. |
f_n_result |
ndarray
|
The results of the root finding wrt the new chemical potential array. |
Source code in src/neutron_rich_bmm/chiral.py
pressure(orders='all', matter='SNM')
The pressure of the chiral EOS. Note: Rest mass will not affect this calculation, so no option for adding the rest mass is included here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orders
|
str
|
Command to determine how many orders in the EFT expansion to calculate. Default is 'all', but can be set to 'N3LO' to only return that one. |
'all'
|
Returns:
| Type | Description |
|---|---|
|
self.pressure_s, self.pressure_s_stds (numpy.ndarray): The pressure and standard deviation of the pressure. |
Source code in src/neutron_rich_bmm/chiral.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
Perturbative QCD EOS code
Gorda(mu, X, Nf, mu_FG=None)
function since it is already calibrated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The quark chemical potential needed to generate the mean and standard deviation of the pressure in the pQCD EOS model. |
required |
X
|
int
|
The value of the renormalization scale parameter. |
required |
Nf
|
int
|
The number of flavours of quarks considered. |
required |
mu_FG
|
ndarray
|
The FG chemical potential array. |
None
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/gorda_model.py
evaluate(input_space=None, N2LO=True, scaled=True)
The evaluation function for Taweret to obtain the calibrated mean and variance of the pQCD model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_space
|
ndarray
|
The number density array. |
None
|
N2LO
|
bool
|
If we only want the data from the pQCD pressure at N2LO. Default is True. |
True
|
scaled
|
bool
|
If the data is scaled, this is True. Else, it is False. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
|
mean, std_dev (numpy.ndarray): The mean and standard deviations at the selected points in the input space of the pQCD pressure. |
Source code in src/neutron_rich_bmm/gorda_model.py
log_likelihood_elementwise()
PQCD(X=1, Nf=2)
the rest of the code.
:Example: PQCD(X=1, Nf=2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
int
|
The value of the coefficient multiplying mu to determine the renormalization scale. Default is 1, as in Gorda et al. (2023). |
1
|
Nf
|
int
|
The number of different quark flavours being considered. Default is 2, for SNM. NSM is 3. |
2
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
alpha_s(mu, loop=2)
The function for alpha_s with an option for either first order or second order (loops) inclusion.
:Example: PQCD.alpha_s(mu, loop=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
loop
|
int
|
The order at which alpha_s is calculated. Default is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
alpha_s |
ndarray
|
The values of alpha_s at the order requested. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
c_0(x)
The c0 coefficient of pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
The quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the coefficient at each point |
|
|
in the array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
c_1(x)
The c1 coefficient of pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
The quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the coefficient at each point |
|
|
in the array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
c_2(x)
The c2 coefficient of pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
The quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the coefficient at each point |
|
|
in the array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
expQ(x)
The expansion parameter function for pQCD. Default here is Nf * alpha_s / pi, but another may be substituted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
The quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the expansion parameter at each |
|
|
point in the quark chemical potential array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
inversion(n_mu=None)
Function to invert n(mu) to obtain mu(n).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_mu
|
array
|
Linspace over n_q for the inversion. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
n_mu |
ndarray
|
The number density. |
f_mu_2_new |
array
|
The array corresponding to the inverted function values for mu(n). |
f_mu_FG_new |
ndarray
|
The values of the FG chemical potential. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
mask_array(array, neg=False, fill_value=None)
staticmethod
Returns a masked array from an original array that contains unwanted nan values. Can also fill values in the place of the mask, if desired.
:Example: PQCD.mask_array(array=mu, fill_value=0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
The array with values to mask. |
required |
neg
|
bool
|
If False, will not also mask negative values. If True, will check for negative values and mask using current fill value. |
False
|
fill_value
|
(int, float)
|
The value with which to fill the mask. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
masked_array |
ndarray
|
The masked array with or without filled values. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
mu_1(mu_FG)
The mu1 term of pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu_FG
|
array
|
The FG quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of mu1 at each point |
|
|
in the array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
mu_2(mu_FG)
The mu2 term of pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu_FG
|
array
|
The FG quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of mu2 at each point |
|
|
in the array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
n_FG_mu(mu)
Free quark number density calculation from P_FG(mu) derivative. Note that this will yield a different n value for the same mu value as n_mu yields, so scaling must be taken into account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The input chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n_FG |
ndarray
|
The result of the number density at the input chemical potential. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
n_convert_mu(density)
The function that converts from a desired number density to quark chemical potential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
density
|
linspace
|
The density array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
mu_FG |
ndarray
|
The FG quark chemical potential. |
mu_n |
ndarray
|
The quark chemical potential array. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
n_mu(mu)
Simple first derivative of the pressure (up to second order in P(mu) equation) with respect to the chemical potential to obtain the number density with respect to mu.
NOTE: this derivative is to second order in P, so the equation will be: n(mu) = dP0/dmu + dP1/mu + dP2/mu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n |
ndarray
|
The array of the number density with respect to the chemical potential. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
pressure_FG(mu)
The FG contribution to the pressure in terms of mu.
:Example: PQCD.pressure_FG(mu=np.linspace())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original range in mu. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
p_FG |
linspace
|
The zeroth order (LO) contribution the pressure. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
pressure_KLW(mu_FG)
The pressure equation written out for the KLW inversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu_FG
|
array
|
The FG quark chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pressure_n |
dict
|
The values of the pressure from the KLW inversion at LO, NLO, and N2LO. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
pressure_mu(mu, order=2)
The pressure with respect to mu for NLO or N2LO. Note: alpha_s has been used up to second order here to maintain the validity of the value of alpha_s at 2 GeV. From Gorda et al. (2023), supplemental material.
:Example: PQCD.pressure_mu(mu=np.linspace(), order=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original range of mu. |
required |
order
|
int
|
The order at which the pressure is calculated. Default is 2, options are 1 and 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
pressure |
ndarray
|
The pressure as a function of mu. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
pressure_old(mu, order=2)
Old version of the pressure, using Nf=3 implicitly. Not used in the paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pressure |
ndarray
|
The value of the pressure at the chemical potentials. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
yref(x)
The function to evaluate yref from pQCD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
The quark chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
yref |
numpy.2darray
|
The [:,None] array for yref. |
Source code in src/neutron_rich_bmm/pqcd_reworked.py
Kurkela(X=2, Nf=3)
A simple class to find the roots and perform the integration needed for the Kurkela et al. (2010) CQM paper formulation of the pressure of massless quarks.
Also converts from chemical potential to number density if needed.
Source code in src/neutron_rich_bmm/pqcd.py
c_0(mu)
LO coefficent for the pQCD EOS using Kurkela formalism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The chemical potential for the pQCD EOS. |
required |
Returns:
| Type | Description |
|---|---|
|
np.ones(len(mu)) (numpy.ndarray): The leading order coefficient. |
Source code in src/neutron_rich_bmm/pqcd.py
c_1(mu)
The NLO coefficient for the pQCD EOS using Kurkela formalism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential array. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the coefficient. |
Source code in src/neutron_rich_bmm/pqcd.py
c_2(mu)
The N2LO coefficent for the pQCD EOS using Kurkela formalism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of the coefficient. |
Source code in src/neutron_rich_bmm/pqcd.py
expQ(mu)
The expansion parameter, Q, of the pQCD EOS using the Kurkela formalism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potentials. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of expQ at the chosen potentials. |
Source code in src/neutron_rich_bmm/pqcd.py
find_roots()
Function to determine the value of the chemical potential when the number density reaches zero, so that we can define the limits of our integration for the pressure.
Returns:
| Type | Description |
|---|---|
|
[root1, root2] (numpy.array): The roots of the first and second order number densities in the chemical potential. |
Source code in src/neutron_rich_bmm/pqcd.py
gp_interpolation(mu, kernel=None, center=0.0, sd=1.0)
The function responsible for fitting the coefficients with a GP and predicting at new points. This information will be used in constructing our truncated GP in the function 'Uncertainties'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The chemical potential linspace needed. |
required |
kernel
|
obj
|
The kernel needed for the interpolation GP. Can be fed in from the outside for specific parameter alterations. |
None
|
center
|
float
|
Value for the center of the prior. |
0.0
|
sd
|
float
|
The scale of the prior. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
pred |
ndarray
|
An array of predictions from the GP. |
std |
ndarray
|
The standard deviation at the points in 'pred'. |
underlying_std |
ndarray
|
The underlying standard deviation of the GP. |
Source code in src/neutron_rich_bmm/pqcd.py
gp_kernel()
The kernel that we will use both for interpolating the coefficients and for predicting the truncation error bands.
Returns:
| Type | Description |
|---|---|
|
self.kernel (sklearn object): The kernel needed for the GPs in both 'uncertainties' and 'gp_interpolation'. |
Source code in src/neutron_rich_bmm/pqcd.py
gp_mask(mu)
The mask array needed to correctly separate our training and testing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The chemical potential linspace needed. |
required |
Returns:
| Type | Description |
|---|---|
|
self.mask (numpy.ndarray): The mask for use when interpolating or using the truncated GP. |
Source code in src/neutron_rich_bmm/pqcd.py
inversion(n_mu=None)
Function to invert n(mu) to obtain mu(n).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_mu
|
array
|
Linspace over n_q for the inversion. |
None
|
Returns:
| Type | Description |
|---|---|
|
f_mu_1_result, f_mu_2_result (numpy.array): The two arrays corresponding to the inverted function values for mu(n^(1)) and mu(n^(2)). |
Source code in src/neutron_rich_bmm/pqcd.py
n_first(mu)
The first order in the number density, to be solved to find the root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potentials. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n |
ndarray
|
The number density array. |
Source code in src/neutron_rich_bmm/pqcd.py
n_second(mu)
The second order in the number density, to be solved to find the root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potentials. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n |
ndarray
|
The number density. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure(mu, n_mu=None, scaled=True)
Calculation of the pressure with respect to the chemical potential using the method of Kurkela et al. (2010). Employs the integration of the number density with respect to mu, using the integration limits determined by the find_roots function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The linspace in chemical potential with which we started. |
required |
n_mu
|
ndarray
|
The corresponding number density. |
None
|
scaled
|
bool
|
Toggle to return either scaled pressure (wrt free quark gas) or to return without scaling. Default is True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
mu_array |
dict
|
Dictionary of the new mu arrays spanning the integration limits of the pressure integration. |
pressure_1 |
ndarray
|
The mean value of the pressure at first order for the chosen chemical potential (or number density) array. |
pressure_2 |
ndarray
|
The mean value of the pressure at second order for the chosen chemical potential (or number density) array. |
Source code in src/neutron_rich_bmm/pqcd.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
speed_sound(mu, n)
The speed of sound calculation. Not used in the paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The chemical potential. |
required |
n
|
ndarray
|
The number density. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cs2 |
ndarray
|
The speed of sound. |
Source code in src/neutron_rich_bmm/pqcd.py
uncertainties(mu, n_orders=3, kernel=None, test=None)
Calculation of the truncation error bands for the pQCD EOS, using the Kurkela et al. (2010) formulation for the pressure. This function uses techniques from the gsum package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The linspace of chemical potential needed. |
required |
n_orders
|
int
|
The highest order to which the pressure EOS is calculated. |
3
|
kernel
|
obj
|
The kernel needed for the interpolation and truncation GP. Can be fed in from the outside to change parameters. |
None
|
test
|
ndarray
|
Testing array. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
ndarray
|
The data array. |
|
self.coeffs (numpy.ndarray): The values of the coefficents at the chemical potential mu. |
||
std_trunc |
ndarray
|
The arrays of truncation errors per each order. |
Source code in src/neutron_rich_bmm/pqcd.py
yref(mu)
The reference for the expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
yref |
ndarray
|
The values of yref at the given chemical potentials. |
Source code in src/neutron_rich_bmm/pqcd.py
PQCD(X=2, Nf=3)
the rest of the code.
:Example: PQCD(mu=np.linspace(), X=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
Range of values to use for mu. Units: GeV. |
required |
X
|
int
|
The value of the coefficient multiplying mu to determine the renormalization scale. Default is 2, as in Kurkela et al. (2010). |
2
|
Nf
|
int
|
The number of different quark flavours being considered. Default is 3. |
3
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/pqcd.py
alpha_s(mu, loop=2)
The function for alpha_s with an option for either first order or second order (loops) inclusion.
:Example: PQCD.alpha_s(mu, loop=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
loop
|
int
|
The order at which alpha_s is calculated. Default is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
alpha_s |
ndarray
|
The values of alpha_s for the input chemical potential. |
Source code in src/neutron_rich_bmm/pqcd.py
cs2(n, mu)
Calculaton of the speed of sound. Not used in this paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
ndarray
|
Number density array. |
required |
mu
|
ndarray
|
Corresponding chemical potential array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cs2 |
ndarray
|
The speed of sound. |
Source code in src/neutron_rich_bmm/pqcd.py
mask_array(array, neg=False, fill_value=None)
staticmethod
Returns a masked array from an original array that contains unwanted nan values. Can also fill values in the place of the mask, if desired.
:Example: PQCD.mask_array(array=mu, fill_value=0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
The array with values to mask. |
required |
neg
|
bool
|
If False, will not also mask negative values. If True, will check for negative values and mask using current fill value. |
False
|
fill_value
|
(int, float)
|
The value with which to fill the mask. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
masked_array |
ndarray
|
The masked array with or without filled values. |
Source code in src/neutron_rich_bmm/pqcd.py
n_1(mu)
The first order (NLO) term in the number density of Eq. (59) in Kurkela et al. (2010).
:Example: PQCD.n_1(self, mu=np.linspace())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original mu range. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n_1 |
ndarray
|
The first order contribution to the number density. |
Source code in src/neutron_rich_bmm/pqcd.py
n_2(mu)
The second order (NNLO) term in the number density in Eq. (61) of Kurkela et al. (2010).
:Example: PQCD.n_2(mu=np.linspace())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original mu range. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n_2 |
ndarray
|
The second order contribution to the number density. |
Source code in src/neutron_rich_bmm/pqcd.py
n_FG(mu)
The zeroth order (LO) term in the number density, from Eq. (59) in Kurkela et al. (2010). Aka the FG contribution.
:Example: PQCD.n_FG(mu=np.linspace())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original mu range. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n_FG |
ndarray
|
The FG contribution to the number density. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure_FG(mu)
The FG contribution to the pressure in terms of mu.
:Example: PQCD.pressure_FG(mu=np.linspace())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original range in mu. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
p_FG |
linspace
|
The zeroth order (LO) contribution the pressure. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure_mu(mu, order=2)
The pressure with respect to mu for either NLO or NNLO. Note: alpha_s has been used up to second order here to maintain the validity of the value of alpha_s at 2 GeV.
:Example: PQCD.pressure_mu(mu=np.linspace(), order=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
linspace
|
The original range of mu. |
required |
order
|
int
|
The order at which the pressure is calculated. Default is 2, options are 1 and 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
pressure |
ndarray
|
The pressure as a function of mu. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure_n(n, alpha_s_mu=None)
The pressure as a function of number density, to first order.
:Example:
PQCD.pressure_n(n=np.linspace(), alpha_s_mu=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
linspace
|
The range in number density being considered. |
required |
alpha_s_mu
|
(linspace, ndarray)
|
A possible different chemical potential range to send to alpha_s. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
p_n |
ndarray
|
The pressure as a function of density, at NLO. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure_n3lo(mu, scaled=False)
A first attempt at coding the results from Gorda et al. (2023) including N3LO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
ndarray
|
The quark chemical potential. |
required |
scaled
|
bool
|
Whether the data is scaled or not. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
p_n3lo |
ndarray
|
The pressure at N3LO. |
Source code in src/neutron_rich_bmm/pqcd.py
pressure_n_FG(n)
FG pressure with respect to number density n.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
ndarray
|
The baryon number density. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
p_n_FG |
ndarray
|
The FG pressure as a function of density. |
Source code in src/neutron_rich_bmm/pqcd.py
Truncation(x, x_FG, norders, orders, yref, expQ, coeffs, mask=None)
The truncation error class that wraps the gsum package. For use on the pQCD EOS results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Quark chemical potential. |
required |
x_FG
|
2D array
|
FG quark chemical potential. |
required |
norders
|
int
|
Number of orders used. |
required |
orders
|
list
|
The list of orders ([0 1 2], etc.) |
required |
yref
|
function
|
Functional form for yref. |
required |
expQ
|
function
|
Functional form for the expansion parameter. |
required |
coeffs
|
array
|
The coefficient array of arrays. Must be transposed when sent in to this class. |
required |
mask
|
bool array
|
If using a mask, send the mask in here. |
None
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/truncation_error.py
diagnostics(dx_train=30, dx_test=15)
The diagnostic function to check the validity of the truncation error obtained via gsum. Uses gsum to perform Mahalanobis distance and pivoted Cholesky calculations. Plots the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dx_train
|
int
|
The number to use as a step size for the training data. |
30
|
dx_test
|
int
|
The number to use as a step size for the testing data. |
15
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/truncation_error.py
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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
gp_interpolation(center=0.0, sd=1.0)
The function responsible for fitting the coefficients with a GP and predicting at new points. This information will be used in constructing our truncated GP in the function 'Uncertainties'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
The center value for the prior. |
0.0
|
sd
|
float
|
The scale for the prior. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
pred |
array
|
An array of predictions from the GP. |
std |
array
|
The standard deviation at the points in 'pred'. |
underlying_std |
array
|
The underlying standard deviation of the GP. |
Source code in src/neutron_rich_bmm/truncation_error.py
gp_kernel(ls=3.0, sd=0.5, center=0, nugget=1e-10)
The kernel that we will use both for interpolating the coefficients and for predicting the truncation error bands. This one is unfixed, so the value of the ls obtained here will be used to fix the second run when calling params attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ls
|
float
|
The lengthscale guess for the kernel. |
3.0
|
sd
|
float
|
The scale for the prior. |
0.5
|
center
|
float
|
The center value for the prior. |
0
|
nugget
|
(int, float)
|
The value of the nugget to send to the Cholesky decomposition. |
1e-10
|
Returns:
| Name | Type | Description |
|---|---|---|
kernel |
sklearn object
|
The kernel needed for the GPs. |
Source code in src/neutron_rich_bmm/truncation_error.py
gp_mask(mu)
The mask array needed to correctly separate our training and testing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
array
|
The chemical potential linspace needed. |
required |
Returns:
| Type | Description |
|---|---|
|
self.mask (array): The mask for use when interpolating or using the truncated GP. |
Source code in src/neutron_rich_bmm/truncation_error.py
uncertainties(data=None, expQ=None, yref=None, sd=0.5, nugget=1e-10, excluded=None)
Calculation of the truncation error bands for the pQCD EOS, using the Gorda et al. (2021) formulation for the pressure. This function uses techniques from the gsum package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array
|
The data given in an array of arrays for each order-by-order result. |
None
|
expQ
|
function
|
The functional form of the expansion parameter for gsum to use. |
None
|
yref
|
function
|
The functional form of yref for gsum to use. |
None
|
sd
|
float
|
The scale for the prior. |
0.5
|
nugget
|
(int, float)
|
The nugget for the Cholesky decomposition. |
1e-10
|
excluded
|
list
|
The orders we wish to exclude from training on in the coefficient arrays. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
array
|
The data array, containing partials at each order. |
|
self.coeffs (array): The values of the coefficents at x. |
||
std_trunc |
array
|
The arrays of truncation errors per each order. |
Source code in src/neutron_rich_bmm/truncation_error.py
TruncationDens(nb, norders, orders, yref, expQ, coeffs, mask=None)
The truncation error class that wraps the gsum package. For use on the pQCD EOS results, in density (KLW).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nb
|
array
|
Baryon number density. |
required |
norders
|
int
|
Number of orders used. |
required |
orders
|
list
|
The list of orders ([0 1 2], etc.) |
required |
yref
|
function
|
Functional form for yref, dependent on the number density. |
required |
expQ
|
function
|
Functional form for the expansion parameter, dependent on the number density. |
required |
coeffs
|
array
|
The coefficient array of arrays. Must be transposed when sent in to this class. Dependent on number density. |
required |
mask
|
boolean array
|
If using a mask over some orders, send the mask in here. |
None
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/neutron_rich_bmm/truncation_error_dens.py
diagnostics(dx_train=30, dx_test=15)
The diagnostic function to check the validity of the truncation error obtained via gsum. Uses gsum to perform Mahalanobis distance and pivoted Cholesky calculations. Plots the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dx_train
|
int
|
The number to use as a step size for the training data. |
30
|
dx_test
|
int
|
The number to use as a step size for the testing data. |
15
|
Returns:
| Type | Description |
|---|---|
|
None |
Source code in src/neutron_rich_bmm/truncation_error_dens.py
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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
gp_interpolation(center=0.0, dof=3.0, sd=1.0)
The function responsible for fitting the coefficients with a GP and predicting at new points. This information will be used in constructing our truncated GP in the function 'Uncertainties'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
The center value for the prior. |
0.0
|
sd
|
float
|
The scale for the prior. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
pred |
ndarray
|
An array of predictions from the GP. |
std |
ndarray
|
The standard deviation at the points in 'pred'. |
underlying_std |
ndarray
|
The underlying standard deviation of the GP. |
Source code in src/neutron_rich_bmm/truncation_error_dens.py
gp_kernel(ls=3.0, sd=0.5, center=0, nugget=1e-10)
The kernel that we will use both for interpolating the coefficients and for predicting the truncation error bands. This one is unfixed, so the value of the ls obtained here will be used to fix the second run when calling params attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ls
|
float
|
The lengthscale guess for the kernel. |
3.0
|
sd
|
float
|
The scale for the prior. |
0.5
|
center
|
float
|
The center value for the prior. |
0
|
nugget
|
(int, float)
|
The value of the nugget to send to the Cholesky decomposition. |
1e-10
|
Returns:
| Name | Type | Description |
|---|---|---|
kernel |
sklearn object
|
The kernel needed for the GPs. |
Source code in src/neutron_rich_bmm/truncation_error_dens.py
gp_mask(nb)
The mask array needed to correctly separate our training and testing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nb
|
ndarray
|
The number density linspace needed. |
required |
Returns:
| Type | Description |
|---|---|
|
self.mask (numpy.ndarray): The mask for use when interpolating or using the truncated GP. |
Source code in src/neutron_rich_bmm/truncation_error_dens.py
uncertainties(data=None, expQ=None, yref=None, dof=3.0, sd=0.5, nugget=1e-10, excluded=None)
Calculation of the truncation error bands for the pQCD EOS, using the Gorda et al. (2023) formulation for the pressure. This function uses techniques from the gsum package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The data given in an array of arrays for each order-by-order result. |
None
|
expQ
|
function
|
The functional form of the expansion parameter for gsum to use. |
None
|
yref
|
function
|
The functional form of yref for gsum to use. |
None
|
sd
|
float
|
The scale for the prior. |
0.5
|
nugget
|
(int, float)
|
The nugget for the Cholesky decomposition. |
1e-10
|
excluded
|
list
|
The orders we wish to exclude from training on in the coefficient arrays. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
ndarray
|
The data array, containing partials at each order. |
|
self.coeffs (numpy.ndarray): The values of the coefficents at nb. |
||
std_trunc |
ndarray
|
The arrays of truncation errors per each order. |