CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling_ThreePointCorrelation.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2017 by Federico Marulli *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
42 
43 using namespace std;
44 
45 using namespace cbl;
46 using namespace measure;
47 using namespace measure::threept;
48 using namespace modelling;
49 using namespace measure::threept;
50 
51 
52 // ============================================================================================
53 
54 
55 std::shared_ptr<cbl::modelling::threept::Modelling_ThreePointCorrelation> cbl::modelling::threept::Modelling_ThreePointCorrelation::Create (const std::shared_ptr<measure::threept::ThreePointCorrelation> threept)
56 {
57  if (threept->threePType()==measure::threept::ThreePType::_angular_connected_)
58  return move(unique_ptr<Modelling_ThreePointCorrelation_angular_connected> (new Modelling_ThreePointCorrelation_angular_connected(threept)));
59 
60  else if (threept->threePType()==measure::threept::ThreePType::_angular_reduced_)
61  return move(unique_ptr<modelling::threept::Modelling_ThreePointCorrelation_angular_reduced> (new Modelling_ThreePointCorrelation_angular_reduced(threept)));
62 
63  else if (threept->threePType()==measure::threept::ThreePType::_comoving_connected_)
64  return move(unique_ptr<Modelling_ThreePointCorrelation_comoving_connected> (new Modelling_ThreePointCorrelation_comoving_connected(threept)));
65 
66  else if (threept->threePType()==measure::threept::ThreePType::_comoving_reduced_)
67  return move(unique_ptr<Modelling_ThreePointCorrelation_comoving_reduced> (new Modelling_ThreePointCorrelation_comoving_reduced(threept)));
68 
69  else ErrorCBL("no such type of object, or error in the input parameters!", "Create", "Modelling_ThreePointCorrelation.cpp");
70 
71  return NULL;
72 }
73 
74 
75 // ============================================================================================
76 
77 
78 std::shared_ptr<cbl::modelling::threept::Modelling_ThreePointCorrelation> cbl::modelling::threept::Modelling_ThreePointCorrelation::Create (const measure::threept::ThreePType threePType, const std::shared_ptr<data::Data> threept_dataset)
79 {
80  if (threePType==measure::threept::ThreePType::_angular_connected_)
81  return move(unique_ptr<Modelling_ThreePointCorrelation_angular_connected> (new Modelling_ThreePointCorrelation_angular_connected(threept_dataset)));
82 
83  else if (threePType==measure::threept::ThreePType::_angular_reduced_)
84  return move(unique_ptr<Modelling_ThreePointCorrelation_angular_reduced> (new Modelling_ThreePointCorrelation_angular_reduced(threept_dataset)));
85 
86  else if (threePType==measure::threept::ThreePType::_comoving_connected_)
87  return move(unique_ptr<Modelling_ThreePointCorrelation_comoving_connected> (new Modelling_ThreePointCorrelation_comoving_connected(threept_dataset)));
88 
89  else if (threePType==measure::threept::ThreePType::_comoving_reduced_)
90  return move(unique_ptr<Modelling_ThreePointCorrelation_comoving_reduced> (new Modelling_ThreePointCorrelation_comoving_reduced(threept_dataset)));
91 
92  else ErrorCBL("no such type of object, or error in the input parameters!", "Create", "Modelling_ThreePointCorrelation.cpp");
93 
94  return NULL;
95 }
96 
97 // ============================================================================================
98 
99 
101 {
102  m_data_model.Q_DM = Q_DM;
103 }
104 
105 
106 // ============================================================================================
107 
108 
109 void cbl::modelling::threept::Modelling_ThreePointCorrelation::set_data_Q_nonlocal (const cosmology::Cosmology cosmology, const double r1, const double r2, const std::vector<double> theta, const string model, const std::vector<double> kk, const std::vector<double> Pk_matter)
110 {
111  m_data_model.cosmology = make_shared<cosmology::Cosmology>(cosmology);
112  m_data_model.r1 = r1;
113  m_data_model.r2 = r2;
114  m_data_model.theta = theta;
115  m_data_model.model = model;
116  m_data_model.kk = kk;
117  m_data_model.Pk_matter = Pk_matter;
118 }
119 
120 
121 // ============================================================================================
122 
123 
124 void cbl::modelling::threept::Modelling_ThreePointCorrelation::set_data_model_zeta_RSD (const double r1, const double r2, const cosmology::Cosmology cosmology, const double redshift, const string method_Pk, const bool NL, const int max_ll, const double k_min, const double k_max, const int step_k, const double r_min, const double r_max, const int step_r, const bool force_realSpace, const bool use_k, const bool store_output, const string output_root, const int norm, const double prec)
125 {
126  m_data_model.cosmology = make_shared<cosmology::Cosmology>(cosmology);
127 
128  m_data_model.r1 = r1;
129  m_data_model.r2 = r2;
130  m_data_model.redshift = redshift;
131  m_data_model.method_Pk = method_Pk;
132  m_data_model.NL = NL;
133  m_data_model.k_min = k_min;
134  m_data_model.k_max = k_max;
135  m_data_model.step_k = step_k;
136  m_data_model.kk = logarithmic_bin_vector(m_data_model.step_k, m_data_model.k_min, m_data_model.k_max);
137  m_data_model.r_min = r_min;
138  m_data_model.r_max = r_max;
139  m_data_model.step_r = step_r;
140  m_data_model.rr = linear_bin_vector(m_data_model.step_r, m_data_model.r_min, m_data_model.r_max);
141  m_data_model.store_output = store_output;
142  m_data_model.output_root = output_root;
143  m_data_model.norm = norm;
144  m_data_model.prec = prec;
145  m_data_model.force_realSpace = force_realSpace;
146  m_data_model.max_ll = max_ll;
147  m_data_model.use_k = use_k;
148 
149 
150  try {
151  m_data_model.sigma8_z = m_data_model.cosmology->sigma8(m_data_model.redshift);
152  }
153  catch(cbl::glob::Exception &exc) {
154  coutCBL << "sigma8 is not set, computing from the power spectrum, method_Pk = "+m_data_model.method_Pk << endl;
155  m_data_model.sigma8_z = m_data_model.cosmology->sigma8_Pk(m_data_model.method_Pk, m_data_model.redshift, m_data_model.store_output, m_data_model.output_root);
156  }
157  m_data_model.linear_growth_rate_z = m_data_model.cosmology->linear_growth_rate(m_data_model.redshift, 1.);
158 
159  m_data_model.Pk_matter = m_data_model.cosmology->Pk_matter(m_data_model.kk, m_data_model.method_Pk, m_data_model.NL, m_data_model.redshift, m_data_model.store_output, m_data_model.output_root, m_data_model.norm, m_data_model.k_min, m_data_model.k_max, m_data_model.prec);
160 }
#define coutCBL
CBL print message.
Definition: Kernel.h:734
The class Modelling_ThreePointCorrelation.
The class Modelling_ThreePointCorrelation_angular_connected.
The class Modelling_ThreePointCorrelation_angular_reduced.
The class Modelling_ThreePointCorrelation_comoving_connected.
The class Modelling_ThreePointCorrelation_comoving_reduced.
The class Cosmology.
Definition: Cosmology.h:277
The class Exception.
Definition: Exception.h:111
void set_data_model_zeta_RSD(const double r1, const double r2, const cbl::cosmology::Cosmology cosmology, const double redshift, const std::string method_Pk="CAMB", const bool NL=false, const int max_ll=5, const double k_min=1.e-4, const double k_max=100, const int step_k=500, const double r_min=1.e-4, const double r_max=200, const int step_r=200, const bool force_realSpace=false, const bool use_k=false, const bool store_output=true, const std::string output_root=cbl::par::defaultString, const int norm=-1, const double prec=1.e-4)
set the data model for the three-point correlation function (see Slepian, Eisenstein 2017)
static std::shared_ptr< Modelling_ThreePointCorrelation > Create(const std::shared_ptr< measure::threept::ThreePointCorrelation > threep)
static factory used to construct modelling of three-point correlation functions of any type
void set_data_model(const std::vector< double > Q_DM)
set the data model for the three-point correlation function
void set_data_Q_nonlocal(const cosmology::Cosmology cosmology, const double r1, const double r2, const std::vector< double > theta, const std::string model, const std::vector< double > kk, const std::vector< double > Pk_matter)
set the data model for the three-point correlation function with non-local contributions
ThreePType
the three-point correlation function type
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
std::vector< T > logarithmic_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with logarithmically spaced values
Definition: Kernel.h:1621
std::vector< T > linear_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with linearly spaced values
Definition: Kernel.h:1604
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780