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 quadratic and cross-product terms appended below the original rows. |
Source code in src/slmemulator/SLM.py
SLM(X, dt, error_threshold=0.0001, max_r=None)
Dynamic Mode Decomposition of 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, goes up to the maximum possible rank (min(X.shape)). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(Phi, omega, lambda_vals, b, Xdmd, S, r_optimal) where Phi are |
|
|
the DMD modes (truncated to the original variables), omega the |
||
|
continuous-time eigenvalues, lambda_vals the discrete-time |
||
|
eigenvalues, b the mode amplitudes, Xdmd the reconstruction of the |
||
|
original (non-augmented) variables, S the singular values of the |
||
|
augmented snapshot matrix, and r_optimal the selected rank. |
Source code in src/slmemulator/SLM.py
solve_tov(fileName, tidal=False, parametric=False, mseos=True)
Solves the TOV equation and returns radius, central pressure and mass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileName
|
str
|
Filename containing the EOS in the format nb (fm^-3), E (MeV), P (MeV/fm^3). For non-parametric runs this is the name of a file in the packaged EOS_Data; for parametric runs it is looked up in the generated EOS_files directory. |
required |
tidal
|
bool
|
Also compute the tidal Love number k2. Default False. |
False
|
parametric
|
bool
|
Whether the EOS file comes from a parametric run. |
False
|
mseos
|
bool
|
For parametric runs, MSEOS (True) or Quarkyonia (False). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dataArray |
ndarray
|
Data array containing radii, central pressure and mass (includes tidal deformability k_2 if tidal is True). |
Source code in src/slmemulator/SLM.py
cleanData
clean_directory(directory: str | None = 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
Project path configuration for slmemulator.
get_paths(output_base_dir: Path | None = 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 (Star Log-extended eMulator) 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 |
dict[str, Path]
|
configurations. |
Source code in src/slmemulator/config.py
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 | |
create_necessary_dirs(paths: dict[str, Path], additional_dirs: list[Path] | None = None) -> None
Creates necessary directories specified in a dictionary and an optional list.
Iterates through the known output-directory keys of paths (plus any
additional_dirs) and creates each directory if it does not already
exist (mkdir(parents=True, exist_ok=True)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
dict[str, Path]
|
A dictionary as returned by
:func: |
required |
additional_dirs
|
list[Path]
|
Additional directories to create (e.g., user-managed data or model directories). Defaults to None. |
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
Parametric SLM built on Banach-GRIM kernel interpolation.
Fits directly on TOV data files (columns: radius, central pressure, mass [, k2]) computed at known EOS parameters, and predicts the log-curves at new parameter values by kernel interpolation of the full curve matrices across min-max-normalized parameter space.
This replaces the earlier k-nearest-neighbour version: k-NN averaging of DMD components is piecewise constant in parameter space and ill-posed for the eigenpairs (mode ordering/sign ambiguity), whereas kernel interpolation of the curves is exact at the training points and smooth in between. The DMD components returned by predict() are computed from the predicted curve, so they are always self-consistent.
For an end-to-end emulator that also generates the training data (EOS generation + TOV solves), see slmemulator.TOVEmulator.
ParametricSLM(fileList, filePath=None, tidal=False, params=None, reg=1e-10, length_scale=None, error_threshold=1e-06, max_r=None)
Parametric SLM over a set of TOV data files.
Example
pslm = ParametricSLM(fileList, filePath, tidal=True, params=[[300, 0.1], [300, 0.3], ...]) pslm.fit() Phi, omega, eigs, b, Xdmd, t = pslm.predict([400.0, 0.2])
Parameters
fileList : sequence of str or Path TOV data files; each contains columns radius (km), central pressure (MeV/fm^3), mass (M_sun) and, if tidal, k2. All files must share the same number of rows. filePath : str or Path, optional Directory prepended to relative file names. tidal : bool Whether the files carry a 4th (k2) column to be used. Default False. params : array-like (n_files, n_params), optional EOS parameters of each file, in the same order as fileList. If not given, parameters are parsed from the file names (every underscore- separated token of the stem that parses as a float) — prefer passing them explicitly, since file-name parsing cannot recover values whose decimal points were replaced by underscores. reg : float Tikhonov regularization of the kernel interpolant. Default 1e-10. length_scale : float, optional RBF length scale in normalized parameter units (default: median pairwise distance of the normalized training parameters). error_threshold, max_r : Passed to SLM() when computing DMD components of predicted curves.
Source code in src/slmemulator/pSLM.py
params_from_filename(file_path)
staticmethod
Extract EOS parameters from a file name: every underscore-separated token of the stem that parses as a float (e.g. 'MR_3.00e+02_1.00e-01.txt' -> [300.0, 0.1]).
Source code in src/slmemulator/pSLM.py
fit()
Load all training files and fit the kernel interpolant.
Source code in src/slmemulator/pSLM.py
predict_log(theta)
Interpolated log-curve matrix (n_quantities, n_points) at theta.
Source code in src/slmemulator/pSLM.py
predict_curves(theta)
predict(theta, dt=1.0)
Predict at parameter vector theta.
Returns (Phi, omega, eigs, b, Xdmd, t) — the same shape of result as the earlier k-NN implementation, but the DMD components are computed from the kernel-interpolated curve, so they are self-consistent. Xdmd is the log-space SLM reconstruction; np.exp(Xdmd.real) gives the physical curves.
Source code in src/slmemulator/pSLM.py
gaussian_kernel(x1, x2, sigma=1.0)
Gaussian kernel between two parameter vectors (kept for backward compatibility; the interpolation itself uses banach_grim.rbf_kernel).
Source code in src/slmemulator/pSLM.py
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
Recombination thinning for the Banach GRIM algorithm (arXiv:2205.07495).
The implementation lives in banach_grim.py (so that module stays self-contained); this module re-exports it alongside the Gaussian RBF helper.
recombination_thinning(M, weights, tol=1e-12, max_iter=None)
Reduce the support of nonnegative weights while preserving linear moments.
Given M of shape (r, N) and weights w >= 0 of shape (N,), returns
new weights b >= 0 with M @ b == M @ w (to numerical precision) and
support of at most r atoms (fewer if M's active columns are rank
deficient). This is the recombination step of the Banach GRIM algorithm
(Lemma 3.1 of arXiv:2205.07495): with an all-ones row included in M, the
total mass sum(b) == sum(w) is preserved as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
M
|
ndarray
|
Constraint matrix, shape (r, N). Row k holds the values of the k-th linear functional on the N atoms. |
required |
weights
|
ndarray
|
Nonnegative weights, shape (N,). |
required |
tol
|
float
|
Singular values below |
1e-12
|
max_iter
|
int
|
Safety cap on elimination steps (default N). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
b |
ndarray
|
Nonnegative weights, shape (N,), with
|
Source code in src/slmemulator/banach_grim.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 = TOV(eos_filepath='path/to/eos', tidal=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eos_filepath
|
str or Path
|
The path to the EOS data table to be used. Supported formats: .table (compOSE), .dat/.txt (columns nb, E, P[, cs2]), and .npz (keys density, edens, pres, cs2). |
None
|
tidal
|
bool
|
Whether to calculate tidal deformability or not. Default is False. |
False
|
solver
|
str
|
One of "RK4", "RK2", "euler", or "solve_ivp". Default is "RK4". |
'RK4'
|
solve_ivp_kwargs
|
dict
|
Keyword arguments passed to scipy.integrate.solve_ivp (only used when solver="solve_ivp"). |
None
|
sol_pts
|
int
|
Number of integration steps for the fixed-step solvers. Default is 4000. |
4000
|
Source code in src/slmemulator/TOV_class.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
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 or array - like
|
Initial value(s) of 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 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 or array - like
|
Initial value(s) of 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 or array - like
|
Initial value(s) of 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
tovsolve(pcent)
Solves the TOV equations for a single central pressure and returns the stellar profile up to the surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pcent
|
float
|
Central pressure in scaled units (P/pres0). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
solns |
ndarray
|
Columns of radius (km), pressure (MeV/fm^3) and mass (M_sun); the metric function y is appended as a fourth column when tidal is True. |
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_mass (array): The array of total maximum mass values. |
|
|
When tidal is True, self.k2 and self.tidal_deformability are |
|
|
returned as well. |
Source code in src/slmemulator/TOV_class.py
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 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
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 |
float or array
|
The central density, one value per EOS draw. |
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 |
float or array
|
The 1.4 M_sol radius, one value per EOS draw. |
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