diff options
Diffstat (limited to 'plugins/ZamTube/triode.cpp')
-rw-r--r-- | plugins/ZamTube/triode.cpp | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/plugins/ZamTube/triode.cpp b/plugins/ZamTube/triode.cpp index 9796063..ec42960 100644 --- a/plugins/ZamTube/triode.cpp +++ b/plugins/ZamTube/triode.cpp @@ -31,13 +31,47 @@ T Triode::getIa(T Vgk, T Vpk) const { Vgk = 0.0; } - /* exact solution (expensive) */ - T ee1 = Vpk*log1p(exp(kp*(1./mu+Vgk/sqrt(kvb+Vpk*Vpk))))/kp; - if (ee1 < 0) { - return 0.; - } - //printf("Vpk=%f ans=%f e1=%f exact_e1=%f\n", Vpk, ans, e1, ee1); - return 1e+6*pow(ee1, kx) / kg1; + /* f(x,y) = (y*log(1+kp/mu*exp(1+mu*x/sqrt(kvb+y*y))))^kx + * = (y*log(1+6*exp(1+100*x/sqrt(300+y*y))))^1.4 + * + * Let y' = y * sqrt(300) + * Let x' = x * 100 / sqrt(300) + * + * f(x',y') = (y'*log(1+6*exp(1+x'/sqrt(1+y'*y'))))^1.4 + * + * When -x'/y' < 17 + * f(x',y') ~= (y' - 3*exp(1)*x')^1.4 + * f(x,y) ~= (y/sqrt(300) - 3*exp(1)*x*sqrt(300)/100)^1.4 + * + * When |x'| is small && y' is large + * f(x',y') ~= (y'*log(1 + 6*exp(1)))^1.4 + * f(x,y) ~=(y/sqrt(300)*log(1 + 6*exp(1)))^1.4 + * + * Otherwise, use exact solution + */ + float f = 0.f; + float sc = 1e+6 / kg1; +/* +#define G_NEG_SMALL -1.f +#define P_LARGE 150.f + float e1 = expf(1.f); + float r300 = sqrtf(300.f); + + if (-Vgk/Vpk < 17.) { + f = sc * powf(Vpk / r300 - 3.f * e1 * Vgk * r300 / 100., 1.4f); + } else if ((Vgk > G_NEG_SMALL) && (Vpk > P_LARGE)) { + f = sc * powf(Vpk * log1pf(6.f*e1) / r300, 1.4f); + } else { +*/ + /* exact solution (expensive) */ + float ee1 = Vpk*log1pf(expf(kp*(1./mu+Vgk/sqrtf(kvb+Vpk*Vpk))))/kp; + if (ee1 < 0) { + return 0.; + } + f = sc * powf(ee1, kx); +// } + //printf("Vpk=%f e1=%f exact_e1=%f\n", Vpk, ans, e1, ee1); + return f; } T Triode::iterateNewtonRaphson(T x, T dx, T Vgk, T a, T R) const { |