SPHtoGrid.jl

Package to map SPH particle data to a cartesian grid
Author LudwigBoess
Popularity
6 Stars
Updated Last
3 Months Ago
Started In
July 2020
Documentation Build Status Licence Citation
Build Status codecov.io License: GPL v3 DOI

SPHtoGrid.jl

This package maps SPH quantities to a cartesian grid or a healpix sphere. It is based on Smac by Klaus Dolag und Smac2 by Julius Donnert.

Please see the Documentation for details.

Quickstart

You can map SPH data to a grid using the function sphMapping:

function sphMapping(Pos::Array{<:Real}, HSML::Array{<:Real}, M::Array{<:Real}, 
                    Rho::Array{<:Real}, Bin_Quant::Array{<:Real}, 
                    Weights::Array{<:Real}=Rho;
                    param::mappingParameters,
                    kernel::AbstractSPHKernel,
                    show_progress::Bool=true,
                    parallel::Bool=false,
                    reduce_image::Bool=true,
                    return_both_maps::Bool=false,
                    dimensions::Int=2,
                    calc_mean::Bool=false,
                    sort_z::Bool=false)


    [...]

end

Define parameters for mapping

To map the data you need to define the mapping parameters via the mappingParameters object. One way to set this up is by defining the limits of the map as

par = mappingParameters(xlim=[xmin, xmax],
                        ylim=[ymin, ymax],
                        zlim=[zmin, zmax],
                        Npixels=200)

or give a center position and the size in each direction

par = mappingParameters(center=[x0, y0, z0], 
                        x_size=x_size, 
                        y_size=y_size,
                        z_size=z_size,
                        Npixels=200)

Instead of Npixels you can also give the keyword argument pixelSideLength if you prefer to define your image that way.

Select Kernel

You also need to choose the kernel you used in the simulation. For this you need to install the package SPHKernels.jl. You can currently use these kernels:

k = Cubic()
k = Quintic()
k = WendlandC4()
k = WendlandC6()
k = WendlandC8()

Please see the SPHKernels docs for more details.

Mapping

With the setup done you can now map (e.g.) density of your data using the function above as:

image = sphMapping(x, hsml, m, rho, rho, param=par, kernel=k)

Replacing the second rho with any other quantity would map that quantity of course. Please note: This function doesn't do any unit conversion for you, so you need to convert to the desired units beforehand. You can do this e.g. with GadgetUnits.jl.

Image now contains a 2D array with the binned data and can easily be plotted with imshow() from any plotting package of your choosing.

The keyword parallel = true causes the run to use multiple processors. For this you need to start julia with julia -p <N> where <N> is the number of processors in your machine, or define

using Distributed
addprocs(8)

# now you can load SPHtoGrid
using SPHtoGrid

Conserved quantities

Particles are mapped to a grid while also conserving the particle volume, following the algorithm described in Dolag et. al. 2006.