Computation of characteristic velocities and momentums

These functions are used internally and none are exported.

These functions depend on the particulars of the simulation code (e.g. units).


GalaxyInspector.computeAngularMomentumMethod
computeAngularMomentum(
    positions::Matrix{<:Unitful.Length},
    velocities::Matrix{<:Unitful.Velocity},
    masses::Vector{<:Unitful.Mass},
)::Vector{Vector{<:AngularMomentum}}

Compute the angular momentum of each cell/particle, with respect to the origin.

Arguments

  • positions::Matrix{<:Unitful.Length}: Positions of the cells/particles. Each column is a cell/particle and each row a dimension.
  • velocities::Matrix{<:Unitful.Velocity}: Velocities of the cells/particles. Each column is a cell/particle and each row a dimension.
  • masses::Vector{<:Unitful.Mass}: Mass of every cell/particle.

Returns

  • The angular momentum of each cell/particle.
source
GalaxyInspector.computeCircularityMethod
computeCircularity(data_dict::Dict; <keyword arguments>)::Vector{Float64}

Compute the circularity of each particle of the given type, with respect to the origin and the $z$ direction [0, 0, 1].

The circularity of a particle is,

\[\epsilon = j_z / j_\mathrm{circ} \, ,\]

where $j_z$ is the $z$ component of its specific angular momentum, and $j_\mathrm{circ}$ is the specific angular momentum of a circular orbit,

\[j_\mathrm{circ} = r \, v_\mathrm{circ} = \sqrt{\mathrm{G} \, r \, M(r)} \, ,\]

where $r$ is the radial distance of the particle, and $M(r)$ is the total mass within a sphere of radius $r$.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • type::Symbol=:stars: Target component.

Returns

  • The circularity $\epsilon$ of each particle.
source
GalaxyInspector.computeComponentVcmMethod
computeComponentVcm(data_dict::Dict, component::Symbol)::Vector{<:Unitful.Velocity}

Compute the velocity of the given component center of mass.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • component::Symbol: Target component, it can be any of the keys of PARTICLE_INDEX.

Returns

  • The velocity of the center of mass.
source
GalaxyInspector.computeGlobalAngularMomentumMethod
computeGlobalAngularMomentum(data_dict::Dict; <keyword arguments>)::Vector{<:Number}

Compute the total angular momentum with respect to the origin of the whole system.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • normal::Bool=true: If the result will be normalized.

Returns

  • The angular momentum.
source
GalaxyInspector.computeGlobalSpinParameterMethod
computeGlobalSpinParameter(data_dict::Dict; <keyword arguments>)::Float64

Compute the spin parameter of the whole system.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • R::Unitful.Length=DISK_R: Radius.

Returns

  • The spin parameter.
source
GalaxyInspector.computeGlobalVcmMethod
computeGlobalVcm(data_dict::Dict)::Vector{<:Unitful.Velocity}

Compute the velocity of the global center of mass.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...

Returns

  • The velocity of the global center of mass.
source
GalaxyInspector.computeSpinParameterMethod
computeSpinParameter(
    positions::Matrix{<:Unitful.Length},
    masses::Vector{<:Unitful.Mass},
    velocities::Matrix{<:Unitful.Velocity};
    <keyword arguments>
)::Float64

Compute the spin parameter for a system of cells/particles, with respect to the origin.

The spin parameter was originally defined by Peebles (1969) as,

\[\lambda = \frac{J \, \sqrt{E}}{G \, M^{5/2}} \, ,\]

where $J$ is the norm of the total angular momentum, $M$ the total mass, $G$ the gravitational constant, and

\[E = |E_P + E_k| \, ,\]

where $E_P$ is the total potential energy and $E_k$ is the total kinetic energy (including thermal energy of the gas).

Due to the computational complexity of calculating $E_P$ for a large group of particles, Bullock et al. (2001) proposed an alternative definition of the spin parameter,

\[\lambda = \frac{J}{\sqrt{2} \, M \, R \, V} \, ,\]

where $J$ is the norm of the total angular momentum inside a sphere of radius $R$ containing mass $M$, and

\[V = \sqrt{\frac{G \, M}{R}} \, ,\]

is the circular velocity.

Arguments

  • positions::Matrix{<:Unitful.Length}: Positions of the cells/particles. Each column is a cell/particle and each row a dimension.
  • velocities::Matrix{<:Unitful.Velocity}: Velocities of the cells/particles. Each column is a cell/particle and each row a dimension.
  • masses::Vector{<:Unitful.Mass}: Mass of every cell/particle.
  • R::Unitful.Length=DISK_R: Radius.

Returns

  • The spin parameter.

References

P. J. E. Peebles (1969). Origin of the Angular Momentum of Galaxies. Astrophysical Journal, 155, 393. doi:10.1086/149876

J. S. Bullock et al. (2001). A Universal Angular Momentum Profile for Galactic Halos. The Astrophysical Journal, 555(1), 240. doi:10.1086/321477

J. Zjupa et al. (2017). Angular momentum properties of haloes and their baryon content in the Illustris simulation. Monthly Notices of the Royal Astronomical Society, 466(2), 1625–1647. doi:10.1093/mnras/stw2945

source
GalaxyInspector.computeTotalAngularMomentumMethod
computeTotalAngularMomentum(
    positions::Matrix{<:Unitful.Length},
    velocities::Matrix{<:Unitful.Velocity},
    masses::Vector{<:Unitful.Mass};
    <keyword arguments>
)::Vector{<:Number}

Compute the total angular momentum of a group of cells/particles, with respect to the origin.

Arguments

  • positions::Matrix{<:Unitful.Length}: Positions of the cells/particles. Each column is a cell/particle and each row a dimension.
  • velocities::Matrix{<:Unitful.Velocity}: Velocities of the cells/particles. Each column is a cell/particle and each row a dimension.
  • masses::Vector{<:Unitful.Mass}: Mass of every cell/particle.
  • normal::Bool=true: If the result will be normalized.

Returns

  • The angular momentum.
source
GalaxyInspector.computeVcircMethod
computeVcirc(
    data_dict::Dict;
    <keyword arguments>
)::Tuple{Vector{<:Unitful.Length},Vector{<:Unitful.Velocity}}

Compute the circular velocity of each particle of the given type, with respect to the origin.

The circular velocity of a particle is,

\[v_\mathrm{circ} = \sqrt{\frac{\mathrm{G} \, M(r)}{r}} \, ,\]

where $r$ is the radial distance of the particle, and $M(r)$ is the total mass within a sphere of radius $r$.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • type::Symbol=:stars: Target component.

Returns

  • A tuple with two elements:

    • A vector with the radial distance of each particle to the origin.
    • A vector with the circular velocity of each particle.
source
GalaxyInspector.computeVcmMethod
computeVcm(data_dict::Dict, subhalo_abs_idx::Int)::Vector{<:Unitful.Velocity}

Read the velocity of the center of mass of a given subhalo.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • subhalo_abs_idx::Int: Absolute index of the target subhalo (subfind). Starts at 1.

Returns

  • The specified velocity.
source
GalaxyInspector.computeVcmMethod
computeVcm(data_dict::Dict, cm_type::Symbol)::Vector{<:Unitful.Velocity}

Compute the velocity of a characteristic center of the system.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • cm_type::Symbol: It can be:

    • :global_cm -> Center of mass of the whole system.
    • :{component} -> Center of mass of the given component (e.g. :stars, :gas, :halo, etc). It can be any of the keys of PARTICLE_INDEX.
    • :zero -> Origin.

Returns

  • The specified velocity.
source
GalaxyInspector.computeVcmMethod
computeVcm(data_dict::Dict, subfind_idx::NTuple{2,Int})::Vector{<:Unitful.Velocity}

Read the velocity of the center of mass of a given halo or subhalo.

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • subfind_idx::NTuple{2,Int}: Tuple with two elements:

    • Index of the target halo (FoF group). Starts at 1.
    • Index of the target subhalo (subfind), relative to the target halo. Starts at 1. If it is set to 0, the potential minimum of the halo with index halo_idx is returned.

Returns

  • The specified velocity.
source
GalaxyInspector.computeVpolarMethod
computeVpolar(
    data_dict::Dict,
    component::Symbol;
    <keyword arguments>
)::Vector{<:Unitful.Velocity}

Compute the cylindrical components of the velocity, $\mathbf{\vec{v}} = v_r \, \mathbf{e_r} + v_\theta \, \mathbf{e_\theta} + v_z \, \mathbf{e_z}$.

The speed in the radial direction expressed in Cartesian coordinates is

\[v_r = \frac{x \, v_x + y \, v_y}{\sqrt(x^2 + y^2)} \, ,\]

in the tangential direction is

\[v_\tau = \frac{x \, v_y - y \, v_x}{\sqrt(x^2 + y^2)} \, ,\]

and the speed in the z direction will be computes as

\[v^*_z = v_z \, \mathrm{sign}(z) \, ,\]

in order to distinguish between inflows ($v^*_z < 0$) and outflows ($v^*_z > 0$).

Arguments

  • data_dict::Dict: A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
  • component::Symbol: Which component will be calculated. The options are:

    • :radial -> Stellar radial speed ($v_r$).
    • :tangential -> Stellar tangential speed ($v_\theta$).
    • :zstar -> Stellar speed in the z direction, computed as $v_z \, \mathrm{sign}(z)$.
  • type::Symbol=:stars: Target cell/particle type.

Returns

  • The chosen cylindrical component of the velocity.
source