OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
formulary.h
Go to the documentation of this file.
1 
15 //-------------------------------------------------------------------
16 
17 
18  #ifndef DECL_FORMULARY_H
19  #define DECL_FORMULARY_H
20 
21 
22 //--------------------------------------------------------------
23 // Make Gaussian
24 template<class T>
25 valarray<T> Gaussian(const size_t N, const T vmin, const T vmax, const T vth){
26 
27 // Make axis first
28  valarray<T> G(N);
29  for (size_t i(0); i < N; ++i) {
30  G[i] = static_cast<T>(i);
31  }
32  G *= (vmax-vmin)/(static_cast<T>(N-1));
33  G += vmin;
34 
35 // Make Gaussian
36  T C(pow( 1.0/ (sqrt(2.0*M_PI)*vth), 3));
37  T al( (-0.5) / (vth*vth));
38  for (size_t i(0); i < N; ++i) {
39  G[i] = exp( al * G[i]*G[i] );
40  }
41  G *= C;
42 
43  return G;
44 }
45 //-------------------------------------------------------------------
46 
47 //--------------------------------------------------------------
48 class units {
49  public:
50 // Contents
51  string label; // e.g. label = sec
52  double d; // e.g. x[label] = c * x[1/wp] => c = 1/wp
53 
54 // Constructors
55  units() : label("default"), d(0.0) {}
56  units(string _x, double _d) : label(_x), d(_d){}
57 
58 // Copy constructor
59  units(const units& other) {
60  label = other.label;
61  d = other.d;
62  }
63  ~units(){ }
64 };
65 //-------------------------------------------------------------------
66 
67 //-------------------------------------------------------------------
68 class Formulary {
69  public:
70 // Construct an underlying dictionary for units
71  Formulary();
72 
73 // Access to unit systems
74  units Units(string key) { return D[key]; }
75  units Units(string key1, string key2) { return D[key1+"_"+key2]; }
76  string Label(string key) { return D[key].label; }
77  string Label(string key1, string key2) { return D[key1+"_"+key2].label; }
78  double Uconv(string key) { return D[key].d; }
79  double Uconv(string key1, string key2) { return D[key1+"_"+key2].d; }
80 
81 // Coulomb logarithms
82  double LOGee(double ne, double Te);
83  double LOGee(double ne, string un, double Te, string uT);
84  double LOGei(double ne, double Te, double Z);
85  double LOGei(double ne, string un, double Te, string uT, double Z);
86  double LOGii(double m1, double Z1, double n1, double T1, double m2, double Z2, double n2, double T2);
87 
88 // Formulary functions
89  double vth(double Te);
90  double vth(double Te, string uT);
91  double Tau_e(double ne, double Te);
92  double Tau_e(double ne, string un, double Te, string uT);
93  double Tau_i(double ne, double Te, double Zeta);
94  double MFP(double ne, double Te);
95  double MFP(double ne, string un, double Te, string uT);
96 
97 // Normalization density
98  //const double n = 1.0e+21; // cm-3
99  double n; // cm-3
100  double wp;
101  double skindepth;
102  double B0;
103  double T0;
104  double Zeta;
105  // const double ref_nuei;
106 
107 // Physical constants
108 
109  // double oneover_atomic_Z = 1.0/Input::List().Zeta;
110  static constexpr double pi=3.141592653589793238;
111 
112  static constexpr double cL = 299792458;//3e8; // speed of light over v electron thermal
113  static constexpr double eps0=8.854187817e-12;//8.85e-12;
114  static constexpr double qe = -1.60217662e-19; //1.6e-19 // electron charge.
115  static constexpr double me = 9.10938356e-31; //9.11e-31 //electron mass
116  static constexpr double me_over_mp = 0.000544617024;
117  static constexpr double keVnorm = 510.9989461; //to be multiplied by v^2/c^2
118 
119  static constexpr double c = 2.99792458*1.0e+10; // cm/sec
120  static constexpr double e = 4.80320425*1.0e-10; // Franklin or statC
121  static constexpr double m = 9.10938215*1.0e-28; // gr
122 
123  private:
124  map<string,units> D;
125 
126  static constexpr double nmin = 1.0e-8;
127 };
128 //--------------------------------------------------------------
129 
131 //--------------------------------------------------------------
132 //**************************************************************
133 
134 
135  #endif
Formulary & formulary()
Definition: formulary.cpp:328
units Units(string key1, string key2)
Definition: formulary.h:75
map< string, units > D
Definition: formulary.h:124
double T0
Definition: formulary.h:103
units(const units &other)
Definition: formulary.h:59
double wp
Definition: formulary.h:100
string Label(string key1, string key2)
Definition: formulary.h:77
double Zeta
Definition: formulary.h:104
double d
Definition: formulary.h:52
~units()
Definition: formulary.h:63
double Uconv(string key)
Definition: formulary.h:78
units(string _x, double _d)
Definition: formulary.h:56
valarray< T > Gaussian(const size_t N, const T vmin, const T vmax, const T vth)
Definition: formulary.h:25
string Label(string key)
Definition: formulary.h:76
double Uconv(string key1, string key2)
Definition: formulary.h:79
double B0
Definition: formulary.h:102
units()
Definition: formulary.h:55
double n
Definition: formulary.h:99
double skindepth
Definition: formulary.h:101
units Units(string key)
Definition: formulary.h:74
string label
Definition: formulary.h:51