GLAMERDOC++
Gravitational Lensing Code Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TreeQuadParticles< PType > Class Template Reference

TreeQuadParticles is a class for calculating the deflection, kappa and gamma by tree method. More...

#include <quadTree.h>

Public Member Functions

 TreeQuadParticles (PType *xpt, IndexType Npoints, float mass_fixed=-1, float size_fixed=-1, PosType my_inv_area=0, int bucket=5, PosType theta_force=0.1, bool my_periodic_buffer=false, PosType my_inv_screening_scale=0, PosType maximum_range=-1)
 Constructor meant for point particles, simulation particles. More...
 
 ~TreeQuadParticles ()
 Particle positions and other data are not destroyed.
 
void force2D (PosType const *ray, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi) const
 Force2D calculates the defection, convergence and shear using the plane-lens approximation. The tree is walked iteratively. More...
 
void force2D_recur (const PosType *ray, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi)
 Force2D_recur calculates the defection, convergence and shear using the plane-lens approximation. More...
 
void neighbors (PosType ray[], PosType rmax, std::list< IndexType > &neighbors) const
 find all points within rmax of ray in 2D More...
 
void printParticlesInBranch (unsigned long number)
 
void printBranchs (int level=-1)
 

Protected Member Functions

void BuildQTreeNB (PType *xp, IndexType Nparticles)
 
void _BuildQTreeNB (IndexType nparticles, IndexType *particles)
 tree must be created and first branch must be set before start
 
short WhichQuad (PosType *x, QBranchNB &branch)
 returns an index for which of the four quadrangles of the branch the point x[] is in
 
bool inbox (const PosType *ray, const PosType *p1, const PosType *p2)
 
void CalcMoments ()
 
void rotate_coordinates (PosType **coord)
 simple rotates the coordinates in the xp array
 
PosType alpha_h (PosType r2s2, PosType sigma) const
 
PosType kappa_h (PosType r2s2, PosType sigma) const
 
PosType gamma_h (PosType r2s2, PosType sigma) const
 
PosType phi_h (PosType r2s2, PosType sigma) const
 
void b_spline_profile (PosType *xcm, PosType r, PosType Mass, PosType size, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi) const
 
void exponential_profile (PosType *xcm, PosType rcm2, PosType Mass, PosType size, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi) const
 
void cuttoffscale (QTreeNB< PType > *tree, PosType *theta)
 
void walkTree_recur (QBranchNB *branch, PosType const *ray, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi)
 
void walkTree_iter (QBiterator< PType > &treeit, PosType const *ray, PosType *alpha, KappaType *kappa, KappaType *gamma, KappaType *phi) const
 

Protected Attributes

PType * xxp
 
bool MultiMass
 
double mass_fixed = 0.0
 
bool MultiRadius
 
double size_fixed = 0.0
 
double inv_area
 
IndexType Nparticles
 
int Nbucket
 
PosType force_theta
 
PosType max_range
 
std::unique_ptr< QTreeNB< PType > > tree
 
std::vector< IndexType > index
 
std::vector< PosType > workspace
 
PosType realray [2]
 
int incell
 
int incell2
 
bool periodic_buffer
 if true there is one layer of peridic buffering
 
PosType inv_screening_scale2
 
PosType original_xl
 
PosType original_yl
 
PosType phiintconst
 

Detailed Description

template<typename PType>
class TreeQuadParticles< PType >

TreeQuadParticles is a class for calculating the deflection, kappa and gamma by tree method.

simpleTree.h

Created on: Oct 14, 2011 Author: bmetcalf

  TreeQuadParticles is evolved from TreeSimple and TreeForce.  It splits each cell into four equal area
  subcells instead of being a binary tree like TreeSimple.  When the "particles" are given sizes
  the tree is built in such a way the large particles are stored in branches that are no smaller
  than their size.  In this way particles are stored on all levels of the tree and not just in the
  leaves.  This improves efficiency when particles of a wide range of sizes overlap in 2D.
  The default value of theta = 0.1 generally gives better than 1% accuracy on alpha.
  The shear and kappa are always more accurate than the deflection.
   Parameters:
    inv_area - If not zero, there is an effective uniform negative mass sheet that compensates for the positive mass.  This should be this should be set to the area in Mpc^-2 over which the integral of the surface density should be zero.
*

Constructor & Destructor Documentation

◆ TreeQuadParticles()

template<typename PType >
TreeQuadParticles< PType >::TreeQuadParticles ( PType *  xpt,
IndexType  Npoints,
float  mass_fixed = -1,
float  size_fixed = -1,
PosType  my_inv_area = 0,
int  bucket = 5,
PosType  theta_force = 0.1,
bool  my_periodic_buffer = false,
PosType  my_inv_screening_scale = 0,
PosType  maximum_range = -1 
)

Constructor meant for point particles, simulation particles.

Parameters
my_inv_areaif the total mass in field is meant to be zero this should be set to the inverse of the area of the region in Mpc^-2
my_periodic_bufferif true a periodic buffer will be imposed in the force calulation. See documentation on TreeQuadParticles::force2D() for details. See note for TreeQuadParticles::force2D_recur().
my_inv_screening_scalethe inverse of the square of the sreening length. See note for TreeQuadParticles::force2D_recur().
maximum_rangeif set this will cause the tree not be fully construct down to the bucket size outside this range

Member Function Documentation

◆ force2D()

template<typename PType >
void TreeQuadParticles< PType >::force2D ( PosType const *  ray,
PosType *  alpha,
KappaType *  kappa,
KappaType *  gamma,
KappaType *  phi 
) const

Force2D calculates the defection, convergence and shear using the plane-lens approximation. The tree is walked iteratively.

The output alpha[] is in units of mass_scale/Mpc, ie it needs to be
divided by Sigma_crit and multiplied by mass_scale to be the deflection
in the lens equation expressed on the lens plane or multiplied by
4*pi*G*mass_scale to get the deflection angle caused by the plane lens.

kappa and gamma need to by multiplied by mass_scale/Sigma_crit to get
the traditional units for these where Sigma_crit are in the mass/units(ray)^2
NB : the units of sigma_backgound need to be mass/units(ray)^2

If periodic_buffer == true a periodic buffer is included. The ray is calculated as if there where identical copies of it on the borders of the tree's root branch. This is not the same thing as periodic boundary conditions, because there are not an infinite number of copies in all direction as for the DFT force solver.

If inv_screening_scale2 != 0 the mass of cells are reduced by a factor of exp(-|ray - center of mass|^2*inv_screening_scale2) which screens the large scale geometry of the simulation on the sky. This is useful when the region is rectangular instead of circular.

◆ force2D_recur()

template<typename PType >
void TreeQuadParticles< PType >::force2D_recur ( const PosType *  ray,
PosType *  alpha,
KappaType *  kappa,
KappaType *  gamma,
KappaType *  phi 
)

Force2D_recur calculates the defection, convergence and shear using the plane-lens approximation.

This function should do the same work as TreeQuadParticles::force2D() except it is done recursively instead of iteratively. This is done to enable multi-threading of the force calculation.

 The output alpha[] is in units of mass_scale/Mpc, ie it needs to be
 divided by Sigma_crit and multiplied by mass_scale to be the deflection
 in the lens equation expressed on the lens plane or multiplied by
 4*pi*G*mass_scale to get the deflection angle caused by the plane lens.

 kappa and gamma need to by multiplied by mass_scale/Sigma_crit to get
 the traditional units for these where Sigma_crit are in the mass/units(ray)^2
 NB : the units of sigma_backgound need to be mass/units(ray)^2

If periodic_buffer == true a periodic buffer is included. The ray is calculated as if there where identical copies of it on the borders of the tree's root branch. This is not the same thing as periodic boundary conditions, because there are not an infinite number of copies in all direction as for the DFT force solver.

If inv_screening_scale2 != 0 the mass of cells are reduced by a factor of exp(-|ray - center of mass|^2*inv_screening_scale2) which screens the large scale geometry of the simulation on the sky. This is useful when the region is rectangular instead of circular.

◆ neighbors()

template<typename PType >
void TreeQuadParticles< PType >::neighbors ( PosType  ray[],
PosType  rmax,
std::list< IndexType > &  neighbors 
) const

find all points within rmax of ray in 2D

Returns the halos that are within rmax of ray[].

◆ printBranchs()

template<typename PType >
void TreeQuadParticles< PType >::printBranchs ( int  level = -1)

Prints to stdout the borders of each branch in the tree below level. If level < 0 or not specified the whole tree will be printed.

◆ printParticlesInBranch()

template<typename PType >
void TreeQuadParticles< PType >::printParticlesInBranch ( unsigned long  number)

This is a diagnostic routine that prints the position of every point in a given branch of the tree.


The documentation for this class was generated from the following file: