1 /*****************************************************************************/
2 /* 8888888 88888888 88888888 */
5 /* 8 88888888 88888888 */
8 /* 888888 888888888 888888888 */
10 /* A Two-Dimensional General Purpose Semiconductor Simulator. */
13 /* Last update: Nov 29, 2005 */
17 /* NINT, No.69 P.O.Box, Xi'an City, China */
19 /*****************************************************************************/
20 //sevel types of vsource are defined here
21 //reference: spice vsource model
29 enum VSOURCE_CARD_ERROR
33 VSOURCE_UNKNOW_PARAMETER
41 virtual double vapp(double t
)=0;
46 class VDC
: public VSource
52 VDC(double t1
,double v1
): td(t1
),Vdc(v1
){};
54 { return t
>=td
? Vdc
:0;};
59 class VSIN
: public VSource
68 VSIN(double t1
,double v0
,double v1
,double f1
,double a1
): td(t1
),V0(v0
),Vamp(v1
),fre(f1
),alpha(a1
){};
70 { return t
>=td
? V0
+Vamp
*exp(-alpha
*(t
-td
))*sin(2*3.14159265359*fre
*(t
-td
)):V0
;};
74 class VPULSE
: public VSource
84 VPULSE(double t1
,double v1
,double v2
,double t2
,double t3
,double t4
, double t5
):
85 td(t1
),tr(t2
),tf(t3
),pw(t4
),pr(t5
),Vlo(v1
),Vhi(v2
){};
95 return Vlo
+t
*(Vhi
-Vlo
)/tr
;
99 return Vhi
-(t
-tr
-pw
)*(Vhi
-Vlo
)/tf
;
107 class VEXP
: public VSource
116 VEXP(double t1
,double v1
,double v2
,double t2
,double t3
,double t4
):
117 td(t1
),trc(t2
),tfd(t3
),tfc(t4
),Vlo(v1
),Vhi(v2
){};
118 double vapp(double t
)
123 return Vlo
+(Vhi
-Vlo
)*(1-exp(-(t
-td
)/trc
));
125 return Vlo
+(Vhi
-Vlo
)*(1-exp(-(t
-td
)/trc
))+(Vlo
-Vhi
)*(1-exp(-(t
-tfd
)/tfc
));
130 class VSHELL
: public VSource
134 double (*Vapp_Shell
)(double);
138 VSHELL(void * dp
, void * fp
, double s_t
,double s_V
)
141 Vapp_Shell
= (double (*)(double)) fp
;
145 double vapp(double t
)
147 return scale_V
*Vapp_Shell(t
/scale_t
);
149 ~VSHELL() {dlclose(dll
);}