VERB_code_2.3
AdditionalSourcesAndLosses.cpp
Go to the documentation of this file.
1 
8 #include <math.h>
10 
11 #define err 1e-3
12 
20 void AdditionalSourcesAndLosses::Create_SL(Parameters_structure::SL_structure &SL, Grid &grid, int numberOfIterations, double timeStep) {
21 
22 
24 
25  // Check do we have a magnetopause
26  if (SL.useLmp == true & SL.Lmp.size_x > 0 & SL.Lmp.size_y > 0)
27  {
28  // magnetopause determined
29  //grid.alpha.size;
30  //grid.L.size;
31  //grid.pc.size;
32 
33  this->timeStep = timeStep;
34 
35  // Create our losses array, after we will fill it
36  arr.AllocateMemory(grid.L.size, grid.pc.size, grid.alpha.size);
37  }
38 
39 
40  // \todo: add code here
41 
42  // Add magnetopause shadowing here
43  /*
44  1. Load data from file (I think whole file)
45  2. File should contain information about L* magnitomause position for current pitch angle
46  3. Check grid and number of interations
47  4. Maybe do linear interpolation for interation (maybe later)
48 
49  5. Rest in update!
50  */
51 }
52 
60  // for each iteration build SL array corresponded to losses by magnetopause
61 
62  if (SL.useLmp == true)
63  for (int il = 0; il < grid.L.size; il++)
64  for (int im = 0; im < grid.pc.size; im++)
65  for (int ia = 0; ia < grid.alpha.size; ia++)
66  {
67  // We are in the right position of the array
68 
69  if (grid.L.arr[il][im][ia] >= SL.Lmp[iteration][ia]) // our client
70  {
72  double tau_d;
73  tau_d = AdditionalSourcesAndLosses::drift_time(grid.pc.arr[il][im][ia], grid.alpha.arr[il][im][ia], grid.L.arr[il][im][ia]);
74  arr[il][im][ia] = exp(-1 * this->timeStep / tau_d);
75  }
76 
77 
78  else
79  arr[il][im][ia] = 1;
80  }
81 
82  /*
83  1. Take loaded file and apply interation to that file
84  2. Build 3d array of current magnetopause shadowing
85  */
86 
87 }
88 
89 // Walt (4.47)
97 double AdditionalSourcesAndLosses::drift_time(double pc, double alpha, double L)
98 {
99  double Cd = 1.557E4 / 86400; // days for electrons
100  double gamma = sqrt( 1 + pc*pc / (VC::mc2 * VC::mc2) );
101 
102  double td = Cd* (1 / L ) * gamma / (gamma * gamma - 1) * (1 - 1/3 * pow(sin(alpha),0.62) );
103 
104  return td;
105 }
int size_y
size x, size y
Definition: Matrix.h:141
void Update(int iteration, Parameters_structure::SL_structure &SL, Grid &grid)
GridElement alpha
grid elements to be used
Definition: Grid.h:59
bool useLmp
magnetopause position flag
Definition: Parameters.h:246
Matrix3D< double > arr
array of grid points
Definition: Grid.h:30
int size_x
size x, size y
Definition: Matrix.h:141
static const double exp
exponential
Matrix3D< double > arr
array of sources and losses values
void AllocateMemory(int size_x, int size_y, int size_z)
Definition: Matrix.cpp:841
static const double mc2
m*c^2 = 0.511 MeV
Matrix2D< double > Lmp
magnetopause position Lmp (time, alpha)
Definition: Parameters.h:245
int size
size of grid element
Definition: Grid.h:39
void Create_SL(Parameters_structure::SL_structure &SL, Grid &grid, int numberOfIterations, double timeStep)
GridElement L
grid elements to be used
Definition: Grid.h:59
double drift_time(double pc, double alpha, double L)
Computational grid composed of 3 different GridElement.
Definition: Grid.h:53
Sources and losses parameters structure.
Definition: Parameters.h:238
GridElement pc
grid elements to be used
Definition: Grid.h:59