VERB_code_2.2  2
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Parameters.h
Go to the documentation of this file.
1 /**
2  * \file Parameters.h
3  * \brief Defenition of the struct Parameters_structure, struct DxxParameters_structure and supporting function
4  * All parameters, loaded from .ini file are described here in one structure.
5  * Each brunch of the structure holds parameters for one oblect (class) intitialization
6  * So, we need to pass one structure (brunch of the main structure) to the classes cunstructors
7  *
8  * \ref todo
9  *
10  * \author Developed by Dmitry Subbotin under supervision of the PI Yuri Shprits
11  */
12 
13 #ifndef LOAD_CONSTANCE_H // continue if have not load this file yet
14 
15 /// \def LOAD_CONSTANCE_H
16 /// \brief Check if LOAD_CONSTANCE_H is defined, to not include the class more then one time.
17 #define LOAD_CONSTANCE_H
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 #include "../Matrix/Matrix.h"
23 #include "../VariousFunctions/variousConstants.h"
24 #include "../Logging/Output.h"
25 #include <sstream>
26 
27 using namespace std;
28 
29 /** Diffusion coefficient parameters
30  * Structure for diffusion coefficient Dxx. Each object in the code correspont to certan type of diffusion (Hiss Daa - pitch-angle diffusion by Hiss waves).
31  */
33 public:
34  string DxxType; ///< Dxx type. Check %StrToVal(string input, DiffusionCoefficientTypes &place) for known values.
35  string DxxName; ///< Dxx name.
36 
37  string waveType; ///< Wave type (chorus, hiss etc). Check %StrToVal(string input, WaveTypes &place) for known values.
38  string waveName; ///< Wave name.
39 
40  string filetype; ///< Type of the file (w/wo grid etc)
41  string filename; ///< File name for loading ot saving diffusion coefficients array.
42 
43  double time_start; ///< Time, when diffusion coefficient starts.
44  double time_end; ///< Time, when diffusion coefficient ends.
45 
46  bool useScale; ///< Flag, use scaling if equal to true.
47  double DxxKp; ///< Kp value associated with parameters (for Kp-scaling)
48 
49  string loadOrCalculate; ///<Load diffusion coefficient or calculate flag.
50 
51  string numberDensity; ///< Number density model. Check StrToVal(string input, NumberDencities &place) for known values.
52  double MLT_averaging; ///<MLT averaging part of the orbit.
53 
54  double multiplicator; ///< Dxx is multiplied to this number after all other operations. Useful for fast Dxx modifications.
55 
56  string Omega_mType; ///<Omega_m type. Check StrToVal(string input, Omega_mTypes &place) for known values.
57  double Omega_m; ///< Omega_m value.
58  double d_omega; ///< d_omega value.
59  double omega_uc; ///< omega upper cutoff
60  double omega_lc; ///< omega lower cutoff
61 
62  //@{
63  /// \todo eta1, eta2, eta3
64  double eta1, eta2, eta3;
65  //@}
66 
67  double Bw; ///< Bw value.
68  bool BwFromLambda; ///< Bw lambda dependance flag.
69  int nint; ///< Number of points in integral
70  double mirror_point_coeff; ///< Coefficient for mirror point (like 0.999, cause we can not integrate all the way to mirror point)
71  double lam_min; ///< Minimum latitude.
72  double lam_max; ///< Maximum latitude.
73 
74  double nu;
75  double s; ///< 1 corresponds to R mode
76  double f;
77 
78  // DEPRECATED
79  //double cfm;
80  string particle; ///< Type of particles, produced wave? Ions or electrons. Check StrToVal(string input, ParticleTypes &place) for known values.
81 
82  // global
83  double L, EMeV, Alpha;
84 
85  /** \brief Load parameters of the waves from file to the structure
86  * \param filename - location of the file "Wave_Dxx.ini" */
87  bool Load_dxx_parameters(string filename);
88 
89 };
90 
91 /** Main parameters structure.
92  * The structure was modified withoud multiple substructures according to request of project PI
93  */
95  // General parameters Days
96  int outputLvl; ///< Detalization level of screen output.
97  double nDays; ///< Simulation total time, days.
98  double timeStep; ///< Time step, hours.
99  int totalIterationsNumber; ///< Total number of iterations.
100  bool useRadialDiffusion; ///< Using diffusions flags.
101  bool useAlphaDiffusion; ///< Using diffusions flags.
102  bool useEnergyDiffusion; ///< Using diffusions flags.
103  bool useEnergyAlphaMixedTerms; ///< Using mixed terms flags.
104 
105  string DLLType; ///< DLL type (which method to use to calculate). Check StrToVal(string input, DLLTypes &place) for known values.
106  Matrix1D<double> Kp; ///< Kp array
107  string useKp; ///< Flag, using Kp index. constant - use constant value, file - read from file.
108  double constKp; ///< constant Kp value (if it's constant).
109  string fileKp; ///< Kp file name.
110  Matrix1D<double> Bf; ///< Boundary flux array
111  string useBf; ///< Flag, using boundary flux dependences if equal true.
112  double constBf; ///< constant Bf value (if it's constant).
113  string fileBf; ///< Bf file name.
114  Matrix1D<double> Lpp; ///< Lpp array
115  string useLpp; ///< Flag, using plasma pause location dependences if equal true.
116  double constLpp; ///< constant Lpp value (if it's constant).
117  string fileLpp; ///< Lpp file name.
118  string usetau, usetauLpp;
119  Matrix1D<double> tau; ///< Lifetime out of the plasmasphere.
120  Matrix1D<double> tauLpp; ///< Lifetime inside of the plasmasphere.
121 
122  bool outputModelMatrix; ///< Output model matrix.
123  bool NoNegative; ///< Artificially no negative PSD
124 
125  bool useLossCone; ///< Flag to use the loss cone in the calculation
126 
127  /** General programm output parameters structure.
128  */
130  double timeStep; ///< Time step for output.
131  int iterStep; ///< Number of iterations between outputs
132  string logFileName; ///< log-file name.
133  string folderName; ///< output folder name.
134  string fileName1D; ///< 1d-output file name.
135  } general_Output_parameters;
136 
137  string
138  radialDiffusionGrid_type, ///< Local diffusions grid type
139  localDiffusionsGrid_type; ///< Radial diffusion grid type
140 
141  string radialDiffusionGrid_filename; ///< filename, if grid load from file
142  string localDiffusionsGrid_filename; ///< filename, if grid load from file
143 
144  /** %Grid element parameters structure.
145  */
146  struct GridElement {
147  string name; ///< Grid element name. Optional.
148  int size; ///< Grid size.
149  bool useLogScale;///< Flag, use logarithmic scale.
150  double min; ///< min value.
151  double max; ///< max value.
152 
153  }
154  radialDiffusionGrid_L,
155  radialDiffusionGrid_pc,
156  radialDiffusionGrid_alpha,
157  radialDiffusionGrid_epc,
158  localDiffusionsGrid_L,
159  localDiffusionsGrid_pc,
160  localDiffusionsGrid_alpha,
161  localDiffusionsGrid_epc;
162 
163 
164  /** Bundary conditions parameters structure.
165  */
167  string type; ///< Type. Check StrToVal(string input, BoundaryConditionTypes &place) for known values.
168  double value; ///< Value (if it is constant value on the boundary).
169  string filename; ///< File name to load boundary conditions from.
170 
171 
172  }
173  L_LowerBoundaryCondition,
174  L_UpperBoundaryCondition,
175  pc_LowerBoundaryCondition,
176  pc_UpperBoundaryCondition,
177  alpha_LowerBoundaryCondition,
178  alpha_UpperBoundaryCondition;
179 
180  /** %PSD parameters structure.
181  */
182  struct PSD {
183  /** Initial %PSD parameters structure.
184  */
185  string initial_PSD_Type; ///< Tells us where to get initial %PSD values. Check StrToVal(string input, InitialPSDTypes &place) for known values.
186  string initial_PSD_fileName; ///< File name, if we need to load initial values from file.
187  double initial_PSD_tauSteadyState; ///< Tau for steady state, if we are calculation initial values as steady state solytion.
188 
189  ///////////// kckim //////////////////////////
191  double initial_PSD_tauLppSteadyState; ///< Tau for steady state, if we are calculation initial values as steady state solytion.
192  //////////////////////////////////////////////
193 
194 
195  double initial_PSD_Kp0; ///< Kp for steady state?
196  double initial_PSD_some_constant_value; ///< Some %psd value. Used as initial PSD value everywhere if initial_PSD_Type = IPSDT_CONSTANT or as minimal initial PSD value in other cases. Also used for some inner belt imitation if initial_PSD_Type = IPSDT_STEADY_STATE.
197  string initial_PSD_J_L7_function; ///< Name of the function for flux at L=7. Can be 'J_L7' or 'J_L7_corrected'.
198  double initial_PSD_outer_psd; ///< Outer PSD boundary value for steady state, default 1
199  double initial_PSD_inner_psd; ///< Inner PSD boundary value for steady state, default 0
200 
201  /** %PSD output parameters structure
202  */
203  string output_PSD_folderName; ///< Folder name for psd output.
204  string output_PSD_fileName4D; ///< File name for psd output.
205  double output_PSD_timeStep; ///< Time step for psd output.
206 
207  string approximationMethod; ///< Approximation method. Check StrToVal(string input, ApproximationMethods &place) for known values.
208  string solutionMethod; ///< Solution method. Check StrToVal(string input, SolutionMethods &place) for known values.
209 
211 
212  int SOL_maxiter; ///< Maximum number of steps, for iteration methods
213  int SOL_i_max; ///< For GMRES - number of iterations before restart
214  double SOL_max_iter_err; ///< maximum error, for iteration methods
215  string preconditioner_type; ///< Type of preconditioner to yse.
216  bool use_normalization; ///< To normalize (or not) matrix A from Ax=B system.
217  } GMRES_parameters;
218 
219  } psdRadialDiffusion, ///< %PSD parameters for radial diffusion.
220  psdLocalDiffusions; ///< %PSD parameters for local diffusions.
221 
222  /**
223  * Sources and losses
224  */
225  struct SL_structure {
226  bool SL_L_top;
228  bool SL_E_min;
230  } SL;
231 
232  /** %Interpolation parameters structure
233  */
234  struct Interpolation {
235  string type; ///< Interpolation type: spline, linear etc.
236  string useLog; ///< Flag, if we should interpolate logarighm of the values.
237 
238  /** Parameters for spline interpolation - defined the ratio between spline and linear. 0 - pure spline, 1 - pure linear. */
240 
241  /** Maximum second derivative value, to start using linearSplineCoef. */
243  } interpolation; ///< %Interpolation parameters.
244 
245 
246  // diffusion coefficients
247  // List_of_AllDxxParameters AllDxxParameters; ///< List of diffusion coefficients parameters.
248  vector<DxxParameters_structure> DxxParametersList; ///< List of diffusion coefficients parameters.
249 
250  /** \brief Load parameters of calculation from ini file to the structure.
251  * \param filename - Location of the "Parameters.ini" file */
252  bool Load_parameters(string filename);
253 };
254 
255 /** \brief Convert string to double
256 * \param input - input string
257 * \param place - output */
258 void StrToVal(string input, double &place);
259 /** \brief Convert string to int
260 * \param input - input string
261 * \param place - output */
262 void StrToVal(string input, int &place);
263 /** \brief Return same string
264 * \param input - input string
265 * \param place - output */
266 void StrToVal(string input, string &place);
267 /** \brief Convert string to bool
268 * \param input - input string
269 * \param place - output */
270 void StrToVal(string input, bool &place);
271 
272 /** \brief Return bool from string (Yes|True|1)
273 * \param str - input string */
274 bool str2bool(string str);
275 
276 /** \brief Return string (Yes|No) from bool
277 * \param b - boolean input */
278 string bool2str(bool b);
279 
280 
281 void load_1d(Matrix1D<double> &var, string filename, double dt, int var_size = 0);
282 
283 
284 #endif