2void skip_lines(std::ifstream& file,
int skip_lines) {
4 for(
auto i = 0; i < skip_lines; i ++) {
5 if (!std::getline(file, temp)) {
6 std::cerr <<
"Failed to read or fewer lines in file." << std::endl;
12std::tuple<PG_Kernel<T>,
Raytracer<T>> import_single(std::string foldername) {
14 std::string filename = foldername +
"/inputs.txt";
15 std::ifstream file(filename);
16 std::vector<std::string> inputs;
17 std::vector<std::string> surface_inputs;
19 std::string param_name, equal_sign, value, comment, unit;
21 for(
int i = 0; i < 60; i ++) {
22 std::getline(file, temp);
23 std::stringstream ss(temp);
24 if(ss >> param_name >> equal_sign >> value) {
25 inputs.push_back(value);
29 std::string geometry_file = inputs[1].c_str();
30 std::string surf_prop_file = inputs[2].c_str();
32 Surface<T> surf(foldername +
"/surface_files/" + geometry_file, foldername +
"/surface_files/" + surf_prop_file);
34 T offset_x =
static_cast<T
>(std::atof(inputs[3].c_str()));
35 T offset_y =
static_cast<T
>(std::atof(inputs[4].c_str()));
36 T offset_z =
static_cast<T
>(std::atof(inputs[5].c_str()));
37 T rotation_x =
static_cast<T
>(std::atof(inputs[6].c_str()));
38 T rotation_y =
static_cast<T
>(std::atof(inputs[7].c_str()));
39 T rotation_z =
static_cast<T
>(std::atof(inputs[8].c_str()));
40 T surf_temp =
static_cast<T
>(std::atof(inputs[9].c_str()));
42 T gas_molar_mass =
static_cast<T
>(std::atof(inputs[11].c_str()));
43 T gas_temperature =
static_cast<T
>(std::atof(inputs[12].c_str()));
44 T gas_speed =
static_cast<T
>(std::atof(inputs[13].c_str()));
46 void (*local_kernel)(T*, T*, T*, T*, T*);
49 GSI_parameters[0] =
static_cast<T
>(std::atof(inputs[15].c_str()));
50 GSI_parameters[1] =
static_cast<T
>(std::atof(inputs[16].c_str()));
52 long num_particles =
static_cast<long>(std::atof(inputs[18].c_str()));
54 T incidence_angle =
static_cast<T
>(std::atof(inputs[19].c_str())) * M_PI / 180.0;
56 local_kernel = sample_CLL;
58 T offset[4] = {offset_x, offset_y, offset_z};
60 surf.get_geometry().rotate(0, rotation_x * M_PI / 180.0);
61 surf.get_geometry().rotate(1, rotation_y * M_PI / 180.0);
62 surf.get_geometry().rotate(2, rotation_z * M_PI / 180.0);
63 surf.get_geometry().shift(offset);
64 surf.get_geometry().add_surface_property(
"temperature", surf_temp);
65 surf.get_geometry().add_GSI_property(
"alpha_n", GSI_parameters[0]);
66 surf.get_geometry().add_GSI_property(
"sigma_t", GSI_parameters[1]);
67 surf.get_local_parameters()[0] = surf_temp;
68 surf.get_local_parameters()[1] = GSI_parameters[0];
69 surf.get_local_parameters()[2] = GSI_parameters[1];
71 Gas<T> atmosphere(1.0, gas_temperature, gas_molar_mass, gas_speed);
73 Matrix<T> incident_velocity(3, 1, {std::sin(incidence_angle) * gas_speed, 0.0, - std::cos(incidence_angle) * gas_speed});
75 PG_Kernel<T> kernel(surf, atmosphere, local_kernel, incident_velocity, num_particles,
"single");
76 Raytracer<T> raytracer(surf, atmosphere, local_kernel, incident_velocity, num_particles,
"single");
78 return std::make_tuple(kernel, raytracer);
83std::tuple<std::vector<PG_Kernel<T>>, std::vector<Raytracer<T>>> import_batch(std::string foldername) {
85 std::string filename = foldername +
"/inputs.txt";
86 std::ifstream file(filename);
87 std::vector<std::string> inputs;
88 std::vector<std::string> surface_inputs;
90 std::string param_name, equal_sign, value, comment, unit;
92 for(
int i = 0; i < 60; i ++) {
93 std::getline(file, temp);
94 std::stringstream ss(temp);
95 if(ss >> param_name >> equal_sign >> value) {
96 inputs.push_back(value);
100 std::string geometry_file = inputs[1].c_str();
101 std::string surf_prop_file = inputs[2].c_str();
103 T offset_x =
static_cast<T
>(std::atof(inputs[3].c_str()));
104 T offset_y =
static_cast<T
>(std::atof(inputs[4].c_str()));
105 T offset_z =
static_cast<T
>(std::atof(inputs[5].c_str()));
106 T rotation_x =
static_cast<T
>(std::atof(inputs[6].c_str()));
107 T rotation_y =
static_cast<T
>(std::atof(inputs[7].c_str()));
108 T rotation_z =
static_cast<T
>(std::atof(inputs[8].c_str()));
109 T surf_temp =
static_cast<T
>(std::atof(inputs[9].c_str()));
111 T gas_molar_mass =
static_cast<T
>(std::atof(inputs[11].c_str()));
112 T gas_temperature =
static_cast<T
>(std::atof(inputs[12].c_str()));
113 T gas_speed =
static_cast<T
>(std::atof(inputs[13].c_str()));
115 void (*local_kernel)(T*, T*, T*, T*, T*);
118 GSI_parameters[0] =
static_cast<T
>(std::atof(inputs[15].c_str()));
119 GSI_parameters[1] =
static_cast<T
>(std::atof(inputs[16].c_str()));
121 long num_particles =
static_cast<long>(std::atof(inputs[18].c_str()));
123 T incidence_angle =
static_cast<T
>(std::atof(inputs[19].c_str()));
125 T incidence_angle_start =
static_cast<T
>(std::atof(inputs[21].c_str())) * M_PI / 180.0;
126 T incidence_angle_end =
static_cast<T
>(std::atof(inputs[22].c_str())) * M_PI / 180.0;
127 T incidence_angle_step =
static_cast<T
>(std::atof(inputs[23].c_str())) * M_PI / 180.0;
129 T alpha_n_start =
static_cast<T
>(std::atof(inputs[24].c_str()));
130 T alpha_n_end =
static_cast<T
>(std::atof(inputs[25].c_str()));
131 T alpha_n_step =
static_cast<T
>(std::atof(inputs[26].c_str()));
133 T sigma_t_start =
static_cast<T
>(std::atof(inputs[27].c_str()));
134 T sigma_t_end =
static_cast<T
>(std::atof(inputs[28].c_str()));
135 T sigma_t_step =
static_cast<T
>(std::atof(inputs[29].c_str()));
137 local_kernel = sample_CLL;
139 std::vector<PG_Kernel<T>> kernels;
140 std::vector<Raytracer<T>> raytracers;
142 for(
long i = 0; i <= (long)((incidence_angle_end - incidence_angle_start) / incidence_angle_step); i ++) {
143 for(
long j = 0; j <= (long)((alpha_n_end - alpha_n_start) / alpha_n_step); j ++) {
144 for(
long k = 0; k <= (long)((sigma_t_end - sigma_t_start) / sigma_t_step); k ++) {
146 T incidence_angle_local = incidence_angle_start + (T)(i) * incidence_angle_step;
147 T alpha_n_local = alpha_n_start + (T)(j) * alpha_n_step;
148 T sigma_t_local = sigma_t_start + (T)(k) * sigma_t_step;
150 Surface<T> surf(foldername +
"/surface_files/" + geometry_file, foldername +
"/surface_files/" + surf_prop_file);
152 T offset[4] = {offset_x, offset_y, offset_z};
154 surf.get_geometry().rotate(0, rotation_x * M_PI / 180.0);
155 surf.get_geometry().rotate(1, rotation_y * M_PI / 180.0);
156 surf.get_geometry().rotate(2, rotation_z * M_PI / 180.0);
157 surf.get_geometry().shift(offset);
158 surf.get_geometry().add_surface_property(
"temperature", surf_temp);
159 surf.get_geometry().add_GSI_property(
"alpha_n", alpha_n_local);
160 surf.get_geometry().add_GSI_property(
"sigma_t", sigma_t_local);
161 surf.get_local_parameters()[0] = surf_temp;
162 surf.get_local_parameters()[1] = alpha_n_local;
163 surf.get_local_parameters()[2] = sigma_t_local;
165 Gas<T> atmosphere(1.0, gas_temperature, gas_molar_mass, gas_speed);
167 Matrix<T> incident_velocity(3, 1, {std::sin(incidence_angle_local) * gas_speed, 0.0, - std::cos(incidence_angle_local) * gas_speed});
169 std::stringstream stream;
170 stream << std::fixed << std::setprecision(2) <<
"theta_i_" << incidence_angle_local * 180.0 / M_PI <<
"_alpha_n_" <<
171 alpha_n_local <<
"_sigma_t_" << sigma_t_local;
173 PG_Kernel<T> kernel(surf, atmosphere, local_kernel, incident_velocity, num_particles, stream.str());
174 Raytracer<T> raytracer(surf, atmosphere, local_kernel, incident_velocity, num_particles, stream.str());
175 kernels.push_back(kernel);
176 raytracers.push_back(raytracer);
183 return std::make_tuple(kernels, raytracers);
Class representing a Gas with properties such as density, temperature, molar mass,...
Definition Gas.h:10
This class implements a matrix object used for linear algebra and vectorized operations.
Definition Matrix.h:25
Represents a class for the proposed rough surface kernel applied to Poly-Gaussian surfaces.
Definition PG_Kernel.h:26
A class that simulates ray tracing through a surface and gas environment.
Definition Raytracer.h:11
A class representing a surface with geometry and statistical properties.
Definition Surface.h:11