Smooth Particle Hydrodynamics¶
Functions for constructing and interpolation via SPH.
Kernels¶
SPH Objects¶
- class fiesta.sph.SPH1D¶
Class for computing Smooth Particle Hydrodynamic (SPH) density and field estimation in 1D.
- assign_mass(mass: ndarray | None = None) None¶
Assign particles mass, if none they will be assigned
- Parameters:
mass (array, optional) – Particle mass.
- estimate(x: ndarray, dens: ndarray | None = None) ndarray¶
Estimates field at points given.
- Parameters:
x (array) – Cartesian coordinates.
dens (array) – Density at cartesian coordinates, if None this will be computed but will require double the time.
- Returns:
f_est – Field estimation.
- Return type:
array
- get_density(x: ndarray) ndarray¶
Calculates density based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates.
- Returns:
dens – Density estimation.
- Return type:
array
- set_field(f: ndarray) None¶
Sets the field values for SPH field estimation.
- Parameters:
f (array) – Field values at KDTree points.
- setup(k: int = 20, mass: ndarray | None = None) None¶
Set basic settings for the SPH data.
- Parameters:
k (int, optional) – Neighbours for nearest neighbour SPH calculation.
mass (array, optional) – For assigning masses to the particles.
- sph_estimate(x: ndarray, f: ndarray | None = None, dens: ndarray | None = None) ndarray¶
Estimates a field based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates.
f (array) – Field values at KDTree points.
dens (array) – Density at cartesian coordinates, if None this will be computed but will require double the time.
- Returns:
f_est – Field estimation.
- Return type:
array
- class fiesta.sph.SPH2D¶
Class for computing Smooth Particle Hydrodynamic (SPH) density and field estimation in 2D.
- assign_mass(mass: ndarray | None = None) None¶
Assign particles mass, if none they will be assigned.
- estimate(x: float | ndarray, y: float | ndarray, dens: ndarray = None) float | ndarray¶
Estimates field at points given.
- get_density(x: ndarray, y: ndarray) ndarray¶
Calculates density based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates.
y (array) – Cartesian coordinates.
- Returns:
dens – Density estimation.
- Return type:
array
- set_field(f: ndarray) None¶
Sets the field values for SPH field estimation.
- Parameters:
f (array) – Field values at KDTree points.
- setup(k: int = 20, mass: ndarray | None = None) None¶
Set basic settings for the SPH data.
- Parameters:
k (int, optional) – Neighbours for nearest neighbour SPH calculation.
mass (array, optional) – For assigning masses to the particles.
- class fiesta.sph.SPH3D¶
Class for computing Smooth Particle Hydrodynamic (SPH) density and field estimation in 3D.
- assign_mass(mass: ndarray | None = None) None¶
Assign particles mass, if none they will be assigned.
- estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray, dens: ndarray | None = None) float | ndarray¶
Estimates field at points given.
- Parameters:
x (array) – Cartesian coordinates.
y (array) – Cartesian coordinates.
z (array) – Cartesian coordinates.
dens (array) – Density at cartesian coordinates, if None this will be computed but will require double the time.
- Returns:
f_est – Field estimation.
- Return type:
array
- get_density(x: float | ndarray, y: float | ndarray, z: float | ndarray) float | ndarray¶
Calculates density based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates.
y (array) – Cartesian coordinates.
z (array) – Cartesian coordinates.
- Returns:
dens – Density estimation.
- Return type:
array
- set_field(f: float | ndarray) None¶
Sets the field values for SPH field estimation.
- Parameters:
f (array) – Field values at KDTree points.
- setup(k: int = 50, mass: ndarray = None) None¶
Set basic settings for the SPH data.
- Parameters:
k (int, optional) – Neighbours for nearest neighbour SPH calculation.
mass (array, optional) – For assigning masses to the particles.
- sph_estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray, f: ndarray | None = None, dens: ndarray | None = None) float | ndarray¶
Estimates a field based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates.
y (array) – Cartesian coordinates.
z (array) – Cartesian coordinates.
f (array) – Field values at KDTree points.
dens (array) – Density estimation.
- Returns:
f_est – Field estimation.
- Return type:
array
SPH to grid¶
- fiesta.sph.sph4grid2D(x: ndarray, y: ndarray, boxsize: float | List[float], ngrid: int | List[int], f: ndarray | None = None, origin: float | List[float] = 0.0, mass: ndarray | None = None, k: int = 20, periodic: bool = True, subsampling: int = 1, outputgrid: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Estimates a field on a regular grid based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates of the input points.
y (array) – Cartesian coordinates of the input points.
boxsize (float or list of float) – Size of the box in each dimension.
ngrid (int or list of int) – Number of grid points in each dimension.
f (array, optional) – Field values at the input points.
origin (float or list of float, optional) – Origin of the grid.
mass (array, optional) – Mass of the input points. If not provided, it is assumed to be 1 for all points.
k (int, optional) – Number of nearest neighbors to consider.
periodic (bool or list of bool, optional) – Whether to use periodic boundary conditions.
subsampling (int, optional) – Subsampling factor for the output grid.
outputgrid (bool, optional) – Whether to output the grid coordinates.
- Returns:
dgrid (array) – Density field on the regular grid, if f is None.
fgrid (array) – Estimated field on the regular grid, if f is provided.
x2d, y2d (array) – Grid coordinates, if outputgrid is True.
- fiesta.sph.sph4grid3D(x: ndarray, y: ndarray, z: ndarray, boxsize: float | List[float], ngrid: int | List[int], f: ndarray | None = None, origin: float | List[float] = 0.0, mass: ndarray | None = None, k: int = 32, periodic: bool = True, subsampling: int = 1, outputgrid: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Estimates a field on a regular grid based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates of the input points.
y (array) – Cartesian coordinates of the input points.
z (array) – Cartesian coordinates of the input points.
boxsize (float or list of float) – Size of the box in each dimension.
ngrid (int or list of int) – Number of grid points in each dimension.
f (array, optional) – Field values at the input points.
origin (float or list of float, optional) – Origin of the grid.
mass (array, optional) – Mass of the input points. If not provided, it is assumed to be 1 for all points.
k (int, optional) – Number of nearest neighbors to consider.
periodic (bool or list of bool, optional) – Whether to use periodic boundary conditions.
subsampling (int, optional) – Subsampling factor for the output grid.
outputgrid (bool, optional) – Whether to output the grid coordinates.
- Returns:
dgrid (array) – Density field on the regular grid, if f is None.
fgrid (array) – Estimated field on the regular grid, if f is provided.
x3d, y3d, z3d (array) – Grid coordinates, if outputgrid is True.
- fiesta.sph.mpi_sph4grid2D(x: ndarray, y: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, f: ndarray | None = None, origin: float | List[float] = 0.0, mass: ndarray | None = None, k: int = 20, periodic: bool = True, subsampling: int = 1, outputgrid: bool = False, buffer_length: float = 0.0) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Estimates a field on a regular grid based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates of the input points.
y (array) – Cartesian coordinates of the input points.
boxsize (float or list of float) – Size of the box in each dimension.
ngrid (int or list of int) – Number of grid points in each dimension.
MPI (object) – shift.mpiutils MPI object.
f (array, optional) – Field values at the input points.
origin (float or list of float, optional) – Origin of the grid.
mass (array, optional) – Mass of the input points. If not provided, it is assumed to be 1 for all points.
k (int, optional) – Number of nearest neighbors to consider.
periodic (bool or list of bool, optional) – Whether to use periodic boundary conditions.
subsampling (int, optional) – Subsampling factor for the output grid.
outputgrid (bool, optional) – Whether to output the grid coordinates.
buffer_length (float, optional) – Buffer length, must be smaller than the slab x-axis length.
- Returns:
dgrid (array) – Density field on the regular grid, if f is None.
fgrid (array) – Estimated field on the regular grid, if f is provided.
x2d, y2d (array) – Grid coordinates, if outputgrid is True.
- fiesta.sph.mpi_sph4grid3D(x: ndarray, y: ndarray, z: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, f: ndarray | None = None, origin: float | List[float] = 0.0, mass: ndarray | None = None, k: int = 20, periodic: bool = True, subsampling: int = 1, outputgrid: bool = False, buffer_length: float = 0.0) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Estimates a field on a regular grid based on SPH k neighbours.
- Parameters:
x (array) – Cartesian coordinates of the input points.
y (array) – Cartesian coordinates of the input points.
z (array) – Cartesian coordinates of the input points.
boxsize (float or list of float) – Size of the box in each dimension.
ngrid (int or list of int) – Number of grid points in each dimension.
MPI (object) – shift.mpiutils MPI object.
f (array, optional) – Field values at the input points.
origin (float or list of float, optional) – Origin of the grid.
mass (array, optional) – Mass of the input points. If not provided, it is assumed to be 1 for all points.
k (int, optional) – Number of nearest neighbors to consider.
periodic (bool or list of bool, optional) – Whether to use periodic boundary conditions.
subsampling (int, optional) – Subsampling factor for the output grid.
outputgrid (bool, optional) – Whether to output the grid coordinates.
buffer_length (float, optional) – Buffer length, must be smaller than the slab x-axis length.
- Returns:
dgrid (array) – Density field on the regular grid, if f is None.
fgrid (array) – Estimated field on the regular grid, if f is provided.
x2d, y2d (array) – Grid coordinates, if outputgrid is True.