CLASSpp Manual
Cosmology reference and developer manual
Loading...
Searching...
No Matches
input_module.h
Go to the documentation of this file.
1
3#ifndef __INPUT__
4#define __INPUT__
5
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "../species/base_species.h"
11#include "../species/species_build_context.h"
12#include "../species/species_collection.h"
13#include "background.h"
14#include "common.h"
15#include "lensing.h"
16#include "nonlinear.h"
17#include "output.h"
18#include "parser.h"
19#include "perturbations.h"
20#include "primordial.h"
21#include "quadrature.h"
22#include "spectra.h"
23#include "thermodynamics.h"
24#include "transfer.h"
25
26class Cosmology;
27
33 InputModulePtr input;
34 std::shared_ptr<Cosmology> converged;
35};
36
37class InputModule {
38 public:
39 InputModule(FileContent& fc);
40 static void file_content_from_arguments(int argc, char** argv, FileContent& fc);
41
47 static void RejectUnreadParameters(FileContent& fc);
48
52 static ShootingResult DoShooting(const InputModulePtr& input_module);
53
54 FileContent& file_content_;
55 precision precision_;
56 background background_;
57 thermo thermodynamics_;
58 perturbs perturbations_;
59 transfers transfers_;
60 primordial primordial_;
61 spectra spectra_;
62 nonlinear nonlinear_;
63 lensing lensing_;
64 output output_;
66 SpeciesCollection all_species_;
70 SpeciesOmegaBudget omega_budget_;
74 CoupledClusterInputs coupled_inputs_;
78 int shooting_evaluations_ = 0;
79 bool shooting_build_kept_ = false;
80
81 private:
82 // Hook-based shooting (used by DoShooting). theta_s is identified by
83 // target_name == "100*theta_s" / unknown_param == "h"; all targets are scalar.
84 struct ShootingWorkspace {
85 explicit ShootingWorkspace(FileContent& fc_ref) : fc(fc_ref) {}
86 FileContent& fc;
87 std::vector<ShootingTarget> targets; // theta_s first (if present), then species in lex order
88 // Parallel to targets: the all_species_ key owning each target ("" for the module-level
89 // theta_s). Lets ShootingResidual route each slot to its species' ComputeShootingResidual
90 // with the authoritative target (so the species never re-derives it from the file content).
91 std::vector<std::string> target_species_keys;
92 // Parallel to targets: each unknown is solved for in units of its seed's magnitude, so one
93 // tol_shooting_deltax is relative for every target.
94 std::vector<double> unknown_scale;
95 // The most recent successful evaluation: the only one a solver can return without
96 // evaluating again. Its unknowns are the exact strings written into the file content.
97 std::shared_ptr<Cosmology> last;
98 InputModule* last_input = nullptr;
99 std::vector<std::string> last_unknowns;
100 int evaluations = 0;
101 };
102 static void ShootingResidual(const double* x, int x_size, double* output, ShootingWorkspace* w);
103
104 void ConstructSpecies();
105
114 void ReadCoupledCluster();
115
116 void ReadContext(); // phase i: inputs needed to build species
117 void ReadDerived(); // phase iii: everything else + species-dependent reads
118 void SelectPerturbationEvolver(); // phase iv: opt into the explicit evolver
119 void WriteParameterFiles(); // read/unread parameter dump (runs after ReadDerived)
120 void input_read_precisions();
121};
122
123#endif
Definition parser.h:23
Definition species_collection.h:33
Definition input_module.h:32
Definition lensing.h:15
Definition nonlinear.h:53
Definition output.h:24
Definition perturbations.h:99
Definition primordial.h:56
Definition spectra.h:15
Definition species_build_context.h:45
Definition species_build_context.h:30
Definition precision.h:79
Definition thermodynamics.h:72
Definition transfer.h:19