Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
configuration.c
Go to the documentation of this file.
1 
4 /* ----------------------------------------------------------------------------
5  libconfig - A library for processing structured configuration files
6  Copyright (C) 2005-2010 Mark A Lindner
7 
8  This file is part of libconfig.
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public License
12  as published by the Free Software Foundation; either version 2.1 of
13  the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public
21  License along with this library; if not, see
22  <http://www.gnu.org/licenses/>.
23  ----------------------------------------------------------------------------
24 */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdbool.h>
30 #include <libconfig.h>
31 
32 #include <cstream.h>
33 #include <parameters.h>
34 #include <configuration.h>
35 #include <reaction.h>
36 #include <species.h>
37 
56 bool
58  const char *type,
59  const char *comment,
60  const char *sstring,
61  int *par,
62  int value,
63  int count,
64  bool *change,
65  config_setting_t *setting_default,
66  int i)
67 {
68  int j;
69  config_setting_t *elem,*setting_value,*setting_comment;
70 
71  if(!(strncmp(name,sstring,COMPARE_LIMIT))) {
72  if(!(strncmp(type,"int",COMPARE_LIMIT))) {
73  *par = value;
74  if(change) {
75  /* Find the corresponding index in the file default.cfg */
76  for(j=0; j<count; j++) {
77  if(!(strncmp(name,parameter_names[j].name,COMPARE_LIMIT))) {
78  i=j;
79  break;
80  }
81  }
82  /* Get access to the right entry in file default.cfg */
83  elem = config_setting_get_elem(setting_default,i);
84  setting_value = config_setting_get_member(elem,"value");
85  setting_comment = config_setting_get_member(elem,"comment");
86  /* Adapt the value in the configuration file default.cfg */
87  if(setting_value && setting_comment) {
88  config_setting_set_int (setting_value,value);
89  config_setting_set_string(setting_comment,comment);
90  }
91  } else
93  return(TRUE);
94  } else {
95  printf("Warning: wrong type for %s; type =%s\n",name,type);
96  printf("Warning: type must be INT for %s\n",sstring);
97  }
98  }
99  return(FALSE);
100 }
101 
120 bool
122  const char *type,
123  const char *comment,
124  const char *sstring,
125  double *par,
126  double value,
127  int count,
128  bool *change,
129  config_setting_t *setting_default,
130  int i)
131 {
132  int j;
133  config_setting_t *elem,*setting_value,*setting_comment;
134 
135  if(!(strncmp(name,sstring,COMPARE_LIMIT))) {
136  if(!(strncmp(type,"double",COMPARE_LIMIT))) {
137  *par = value;
138  if(change) {
139  /* Find the corresponding index in the file default.cfg */
140  for(j=0; j<count; j++) {
141  if(!(strncmp(name,parameter_names[j].name,COMPARE_LIMIT))) {
142  i=j;
143  break;
144  }
145  }
146  /* Get access to the right entry in file default.cfg */
147  elem = config_setting_get_elem(setting_default,i);
148  setting_value = config_setting_get_member(elem,"value");
149  setting_comment = config_setting_get_member(elem,"comment");
150 
151  /* Adapt the value in the configuration file default.cfg */
152  if(setting_value && setting_comment) {
153  config_setting_set_float(setting_value,value);
154  config_setting_set_string(setting_comment,comment);
155  }
156  } else
158  return(TRUE);
159  } else {
160  printf("Warning: wrong type for %s; type =%s\n",name,type);
161  printf("Warning: type must be DOUBLE for %s\n",sstring);
162  }
163  }
164  return(FALSE);
165 }
186 bool
188  const char *type,
189  const char *comment,
190  const char *sstring,
191  char** par,
192  char* value,
193  int count,
194  bool *change,
195  config_setting_t *setting_default,
196  int i)
197 {
198  int j;
199  config_setting_t *elem,*setting_value,*setting_comment;
200 
201  if(!(strncmp(name,sstring,COMPARE_LIMIT))) {
202  if(!(strncmp(type,"string",COMPARE_LIMIT))) {
203  *par = value;
204  if(change) {
205 /* Find the corresponding index in the file default.cfg */
206  for(j=0; j<count; j++) {
207  if(!(strncmp(name,parameter_names[j].name,COMPARE_LIMIT))) {
208  i=j;
209  break;
210  }
211  }
212  /* Get access to the right entry in file default.cfg */
213  elem = config_setting_get_elem(setting_default,i);
214  setting_value = config_setting_get_member(elem,"value");
215  setting_comment = config_setting_get_member(elem,"comment");
216 
217  /* Adapt the value in the configuration file default.cfg */
218  if(setting_value && setting_comment) {
219  config_setting_set_string(setting_value,value);
220  config_setting_set_string(setting_comment,comment);
221  }
222  } else
224  return(TRUE);
225  } else {
226  printf("Warning: wrong type for %s; type =%s\n",name,type);
227  printf("Warning: type must be STRING for %s\n",sstring);
228  }
229  }
230  return(FALSE);
231 }
232 
238  /*
239  * !!!! DOXYGEN ???
240  * @param[in] name name of the parameter (see e.g., input file default.cfg)
241  * @param[in] type type of parameter (see e.g., input file default.cfg)
242  * @param[in] comment comment to be added to name (see e.g., input file default.cfg)
243  * @param[out] ii position in global array 'parameter_names'
244  * @param[out] ivalue,dvalue,bbool,astring name to be found, may be a 'int','double','bool'
245  * or 'char*'
246  * @param[in] config_setting_t *setting represents s configuration setting
247  * @param[in] count number of elements in array 'parameter_names' to examine
248  * @param[in] *change if TRUE then value in setting_default will be changed
249  *
250  */
251 void
253  const char *type,
254  const char *comment,
255  int ii,
256  int ivalue,
257  double dvalue,
258  bool bbool,
259  const char* astring,
260  config_setting_t *setting,
261  int count,
262  bool *change)
263 {
264  /* An identification name for this run, prog_id */
265  if(change_cfg_string(name,type,comment,"prog_id",&prog_id,(char*)astring,count,change,setting,ii))
266  return;
267 
268  /* Output directory, output_dir */
269  if(change_cfg_string(name,type,comment,"output_dir",&output_dir,(char*)astring,count,change,setting,ii))
270  return;
271 
272  /* Kinetics input file, kin_input */
273  if(change_cfg_string(name,type,comment,"kin_input",&kin_input,(char*)astring,count,change,setting,ii))
274  return;
275 
276  /* Restart from a previous file */
277  if(change_cfg_integer(name,type,comment,"restart",&restart,ivalue,count,change,setting,ii))
278  return;
279 
280  /* The simulation will continue from file */
281  if(change_cfg_string(name,type,comment,"load_file",&load_file,(char*)astring,count,change,setting,ii))
282  return;
283 
284  /* The name of a file with photoionization parameters */
285  if(change_cfg_string(name,type,comment,"photoionization_file",&photoionization_file,
286  (char*)astring,count,change,setting,ii))
287  return;
288 
289  /* Time interval for output to be written to disk */
290  if(change_cfg_double(name,type,comment,"output_dt",&output_dt,dvalue,count,change,setting,ii))
291  return;
292 
293  /* Output of the Poisson grids, including the potential */
294  if(change_cfg_integer(name,type,comment,"pois_output",&pois_output,ivalue,count,change,setting,ii))
295  return;
296 
297  /* Margin outside the grids in the output of the cdr equation */
298  if(change_cfg_integer(name,type,comment,"cdr_output_margin",&cdr_output_margin,ivalue,count,change,setting,ii))
299  return;
300 
301  /* Output of the Poisson grids, including the potential */
302  if(change_cfg_integer(name,type,comment,"photo_bnd_right",&photo_bnd_right,ivalue,count,change,setting,ii))
303  return;
304 
305  /* Margin outside the grids in the output of the Poisson equation */
306  if(change_cfg_integer(name,type,comment,"pois_output_margin",&pois_output_margin,ivalue,count,change,setting,ii))
307  return;
308 
309  /* Sometimes, we can issue warnings about strange things happening in the
310  * program. Most of the time something is going wrong and you should
311  * revise your parameters.
312  */
313  if(change_cfg_double(name,type,comment,"warn_min_timestep",&warn_min_timestep,dvalue,count,change,setting,ii))
314  return;
315 
316  /* Imposing a limit for the disk space is hard but it is the law.
317  *
318  * The default is 1 Tb -> You should use something smaller.
319  */
320  if(change_cfg_integer (name,type,comment,"max_disk_space_mb",&max_disk_space_mb,ivalue,count,change,setting,ii))
321  return;
322 
323  /************************
324  * Numerical parameters *
325  ************************/
326 
327  /* Number of gridpoints in r direction at level 0. */
328  if(change_cfg_integer (name,type,comment,"gridpoints_r",&gridpoints_r,ivalue,count,change,setting,ii))
329  return;
330 
331  /* Number of gridpoints in z direction at level 0. */
332  if(change_cfg_integer (name,type,comment,"gridpoints_z",&gridpoints_z,ivalue,count,change,setting,ii))
333  return;
334 
335  /* Number of azimuthal modes. */
336  if(change_cfg_integer (name,type,comment,"max_ntheta",&max_ntheta,ivalue,count,change,setting,ii))
337  return;
338 
339  /* Initial time may be away from 0 */
340  if(change_cfg_double(name,type,comment,"start_t",&start_t,dvalue,count,change,setting,ii))
341  return;
342 
343  /* End time of simulation, originally 500.0 */
344  if(change_cfg_double(name,type,comment,"end_t",&end_t,dvalue,count,change,setting,ii))
345  return;
346 
347  /* The actual timestep may be smaller that this one, if it is needed
348  * to satisfy the Courant constraint.
349  */
350  if(change_cfg_double(name,type,comment,"attempt_dt",&attempt_dt,dvalue,count,change,setting,ii))
351  return;
352 
353  /* Number of levels that are used for the Poisson equation
354  * but NOT for the cdr integrator.
355  */
356  if(change_cfg_integer (name,type,comment,"extra_pois_levels",&extra_pois_levels,ivalue,count,change,setting,ii))
357  return;
358 
359  /* Maximum nesting depth */
360  if(change_cfg_integer (name,type,comment,"max_levels",&max_levels,ivalue,count,change,setting,ii))
361  return;
362 
363  /* Total number of species */
364  if(change_cfg_integer (name,type,comment,"no_species",&no_species,ivalue,count,change,setting,ii))
365  return;
366 
367  /* Maximum error allowed in the Poisson solver.
368  * Cells with larger errors will be further refined.
369  */
370  if(change_cfg_double(name,type,comment,"pois_max_error",&pois_max_error,dvalue,count,change,setting,ii))
371  return;
372 
373  /* Maximum refinement level for the Poisson solver. */
374  if(change_cfg_integer(name,type,comment,"pois_max_level",&pois_max_level,ivalue,count,change,setting,ii))
375  return;
376 
377  /* These are photo-ionization parameters equivalent to the Poisson ones.
378  * If extra_photo_levels < 0, then these parameters are ignored and the
379  * poisson-parameters are used. If extra_photo_levels_2 < 0 then the
380  * parameters for the second term are ignored and the parameters for the
381  * first term are used for both terms.
382  */
383 
384  /* First photo-ionization term */
385  if(change_cfg_integer (name,type,comment,"extra_photo_levels",&extra_photo_levels,ivalue,count,change,setting,ii))
386  return;
387 
388  /* Maximum level of refinement in the photo-ionization solver.*/
389  if(change_cfg_integer (name,type,comment,"photo_max_level",&photo_max_level,ivalue,count,change,setting,ii))
390  return;
391 
392  /* Error threshold that leads to refinement in the photo-ionization code. */
393  if(change_cfg_double(name,type,comment,"photo_max_error",&photo_max_error,dvalue,count,change,setting,ii))
394  return;
395 
396  /* Photo-ionization boundary condition at r = L_r
397  * 1 means homogeneous Neumann boundary conditions
398  * -1 means homogeneous Dirichlet boundary conditions.
399  */
400  if(change_cfg_integer(name,type,comment,"photo_bnd_right" ,&photo_bnd_right ,ivalue,count,change,setting,ii))
401  return;
402 
403  if(change_cfg_integer(name,type,comment,"photo_bnd_bottom",&photo_bnd_bottom,ivalue,count,change,setting,ii))
404  return;
405 
406  if(change_cfg_integer(name,type,comment,"photo_bnd_top" ,&photo_bnd_top ,ivalue,count,change,setting,ii))
407  return;
408 
409 
410  /* Second photo-ionization term: Extra levels for the photo-ionization solver. */
411  if(change_cfg_integer(name,type,comment,"extra_photo_levels_2",&extra_photo_levels_2,ivalue,count,change,setting,ii))
412  return;
413 
414  /* Maximum level of refinement in the photo-ionization solver.*/
415  if(change_cfg_integer(name,type,comment,"photo_max_level_2",&photo_max_level_2,ivalue,count,change,setting,ii))
416  return;
417 
418 
419  /* Error threshold that leads to refinement in the photo-ionization code.*/
420  if(change_cfg_double(name,type,comment,"photo_max_error_2",&photo_max_error_2,dvalue,count,change,setting,ii))
421  return;
422 
423  /* Photo-ionization boundary condition at r = L_r.
424  * 1 for homogeneous Neumann,
425  * -1 for homogeneous Dirichlet
426  */
427  if(change_cfg_integer(name,type,comment,"photo_bnd_right_2",&photo_bnd_right_2,ivalue,count,change,setting,ii))
428  return;
429 
430  /* Photo-ionization boundary condition at z = 0.
431  * 1 for homogeneous Neumann,
432  * -1 for homogeneous Dirichlet
433  */
434  if(change_cfg_integer(name,type,comment,"photo_bnd_bottom_2",&photo_bnd_bottom_2,ivalue,count,change,setting,ii))
435  return;
436 
437  /* Photo-ionization boundary condition at z = L_z.
438  * 1 for homogeneous Neumann,
439  * -1 for homogeneous Dirichlet
440  */
441  if(change_cfg_integer(name,type,comment,"photo_bnd_top_2",&photo_bnd_top_2,ivalue,count,change,setting,ii))
442  return;
443 
444  /* Boundary conditions for the CDR system. */
445  if(change_cfg_integer(name,type,comment,"cdr_bnd_bottom",&cdr_bnd_bottom,ivalue,count,change,setting,ii))
446  return;
447 
448  if(change_cfg_integer(name,type,comment,"cdr_bnd_top",&cdr_bnd_top,ivalue,count,change,setting,ii))
449  return;
450 
451  if(change_cfg_integer(name,type,comment,"cdr_bnd_right",&cdr_bnd_right,ivalue,count,change,setting,ii))
452  return;
453 
454  if(change_cfg_integer(name,type,comment,"pois_bnd_right",&pois_bnd_right,ivalue,count,change,setting,ii))
455  return;
456 
457  if(change_cfg_integer(name,type,comment,"pois_bnd_bottom",&pois_bnd_bottom,ivalue,count,change,setting,ii))
458  return;
459 
460  if(change_cfg_integer(name,type,comment,"pois_bnd_top",&pois_bnd_top,ivalue,count,change,setting,ii))
461  return;
462 
463  /* Courant numbers. */
464  if(change_cfg_double(name,type,comment,"nu_a",&nu_a,dvalue,count,change,setting,ii))
465  return;
466 
467  if(change_cfg_double(name,type,comment,"nu_d",&nu_d,dvalue,count,change,setting,ii))
468  return;
469 
470  if(change_cfg_double(name,type,comment,"nu_rt",&nu_rt,dvalue,count,change,setting,ii))
471  return;
472 
473  if(change_cfg_double(name,type,comment,"nu_f",&nu_f,dvalue,count,change,setting,ii))
474  return;
475 
476  /* Refinement criteria for the CDR equation. */
477  if(change_cfg_double(name,type,comment,"ref_threshold_eabs",&ref_threshold_eabs,dvalue,count,change,setting,ii))
478  return;
479 
480  /* Refinement criteria for the CDR equation. */
481  if(change_cfg_integer(name,type,comment,"ref_level_eabs",&ref_level_eabs,ivalue,count,change,setting,ii))
482  return;
483 
484  if(change_cfg_double(name,type,comment,"ref_threshold_charge",&ref_threshold_charge,dvalue,count,change,setting,ii))
485  return;
486 
487  if(change_cfg_double(name,type,comment,"ref_threshold_dens",&ref_threshold_dens,dvalue,count,change,setting,ii))
488  return;
489 
490  if(change_cfg_double(name,type,comment,"ref_threshold_edge",&ref_threshold_edge,dvalue,count,change,setting,ii))
491  return;
492 
493  /* r- and z-length of the minimal refinement area in the cdr equation*/
494  if(change_cfg_integer(name,type,comment,"cdr_brick_dr",&cdr_brick_dr,ivalue,count,change,setting,ii))
495  return;
496 
497  if(change_cfg_integer(name,type,comment,"cdr_brick_dz",&cdr_brick_dz,ivalue,count,change,setting,ii))
498  return;
499 
500  /* Maximum refinement level for the cdr solver. */
501  if(change_cfg_integer(name,type,comment,"cdr_max_level",&cdr_max_level,ivalue,count,change,setting,ii))
502  return;
503 
504  /* Interpolation method. */
505  if(change_cfg_integer(name,type,comment,"cdr_interp_in",&cdr_interp_in,ivalue,count,change,setting,ii))
506  return;
507 
508  if(change_cfg_integer(name,type,comment,"cdr_interp_bnd",&cdr_interp_bnd,ivalue,count,change,setting,ii))
509  return;
510 
511  /***********************
512  * Physical parameters *
513  ***********************/
514  if(change_cfg_double(name,type,comment,"L_r",&L_r,dvalue,count,change,setting,ii))
515  return;
516 
517  if(change_cfg_double(name,type,comment,"L_z",&L_z,dvalue,count,change,setting,ii))
518  return;
519 
520  if(change_cfg_double(name,type,comment,"diffusion_coeff",&diffusion_coeff,dvalue,count,change,setting,ii))
521  return;
522 
523  if(change_cfg_double(name,type,comment,"attachment_rate",&attachment_rate,dvalue,count,change,setting,ii))
524  return;
525 
526  if(change_cfg_double(name,type,comment,"attachment_E0",&attachment_E0,dvalue,count,change,setting,ii))
527  return;
528 
529  /* Constant external electric field. */
530  if(change_cfg_double(name,type,comment,"E0_x",&E0_x,dvalue,count,change,setting,ii))
531  return;
532 
533  if(change_cfg_double(name,type,comment,"E0_y",&E0_y,dvalue,count,change,setting,ii))
534  return;
535 
536  if(change_cfg_double(name,type,comment,"E0_z",&E0_z,dvalue,count,change,setting,ii))
537  return;
538 
539  /* Constant external electric field. */
540  if(change_cfg_double(name,type,comment,"rise_time",&rise_time,dvalue,count,change,setting,ii))
541  return;
542 
543  if(change_cfg_double(name,type,comment,"off_time",&off_time,dvalue,count,change,setting,ii))
544  return;
545 
546  if(change_cfg_integer(name,type,comment,"has_photoionization",&has_photoionization,ivalue,count,change,setting,ii))
547  return;
548 
549  /* Width of the initial seed in x-, y- and z-direction */
550  if(change_cfg_double(name,type,comment,"seed_sigma_x",&seed_sigma_x,dvalue,count,change,setting,ii))
551  return;
552 
553  if(change_cfg_double(name,type,comment,"seed_sigma_y",&seed_sigma_y,dvalue,count,change,setting,ii))
554  return;
555 
556  if(change_cfg_double(name,type,comment,"seed_sigma_z",&seed_sigma_z,dvalue,count,change,setting,ii))
557  return;
558 
559  if(change_cfg_double(name,type,comment,"seed_N",&seed_N,dvalue,count,change,setting,ii))
560  return;
561 
562  /* Initial background ionization */
563  if(change_cfg_double(name,type,comment,"background_ionization",&background_ionization,dvalue,count,change,setting,ii))
564  return;
565 
566  /* Length of exponential increase of the pre-ionization for atmospherical
567  * models
568  */
569  if(change_cfg_double(name,type,comment,"background_increase_length",&background_increase_length,
570  dvalue,count,change,setting,ii))
571  return;
572 
573  /* Use the point-plane geometry? */
574  if(change_cfg_integer(name,type,comment,"pois_inhom",&pois_inhom,ivalue,count,change,setting,ii))
575  return;
576 
577  /* Number of mirror charges to use*/
578  if(change_cfg_integer(name,type,comment,"pois_inhom_reflections",&pois_inhom_reflections,ivalue,count,change,setting,ii))
579  return;
580 
581  /* Length of the needle */
582  if(change_cfg_double(name,type,comment,"needle_length",&needle_length,dvalue,count,change,setting,ii))
583  return;
584 
585  /* Radius of the needle */
586  if(change_cfg_double(name,type,comment,"needle_radius",&needle_radius,dvalue,count,change,setting,ii))
587  return;
588 
589  /* If nonzero, the charge is fixed, not floating
590  * Simulation of charged clouds close to the earth surface.
591  */
592  if(change_cfg_double(name,type,comment,"pois_inhom_fixed_q",&pois_inhom_fixed_q,dvalue,count,change,setting,ii))
593  return;
594 
595  /* Constant ionization rate. */
596  if(change_cfg_double(name,type,comment,"constant_source",&constant_source,dvalue,count,change,setting,ii))
597  return;
598 
599  /* Random perturbations for stability analysis. */
600  if(change_cfg_double(name,type,comment,"perturb_epsilon",&perturb_epsilon,dvalue,count,change,setting,ii))
601  return;
602 
603  /* Perturb only modes up to perturb_max_k, i.e. large number to perturb all */
604  if(change_cfg_integer(name,type,comment,"perturb_max_k",&perturb_max_k,ivalue,count,change,setting,ii))
605  return;
606 
607  /******************
608  * Sprites module *
609  ******************/
610  if(change_cfg_integer(name,type,comment,"sprite_module",&sprite_module,ivalue,count,change,setting,ii))
611  return;
612 
613  if(change_cfg_double(name,type,comment,"dens_decay_len",&dens_decay_len,dvalue,count,change,setting,ii))
614  return;
615 
616  if(change_cfg_double(name,type,comment,"sprite_dens_0",&sprite_dens_0,dvalue,count,change,setting,ii))
617  return;
618 
619  if(change_cfg_double(name,type,comment,"sprite_dens_q",&sprite_dens_q,dvalue,count,change,setting,ii))
620  return;
621 
622  if(change_cfg_integer(name,type,comment,"sprite_sign",&sprite_sign,ivalue,count,change,setting,ii))
623  return;
624 
625 }
626 
627 /* @brief Read just one parameter from configuration file connected
628  * to setting2.
629  *
630  * In case setting1 and setting2 are different then
631  * the value in setting1 will be overwritten by the value of setting2.
632  *
633  * In case setting1 and setting2 are the same then
634  * the value in setting1 will be added.
635  *
636  * @param[in] config_setting_t *setting1 represents s configuration setting
637  * @param[in] config_setting_t *setting2 represents s configuration setting
638  * @param[in] ii position in array 'parameter_names'
639  * @param[in] count number of elements in parameter array to examine
640  * @param[in] *change if TRUE then value in setting_default will be changed
641  *
642  */
643 bool
645  config_setting_t *setting2,
646  int ii,
647  int count,
648  bool *change)
649 {
650  const char *type,*name,*comment;
651  double dvalue;
652  int ivalue;
653  int bbool;
654  const char* astring;
655  config_setting_t *elem = config_setting_get_elem(setting2,ii);
656 
657  /* Only output the record if all of the expected fields are present. */
658  if(config_setting_lookup_string(elem, "type", &type) &&
659  config_setting_lookup_string(elem, "name", &name) &&
660  config_setting_lookup_string(elem, "comment",&comment) &&
661  (config_setting_lookup_float (elem,"value", &dvalue) ||
662  config_setting_lookup_int (elem,"value", &ivalue) ||
663  config_setting_lookup_bool (elem,"value", &bbool ) ||
664  config_setting_lookup_string(elem,"value", &astring))
665  ) {
666  printf("\n# %s\n",comment);
667  if(!(strncmp(type,"string",COMPARE_LIMIT)))
668  printf("(%s) %s=%s\n",type,name,astring);
669  if(!(strncmp(type,"double",COMPARE_LIMIT)))
670  printf("(%s) %s=%g\n",type,name,dvalue);
671  if(!(strncmp(type,"int",COMPARE_LIMIT)))
672  printf("(%s) %s=%i\n",type,name,ivalue);
673  if(!(strncmp(type,"bool",COMPARE_LIMIT)))
674  printf("(%s) %s=%i\n",type,name,bbool);
675  } else {
676  printf("read_parameter: type is no string, double, int or bool but something else\n");
677  return(FALSE);
678  }
679 
680  change_cfg_parameters(name,type,comment,ii,ivalue,dvalue,bbool,astring,
681  setting1,count,change);
682  return(TRUE);
683 }
684 
685 /* @brief Reads the specifications of specie number 'ii' in the configuration
686  * file related to *setting. Initializes the fields of *temp_s.
687  *
688  * @param[in] *setting Of type config_setting_t. It represents a configuration
689  * setting
690  * @param[in] ii position in global 'parameter_names' array
691  * @param[out] *temp_s Of type 'species_t'. Its fields will be initialized
692  * with values "name","mass" and "charge" read
693  * from setting connected to configuration file
694  */
695 bool
697  int ii,
698  species_t *temp_s)
699 {
700  config_setting_t *elem = config_setting_get_elem(setting,ii);
701 
702  /* Only output the record if all of the expected fields are present. */
703  if (!(config_setting_lookup_string(elem,"name",&temp_s->name) &&
704  config_setting_lookup_float (elem,"mass",&temp_s->mass) &&
705  config_setting_lookup_float (elem,"charge",&temp_s->charge)))
706  {
707  printf("wrong types in kinetic file for species\n");
708  return(FALSE);
709  }
710  return(TRUE);
711 }
712 
713 /* @brief Read the specifications of seed number 'ii' in the configuration
714  * file related to *setting. Initialize *temp_se.
715  *
716  * @param[in] *setting of type config_setting_t. It represents a configuration
717  * setting
718  * @param[in] ii position in global array '*seed_index'
719  * @param[out] *temp_se of type 'seed_t' describing a seed
720  */
721 bool
723  int ii,
724  seed_t *temp_se)
725 {
726  config_setting_t *elem = config_setting_get_elem(setting,ii);
727 
728  /* Only output the record if all of the expected fields are present. */
729  if (!(config_setting_lookup_string(elem,"species",&temp_se->kind_species) &&
730  config_setting_lookup_float (elem,"value",&temp_se->value) &&
731  config_setting_lookup_string(elem,"type",&temp_se->kind_type)))
732  {
733  printf("wrong types in kinetic file for seed: species,value or type\n");
734  return(FALSE);
735  }
736 
737  /* Find the position in the species-array of a given species */
738  temp_se->species = find_species_by_name(temp_se->kind_species);
739 
740  /* Translate string 'kind_type' into integer value,
741  * temp_se->type = -1 denotes unknown */
742  if (strcmp(temp_se->kind_type,"gaussian") == 0)
743  temp_se->type = 0;
744  else if (strcmp(temp_se->kind_type,"constant") == 0)
745  temp_se->type = 1;
746  else
747  temp_se->type = -1;
748 
749  if (!(config_setting_lookup_float(elem,"x0",&temp_se->x0)))
750  { temp_se->x0=0.0; }
751  if (!(config_setting_lookup_float(elem,"y0",&temp_se->y0)))
752  { temp_se->y0=0.0; }
753  if (!(config_setting_lookup_float(elem,"z0",&temp_se->z0)))
754  { temp_se->z0=0.0; }
755 
756  if (!(config_setting_lookup_float (elem,"sigma_x",&temp_se->sigma_x)))
757  { temp_se->sigma_x=0.0; }
758  if (!(config_setting_lookup_float(elem,"sigma_y",&temp_se->sigma_y)))
759  { temp_se->sigma_y=0.0; }
760  if (!(config_setting_lookup_float(elem,"sigma_z",&temp_se->sigma_z)))
761  { temp_se->sigma_z=0.0; }
762 
763  return(TRUE);
764 }
765 
766 /* @brief Read the specifications of reaction number 'ii' in the configuration
767  * file related to *setting. Initialize *temp_r.
768  *
769  * @param[in] *setting of type config_setting_t. It represents a configuration
770  * setting
771  * @param[in] ii position in global array '*reaction_index'
772  * @param[out] *temp_r of type 'reaction_t' describing a reaction
773  */
774 bool
776  int ii,
777  reaction_t *temp_r)
778 {
779  config_setting_t *elem = config_setting_get_elem(setting,ii);
780  const char *table;
781  const char *error;
782  int cnt;
783 
784  /* Only output the record if fields nin and nout are present. */
785  if (!(config_setting_lookup_string(elem,"reacttable",&table)))
786  {
787  printf("wrong types in kinetic file for reaction.reacttable\n");
788  return(FALSE);
789  } else
790  temp_r->tablefile = (char *) table;
791 
792  /* Only output the record if fields nin and nout are present. */
793  if (!(config_setting_lookup_int(elem,"nin",&temp_r->nin) &&
794  config_setting_lookup_int(elem,"nout",&temp_r->nout)))
795  {
796  printf("wrong types in kinetic file for reactions\n");
797  return(FALSE);
798  }
799 
800  error="not_init";
801  for(cnt = 0; cnt < REACTION_MAX_IN; ++cnt) {
802  temp_r->input[cnt] = -1;
803  temp_r->inname[cnt]=error;
804  }
805 
806  config_setting_lookup_string(elem,"specin0",&temp_r->inname[0]);
807  config_setting_lookup_string(elem,"specin1",&temp_r->inname[1]);
808  config_setting_lookup_string(elem,"specin2",&temp_r->inname[2]);
809  config_setting_lookup_string(elem,"specin3",&temp_r->inname[3]);
810 
811  /* Find the position in the species-array of a given species */
812  for(cnt = 0; cnt < temp_r->nin; cnt++) {
813  if(strcmp(temp_r->inname[cnt],error)==0)
814  {
815  printf("NOT all reaction.specin initialized for reaction %d and specie %d\n",ii,cnt);
816  exit(1);
817  }
818  else
819  temp_r->input[cnt] = find_species_by_name(temp_r->inname[cnt]);
820  }
821 
822  for(cnt = 0; cnt < REACTION_MAX_OUT; ++cnt) {
823  temp_r->output[cnt] = -1;
824  temp_r->outname[cnt]=error;
825  }
826 
827  config_setting_lookup_string(elem,"specout0",&temp_r->outname[0]);
828  config_setting_lookup_string(elem,"specout1",&temp_r->outname[1]);
829  config_setting_lookup_string(elem,"specout2",&temp_r->outname[2]);
830  config_setting_lookup_string(elem,"specout3",&temp_r->outname[3]);
831  config_setting_lookup_string(elem,"specout4",&temp_r->outname[4]);
832  config_setting_lookup_string(elem,"specout5",&temp_r->outname[5]);
833 
834  /* Find the position in the species-array of a given species */
835  for(cnt = 0; cnt < temp_r->nout; cnt++) {
836  if(strcmp(temp_r->outname[cnt],error)==0)
837  {
838  debug(1,"temp_r->outname[%d]=%s; error=%s\n",cnt,temp_r->outname[cnt],error);
839  printf("NOT all reaction.specout initialized for reaction %d and specie %d\n",ii,cnt);
840  exit(1);
841  }
842  else
843  temp_r->output[cnt] = find_species_by_name(temp_r->outname[cnt]);
844  }
845 
846  return(TRUE);
847 }