the DF module

This method is strongly inspired from the nbodpy code from Errani: https://rerrani.github.io/code.html https://github.com/rerrani/nbopy

class pNbody.DF.DistributionFunction(Rmin=0.01, Rmax=100, Rinf=inf, NR=10000.0, NE=10000.0, fctDensity=None, fctCumulativeMass=None, fctPotential=None, TotalMass=None, G=1.0, EPSREL=1e-06)
Init()

Perform initialization

PLikelihood(e, r)

likelihood of a particle to have an energy E at a fixed radius dP/dr * DF(e)

checkDF()

check whether DF is physical - if not, check for rounding errors in integration, try increasing/decreasing NR, NE

clean()

clean DF

computeCumulativeMass()

compute the “normalized” cumulative mass

computeDF()

Compute the DF using the set of relative energies self.E

computeMaxLikelihood()

for each radius in self.R, compute the maximum likelihood

computePLikelihoodForR(R)

compute the energy probability distribution for a given radius

computeTotalMass()

compute the total mass function by numerical integration

dPdr(e, r)

phase space volume element per energy accessible at given energy e and fixed radius r sqrt( 2(psi-e) ) r^2 see BT, integrand of Eq 4.56

sample(N, Ndraw, irand=0)

N : number of particles to draw Ndraw : number of random numbers drawn at a time

return pos and vel

save(name, ftype, ptype, u)

save the model

setCumulativeMassfct()

define the “normalized” cumulative mass function (direct integration)

setDFfct()

define the distribution function through the Eddington formula. Note that we assume dnu/dpsi equal to 0.

setEnergyBins(log=False)

define a list of energy, from max(Psi) (R=Rmin) to Emax/NE (avoid E=0)

setNu()

set Nu (array), the probability (normalized density)

setPotentialfct()

define the potential function (it is faster to use quad instead of fctMr)

setPsi()

set Psi (array), the relative potential

setRadialBins(log=True)

define a list of radius