VERB_code_2.2  2
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
PSD.h
Go to the documentation of this file.
1 /**
2 * \file PSD.cpp
3 *
4 * \brief Makes operations with %PSD (Phase Space Density (%PSD).) (like, diffusion).
5 *
6 * \author Developed under supervision of the PI Yuri Shprits
7 *
8 * \todo
9 * - What Interpolate function does
10 */
11 
12 
13 #ifndef PhaseSpaceDensity_H
14 /// \def PhaseSpaceDensity_H
15 /// \brief Check if PhaseSpaceDensity_H is defined, to not include the class more then one time.
16 #define PhaseSpaceDensity_H
17 
18 // General C++ headers
19 #include <fstream>
20 #include <string>
21 // Type of data (it could be deptecated)
22 #include <map>
23 
24 // Operations with Grig array
25 #include "../Grid/Grid.h"
26 // Operations with matrixes
27 #include "../Matrix/Matrix.h"
28 // Operations with coefficients
29 #include "../DiffusionCoefficient/DiffusionCoefficient.h"
30 // Pfrfmeters from ini file
31 #include "../Parameters/Parameters.h"
32 // Equation solver (main algoritm)
33 #include "MatrixSolver.h"
34 
35 
36 using namespace std;
37 
38 
39 /**
40 * \brief Phase Space Density class.
41 *
42 * Do diffusions and store the result in parent class Matrix3D.
43 * Do all possible operations with %PSD (like output, loading, etc).
44 */
45 class PSD {
46 public:
47 
48 
49  /// \brief array of PSD values
51 
52  /// \brief Parameters from ini file
54 
55  /**
56  * \brief Create inital PSD (Steady State)
57  *
58  * \param parameters - interpolation parameters structure
59  * \param &grid - grid
60  * \param L_UpperBoundaryCondition - upper L boundary values, in case we need to create initial PSD as a steady state radial diffusion solution
61  */
62  void Create_Initial_PSD(Parameters_structure::PSD parameters, Grid &grid, BoundaryCondition L_UpperBoundaryCondition);
63 
64  /**
65  * \brief Interpolation function.
66  *
67  * \param &otherPSD - %PSD to interpolat to the values from
68  * \param interpolationParameters_structure -
69  * \param &oldGrid - old grid
70  * \param &newGrid - new grid
71  * \param newGrid_pc_lowerBoundaryCondition - upper energy boundary VALUE
72  * \param newGrid_pc_upperBoundaryCondition - lower energy boundary VALUE
73  */
74  void Interpolate(PSD &otherPSD, Parameters_structure::Interpolation interpolationParameters, Grid &oldGrid, Grid &newGrid, Matrix2D<double> newGrid_pc_lowerBoundaryCondition, Matrix2D<double> newGrid_pc_upperBoundaryCondition);
75 
76  /**
77  * \brief Calculate initial %PSD from steady state.
78  *
79  * \param &L - grid element L
80  * \param &pc - grid element pc
81  * \param &alpha - grid element alpha
82  * \param tau - life time
83  * \param Kp - Kp value
84  * \param min_f - minimum of finction (should be some positive value)
85  * \param J_L7_function - parameter, J_L7 function. Can be J_L7 or J_L7_corrected
86  * \param fb_out - value at the outer L boundary
87  * \param fb_in - value at the inner L boundary
88  *
89  */
90  void Load_initial_f(GridElement &L, GridElement &pc, GridElement &alpha, double tau, double Kp, double min_psd = 1.e-99, string J_L7_function = "J_L7", double fb_out = 1, double fb_in = 0);
91 
92  /**
93  * \brief Calculate initial %PSD from steady state (kckim).
94  *
95  * \param &L - grid element L
96  * \param &pc - grid element pc
97  * \param &alpha - grid element alpha
98  * \param tau - life time
99  * \param Kp - Kp value
100  * \param min_f - minimum of finction (should be some positive value)
101  * \param J_L7_function - parameter, J_L7 function. Can be J_L7 or J_L7_corrected
102  */
103  void Load_initial_f_two_zone(GridElement &L, GridElement &pc, GridElement &alpha, double tau, double tauLpp, double Kp, double min_psd = 1.e-99, string J_L7_function = "J_L7", double fb_out = 1, double fb_in = 0);
104 
105 
106  /**
107  * \brief Calculate initial %PSD from steady state using boundary conditions.
108  *
109  * \param &L - grid element L
110  * \param &pc - grid element pc
111  * \param &alpha - grid element alpha
112  * \param tau - life time
113  * \param Kp - Kp value
114  * \param L_UpperBoundaryCondition - values at the outer L boundary, in case we need to create initial PSD as a steady state radial diffusion solution
115  * \param min_f - minimum of finction (should be some positive value)
116  * \param J_L7_function - parameter, J_L7 function. Can be J_L7 or J_L7_corrected
117  * \param fb_out - upper boundary value for steady-state solution
118  * \param fb_in - lower boundary value for steady-state solution
119  */
120  void Load_initial_f_from_outer_L(GridElement &L, GridElement &pc, GridElement &alpha, double tau, double Kp, Matrix2D<double> L_UpperBoundaryCondition, double min_psd = 1.e-99, double fb_out = 1, double fb_in = 0);
121 
122 
123  void Load_initial_f_2d(GridElement &L, GridElement &pc, GridElement &alpha, const char *filename);
124 
125 
126  void Load_initial_f_file(GridElement &L, GridElement &pc, GridElement &alpha, const char *filename, bool with_grid);
127 
128 
129  void Load_initial_f_maxwell(GridElement &L, GridElement &pc, GridElement &alpha);
130 
131  // Explicit mixed terms
132  void DiffusionMixTermExplicit(double dt, double Lpp,
134  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
135  Matrix2D<double> pc_lowerBoundaryCondition,
136  Matrix2D<double> pc_upperBoundaryCondition,
137  Matrix2D<double> alpha_lowerBoundaryCondition,
138  Matrix2D<double> alpha_upperBoundaryCondition,
139  string pc_lowerBoundaryCondition_calculationType,
140  string pc_upperBoundaryCondition_calculationType,
141  string alpha_lowerBoundaryCondition_calculationType,
142  string alpha_upperBoundaryCondition_calculationType);
143 
144 
145  void Diffusion_alpha(double dt, double Lpp,
147  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
148  Matrix2D<double> alpha_lowerBoundaryCondition,
149  Matrix2D<double> alpha_upperBoundaryCondition,
150  string alpha_lowerBoundaryCondition_calculationType,
151  string alpha_upperBoundaryCondition_calculationType);
152 
153  void Diffusion_pc(double dt, double Lpp,
154  DiffusionCoefficient &Dpcpc, DiffusionCoefficient &DpcpcLpp,
155  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
156  Matrix2D<double> pc_lowerBoundaryCondition,
157  Matrix2D<double> pc_upperBoundaryCondition,
158  string pc_lowerBoundaryCondition_calculationType,
159  string pc_upperBoundaryCondition_calculationType);
160 
161  void Diffusion_L(double dt, double Lpp,
163  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
164  Matrix2D<double> lowerBoundaryCondition,
165  Matrix2D<double> upperBoundaryCondition,
166  string lowerBoundaryCondition_calculationType,
167  string upperBoundaryCondition_calculationType,
168  double tau, double tauLpp);
169 
170 
171  void Diffusion_pc_alpha(double dt, double Lpp,
172  DiffusionCoefficient &Dpcpc, DiffusionCoefficient &DpcpcLpp,
175  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
176  Matrix2D<double> pc_lowerBoundaryCondition,
177  Matrix2D<double> pc_upperBoundaryCondition,
178  Matrix2D<double> alpha_lowerBoundaryCondition,
179  Matrix2D<double> alpha_upperBoundaryCondition,
180  string pc_lowerBoundaryCondition_calculationType,
181  string pc_upperBoundaryCondition_calculationType,
182  string alpha_lowerBoundaryCondition_calculationType,
183  string alpha_upperBoundaryCondition_calculationType);
184 
185  void Diffusion_pc_alpha_KC(double dt, double Lpp,
186  DiffusionCoefficient &Dpcpc, DiffusionCoefficient &DpcpcLpp,
189  GridElement &L, GridElement &pc, GridElement &alpha, Matrix3D<double> Jacobian,
190  Matrix2D<double> pc_lowerBoundaryCondition,
191  Matrix2D<double> pc_upperBoundaryCondition,
192  Matrix2D<double> alpha_lowerBoundaryCondition,
193  Matrix2D<double> alpha_upperBoundaryCondition,
194  string pc_lowerBoundaryCondition_calculationType,
195  string pc_upperBoundaryCondition_calculationType,
196  string alpha_lowerBoundaryCondition_calculationType,
197  string alpha_upperBoundaryCondition_calculationType);
198 
199  CalculationMatrix matr_A, matr_B, matr_C;
200 
201 
202  //// scale boundary flux ////////
203  //void ScaleBoundaryFlux(Parameters_structure::PSD parameters, GridElement &L, GridElement &pc, GridElement &alpha);
204  /////////////////////////////////
205 
206  void SourcesAndLosses(
208  GridElement &L, GridElement &pc, GridElement &alpha,
209  Matrix3D<double> &SL,
210  double dt,
211  double Lpp, double tau, double tauLpp, double Kp);
212 
213  // output functions
214  void Output_without_grid(double time);
216 
217 };
218 
219 /** Compute steady state solution for 1D diffusion
220 */
221 void steady_state(Matrix1D<double> &f, double tau, double Kp, int nx, Matrix1D<double> &CL, double f_bnd_out = 1, double f_bnd_in = 0);
222 // kckim
223 void steady_state_two_zone(Matrix1D<double> &f, Matrix1D<double> &tau, double Kp, double alpha, Matrix1D<double> &Ke, int nx, Matrix1D<double> &CL, double f_bnd_out = 1, double f_bnd_in = 0);
224 //
225 
226 #endif
227