summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2019-01-14 02:32:37 +1100
committerDamien Zammit <damien@zamaudio.com>2019-01-14 02:32:37 +1100
commita76f0fba442bad95bab835cc23c29bfd02cead86 (patch)
tree7e67b1bf94537ce7117bc781ebed6175cdf96c27
parent26392514131a1baa32d8bb0a926e7540597ba01e (diff)
Use final calculated plate voltage to get plate current and remove fudge
-rw-r--r--plugins/ZamTube/triode.cpp5
-rw-r--r--plugins/ZamTube/wdfcircuits.h7
2 files changed, 5 insertions, 7 deletions
diff --git a/plugins/ZamTube/triode.cpp b/plugins/ZamTube/triode.cpp
index 3b70782..a32bbf3 100644
--- a/plugins/ZamTube/triode.cpp
+++ b/plugins/ZamTube/triode.cpp
@@ -13,7 +13,6 @@ T Triode::compute(T a, T R, T Vgate, T Vk) {
T Vak = VakGuess; // initial guess
int iteration = 0;
T err = 1e6;
- T Iak = 0.0;
while (fabs(err)/fabs(Vak) > 1e-9){
VakGuess = iterateNewtonRaphson(Vak, 1e-6, Vgk, a, R);
err = Vak - VakGuess;
@@ -25,7 +24,7 @@ T Triode::compute(T a, T R, T Vgate, T Vk) {
}
++iteration;
}
- T b = Vak - R*Iak;
+ T b = Vak - R*getIa(Vgk, Vak);
//printf("Vgate=%f Vk=%f Vgk=%f b=%f\n", Vgate, Vk, Vgk, b);
return b;
@@ -45,7 +44,7 @@ T Triode::getIa(T Vgk, T Vak) {
T kp = 600.;
T kvb = 300.;
- T e1 = Vak/kp*log(1.+exp(kp*(1./mu+Vgk/pow(kvb+Vak*Vak, 0.5))));
+ T e1 = Vak*log(1.+exp(kp*(1./mu+Vgk/pow(kvb+Vak*Vak, 0.5))))/kp;
if (e1 < 0) {
return 0.;
}
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h
index a54517b..e2b9547 100644
--- a/plugins/ZamTube/wdfcircuits.h
+++ b/plugins/ZamTube/wdfcircuits.h
@@ -69,14 +69,13 @@ public:
}
Real advanc(Real ViE) {
- Real fudge = 0.997; // Critical to make Vk = ~2V when -15dbFS sine wave is input
//Get Bs
//P1_3GetB
Real Ckb = Cka;
//P1_1SetA
//RkGetB
//P1_2SetA
- Real P1_3b3 = -fudge*P1_3Gamma1*(-Ckb);
+ Real P1_3b3 = -P1_3Gamma1*(-Ckb);
Real Cob = Coa;
//S3_1SetA
//RoGetB
@@ -85,7 +84,7 @@ public:
//P2_1SetA
//E500GetB
//P2_2SetA
- Real P2_3b3 = E500E - fudge*P2_3Gamma1*(E500E - S3_3b3);
+ Real P2_3b3 = E500E - P2_3Gamma1*(E500E - S3_3b3);
//S2_2SetA
Real S2_3b3 = -(P1_3b3 + P2_3b3);
//S1_3GetB
@@ -106,7 +105,7 @@ public:
Real S1_3b3 = -(P0_3b3);
//Call tube model
Vg = -S1_3b3;
- Real b = t.compute(-S2_3b3, S2_3Gamma1, Vg-Vk, Vk);
+ Real b = t.compute(-S2_3b3, S2_3Gamma1, Vg, Vk);
//Set As
//S2_3SetA
Real S2_3b1 = P1_3b3 - S2_3Gamma1*(P1_3b3 + P2_3b3 + b);