API reference¶
Generated from the docstrings. Only the names in __all__ of each package are
covered by the compatibility promise; see
Public API and conventions for the rules that apply to all of them.
Metrics¶
warpica.metrics ¶
Metric generators and 3+1 tools.
Every name in __all__ is part of the supported public API.
metric_get_alcubierre ¶
metric_get_alcubierre(grid_size: GridSize, world_centre: Vector, v: float, R: float, sigma: float, grid_scale: Vector | None = None) -> TensorDict
Build the Alcubierre metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R
|
float
|
Bubble radius in spatial coordinate units. |
required |
sigma
|
float
|
Wall steepness, in inverse spatial coordinate units. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +).
metric_get_alcubierre_comoving ¶
metric_get_alcubierre_comoving(grid_size: GridSize, world_centre: Vector, v: float, R: float, sigma: float, grid_scale: Vector | None = None) -> TensorDict
Build the Alcubierre metric in comoving coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R
|
float
|
Bubble radius in spatial coordinate units. |
required |
sigma
|
float
|
Wall steepness, in inverse spatial coordinate units. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +). The comoving construction requires a single time slice.
metric_get_lentz ¶
metric_get_lentz(grid_size: GridSize, world_centre: Vector, v: float, scale: float | None, grid_scale: Vector | None = None) -> TensorDict
Build the Lentz metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
scale
|
float or None
|
Size of the piecewise Lentz regions. None uses the largest spatial grid dimension divided by seven. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +).
metric_get_lentz_comoving ¶
metric_get_lentz_comoving(grid_size: GridSize, world_centre: Vector, v: float, scale: float | None, grid_scale: Vector | None = None) -> TensorDict
Build the Lentz metric in comoving coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
scale
|
float or None
|
Size of the piecewise Lentz regions. None uses the largest spatial grid dimension divided by seven. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +). The comoving construction requires a single time slice.
metric_get_minkowski ¶
metric_get_minkowski(grid_size: GridSize, grid_scaling: Vector | None = None) -> TensorDict
Build the Minkowski metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +).
metric_get_modified_time ¶
metric_get_modified_time(grid_size: GridSize, world_centre: Vector, v: float, R: float, sigma: float, A: float, grid_scaling: Vector | None = None) -> TensorDict
Build the modified-time metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R
|
float
|
Bubble radius in spatial coordinate units. |
required |
sigma
|
float
|
Wall steepness, in inverse spatial coordinate units. |
required |
A
|
float
|
Lapse modification factor; the interior lapse approaches 1 / A. |
required |
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +).
metric_get_modified_time_comoving ¶
metric_get_modified_time_comoving(grid_size: GridSize, world_centre: Vector, v: float, R: float, sigma: float, A: float, grid_scaling: Vector | None = None) -> TensorDict
Build the modified-time metric in comoving coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R
|
float
|
Bubble radius in spatial coordinate units. |
required |
sigma
|
float
|
Wall steepness, in inverse spatial coordinate units. |
required |
A
|
float
|
Lapse modification factor; the interior lapse approaches 1 / A. |
required |
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +). The comoving construction requires a single time slice.
metric_get_schwarzschild ¶
metric_get_schwarzschild(grid_size: GridSize, world_centre: Vector, r_s: float, grid_scaling: Vector | None = None) -> TensorDict
Build the Schwarzschild metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
r_s
|
float
|
Schwarzschild radius in spatial coordinate units. |
required |
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +) and requires a single time slice. For nonzero r_s, the grid must exclude the origin and coordinate horizon.
metric_get_van_den_broeck ¶
metric_get_van_den_broeck(grid_size: GridSize, world_centre: Vector, v: float, R_1: float, sigma_1: float, R_2: float, sigma_2: float, A: float, grid_scale: Vector | None = None) -> TensorDict
Build the Van den Broeck metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R_1
|
float
|
Radius of the inner spatial-expansion profile. |
required |
sigma_1
|
float
|
Steepness of the inner profile. |
required |
R_2
|
float
|
Radius of the outer shift profile. |
required |
sigma_2
|
float
|
Steepness of the outer profile. |
required |
A
|
float
|
Amplitude of the spatial-expansion profile. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +). The effective velocity parameter is v * (1 + A)**2.
metric_get_van_den_broeck_comoving ¶
metric_get_van_den_broeck_comoving(grid_size: GridSize, world_centre: Vector, v: float, R_1: float, sigma_1: float, R_2: float, sigma_2: float, A: float, grid_scale: Vector | None = None) -> TensorDict
Build the Van den Broeck metric in comoving coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
v
|
float
|
Bubble speed parameter in units of the speed of light. |
required |
R_1
|
float
|
Radius of the inner spatial-expansion profile. |
required |
sigma_1
|
float
|
Steepness of the inner profile. |
required |
R_2
|
float
|
Radius of the outer shift profile. |
required |
sigma_2
|
float
|
Steepness of the outer profile. |
required |
A
|
float
|
Amplitude of the spatial-expansion profile. |
required |
grid_scale
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order, in seconds and metres. Defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
Notes
The metric uses signature (-, +, +, +). The comoving construction requires a single time slice. The effective velocity parameter is v * (1 + A)**2.
metric_get_warp_shell_comoving ¶
metric_get_warp_shell_comoving(grid_size: GridSize, world_centre: Vector, m: float, R_1: float, R_2: float, R_buff: float | None = 0, sigma: float | None = 0, smooth_factor: float | None = 1, v_warp: float | None = 0, do_warp: bool = False, grid_scaling: Vector | None = None) -> TensorDict
Build a static spherical shell with an optional x-directed shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Grid shape (nt, nx, ny, nz), requiring nt = 1. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets; spatial coordinates use (index + 1) * spacing minus the corresponding offset. |
required |
m
|
float
|
Nonnegative shell mass in kilograms. |
required |
R_1
|
float
|
Inner and outer shell radii in metres, with 0 <= R_1 < R_2. |
required |
R_2
|
float
|
Inner and outer shell radii in metres, with 0 <= R_1 < R_2. |
required |
R_buff
|
float or None
|
Buffer at each end of the shift transition; default is zero. |
0
|
sigma
|
float or None
|
Nonnegative sigmoid sharpness; default is zero. |
0
|
smooth_factor
|
float or None
|
Moving-average span, or fraction of radial samples when between zero and one. Defaults to one. |
1
|
v_warp
|
float or None
|
Dimensionless x-directed shift amplitude; default is zero. |
0
|
do_warp
|
bool
|
Include the shift when true; defaults to false. |
False
|
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in seconds and metres; defaults to unit spacing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Covariant Cartesian metric with radial profiles stored in params. |
Notes
Radial profiles use 100,000 samples and linear interpolation. The shell must satisfy the constant-density pressure model's compactness limit and the smoothed profile must contain no coordinate horizon.
warpica.metrics.custom_metric.custom_metric ¶
custom_metric(grid_size: GridSize, world_centre: Vector, grid_scaling: Vector, alpha_function: Callable[[float, float, float, float], float], beta_function: Callable[[float, float, float, float], Vector], gamma_function: Callable[[float, float, float, float], Sequence[Sequence[float]] | Array]) -> TensorDict
Build a metric from lapse, covariant shift, and spatial-metric callbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
array_like of int, shape (4,)
|
Number of samples along the (t, x, y, z) axes. |
required |
world_centre
|
(array_like, shape(4))
|
Coordinate offsets in (t, x, y, z) order. Grid coordinates are (index + 1) * spacing - world_centre. |
required |
grid_scaling
|
(array_like, shape(4))
|
Grid spacings in (t, x, y, z) order. |
required |
alpha_function
|
callable
|
Function of (t, x, y, z) returning the scalar lapse. |
required |
beta_function
|
callable
|
Function of (t, x, y, z) returning three covariant shift components. |
required |
gamma_function
|
callable
|
Function of (t, x, y, z) returning a symmetric 3 by 3 spatial metric. Only the upper triangle is read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
metric |
dict
|
Cartesian covariant metric, grid scaling, and identifying metadata.
Components use |
warpica.metrics.three_plus_one_builder.three_plus_one_builder ¶
three_plus_one_builder(alpha: Array, beta: Sequence[Array], gamma: Sequence[Sequence[Array]]) -> list[list[Array]]
Assemble a covariant spacetime metric from its 3+1 fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
ndarray
|
Lapse field, with shape (nt, nx, ny, nz). |
required |
beta
|
list of arrays
|
Three covariant shift fields. |
required |
gamma
|
list of lists of arrays
|
Symmetric 3 by 3 covariant spatial-metric fields. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tensor |
list of lists of arrays
|
A 4 by 4 component table; each component has the input grid shape. |
Notes
The input shift is covariant. Its index is raised with the inverse spatial metric when computing the time-time component.
warpica.metrics.three_plus_one_decomposer.three_plus_one_decomposer ¶
three_plus_one_decomposer(metric: TensorDict) -> tuple[Array, list[Array], list[list[Array]], list[Array], list[list[Array]]]
Decompose a spacetime metric into lapse, shift, and spatial fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric metadata and components indexed as |
required |
Returns:
| Name | Type | Description |
|---|---|---|
alpha |
ndarray
|
Lapse field, with shape (nt, nx, ny, nz). |
beta_down |
list of arrays
|
Three covariant shift components. |
gamma_down |
list of lists of arrays
|
Covariant spatial metric. |
beta_up |
list of arrays
|
Three contravariant shift components. |
gamma_up |
list of lists of arrays
|
Inverse spatial metric. |
Solver¶
warpica.solver.get_energy_tensor.get_energy_tensor ¶
get_energy_tensor(metric: TensorDict, diff_order: DiffOrder | None = 'fourth', *, gpu: Backend | None = None) -> TensorDict
Compute the contravariant stress-energy tensor of a metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric metadata and components indexed as |
required |
diff_order
|
(second, fourth)
|
Finite-difference accuracy order. Default is 'fourth'. |
'second'
|
gpu
|
(None, numpy, cupy, torch - directml)
|
Array backend for curvature calculations. None selects NumPy. Only the NumPy path is covered by the stability promise; 'cupy' and 'torch-directml' are experimental. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
energy |
dict
|
Stress-energy components as host arrays, with coordinate, index, finite-difference order, and source metric metadata. |
Notes
Every axis must have either one sample or at least 3 (second order) or 5 (fourth order); a shorter axis raises ValueError instead of silently giving zero derivatives.
DirectML uses float32 curvature. Final SI scaling and index contraction use float64 on the CPU for every device backend. The input metric is not modified.
Analyser¶
warpica.analyser.eval_metric.eval_metric ¶
eval_metric(metric: TensorDict, keep_positive: bool | None = True, num_angular_vec: int | None = 100, num_time_vec: int | None = 10, gpu: Backend | None = None, *, diff_order: DiffOrder | None = 'fourth') -> TensorDict
Evaluate stress-energy, sampled energy conditions, and Eulerian scalars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric metadata and components indexed as |
required |
keep_positive
|
bool
|
Keep positive energy-condition values. If false, clip them to zero. |
True
|
num_angular_vec
|
int
|
Number of sampled spatial directions; default is 100. |
100
|
num_time_vec
|
int
|
Number of timelike speed samples; default is 10. |
10
|
gpu
|
(None, numpy, cupy, torch - directml)
|
Array backend for curvature calculations. None selects NumPy. |
None
|
diff_order
|
(second, fourth)
|
Finite-difference accuracy order. Default is 'fourth'. |
'second'
|
Returns:
| Name | Type | Description |
|---|---|---|
output |
dict
|
Input metric, coordinate and Eulerian stress-energy tensors, null, weak, strong, and dominant condition maps, and expansion, shear, and vorticity scalars. |
warpica.analyser.get_energy_conditions.get_energy_conditions ¶
get_energy_conditions(energy_tensor: TensorDict, metric: TensorDict, condition: str, num_angular_vec: int | None = None, num_time_vec: int | None = None, return_vec: Literal[False] | None = None, gpu: str | None = None) -> Array
get_energy_conditions(energy_tensor: TensorDict, metric: TensorDict, condition: str, num_angular_vec: int | None, num_time_vec: int | None, return_vec: Literal[True], gpu: str | None = None) -> tuple[Array, Array, Array]
get_energy_conditions(energy_tensor: TensorDict, metric: TensorDict, condition: str, num_angular_vec: int | None = None, num_time_vec: int | None = None, return_vec: bool | None = None, gpu: str | None = None) -> Array | tuple[Array, Array, Array]
Evaluate an energy condition over sampled observer directions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy_tensor
|
dict
|
Stress-energy tensor; transformed to the Eulerian frame if needed. |
required |
metric
|
dict
|
Metric metadata and components indexed as |
required |
condition
|
(Null, Weak, Strong, Dominant)
|
Energy condition, compared case-insensitively. |
'Null'
|
num_angular_vec
|
int or None
|
Number of spatial directions; None selects 100. |
None
|
num_time_vec
|
int or None
|
Number of speed samples for timelike observers; None selects 10. |
None
|
return_vec
|
bool or None
|
If true, also return per-sample values and the sampled vector field. |
None
|
gpu
|
str or None
|
Retained for API compatibility; analysis runs on the CPU. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
map_array |
ndarray
|
Worst sampled value at each grid cell. Negative values indicate a violation; shape is (nt, nx, ny, nz). |
vec |
(ndarray, optional)
|
Per-direction values, returned only when return_vec is true. Trailing axes are angular samples, then speed samples for timelike conditions. |
vector_field_out |
(ndarray, optional)
|
Sampled four-vectors, returned only when return_vec is true. |
Notes
Finite directional sampling is not a proof that a condition holds for all observers. Neither input tensor is modified.
warpica.analyser.get_scalars.get_scalars ¶
get_scalars(metric: TensorDict, diff_order: DiffOrder = 'fourth') -> tuple[Array, Array, Array]
Compute kinematic scalars for the Eulerian observer field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric metadata and components indexed as |
required |
diff_order
|
(second, fourth)
|
Finite-difference accuracy order. Default is 'fourth'. |
'second'
|
Returns:
| Name | Type | Description |
|---|---|---|
expansion_scalar |
ndarray
|
Trace of the projected symmetric velocity gradient. |
shear_scalar |
ndarray
|
One half of the shear tensor contracted with itself. |
vorticity_scalar |
ndarray
|
One half of the vorticity tensor contracted with itself. All outputs have shape (nt, nx, ny, nz). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an axis has two or more samples but too few for the stencil (5 for fourth order, 3 for second order). One sample is accepted. |
warpica.analyser.get_momentum_flow_lines.get_momentum_flow_lines ¶
get_momentum_flow_lines(energy_tensor: TensorDict, start_points: Sequence[ArrayLike] | Array, step_size: float, max_steps: int, scale_factor: float) -> list[Array]
Trace momentum-flow paths by explicit Euler integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy_tensor
|
dict
|
Contravariant stress-energy tensor containing 3D component fields or 4D fields with a singleton time axis. |
required |
start_points
|
(array_like, shape(3, ...))
|
Starting x, y, and z coordinates in one-based grid units. |
required |
step_size
|
float
|
Positive integration step multiplying the sampled momentum. |
required |
max_steps
|
int
|
Maximum number of integration steps, at least zero. |
required |
scale_factor
|
float
|
Multiplier applied to each momentum component. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
paths |
list of ndarrays
|
One array of shape (n_steps + 1, 3) per seed. Paths stop at the interpolation boundary or a NaN position. |
warpica.analyser.change_tensor_index.change_tensor_index ¶
change_tensor_index(input_tensor: TensorDict, index: str, metric_tensor: TensorDict | None = None) -> TensorDict
Return a tensor copy with the requested index convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_tensor
|
dict
|
Tensor metadata and component fields. |
required |
index
|
str
|
Target: 'covariant', 'contravariant', 'mixedupdown', or 'mixeddownup'. Metric tensors cannot use mixed indices. |
required |
metric_tensor
|
dict
|
Reference metric, required for non-metric tensors. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
output |
dict
|
New dictionary with independent component arrays and updated index. Other metadata is shallow-copied. |
warpica.analyser.do_frame_transfer.do_frame_transfer ¶
do_frame_transfer(metric: TensorDict, energy_tensor: TensorDict, frame: str, gpu: str | None = None) -> TensorDict
Transform stress-energy to a local Eulerian orthonormal frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric metadata and components indexed as |
required |
energy_tensor
|
dict
|
Stress-energy tensor in any supported index convention. |
required |
frame
|
Eulerian
|
Target frame, compared case-insensitively. |
'Eulerian'
|
gpu
|
str or None
|
Retained for compatibility; this transformation runs on the CPU. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
transformed_energy_tensor |
dict
|
Independent tensor copy with contravariant Eulerian components. |
Units¶
warpica.units ¶
Physical constants in SI units.
Visualiser¶
warpica.visualiser.plot_tensor.plot_tensor ¶
plot_tensor(tensor: TensorDict, alpha: float | None = None, sliced_planes: Sequence[int] | Array | None = None, slice_locations: Sequence[float] | Array | None = None) -> tuple[Figure, Array]
Plot a two-dimensional slice of all sixteen tensor components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensor
|
dict
|
Metric or stress-energy dictionary with 4D component fields. |
required |
alpha
|
float or None
|
Plot opacity between zero and one. None selects full opacity. |
None
|
sliced_planes
|
array_like of int, shape (2,)
|
Axes to fix, using 1=t, 2=x, 3=y, 4=z. Defaults to (1, 4). |
None
|
slice_locations
|
(array_like, shape(2))
|
One-based grid locations, rounded to the nearest cell. Defaults to the middle cell on each fixed axis. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
figure |
Figure
|
Figure containing the component plots; not shown automatically. |
axes |
(ndarray, shape(4, 4))
|
Matplotlib axes arranged by tensor component. |
Notes
Coordinates use SI grid scaling if available, otherwise one-based grid indices. Call figure.savefig(...) or plt.show() to display the result.
warpica.visualiser.plot_three_plus_one.plot_three_plus_one ¶
plot_three_plus_one(metric: TensorDict, sliced_planes: Sequence[int] | Array | None = None, slice_locations: Sequence[float] | Array | None = None, alpha: float | None = None) -> tuple[Figure, Array]
Plot slices of the lapse, covariant shift, and spatial metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
dict
|
Metric dictionary with components on a (t, x, y, z) grid. |
required |
sliced_planes
|
array_like of int, shape (2,)
|
Axes to fix, using 1=t, 2=x, 3=y, 4=z. Defaults to (1, 4). |
None
|
slice_locations
|
(array_like, shape(2))
|
One-based grid locations, rounded to the nearest cell. Defaults to the middle cell on each fixed axis. |
None
|
alpha
|
float or None
|
Plot opacity between zero and one. None selects full opacity. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
figure |
Figure
|
Figure containing the component plots; not shown automatically. |
axes |
(ndarray, shape(2, 5))
|
Matplotlib axes for the ten independent 3+1 fields. |