Update ChangeLog
[gss-tcad.git] / src / include / lsource.h
blob44b3aa61187de962723c75d19152a7b62bf79ded
1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
3 /* 8 8 8 */
4 /* 8 8 8 */
5 /* 8 88888888 88888888 */
6 /* 8 8888 8 8 */
7 /* 8 8 8 8 */
8 /* 888888 888888888 888888888 */
9 /* */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
11 /* */
12 /* GSS 0.4x */
13 /* Last update: Nov 29, 2005 */
14 /* */
15 /* Gong Ding */
16 /* gdiso@ustc.edu */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
18 /* */
19 /*****************************************************************************/
20 //sevel types of light source are defined here
21 //reference: spice vsource model
23 #ifndef _lsource_h_
24 #define _lsource_h_
25 #include "mathfunc.h"
26 #include <math.h>
27 #include <dlfcn.h>
28 #include "typedef.h"
30 enum LSOURCE_CARD_ERROR
32 LSOURCE_NO_ERROR,
33 LSOURCE_UNKNOW_PARAMETER
36 //virtual base class
37 class LSource
39 public:
40 virtual double currentft(double t)=0;
41 virtual ~LSource(){}
45 class LSource_UNIFORM: public LSource
47 private:
48 double td;
49 double power;
50 public:
51 LSource_UNIFORM(double t1,double p1): td(t1), power(p1){};
52 double currentft(double t)
53 { return t>=td? power:0;};
57 class LSource_PULSE: public LSource
59 private:
60 double td;
61 double tr;
62 double tf;
63 double pw;
64 double pr;
65 double powerlo,powerhi;
66 public:
67 LSource_PULSE(double t1,double t2,double t3,double t4, double t5,double plo,double phi):
68 td(t1),tr(t2),tf(t3),pw(t4),pr(t5),powerlo(plo),powerhi(phi){};
69 double currentft(double t)
71 if(t<td)
72 return powerlo;
73 else
75 t-=td;
76 while(t>pr) t-=pr;
77 if(t<tr)
78 return powerlo+t*(powerhi-powerlo)/tr;
79 else if(t<tr+pw)
80 return powerhi;
81 else if(t<tr+pw+tf)
82 return powerhi-(t-tr-pw)*(powerhi-powerlo)/tf;
83 else return powerlo;
89 //just for single pulse
90 class LSource_GAUSSIAN: public LSource
92 private:
93 double tp;
94 double tb;
95 double power;
96 public:
97 LSource_GAUSSIAN(double t1,double t2,double p1):
98 tp(t1),tb(t2),power(p1){};
99 double currentft(double t)
101 return power*2*exp(-(t-tp)*(t-tp)/tb)/(tb*sqrt(PI)*erfc(tp/tb));
107 class LSource_SHELL: public LSource
109 private:
110 void *dll;
111 double (*Lsource_Shell)(double);
112 double scale_t;
113 public:
114 LSource_SHELL(void * dp, void * fp, double s_t)
116 dll = dp;
117 Lsource_Shell = (double (*)(double)) fp;
118 scale_t = s_t;
120 double currentft(double t)
122 return Lsource_Shell(t/scale_t);
124 ~LSource_SHELL() {dlclose(dll);}
127 #endif