Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
anonymous_namespace{chameleon.cpp} Namespace Reference

Classes

class  ChiSolver
 : class to solve chameleon equations of motion More...
 

Typedefs

typedef double CHI_PREC_t
 accuracy of chameleon solver More...
 
using ES = MultiGridSolver< 3, CHI_PREC_t >::Exit_Status
 acces Exit_Status namespace More...
 

Functions

template<typename T >
void transform_Mesh_to_Grid (const Mesh &mesh, Grid< 3, T > &grid)
 
template<typename T >
void transform_Mesh_to_MultiGrid (const Mesh &mesh, MultiGrid< 3, T > &mltgrid)
 
template<typename T >
void transform_Grid_to_Mesh (Mesh &mesh, const Grid< 3, T > &grid)
 
template<typename T >
void transform_MultiGrid_to_Mesh (Mesh &mesh, const MultiGrid< 3, T > &mltgrid)
 
template<typename T >
void transform_MultiGridSolver_to_Mesh (Mesh &mesh, const MultiGridSolver< 3, T > &sol)
 
template<typename T >
min (const std::vector< T > &data)
 
double min (const Mesh &data)
 
template<typename T >
double min (const Grid< 3, T > &grid)
 
template<typename T >
double min (const MultiGrid< 3, T > &grid)
 

Variables

constexpr double MPL = (double)1
 mass & chi in units of Planck mass More...
 
constexpr double c_kms = (double)299792.458
 speed of light [km / s] More...
 
constexpr CHI_PREC_t MARK_CHI_BOUND_COND = (CHI_PREC_t)-2
 unphysical value of overdensity (< -1) used to indicate that chameleon filed at this point should not be changed More...
 
constexpr CHI_PREC_t SWITCH_BIS_NEW = (CHI_PREC_t)0.1
 when the relative change in solution is less than this, use Newton`s method. Bisection method otherwise More...
 
constexpr CHI_PREC_t CHI_MIN = (CHI_PREC_t)-1
 minimum value of chameleon field, in chi_a units it is '0', in phi units it is '-1' More...
 
constexpr double CONVERGENCE_RES = 0
 stop when total (rms) residual below More...
 
constexpr double CONVERGENCE_RES_MIN = 0
 do not stop if solution didn`t converge below More...
 
constexpr double CONVERGENCE_ERR = 0.97
 stop when improvements between steps slow below More...
 
constexpr double CONVERGENCE_ERR_MIN = 0.8
 do not stop if solution is still improving More...
 
constexpr size_t CONVERGENCE_NUM_FAIL = 5
 stop when number of failed steps is over More...
 
constexpr size_t CONVERGENCE_BI_STEPS = 5
 maximal number of steps inside bisection rootfindg method More...
 
constexpr size_t CONVERGENCE_BI_STEPS_INIT = 3
 maximal number of steps inside bisection initialization method More...
 
constexpr CHI_PREC_t CONVERGENCE_BI_DCHI = (CHI_PREC_t)1e-2
 stop bisection method when chi doesn`t chanege More...
 
constexpr CHI_PREC_t CONVERGENCE_BI_L = (CHI_PREC_t)1e-2
 stop bisection method when residual below More...
 

Detailed Description

PRIVATE FUNCTIONS DEFINITIONS *

Typedef Documentation

anonymous_namespace{chameleon.cpp}::CHI_PREC_t

accuracy of chameleon solver

Definition at line 31 of file chameleon.cpp.

using anonymous_namespace{chameleon.cpp}::ES = typedef MultiGridSolver<3, CHI_PREC_t>::Exit_Status

acces Exit_Status namespace

Definition at line 86 of file chameleon.cpp.

Function Documentation

double anonymous_namespace{chameleon.cpp}::min ( const Mesh data)

Definition at line 142 of file chameleon.cpp.

References Mesh_base< T >::data, and min().

142 { return min(data.data); }
double min(const MultiGrid< 3, T > &grid)
Definition: chameleon.cpp:148
std::vector< T > data
Definition: class_mesh.hpp:33
template<typename T >
double anonymous_namespace{chameleon.cpp}::min ( const Grid< 3, T > &  grid)

Definition at line 145 of file chameleon.cpp.

References Grid< NDIM, T >::get_vec(), and min().

145 { return min(grid.get_vec()); }
double min(const MultiGrid< 3, T > &grid)
Definition: chameleon.cpp:148
const std::vector< T > & get_vec() const
Definition: grid.cpp:51
template<typename T >
double anonymous_namespace{chameleon.cpp}::min ( const MultiGrid< 3, T > &  grid)

Definition at line 148 of file chameleon.cpp.

References MultiGrid< NDIM, T >::get_grid().

Referenced by min().

148 { return min(grid.get_grid()); }
double min(const MultiGrid< 3, T > &grid)
Definition: chameleon.cpp:148
Grid< NDIM, T > & get_grid(size_t level=0)
Definition: multigrid.cpp:17
template<typename T >
void anonymous_namespace{chameleon.cpp}::transform_Grid_to_Mesh ( Mesh mesh,
const Grid< 3, T > &  grid 
)

Definition at line 115 of file chameleon.cpp.

References Grid< NDIM, T >::get_N(), Grid< NDIM, T >::get_Ntot(), mfunc_bm::iz, and Mesh::N.

Referenced by anonymous_namespace{chameleon.cpp}::ChiSolver< T >::set_linear_recursively(), transform_MultiGrid_to_Mesh(), and transform_MultiGridSolver_to_Mesh().

116 {/* copy data in MultiGrid 'N*N*N' onto Mesh 'N*N*(N+2)' */
117  size_t ix, iy, iz;
118  const size_t N_tot = grid.get_Ntot();
119  const size_t N = grid.get_N();
120 
121  if (mesh.N != N) throw std::range_error("Mesh of a different size than Grid!");
122 
123  #pragma omp parallel for private(ix, iy, iz)
124  for (size_t i = 0; i < N_tot; ++i)
125  {
126  ix = i % N;
127  iy = i / N % N;
128  iz = i / (N*N);
129  mesh(ix, iy, iz) = grid[i];
130  }
131 }
int iz
Definition: mfunc_bm.py:17
size_t get_N() const
Definition: grid.cpp:135
size_t get_Ntot() const
Definition: grid.cpp:141
size_t N
Definition: class_mesh.hpp:102
template<typename T >
void anonymous_namespace{chameleon.cpp}::transform_Mesh_to_Grid ( const Mesh mesh,
Grid< 3, T > &  grid 
)

Definition at line 89 of file chameleon.cpp.

References Grid< NDIM, T >::get_N(), Grid< NDIM, T >::get_Ntot(), mfunc_bm::iz, and Mesh::N.

Referenced by anonymous_namespace{chameleon.cpp}::ChiSolver< T >::set_linear_sol_at_level(), and transform_Mesh_to_MultiGrid().

90 {/* copy data in Mesh 'N*N*(N+2)' onto MultiGrid 'N*N*N' */
91  size_t ix, iy, iz;
92  const size_t N_tot = grid.get_Ntot();
93  const size_t N = grid.get_N();
94 
95  if (mesh.N != N) throw std::range_error("Mesh of a different size than Grid!");
96 
97  #pragma omp parallel for private(ix, iy, iz)
98  for (size_t i = 0; i < N_tot; ++i)
99  {
100  ix = i % N;
101  iy = i / N % N;
102  iz = i / (N*N);
103  grid[i] = mesh(ix, iy, iz);
104  }
105 }
int iz
Definition: mfunc_bm.py:17
size_t get_N() const
Definition: grid.cpp:135
size_t get_Ntot() const
Definition: grid.cpp:141
size_t N
Definition: class_mesh.hpp:102
template<typename T >
void anonymous_namespace{chameleon.cpp}::transform_Mesh_to_MultiGrid ( const Mesh mesh,
MultiGrid< 3, T > &  mltgrid 
)

Definition at line 108 of file chameleon.cpp.

References MultiGrid< NDIM, T >::get_grid(), MultiGrid< NDIM, T >::restrict_down_all(), and transform_Mesh_to_Grid().

Referenced by anonymous_namespace{test_chameleon.cpp}::init_overdensity(), App_Var_Chi::ChiImpl::solve(), and TEST_CASE().

109 {
110  transform_Mesh_to_Grid(mesh, mltgrid.get_grid());
111  mltgrid.restrict_down_all();
112 }
void restrict_down_all()
Definition: multigrid.cpp:209
Grid< NDIM, T > & get_grid(size_t level=0)
Definition: multigrid.cpp:17
void transform_Mesh_to_Grid(const Mesh &mesh, Grid< 3, T > &grid)
Definition: chameleon.cpp:89
template<typename T >
void anonymous_namespace{chameleon.cpp}::transform_MultiGrid_to_Mesh ( Mesh mesh,
const MultiGrid< 3, T > &  mltgrid 
)

Definition at line 134 of file chameleon.cpp.

References MultiGrid< NDIM, T >::get_grid(), and transform_Grid_to_Mesh().

Referenced by TEST_CASE().

134 { transform_Grid_to_Mesh(mesh, mltgrid.get_grid()); }
void transform_Grid_to_Mesh(Mesh &mesh, const Grid< 3, T > &grid)
Definition: chameleon.cpp:115
Grid< NDIM, T > & get_grid(size_t level=0)
Definition: multigrid.cpp:17
template<typename T >
void anonymous_namespace{chameleon.cpp}::transform_MultiGridSolver_to_Mesh ( Mesh mesh,
const MultiGridSolver< 3, T > &  sol 
)

Definition at line 137 of file chameleon.cpp.

References MultiGridSolver< NDIM, T >::get_grid(), and transform_Grid_to_Mesh().

Referenced by App_Var_Chi::ChiImpl::gen_pow_spec_binned(), App_Var_Chi::ChiImpl::get_chi_force(), and TEST_CASE().

137 { transform_Grid_to_Mesh(mesh, sol.get_grid()); }
Grid< NDIM, T > & get_grid(size_t level=0)
void transform_Grid_to_Mesh(Mesh &mesh, const Grid< 3, T > &grid)
Definition: chameleon.cpp:115

Variable Documentation

anonymous_namespace{chameleon.cpp}::c_kms = (double)299792.458

speed of light [km / s]

Definition at line 45 of file chameleon.cpp.

anonymous_namespace{chameleon.cpp}::MARK_CHI_BOUND_COND = (CHI_PREC_t)-2

unphysical value of overdensity (< -1) used to indicate that chameleon filed at this point should not be changed

Definition at line 52 of file chameleon.cpp.

Referenced by anonymous_namespace{chameleon.cpp}::ChiSolver< T >::set_screened().

anonymous_namespace{chameleon.cpp}::MPL = (double)1

mass & chi in units of Planck mass

Definition at line 38 of file chameleon.cpp.

anonymous_namespace{chameleon.cpp}::SWITCH_BIS_NEW = (CHI_PREC_t)0.1

when the relative change in solution is less than this, use Newton`s method. Bisection method otherwise

Definition at line 59 of file chameleon.cpp.