Nsenene

Documentation for Nsenene.

Nsenene.densitiesMethod
densities(profile, m)

Calculate the mass density of each field in profile, with particle masses m.

source
Nsenene.densityFunction
density(profile, m)

Calculate the total mass density of profile with particle masses m.

source
Nsenene.total_massMethod
total_mass(profile, m)

Calculate the total mass contained in profile, with particle masses m. Returns a scalar.

Examples

import Nsenene: CylindricalProfile, total_mass

n = 2
m = ones(1, 1, n)

p = CylindricalProfile(1000, 5.0, n)

# psi 1 is a cylinder of density 1.0, radius 1.0, height 2.0
p.psi[:, :, 1] .= (p.R .< 1) .&& (abs.(p.z) .< 2.0/2)

M = total_mass(p, m)
@assert isapprox(M, 2pi, rtol=1e-2)

# psi 2 is a cylinder of density 1.0, radius 1.0, height 4.0
p.psi[:, :, 2] .= (p.R .< 1) .&& (abs.(p.z) .< 4.0/2)

M = total_mass(p, m)
@assert isapprox(M, 2pi + 4pi, rtol=1e-2)

0.0

# output
0.0
source
Nsenene.total_massesFunction
total_masses(profile, m)

Calculate the mass contained by each field in profile, with particle masses m. Returns an array of masses.

Examples

import Nsenene: SphericalProfile, total_masses

n = 3
m = ones(1, n)

p = SphericalProfile(1000, 3.0, n)

# Ball of radius 1
p.psi[:, 1] .= p.r .< 1
# Ball of radius 2
p.psi[:, 2] .= p.r .< 2

M = total_masses(p, m)

@assert isapprox(M[1], 4/3 * π * 1^3, rtol=1e-2)
@assert isapprox(M[2], 4/3 * π * 2^3, rtol=1e-2)
M[3]

# output

0.0
source
Nsenene.Spherical._total_massesMethod
_total_masses(r, psi, m)

Calculate the mass contained by each field of psi with radial coordinates r and particle masses m.

Examples

import Nsenene.Spherical: _total_masses

resol = 1000
nfields = 2

m = ones(1, nfields)
r = range(0, 10, resol)
psi = zeros(resol, nfields)

# Ball of radius 1
psi[r.<1, 1] .= 1

M = _total_masses(psi, r, m)

@assert isapprox(M[1], 4/3 * π * 1^3, atol=1e-1)
M[2]

# output

0.0
source
Nsenene.Cylindrical.CylindricalProfileType
struct CylindricalProfile

Examples

import Nsenene.Cylindrical: CylindricalProfile

resol_R = 64
resol_z = 128

length_R = 10.0
length_z = 20.0

nfields = 2

p = CylindricalProfile(resol_R, resol_z, length_R, length_z, nfields)
maximum(p.R)

# output

10.0
source