API Reference
This section provides a detailed reference for the code in the Star Log-extended eMulator package.
SLM
augment_data_multiple_columns(X)
Augment the data matrix X with nonlinear terms for multiple variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
The data matrix where each row is a variable, and each column is a snapshot in time. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
augmented_X |
ndarray
|
The augmented data matrix with nonlinear terms. |
Source code in src/slmemulator/SLM.py
SLM(X, dt, error_threshold=0.0001, max_r=None)
Dynamic Mode decomposition for the augmented Data. Automatically determines the number of modes (r) based on an error threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
The data matrix where each row is a variable, and each column is a snapshot in time. Expected to be log-transformed where appropriate. |
required |
dt
|
float
|
The time difference of linear DMDs. |
required |
error_threshold
|
float
|
(Optional) The maximum allowed absolute difference between the original data and the DMD reconstruction. Defaults to 1e-4. |
0.0001
|
max_r
|
int
|
(Optional) The maximum number of modes to consider. If None, it will go up to the maximum possible rank (min(X.shape)). |
None
|
Source code in src/slmemulator/SLM.py
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 | |
solve_tov(fileName, tidal=False, parametric=False, mseos=True)
Solves the TOV equation and returns radius, mass and central pressure
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileName
|
str
|
Filename containing the EOS in the format nb (fm^-3), E (MeV), P (MeV/fm^3) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dataArray |
array
|
Data array containing radii, central pressure and mass (includes tidal deformability k_2 if set to true). |
Source code in src/slmemulator/SLM.py
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 | |
cleanData
clean_directory(directory: Optional[str] = None) -> None
Recursively cleans a specified directory by removing common project artifacts and specific, code-generated subdirectories.
The function targets temporary files (by extension) and removes specific directories generated during modeling, plotting, and data processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
The path to the directory to clean. If :obj: |
None
|
defaults to cleaning the **current working directory** (
|
func: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The function modifies the filesystem but does not return a value. |
Source code in src/slmemulator/cleanData.py
config
get_paths(output_base_dir: Optional[Path] = None, eos_name: str = 'MSEOS', is_parametric_run: bool = True, include_slm_paths: bool = True) -> Dict[str, Path]
Generates and returns a dictionary of resolved project paths, dynamically structuring subdirectories based on the Equation of State (EOS) name and run configuration.
The function provides paths for input data, model binaries, general output, and specific subdirectories for results, plots, and test data related to SLM (Sparse Linear Modeling) or pSLM (parametric SLM) runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_base_dir
|
Path
|
The root directory where all generated project outputs (results, plots,
test data) will be stored. If |
None
|
eos_name
|
str
|
The name of the Equation of State (e.g., "MSEOS", "QEOS", "APR"). This name dictates the specific subdirectory created for the current run within the results, plots, and test directories. Defaults to "MSEOS". |
'MSEOS'
|
is_parametric_run
|
bool
|
Flag indicating if the current modeling run is using the parametric SLM
(pSLM) approach. If |
True
|
include_slm_paths
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
Dict[str, Path]
|
dict[str, pathlib.Path]: A dictionary containing all relevant path configurations. Keys include: |
Source code in src/slmemulator/config.py
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 | |
create_necessary_dirs(paths: Dict[str, Path], additional_dirs: Optional[List[Path]] = None) -> None
Creates necessary directories specified in a dictionary and an optional list.
This function iterates through all Path objects provided in the input dictionary's values and the optional list, ensuring that each directory is created if it does not already exist. It uses pathlib.Path.mkdir with parents=True and exist_ok=True, meaning it will create parent directories if necessary and will not raise an error if the directory already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
dict[str, Path]
|
A dictionary where keys are string identifiers (e.g., 'output_path')
and values are :class: |
required |
additional_dirs
|
list[Path]
|
An optional list of additional :class: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The function modifies the filesystem but does not return a value. |
Source code in src/slmemulator/config.py
pSLM
ParametricSLM(fileList, filePath, tidal=False, error_threshold=0.0001, max_r=None)
Source code in src/slmemulator/pSLM.py
augment_data(X)
staticmethod
Augments the input data X by adding quadratic terms (X_i * X_j).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Original data matrix (n, m). |
required |
Returns:
| Type | Description |
|---|---|
|
np.ndarray (np.ndarray): Augmented data matrix. |
Source code in src/slmemulator/pSLM.py
fit()
Fits the Parametric SLM model by processing each file in fileList, performing DMD, and storing the DMD components along with extracted parameters.
Source code in src/slmemulator/pSLM.py
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 | |
predict(param_values, k=1, output_interp=False, distance_threshold=None)
Predicts the dynamics (Xdmd) for a given set of parameters by finding nearest neighbors in the parameter space and averaging their DMD components or using the closest one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param_values
|
list or ndarray
|
A list or array of parameter values to predict for (e.g., [Ls, Lv, zeta, xi] for MSEOS). This argument is mandatory. |
required |
k
|
int
|
Number of nearest neighbors to use for prediction. Defaults to 1 (pure nearest neighbor). |
1
|
output_interp
|
bool
|
If True, interpolate the final Xdmd outputs by averaging curves. If False (default) and k>1, averages the DMD components (Phi, omega, D, b). |
False
|
distance_threshold
|
float
|
If the distance to the closest neighbor exceeds this threshold, a warning is printed. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(Phi_avg/Phi_nn, omega_avg/omega_nn, D_avg/D_nn, b_avg/b_nn, Xdmd_predicted, t) - Reconstructed data (Xdmd_predicted) and related averaged DMD components. |
Raises: ValueError: If the model has not been fitted or no training data is available.
Source code in src/slmemulator/pSLM.py
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 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 | |
is_on_boundary(param, param_min, param_max, tolerance=1e-05)
Checks if a parameter set is on the boundary of the parameter space.
Source code in src/slmemulator/pSLM.py
recombination
gaussian_rbf(r, epsilon)
recombination_thinning(A_matrix, y_vector, initial_solution_x=None, tolerance=1e-09)
Conceptual implementation of the recombination thinning process based on the paper. This function aims to find a sparse solution x' to the linear system Ax = y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A_matrix
|
array
|
The matrix A in the linear system Ax = y. In the context of GRIM, this matrix relates features and linear functionals. |
required |
y_vector
|
array
|
The vector y in the linear system Ax = y. In the context of GRIM, this relates to the target function evaluated by linear functionals. |
required |
initial_solution_x
|
array
|
An initial solution vector x. If None, a least squares solution is computed. |
None
|
tolerance
|
float
|
Tolerance for numerical stability, especially for SVD and checking non-zero components. |
1e-09
|
Returns:
| Type | Description |
|---|---|
|
np.array: A sparser solution vector x' for the system Ax = y. Returns None if the system is inconsistent or other issues. |
Source code in src/slmemulator/recombination.py
scaledTOV
This code solves TOV equations for mass radius relations. This can also plot the mass-radius curve.
USE: To use the code, here are the steps: 1) Include the file in your main code e.g. import tov_class as tc 2) Load the EoS using the ToV loader, tc.ToV(filename, arraysize) 3) call the solver as tc.ToV.mass_radius(min_pressure, max_pressure) 4) To plot, follow the code in main() on creating the dictionary of inputs
Updates: Solves ToV, can only take inputs of pressure (MeV/fm^3), energy density in MeV, baryon density in fm^-3 in ascending order.
TOV(filename, imax)
Solves TOV equations and gives data-table, mass-radius plot and max. mass, central pressure and central density by loading an EoS datafile.
Source code in src/slmemulator/scaledTOV.py
pressure_from_nb(nb: Union[float, np.ndarray]) -> Union[float, np.ndarray]
Evaluates scaled pressure (\(P/P_0\)) given the baryon number density (\(n_B\)) using linear interpolation of the loaded Equation of State (EOS) data.
This function uses :func:scipy.interpolate.interp1d to create an
interpolating function based on the input baryon number density
(:attr:self.nb_in) and scaled pressure (:attr:self.p_in) from the
loaded EOS table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nb
|
float or ndarray
|
The baryon number density (or an array of densities) at which to |
required |
Returns:
| Type | Description |
|---|---|
Union[float, ndarray]
|
float or numpy.ndarray: |
Union[float, ndarray]
|
The interpolated scaled pressure (\(P/P_0\)) value(s) corresponding to |
Union[float, ndarray]
|
the input number density |
Source code in src/slmemulator/scaledTOV.py
energy_from_pressure(pressure: Union[float, np.ndarray]) -> Union[float, np.ndarray]
Evaluates scaled energy density (\(\epsilon/\epsilon_0\)) given the scaled pressure (\(P/P_0\)) using linear interpolation of the loaded Equation of State (EOS) data.
This method handles pressures near zero with a special case for numerical stability.
pressure (float or numpy.ndarray): The scaled pressure (\(P/P_0\)) value(s) at which to evaluate the corresponding scaled energy density.
Returns:
| Type | Description |
|---|---|
Union[float, ndarray]
|
float or numpy.ndarray: The interpolated scaled energy density (\(\epsilon/\epsilon_0\)) value(s). |
Source code in src/slmemulator/scaledTOV.py
pressure_from_energy(energy: Union[float, np.ndarray]) -> Union[float, np.ndarray]
Evaluates scaled pressure (\(P/P_0\)) given the scaled energy density (\(\epsilon/\epsilon_0\)) using linear interpolation of the loaded Equation of State (EOS) data.
This function defines the inverse of the \(\epsilon(P)\) relation.
energy (float or numpy.ndarray): The scaled energy density (\(\epsilon/\epsilon_0\)) value(s) at which to evaluate the corresponding scaled pressure.
Returns:
| Type | Description |
|---|---|
Union[float, ndarray]
|
float or numpy.ndarray: The interpolated scaled pressure (\(P/P_0\)) value(s) corresponding to |
Union[float, ndarray]
|
the input scaled energy density. |
Source code in src/slmemulator/scaledTOV.py
baryon_from_energy(energy)
Evaluate number density from energy using interpolation
RK4(f, x0, t0, te, N)
A simple RK4 solver to avoid overhead of calculating with solve_ivp or any other adaptive step-size function.
Example
tov.RK4(f=func, x0=1., t0=1., te=10., N=100)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
func
|
A Python function for the ODE(s) to be solved. Able to solve N coupled ODEs. |
required |
x0
|
float
|
Guess for the function(s) to be solved. |
required |
t0
|
float
|
Initial point of the grid. |
required |
te
|
float
|
End point of the grid. |
required |
N
|
int
|
The number of steps to take in the range (te-t0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
times |
array
|
The grid of solution steps. |
solution |
array
|
The solutions of each function at each point in the grid. |
Source code in src/slmemulator/scaledTOV.py
TOV_class
TOV(eos_filepath=None, tidal=False, solver='RK4', solve_ivp_kwargs=None, sol_pts=4000)
inertia using RK4. Also includes uncertainty quantification techniques through the highest posterior density interval (HPD or HDI) calculation. Able to accept one EOS from a single curve or draws from an EOS, such as from a Gaussian Process.
Example
tov = TOVSolver(eos_filepath='path/to/eos', tidal=True, moment=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eos_filepath
|
str
|
The path to the EOS data table to be used. |
None
|
tidal
|
bool
|
Whether to calculate tidal deformability or not. Default is False. |
False
|
moment
|
bool
|
Whether to calculate moment of inertia or not. Default is False. |
required |
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in src/slmemulator/TOV_class.py
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 | |
RK4(f, x0, t0, te, N)
A simple RK4 solver to avoid overhead of calculating with solve_ivp or any other adaptive step-size function.
Example
tov.RK4(f=func, x0=1., t0=1., te=10., N=100)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
func
|
A Python function for the ODE(s) to be solved. Able to solve N coupled ODEs. |
required |
x0
|
float
|
Guess for the function(s) to be solved. |
required |
t0
|
float
|
Initial point of the grid. |
required |
te
|
float
|
End point of the grid. |
required |
N
|
int
|
The number of steps to take in the range (te-t0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
times |
array
|
The grid of solution steps. |
solution |
array
|
The solutions of each function at each point in the grid. |
Source code in src/slmemulator/TOV_class.py
RK2(f, x0, t0, te, N)
A simple RK2 solver using the Heun's method. This is a low-fidelity solver.
Example
tov.RK2(f=func, x0=1., t0=1., te=10., N=100)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
func
|
A Python function for the ODE(s) to be solved. Able to solve N coupled ODEs. |
required |
x0
|
float
|
Guess for the function(s) to be solved. |
required |
t0
|
float
|
Initial point of the grid. |
required |
te
|
float
|
End point of the grid. |
required |
N
|
int
|
The number of steps to take in the range (te-t0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
times |
array
|
The grid of solution steps. |
solution |
array
|
The solutions of each function at each point in the grid. |
Source code in src/slmemulator/TOV_class.py
euler(f, x0, t0, te, N)
A simple forward euler solver to avoid overhead of calculating with solve_ivp or any other adaptive step-size function. This is a low fidelity solver!
Example
tov.euler(f=func, x0=1., t0=1., te=10., N=100)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
func
|
A Python function for the ODE(s) to be solved. Able to solve N coupled ODEs. |
required |
x0
|
float
|
Guess for the function(s) to be solved. |
required |
t0
|
float
|
Initial point of the grid. |
required |
te
|
float
|
End point of the grid. |
required |
N
|
int
|
The number of steps to take in the range (te-t0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
times |
array
|
The grid of solution steps. |
solution |
array
|
The solutions of each function at each point in the grid. |
Source code in src/slmemulator/TOV_class.py
tov_equations_scaled(x, y0)
The Tolman-Oppenheimer-Volkoff equations in scaled format, to be solved with the RK4 routine. If selected, the tidal deformability and moment of inertia will be included and solved simultaneously.
Example
tov.tov_equations_scaled(x=0.2, y0=[m_init, p_init])
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
A point in the scaled radius grid. |
required |
y0
|
list
|
The list of initial guesses for each function solved. |
required |
Returns:
| Type | Description |
|---|---|
|
The solutions, in array format, of each function to be solved. |
Source code in src/slmemulator/TOV_class.py
f_x(x, mass, pres, eps)
A function in the tidal deformability calculation.
Example
tov.f_x(x=0.2, mass=1.06, pres=2.34, eps=6.0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The current gridpoint in scaled radius. |
required |
mass
|
float
|
The current mass. |
required |
pres
|
float
|
The current pressure from the EOS. |
required |
eps
|
float
|
The current energy density from the EOS. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of F(x) at the current radius. |
Source code in src/slmemulator/TOV_class.py
q_x(x, mass, pres, eps, cs2)
A function in the calculation of the tidal deformability.
Example
tov.q_x(x=0.1, mass=2.0, pres=1.0, eps=3.0, cs2=0.33)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The current gridpoint in scaled radius. |
required |
mass
|
float
|
The current mass. |
required |
pres
|
float
|
The current pressure from the EOS. |
required |
eps
|
float
|
The current energy density from the EOS. |
required |
cs2
|
float
|
The current speed of sound from the EOS. |
required |
Returns:
| Type | Description |
|---|---|
|
The value of Q(x) at the current radius. |
Source code in src/slmemulator/TOV_class.py
tidal_def(yR, mass, radius)
The calculation of the tidal deformability, Lambda, and the tidal Love number, k2. This function is calculated after the RK4 routine has been completed.
Example
tov.tidal_def(yR=np.array, mass=np.array, radius=np.array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yR
|
float
|
The array of y at the maximum radii points. |
required |
mass
|
float
|
The array of mass at the maximum radii. |
required |
radius
|
float
|
The maximum radii array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tidal_deform |
array
|
The tidal deformability solved at each point in the maximum radius. |
k2 |
array
|
The value of the Love number calculated at the compactness M/R and the value of y at maximum radius. |
Source code in src/slmemulator/TOV_class.py
tov_routine(verbose=False, write_to_file=False)
The TOV routine to solve each set of coupled ODEs and to output the quantities needed to display the M-R curve, as well as the tidal deformability and moment of inertia if desired.
Example
tov.tov_routine(verbose=True, write_to_file=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
Whether to plot quantities and display the full maximum mass array. Default is False. |
False
|
write_to_file
|
bool
|
Choice to write the TOV results to a file located in a folder of the user's choice. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
|
self.total_radius (array): The array of total maximum radius values. |
|
|
self.total_pres_central (array): The array of total central pressure values. |
|
|
self.total_max_mass (array): The array of total maximum mass values. |
Source code in src/slmemulator/TOV_class.py
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 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 547 548 549 550 551 552 553 554 555 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 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 | |
max_arrays()
Returns the max arrays needed for the interval calculation.
Returns:
| Type | Description |
|---|---|
|
self.max_radius_arr (array): Maximum radius array. |
|
|
self.max_pres_arr (array): Maximum central pressure array. |
|
|
self.max_mass_arr (array): Maximum mass array. |
Source code in src/slmemulator/TOV_class.py
central_dens(pres_arr=None)
Calculation to determine the central density of the star at the maximum mass and radius determined from the tov_routine().
Example
tov.central_dens()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pres_arr
|
array
|
An optional pressure array to use for calculating central densities at places other than the absolute TOV maximum mass of each curve. Default is None, and code will use absolute TOV maximum mass central pressure class array. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
c_dens |
array
|
The array of central densities for each EOS used. |
Source code in src/slmemulator/TOV_class.py
canonical_NS_radius()
Calculation of the radius of a 1.4 M_sol neutron star.
Example
tov.canonical_NS_radius()
Returns:
| Name | Type | Description |
|---|---|---|
rad_14 |
array
|
The array of values of the radius for each EOS used. |
Source code in src/slmemulator/TOV_class.py
tovScaledRev
Information about the code: This code solves TOV equations for mass radius relations. This can also plot the mass-radius curve.
The code solves dr/dp and dm/dp instead of the regular way.
USE: To use the code, here are the steps: 1) Include the file in your main code e.g. import tov_class as tc 2) Load the EoS using the ToV loader, tc.ToV(filename, arraysize) 3) call the solver as tc.ToV.mass_radius(min_pressure, max_pressure) 4) To plot, follow the code in main() on creating the dictionary of inputs
Updates: Version 0.0.1-1 Solves ToV, can only take inputs of pressure (MeV/fm^3), energy density in MeV, baryon density in fm^-3 in ascending order.
TOV(filename, imax, tidal=False)
Solves TOV equations and gives data-table, mass-radius plot and max. mass, central pressure and central density by loading an EoS datafile.
Source code in src/slmemulator/tovScaledRev.py
pressure_from_nb(nb)
Evaluate pressure from number density using interpolation
energy_from_pressure(pressure)
Evaluate energy density from pressure using interpolation
Source code in src/slmemulator/tovScaledRev.py
pressure_from_energy(energy)
Evaluate pressure from energy density using interpolation
baryon_from_energy(energy)
Evaluate number density from energy using interpolation