Memosa-FVM  0.2
ElectricUtilityFunctions.h File Reference
#include "PhysicsConstant.h"
#include "Array.h"
#include "Vector.h"
#include "CException.h"
Include dependency graph for ElectricUtilityFunctions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef Vector< double, 3 > VectorD3
 

Functions

template<class T >
const T FermiFunction (const T &energy, const T &fermilevel, const T &temperature)
 
template<class T >
const T ElectronSupplyFunction (const T &energy, const T &fermilevel, const T &temperature)
 
template<class T >
const T PositiveValueOf (T input)
 
template<class T >
const T getMembraneVoltage (const T &currentTime)
 
double SignOf (double x)
 
double findMin (double x1, double x2, double x3, double x4)
 
double findMax (double x1, double x2, double x3, double x4)
 
double distanceFromPointToLine (VectorD3 p1, VectorD3 p2, VectorD3 M)
 
VectorD3 projectionFromPointToLine (VectorD3 p1, VectorD3 p2, VectorD3 M)
 

Typedef Documentation

typedef Vector<double, 3> VectorD3

Definition at line 16 of file ElectricUtilityFunctions.h.

Function Documentation

double distanceFromPointToLine ( VectorD3  p1,
VectorD3  p2,
VectorD3  M 
)

Definition at line 99 of file ElectricUtilityFunctions.h.

References dot(), and mag().

100 {
101  // 3D point p1 and p2 forms a line L
102  // find the shortest distance from point M to line L
103  // assume point H is the projection of M on line L
104  // so the shortest distance is the length of MH
105 
106  VectorD3 v = p2 - p1;
107  if (mag(v) == 0)
108  throw CException ("column center line start and end points are the same!!!");
109 
110  v /= mag(p2-p1);
111  VectorD3 PM = p1 - M;
112  VectorD3 PH = dot(PM, v) * v;
113  VectorD3 HM = PM - PH;
114  double distance = mag(HM);
115  return distance;
116 }
T mag(const Vector< T, 3 > &a)
Definition: Vector.h:260
T dot(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
Definition: Vector.h:253
template<class T >
const T ElectronSupplyFunction ( const T &  energy,
const T &  fermilevel,
const T &  temperature 
)

Definition at line 25 of file ElectricUtilityFunctions.h.

References K_SI, and QE.

Referenced by InjectionDiscretization< X, Diag, OffDiag >::discretize(), and TunnelingDiscretization< X, Diag, OffDiag >::discretize().

26 {
27  T exponent, power, supply;
28 
29  power = -QE * (energy - fermilevel) / (K_SI * temperature);
30  exponent = exp(power);
31 
32  if (exponent <= 0.01)
33  supply = K_SI * temperature * (exponent - pow(exponent, 2.0)/2.0 + pow(exponent, 3.0)/3.0 - pow(exponent, 4.0)/4.0);
34 
35  if (power >= 10.0)
36  supply = K_SI * temperature * power;
37 
38  else
39  supply = K_SI * temperature *log(1+exponent);
40 
41 
42  //supply = K_SI * temperature *log(1+exponent);
43  return supply;
44 }
#define K_SI
#define QE
template<class T >
const T FermiFunction ( const T &  energy,
const T &  fermilevel,
const T &  temperature 
)

Definition at line 19 of file ElectricUtilityFunctions.h.

References K_SI, and QE.

Referenced by ElectricModel< T >::Impl::calculateEquilibriumParameters(), InjectionDiscretization< X, Diag, OffDiag >::discretize(), and TunnelingDiscretization< X, Diag, OffDiag >::discretize().

20 {
21  return 1. / (1. + exp(QE * (energy - fermilevel) / (K_SI * temperature) ));
22 }
#define K_SI
#define QE
double findMax ( double  x1,
double  x2,
double  x3,
double  x4 
)

Definition at line 85 of file ElectricUtilityFunctions.h.

References max().

86 {
87  double max = -1000000000;
88  if (x1 >= max)
89  max = x1;
90  if (x2 >= max)
91  max = x2;
92  if (x3 >= max)
93  max = x3;
94  if (x4 >= max)
95  max = x4;
96  return max;
97 }
double max(double x, double y)
Definition: Octree.cpp:18
double findMin ( double  x1,
double  x2,
double  x3,
double  x4 
)

Definition at line 71 of file ElectricUtilityFunctions.h.

References min().

72 {
73  double min = 1000000000;
74  if (x1 <= min)
75  min = x1;
76  if (x2 <= min)
77  min = x2;
78  if (x3 <= min)
79  min = x3;
80  if (x4 <= min)
81  min = x4;
82  return min;
83 }
double min(double x, double y)
Definition: Octree.cpp:23
template<class T >
const T getMembraneVoltage ( const T &  currentTime)

Definition at line 58 of file ElectricUtilityFunctions.h.

59 {
60  T volt;
61  volt = 1.0;
62  return volt;
63 }
template<class T >
const T PositiveValueOf ( input)
VectorD3 projectionFromPointToLine ( VectorD3  p1,
VectorD3  p2,
VectorD3  M 
)

Definition at line 118 of file ElectricUtilityFunctions.h.

References dot(), and mag().

119 {
120  VectorD3 v = p2 - p1;
121  if (mag(v) == 0)
122  throw CException ("column center line start and end points are the same!!!");
123 
124  v /= mag(p2-p1);
125  VectorD3 PM = p1 - M;
126  VectorD3 PH = dot(PM, v) * v;
127  VectorD3 HM = PM - PH;
128  VectorD3 H = HM + M;
129  return H;
130 }
T mag(const Vector< T, 3 > &a)
Definition: Vector.h:260
T dot(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
Definition: Vector.h:253
double SignOf ( double  x)

Definition at line 65 of file ElectricUtilityFunctions.h.

65  {
66  if (x>0) return 1;
67  else if (x<0) return -1;
68  else return 0;
69 }