paicos.cython package
Submodules
paicos.cython.get_derived_variables module
- paicos.cython.get_derived_variables.get_curvature(Bvec, Bgradient)
This function computes the magnetic field line curvature.
- Parameters:
Bvec (array N, 3) – Magnetic field vector
Bgradient (array N, 3, 3) – Magnetic field gradient tensor
- Returns:
The magnetic field line curvature.
- Return type:
array N
- paicos.cython.get_derived_variables.get_magnitude_of_vector(Bvec)
Computes the magnitude of a vector, e.g., magnetic field strength.
- paicos.cython.get_derived_variables.sum_1d_array_omp(arr, num_threads)
Computes the sum of a 1D array using openmp. Equivalent to np.sum(arr)
- paicos.cython.get_derived_variables.sum_2d_array_omp(arr, num_threads)
Computes the sum of an array along the first index using openmp. Equivalent to np.sum(arr, axis=0)
- paicos.cython.get_derived_variables.sum_arr_times_vector_cross_product(mass, coord, velocity, center, num_threads)
This code calculates sum_i (mass_i (coord_ij - center) x velocity_ij).
That is, it returns the total angular momentum vector.
- paicos.cython.get_derived_variables.sum_arr_times_vector_omp(arr, vector, num_threads)
Computes the sum of an array times a vector. e.g. sum_i M_i vec{v}_i for calculating the center of mass.
Equivalent to np.sum(arr[:, None] * vector, axis=0)
paicos.cython.get_index_of_region module
- paicos.cython.get_index_of_region.get_cube(pos, xc, yc, zc, sidelength_x, sidelength_y, sidelength_z, boxsize, numthreads)
This is a cython implementation of a selection function, which selects points inside a rectangular region (‘cube’ is a misnomer…).
Users should not use this low-level function but instead use paicos.util.get_index_of_cubic_region
- Parameters:
pos (array, (N,3)) – positions
xc (double) – x-position of center
yc (double) – y-position of center
zc (double) – z-position of center
sidelength_x (double) – length of cube along x
sidelength_y (double) – length of cube along y
sidelength_z (double) – length of cube along z
boxsize (double) – size of simulation domain, which for now is assumed to be cubic!
numthreads (int) – number of openmp threads to use
- Returns:
A boleean array with True for points inside the selected region
- Return type:
boolean array (N)
- paicos.cython.get_index_of_region.get_cube_plus_thin_layer(pos, xc, yc, zc, sidelength_x, sidelength_y, sidelength_z, thickness, boxsize, numthreads)
This is a cython implementation of a selection function, which selects points inside a rectangular region (‘cube’ is a misnomer…) + a layer of variable thickness.
Users should not use this low-level function but instead use paicos.util.get_index_of_cubic_region_plus_thin_layer
- Parameters:
pos (array, (N,3)) – positions
xc (double) – x-position of center
yc (double) – y-position of center
zc (double) – z-position of center
sidelength_x (double) – length of cube along x
sidelength_y (double) – length of cube along y
sidelength_z (double) – length of cube along z
thickness (array, (N)) – variable thickness for each point
boxsize (double) – size of simulation domain, which for now is assumed to be cubic!
numthreads (int) – number of openmp threads to use
- Returns:
A boleean array with True for points inside the selected region
- Return type:
boolean array (N)
- paicos.cython.get_index_of_region.get_radial_range(pos, xc, yc, zc, r_min, r_max, numthreads)
This is a cython implementation of a selection function, which selects points inside a spherical shell.
Users should not use this low-level function but instead use paicos.util.get_index_of_radial_range
- Parameters:
pos (array, (N,3)) – positions
xc (double) – x-position of center
yc (double) – y-position of center
zc (double) – z-position of center
r_min (double) – mininum radius
r_max (double) – maxinum radius
numthreads (int) – number of openmp threads to use
- Returns:
A boleean array with True for points inside the selected region
- Return type:
boolean array (N)
- paicos.cython.get_index_of_region.get_radial_range_plus_thin_layer(pos, xc, yc, zc, r_min, r_max, thickness, numthreads)
This is a cython implementation of a selection function, which selects points inside a spherical shell + a thin layer with variable thickness.
Users should not use this low-level function but instead use paicos.util.get_index_of_radial_range_plus_thin_layer
- Parameters:
pos (array, (N,3)) – positions
xc (double) – x-position of center
yc (double) – y-position of center
zc (double) – z-position of center
r_min (double) – mininum radius
r_max (double) – maxinum radius
numthreads (int) – number of openmp threads to use
- Returns:
A boleean array with True for points inside the selected region
- Return type:
boolean array (N)
- paicos.cython.get_index_of_region.get_rotated_cube(pos, xc, yc, zc, sidelength_x, sidelength_y, sidelength_z, boxsize, unit_vector_x, unit_vector_y, unit_vector_z, numthreads)
Same as get_cube but for a rotated cube. Please see paicos.util.get_index_of_rotated_cubic_region for details.
- paicos.cython.get_index_of_region.get_rotated_cube_plus_thin_layer(pos, xc, yc, zc, sidelength_x, sidelength_y, sidelength_z, thickness, boxsize, unit_vector_x, unit_vector_y, unit_vector_z, numthreads)
Same as get_cube_plus_thin_layer but for a rotated cube. Please see paicos.util.get_index_of_rotated_cubic_region_plus_thin_layer for details.
paicos.cython.histogram module
- paicos.cython.histogram.get_hist2d_from_weights(xvec, yvec, weights, lower_x, upper_x, nbins_x, lower_y, upper_y, nbins_y, logspace, numthreads=1)
This is a cython helper function for calculating 2D histograms.
- paicos.cython.histogram.get_hist2d_from_weights_omp(xvec, yvec, weights, lower_x, upper_x, nbins_x, lower_y, upper_y, nbins_y, logspace, numthreads=1)
This is a cython helper function for calculating 2D histograms using openmp.
- paicos.cython.histogram.get_hist_from_weights_and_idigit(num_bins, weights, i_digit)
This is a cython helper function for calculating 1D histograms.
paicos.cython.openmp_info module
- paicos.cython.openmp_info.get_openmp_settings(mpirank, verbose=True)
This helper function returns the maximum number of openmp threads available on the system.
- paicos.cython.openmp_info.simple_reduction(n, num_threads)
This program is a simple reduction using openmp parallel code. The return value should simply be identical to the input, n. Used to find a bug cython/openmp bug that at some point occured on MacOs.
paicos.cython.ray_tracer module
- paicos.cython.ray_tracer.trace_rays_cpu(points, tree_parents, tree_children, tree_bounds, variable, hsml, widths, center, tree_scale_factor, tree_offsets, image, rotation_matrix, tol, numthreads)
- paicos.cython.ray_tracer.trace_rays_cpu_voronoi(points, tree_parents, tree_children, tree_bounds, variable, hsml, widths, center, tree_scale_factor, tree_offsets, image, rotation_matrix, tol, numthreads)
paicos.cython.sph_projectors module
- paicos.cython.sph_projectors.project_image(xvec, yvec, variable, hvec, nx, xc, yc, sidelength_x, sidelength_y, boxsize, numthreads=1)
Projects particles using an SPH-like kernel.
This function assumes that only particles with coordinates
x0 < x < x0 + sidelength_x y0 < y < y0 + sidelength_y
are passed to it. For speed, this is not checked!
Here x0, y0 are the coordinates at the lower, left corner.
- Parameters:
xvec (array, N) – positions along x (horizontal)
yvec (array, N) – positions along y (vertical)
variable (array, N) – variable to be projected (e.g. mass)
hsml (array, N) – size of particles
sidelength_x (double) – size of image along x
sidelength_y (double) – size of image along y
boxsize (double) – size of simulation domain, which for now is assumed to be cubic!
- Returns:
A 2D array with the projected variable.
- Return type:
2d array
- paicos.cython.sph_projectors.project_image_omp(xvec, yvec, variable, hvec, nx, xc, yc, sidelength_x, sidelength_y, boxsize, numthreads)
Same as project_image but here with an openmp parallel implementation.
- paicos.cython.sph_projectors.project_oriented_image(xvec, yvec, zvec, variable, hvec, nx, xc, yc, zc, sidelength_x, sidelength_y, boxsize, unit_vector_x, unit_vector_y, unit_vector_z, numthreads=1)
Same as project_image but here for an arbitrarily oriented image.
- paicos.cython.sph_projectors.project_oriented_image_omp(xvec, yvec, zvec, variable, hvec, nx, xc, yc, zc, sidelength_x, sidelength_y, boxsize, unit_vector_x, unit_vector_y, unit_vector_z, numthreads=1)
Same as project_oriented_image but here with an openmp implementation.