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