GCC Code Coverage Report


Directory: ./
File: src/parameters.cpp
Date: 2026-12-03 12:28:13
Warnings: 1 unchecked decisions!
Exec Total Coverage
Lines: 0 338 0.0%
Functions: 0 15 0.0%
Branches: 0 301 0.0%
Decisions: 0 106 0.0%

Line Branch Decision Exec Source
1 #include <sstream>
2
3 #include "parameters.hpp"
4 #include "system.hpp"
5
6 std::string direction_type_text[] = { "forward", "backward" };
7 std::string geometry_type_text[] = { "cell" };
8 std::string interaction_type_text[] = { "zipFirst", "catFirst", "minimalFourier" };
9 std::string nucleation_type_text[] = { "isotropic", "biased", "ellipse" };
10 std::string bundle_type_text[] = { "simple", "sticky", "noZip", "multiCollision", "Ncollision" };
11
12 ✗ Parameters::Parameters(System* s):
13 ✗ system(s),
14 ✗ v_plus(0.08),
15 ✗ v_min(-0.16),
16 ✗ v_tm(0.01),
17 ✗ k_sev(0.001),
18 ✗ k_cross(0.001),
19 ✗ k_cat(0.005),
20 ✗ k_res(0.007),
21 ✗ k_nuc(0.001),
22 ✗ pp_bforming_time(VERY_LARGE),
23 ✗ pool_density(5.0),
24 ✗ treadmilling_enabled(1),
25 ✗ severing_enabled(0),
26 ✗ cross_severing_enabled(0),
27 ✗ cross_severing_top(1),
28 ✗ cross_severing_start_angle(0),
29 ✗ ppb(0),
30 ✗ restricted_pool(0),
31 ✗ edge_catastrophe_enabled(0),
32 ✗ edge_catastrophe_smooth(0),
33 ✗ p_cat_special_edge_max(0.0),
34 ✗ p_cat_regular_edge_max(0.0),
35 ✗ edg_number(0),
36 ✗ face_number(0),
37 ✗ nucleation_type(NucleationType::ISOTROPIC),
38 ✗ zippering_enabled(1),
39 ✗ catastrophes_enabled(1),
40 ✗ proportional_catastrophes(0),
41 ✗ induced_catastrophe_fraction(0.5),
42 ✗ zip_fraction(1.0),
43 ✗ pp_bk_nuc_fraction(0.0),
44 ✗ cat_start_angle(0),
45 ✗ magic_angle(40),
46 ✗ interaction_type(InteractionType::ZIP_FIRST),
47 ✗ bundle_type(BundleType::SIMPLE),
48 ✗ geom_param("0"),
49 ✗ seed(time(nullptr)),
50 ✗ stop_time(36000),
51 ✗ measurement_interval(600),
52 ✗ wall_clock_limit(1000),
53 ✗ memory_limit(10000000),
54 ✗ input_dir("."),
55 ✗ output_dir("."),
56 ✗ create_subdir(1),
57 ✗ new_parameter_read_interval(VERY_LARGE),
58 ✗ new_parameter_file(""),
59 ✗ movie_enabled(0),
60 ✗ show_output(0),
61 ✗ show_mesh(0),
62 ✗ geometry("2D-plane_1_0_0"),
63 ✗ movie_frame_interval(-1),
64 ✗ geometry_scale_factor(15.0),
65 ✗ c0_calc(0),
66 ✗ x0_calc(0),
67 ✗ z0_calc(0)
68 {
69 ✗ return;
70 }
71
72 ✗ void Parameters::initialize(const char* pf)
73 {
74
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!read_from_file(pf, true))
75 {
76 ✗ std::cout << "Failed to load parameters from file [" << pf << "]. Aborting\n";
77 ✗ exit(-1);
78 }
79 ✗ verify_parameters();
80 ✗ calc_theory_parameters();
81
82 ✗ return;
83 }
84
85 ✗ bool Parameters::reinitialize(const char* pf)
86 {
87
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (read_from_file(pf, false))
88 {
89 ✗ verify_parameters();
90 ✗ calc_theory_parameters();
91 ✗ return (true);
92 }
93 else
94 {
95 return (false);
96 }
97 }
98
99 ✗ bool Parameters::write_to_file()
100 {
101 ✗ std::ofstream& of = system->parameter_file;
102 ✗ of << "# CorticalSim parameters\r\n";
103 ✗ of << "########## Input-Output path ########################\r\n";
104 ✗ of << "inputDir\t" << input_dir << "\r\n";
105 ✗ of << "outputDir\t" << output_dir << "\r\n";
106 ✗ of << "newParameterReadInterval\t" << new_parameter_read_interval << "\r\n";
107 ✗ of << "createSubdir\t" << create_subdir << "\r\n";
108 ✗ of << "newParameterFile\t" << new_parameter_file << "\r\n";
109 ✗ of << "########## Dynamic parameters ##########\r\n";
110 ✗ of << "kSev\t" << k_sev << "\r\n";
111 ✗ of << "kCross\t" << k_cross << "\r\n";
112 ✗ of << "vPlus\t" << v_plus << "\r\n";
113 ✗ of << "vMin\t" << v_min << "\r\n";
114 ✗ of << "vTM\t" << v_tm << "\r\n";
115 ✗ of << "kCat\t" << k_cat << "\r\n";
116 ✗ of << "kRes\t" << k_res << "\r\n";
117 ✗ of << "kNuc\t" << k_nuc << "\r\n";
118 ✗ of << "magic_angle\t" << magic_angle << "\r\n";
119 ✗ of << "poolDensity\t" << pool_density << "\r\n";
120 ✗ of << "nucleationType\t" << static_cast<int>(nucleation_type) << "\r\n";
121 ✗ of << "########## Zip-IndCat-Severing events ######\r\n";
122 ✗ of << "treadmilling\t" << treadmilling_enabled << "\r\n";
123 ✗ of << "ind_cat\t" << catastrophes_enabled << "\r\n";
124 ✗ of << "cat_start_angle\t" << cat_start_angle << "\r\n";
125 ✗ of << "induced_cat_fraction\t" << induced_catastrophe_fraction << "\r\n";
126 ✗ of << "zippering\t" << zippering_enabled << "\r\n";
127 ✗ of << "zipFraction\t" << zip_fraction << "\r\n";
128 ✗ of << "severing\t" << severing_enabled << "\r\n";
129 ✗ of << "crossSevering\t" << cross_severing_enabled << "\r\n";
130 ✗ of << "crossSeveringTop\t" << cross_severing_top << "\r\n";
131 ✗ of << "crossSeveringStartAngle\t" << cross_severing_start_angle << "\r\n";
132 ✗ of << "########## Edge catastrophe specification ####\r\n";
133 std::map<std::string, double>::iterator it;
134 ✗ of << "########################\r\n";
135 ✗ of << "edgNumber\t" << edg_number << "\r\n";
136
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ for (it = edg_cat_map.begin(); it != edg_cat_map.end(); it++)
137 {
138 ✗ of << it->first << "\t" << it->second << "\r\n";
139 }
140 ✗ of << "########################\r\n";
141 ✗ of << "faceNumber\t" << face_number << "\r\n";
142
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ for (it = face_cat_map.begin(); it != face_cat_map.end(); it++)
143 {
144 ✗ of << it->first << "\t" << it->second << "\r\n";
145 }
146 ✗ of << "########################\r\n";
147 ✗ of << "edgeCatastropheSmooth\t" << edge_catastrophe_smooth << "\r\n";
148 ✗ of << "edgeCatastropheEnabled\t" << edge_catastrophe_enabled << "\r\n";
149 ✗ of << "PPBkNucFraction\t" << pp_bk_nuc_fraction << "\r\n";
150 ✗ of << "proportionalCatastrophes\t" << proportional_catastrophes << "\r\n";
151 ✗ of << "########## specific conditions ###########\r\n";
152 ✗ of << "restrictedPool\t" << restricted_pool << "\r\n";
153 ✗ of << "interactionType\t" << static_cast<int>(interaction_type) << "\r\n";
154 ✗ of << "bundleType\t" << static_cast<int>(bundle_type) << "\r\n";
155 ✗ of << "########## Random seed and run time #####\r\n";
156 ✗ of << "memoryLimit\t" << memory_limit << "\r\n";
157 ✗ of << "wallClockLimit\t" << wall_clock_limit << "\r\n";
158 ✗ of << "stopTime\t" << stop_time << "\r\n";
159 ✗ of << "random_seed\t" << seed << "\r\n";
160 ✗ of << "########## Movie select ############\r\n";
161 ✗ of << "movieEnabled\t" << movie_enabled << "\r\n";
162 ✗ of << "movieFrameInterval\t" << movie_frame_interval << "\r\n";
163 ✗ of << "measurementInterval\t" << measurement_interval << "\r\n";
164 ✗ of << "########## Display output ##########\r\n";
165 ✗ of << "showMesh\t" << show_mesh << "\r\n";
166 ✗ of << "showOutput\t" << show_output << "\r\n";
167 ✗ of << "########## Geometry ################\r\n";
168 ✗ of << "geometryScaleFactor\t" << geometry_scale_factor << "\r\n";
169 ✗ of << "geometry\t" << geometry << "\r\n";
170
171 ✗ return true;
172 }
173
174 template <class T>
175 ✗ inline void load_param(bool& recognized, std::ifstream& file, std::string& id, const char* tag, T& target)
176 {
177
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!recognized)
178 {
179
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id == tag)
180 {
181 ✗ file >> target;
182 ✗ recognized = true;
183 }
184 }
185 ✗ return;
186 }
187
188 template <class T>
189 ✗ inline void load_param_maps(bool& recognized,
190 std::ifstream& file,
191 std::string& id,
192 const char* tag,
193 T& target,
194 std::map<std::string, T>& edg_cat_map)
195 {
196
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!recognized)
197 {
198
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id == tag)
199 {
200 ✗ file >> target;
201 ✗ std::string key{ tag };
202 ✗ edg_cat_map[key] = target;
203 ✗ recognized = true;
204 }
205 }
206 ✗ return;
207 }
208
209 template <class T>
210 ✗ inline void load_param_random(bool& recognized, std::ifstream& file, std::string& id, const char* tag, T& target)
211 {
212 ✗ std::stringstream ss;
213
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!recognized)
214 {
215
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id == tag)
216 {
217
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id == "random_seed")
218 {
219 std::string temp;
220 ✗ file >> temp;
221 ✗ std::string ulong_max{ std::to_string(ULONG_MAX) };
222
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ while (temp > ulong_max)
223 {
224 std::cout << temp << " Bigger than" << ulong_max << std::endl;
225 ✗ temp = temp.substr(1);
226 }
227 ss.str(temp);
228 ss >> target;
229 }
230 else
231 {
232
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ std::cout << "Using loadParamRandom for the wrong parameter: " << id << ", quitting.\n";
233 ✗ exit(-1);
234 }
235 ✗ recognized = true;
236 }
237 }
238
239 ✗ return;
240 ✗ }
241
242 template <class T>
243 ✗ inline void load_param_enum_text(bool& recognized,
244 std::ifstream& file,
245 std::string& id,
246 const char* tag,
247 T& target,
248 std::string* compare_list,
249 T compare_count)
250 {
251
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!recognized)
252 {
253
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id == tag)
254 {
255 int i = 0;
256 std::string temp;
257 ✗ file >> temp;
258 // TODO: Fragile - refactor as a priority.
259
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ while (i < static_cast<int>(compare_count))
260 {
261
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (temp == compare_list[i])
262 {
263 ✗ target = (T)i;
264 ✗ break;
265 }
266 ✗ i++;
267 }
268 // TODO: Fragile - refactor as a priority.
269
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (i == static_cast<int>(compare_count))
270 {
271
0/1
? Decision couldn't be analyzed.
✗ std::cerr << "ERROR: No valid value for " << tag << ": " << temp << "\n";
272 ✗ exit(-1);
273 }
274 ✗ recognized = true;
275 }
276 }
277 ✗ return;
278 }
279
280 ✗ bool Parameters::read_from_file(const char* pf, bool initial_run)
281 {
282
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if ((pf == nullptr) || (*pf == 0))
283 {
284 return false;
285 }
286
287 ✗ std::ifstream par_file;
288 ✗ par_file.open(pf);
289
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!par_file.good())
290 {
291 ✗ std::cerr << "Could not open parameter file [" << pf << "].\n";
292 return false;
293 }
294
295
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (show_output == 1)
296 {
297 ✗ std::cout << "Reading parameter file [" << pf << "]\n";
298 }
299
300 std::string id;
301 bool recognized;
302
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ while (par_file.good())
303 {
304 ✗ par_file >> id;
305
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!par_file.good())
306 {
307 break;
308 }
309
310
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (id[0] == '#')
311 {
312 ✗ getline(par_file, id);
313 }
314 else
315 {
316 ✗ recognized = false;
317
318
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (initial_run)
319 {
320 ✗ load_param_random(recognized, par_file, id, "random_seed", seed);
321 }
322
323 ✗ load_param(recognized, par_file, id, "outputDir", output_dir);
324 ✗ load_param(recognized, par_file, id, "inputDir", input_dir);
325 ✗ load_param(recognized, par_file, id, "createSubdir", create_subdir);
326 ✗ load_param(recognized, par_file, id, "newParameterReadInterval", new_parameter_read_interval);
327 ✗ load_param(recognized, par_file, id, "newParameterFile", new_parameter_file);
328 ✗ load_param(recognized, par_file, id, "zippering", zippering_enabled);
329 ✗ load_param(recognized, par_file, id, "ind_cat", catastrophes_enabled);
330 ✗ load_param(recognized, par_file, id, "proportionalCatastrophes", proportional_catastrophes);
331 ✗ load_param(recognized, par_file, id, "induced_cat_fraction", induced_catastrophe_fraction);
332 ✗ load_param(recognized, par_file, id, "cat_start_angle", cat_start_angle);
333 ✗ load_param(recognized, par_file, id, "zipFraction", zip_fraction);
334 ✗ load_param(recognized, par_file, id, "magic_angle", magic_angle);
335 ✗ load_param(recognized, par_file, id, "vPlus", v_plus);
336 ✗ load_param(recognized, par_file, id, "vMin", v_min);
337 ✗ load_param(recognized, par_file, id, "vTM", v_tm);
338 ✗ load_param(recognized, par_file, id, "kCat", k_cat);
339 ✗ load_param(recognized, par_file, id, "kRes", k_res);
340 ✗ load_param(recognized, par_file, id, "kSev", k_sev);
341 ✗ load_param(recognized, par_file, id, "kCross", k_cross);
342 ✗ load_param(recognized, par_file, id, "poolDensity", pool_density);
343 ✗ load_param(recognized, par_file, id, "treadmilling", treadmilling_enabled);
344 ✗ load_param(recognized, par_file, id, "severing", severing_enabled);
345 ✗ load_param(recognized, par_file, id, "crossSevering", cross_severing_enabled);
346 ✗ load_param(recognized, par_file, id, "crossSeveringTop", cross_severing_top);
347 ✗ load_param(recognized, par_file, id, "crossSeveringStartAngle", cross_severing_start_angle);
348 ✗ load_param(recognized, par_file, id, "restrictedPool", restricted_pool);
349 ✗ load_param(recognized, par_file, id, "edgeCatastropheEnabled", edge_catastrophe_enabled);
350 ✗ load_param(recognized, par_file, id, "edgeCatastropheSmooth", edge_catastrophe_smooth);
351 ✗ load_param(recognized, par_file, id, "pCatSpecialEdgeMax", p_cat_special_edge_max);
352 ✗ load_param(recognized, par_file, id, "pCatRegularEdgeMax", p_cat_regular_edge_max);
353 ✗ load_param(recognized, par_file, id, "PPB", ppb);
354 ✗ load_param(recognized, par_file, id, "PPBformingTime", pp_bforming_time);
355 ✗ load_param(recognized, par_file, id, "kNuc", k_nuc);
356 ✗ load_param(recognized, par_file, id, "stopTime", stop_time);
357 ✗ load_param(recognized, par_file, id, "measurementInterval", measurement_interval);
358 ✗ load_param(recognized, par_file, id, "wallClockLimit", wall_clock_limit);
359 ✗ load_param(recognized, par_file, id, "memoryLimit", memory_limit);
360 ✗ load_param(recognized, par_file, id, "movieEnabled", movie_enabled);
361 ✗ load_param(recognized, par_file, id, "movieFrameInterval", movie_frame_interval);
362 ✗ load_param(recognized, par_file, id, "geometryScaleFactor", geometry_scale_factor);
363 ✗ load_param_enum_text<NucleationType>(recognized,
364 par_file,
365 id,
366 "nucleationType",
367 ✗ nucleation_type,
368 nucleation_type_text,
369 NucleationType::COUNT_LAST);
370 ✗ load_param_enum_text<InteractionType>(recognized,
371 par_file,
372 id,
373 "interactionType",
374 ✗ interaction_type,
375 interaction_type_text,
376 InteractionType::COUNT_LAST);
377 ✗ load_param_enum_text<BundleType>(
378 ✗ recognized, par_file, id, "bundleType", bundle_type, bundle_type_text, BundleType::COUNT_LAST);
379 ✗ load_param(recognized, par_file, id, "showOutput", show_output);
380 ✗ load_param(recognized, par_file, id, "showMesh", show_mesh);
381 ✗ load_param(recognized, par_file, id, "geometry", geometry);
382 ✗ load_param(recognized, par_file, id, "edgNumber", edg_number);
383
384
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ for (int edg = 1; edg <= edg_number; edg++)
385 {
386 double edg_cat_val;
387 ✗ std::string edg_cat_type1 = "edgCat_" + std::to_string(edg);
388 ✗ char* edg_cat_type = new char[edg_cat_type1.length() + 1];
389 strcpy(edg_cat_type, edg_cat_type1.c_str());
390 ✗ load_param_maps(recognized, par_file, id, edg_cat_type, edg_cat_val, edg_cat_map);
391 ✗ delete[] edg_cat_type;
392 }
393
394 ✗ load_param(recognized, par_file, id, "faceNumber", face_number);
395
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ for (int face = 1; face <= face_number; face++)
396 {
397 double face_cat_val;
398 ✗ std::string face_cat_type1 = "faceCat_" + std::to_string(face);
399 ✗ char* face_cat_type = new char[face_cat_type1.length() + 1];
400 strcpy(face_cat_type, face_cat_type1.c_str());
401 ✗ load_param_maps(recognized, par_file, id, face_cat_type, face_cat_val, face_cat_map);
402 ✗ delete[] face_cat_type;
403 }
404
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (!recognized)
405 {
406 ✗ std::cerr << "Parameter not recognized: " << id << "\n";
407 }
408 ✗ getline(par_file, id);
409 }
410 }
411
412
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (show_output == 1)
413 {
414 ✗ std::cout << "Finished loading parameters.\n";
415 }
416
417 return true;
418 ✗ }
419
420 ✗ void Parameters::verify_parameters()
421 {
422 // adjust the parameter values in accordance with the swith (on/off) values
423 ✗ v_tm *= treadmilling_enabled;
424 ✗ k_sev *= severing_enabled;
425 ✗ k_cross *= cross_severing_enabled;
426
427 // treadmilling speed is not allowed to exceed the plus-end velocity
428
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (v_tm >= v_plus)
429 {
430 std::cerr
431 ✗ << "ERROR: treadmilling velocity larger than growth velocity. Microtubule growth is not possible. Exiting.\n";
432 ✗ exit(-1);
433 }
434
435 // minus-end velocity is not allowed to exceed the plus-end velocity
436
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (v_min >= v_plus)
437 {
438 std::cerr
439 << "ERROR: Shrinking microtubules overtake growing microtubules. This will lead to queueing problems. "
440 ✗ "Exiting.\n";
441 ✗ exit(-1);
442 }
443
444 // only minus-end velocity is allowed to be negative
445
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if ((v_plus <= 0) || (v_tm < 0) || (k_cat < 0) || (k_res < 0) || (k_nuc < 0) || (k_sev < 0) || (k_cross < 0)
446 ✗ || (pool_density < 0))
447 {
448 ✗ std::cerr << "Only vMin is allowed to be negative. Exiting to avoid nonsensical results.\n";
449 ✗ exit(-1);
450 }
451
452 // if there is a finite tubulin pool, check the validity of poolDensity
453
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (restricted_pool != 0)
454 {
455
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if ((pool_density <= 0) || (pool_density > VERY_LARGE))
456 {
457 std::cerr << "ERROR [finite tubulin pool]: maximum density is out of range (0 : VERY_LARGE) :"
458 ✗ << pool_density << "\n";
459 ✗ exit(-1);
460 }
461 }
462
463 // it is not possible to create movie without valid movie-interval
464
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (movie_enabled)
465 {
466
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (movie_frame_interval < ZERO_CUTOFF)
467 {
468 ✗ std::cerr << "ERROR: movie recording cannot be enabled without specifying 'movieFrameInterval'\n";
469 ✗ exit(-1);
470 }
471 }
472
473 ✗ switch (nucleation_type)
474 {
475 // isotropic nucleation need no conditional check
476 case NucleationType::ISOTROPIC:
477 break;
478
479
0/1
✗ Decision 'true' not taken.
✗ default:
480 ✗ std::cout << "Unknown nucleationType. Aborting.\n";
481 ✗ exit(-1);
482 break;
483 }
484
485 ✗ switch (interaction_type)
486 {
487 // catastrophe first, need no further conditional check
488 case InteractionType::CAT_FIRST:
489 break;
490
491 // zip first needs further check
492
0/1
✗ Decision 'true' not taken.
✗ case InteractionType::ZIP_FIRST:
493
494 // zippering fraction must be in the range: (0.0 - 1.0)
495
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (zippering_enabled)
496 {
497
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (zip_fraction < 0.)
498 {
499 ✗ zip_fraction = 0.;
500 }
501
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (zip_fraction > 1.)
502 {
503 ✗ zip_fraction = 1.;
504 }
505 }
506 break;
507
508 case InteractionType::COUNT_LAST:
509 break;
510 }
511
512
0/1
✗ Decision 'true' not taken.
✗ return;
513 }
514
515 ✗ bool Parameters::calc_theory_parameters(void)
516 {
517 // convert the angle values from degrees to radians
518 ✗ double ma_rad = magic_angle * PI / 180.0;
519 ✗ double cs_rad = cat_start_angle * PI / 180.0;
520
521 ✗ switch (interaction_type)
522 {
523 // zippering first is requested
524
0/1
✗ Decision 'true' not taken.
✗ case InteractionType::ZIP_FIRST:
525
526 // fzippering is enabled
527
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (zippering_enabled)
528 {
529 ✗ z0_calc = (4. / PI) * (1. - std::cos(ma_rad)) * zip_fraction;
530 }
531
532 // zippering is disabled
533 else
534 {
535 ✗ z0_calc = 0;
536 }
537
538 // catastrophe is enabled
539
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (catastrophes_enabled)
540 {
541 // proportional catastrophe is enabled
542
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (proportional_catastrophes)
543 {
544 // magic angle > catastrophe start angle
545
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (magic_angle > cat_start_angle)
546 {
547 ✗ c0_calc = (4.0 / PI) * 2.0 * induced_catastrophe_fraction
548 ✗ * (1. - std::sin(ma_rad) + (ma_rad - cs_rad) * std::cos(ma_rad)) / (PI - 2. * cs_rad);
549 }
550
551 // magic angle <= catastrophe start angle
552 else
553 {
554 ✗ c0_calc = (4.0 / PI) * 2.0 * induced_catastrophe_fraction * (1.0 - std::sin(cs_rad))
555 ✗ / (PI - 2.0 * cs_rad);
556 }
557 }
558
559 // proportional catastrophe is disabled
560 else
561 {
562 ✗ c0_calc = (4.0 / PI) * induced_catastrophe_fraction * std::cos(std::max(ma_rad, cs_rad));
563 }
564 }
565
566 // catastrophe is disabled
567 else
568 {
569 ✗ c0_calc = 0;
570 }
571
572 // calculate x0, using the values of c0 and/or z0
573 ✗ x0_calc = (4.0 / PI) - z0_calc - c0_calc;
574 ✗ break;
575
576 // catastrophe first is requested
577
0/1
✗ Decision 'true' not taken.
✗ case InteractionType::CAT_FIRST:
578
579 // catastrophe is enabled
580
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (catastrophes_enabled)
581 {
582 // proportional catastrophe is enabled
583
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (proportional_catastrophes)
584 {
585 double temp = std::max(0., cs_rad);
586 ✗ c0_calc = (4.0 / PI) * 2.0 * induced_catastrophe_fraction
587 ✗ * (1.0 - std::sin(temp) + (temp - cs_rad) * std::cos(temp)) / (PI - 2.0 * cs_rad);
588 }
589
590 // proportional catastrophe is disabled
591 else
592 {
593 ✗ c0_calc = (4.0 / PI) * induced_catastrophe_fraction * std::cos(std::max(cs_rad, 0.));
594 }
595 }
596
597 // zippering is enabled
598
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (zippering_enabled)
599 {
600 ✗ z0_calc = (4.0 / PI) * (1.0 - std::cos(ma_rad));
601
602 // catastrophe is enabled and (magic angle > catastrophe start angle)
603
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (catastrophes_enabled && (cs_rad < ma_rad))
604 {
605 // proportional catastrophe is enabled
606
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (proportional_catastrophes)
607 {
608 double left_boundary = std::max(0., cs_rad);
609 z0_calc
610 ✗ -= (4.0 / PI) * 2.0 * induced_catastrophe_fraction
611 ✗ * ((left_boundary - cs_rad) * std::cos(left_boundary) - (ma_rad - cs_rad) * std::cos(ma_rad)
612 ✗ - std::sin(left_boundary) + std::sin(ma_rad))
613 ✗ / (PI - 2.0 * cs_rad);
614 }
615
616 // proportional catastrophe is disabled
617 else
618 {
619 ✗ z0_calc -= (4.0 / PI) * induced_catastrophe_fraction * (std::cos(cs_rad) - std::cos(ma_rad));
620 }
621 }
622 }
623
624 // zippering is disabled
625 else
626 {
627 ✗ z0_calc = 0;
628 }
629
630 // calculate x0, using the values of c0 and/or z0
631 ✗ x0_calc = (4.0 / PI) - z0_calc - c0_calc;
632 ✗ break;
633
634 default:
635 std::cerr << "no function to calculate z0, c0, x0 etc. (interactionType = "
636
0/1
✗ Decision 'true' not taken.
✗ << static_cast<int>(interaction_type) << ")\n";
637 return false;
638 }
639
640 // theoretial value of G
641 ✗ double l0 = std::pow(
642 ✗ (2.0 * (-v_min + v_tm) * (v_plus - v_tm) * (v_plus - v_tm)) / (k_nuc * v_plus * (-v_min + v_plus)), 1. / 3.);
643 ✗ double lavg_inv = k_res / (-v_min + v_tm) - k_cat / (v_plus - v_tm);
644 ✗ double g_0 = l0 * lavg_inv;
645
646
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
✗ if (show_output == 1)
647 {
648 std::cout << "===============================================" << std::endl;
649 std::cout << " Calculated theory parameters" << std::endl;
650 std::cout << "===============================================" << std::endl;
651 std::cout << "l0 = " << l0 << std::endl;
652 ✗ std::cout << "lavg = " << -1. / lavg_inv << std::endl;
653 std::cout << "G_0 = -l0/lavg = " << g_0 << std::endl;
654 std::cout << "===============================================" << std::endl;
655 }
656
657 return (true);
658 }
659