diff options
author | Damien Zammit <damien@zamaudio.com> | 2020-11-25 18:56:29 +1100 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2020-12-01 14:18:01 +1100 |
commit | f9d9e12410f86ac53f6c8bd6bb61dbe2791b71d4 (patch) | |
tree | beac912be73b2bfbc1fb9898c45aa8ce8f148dcc | |
parent | 6ea40259d8c8fd7951a6f9606f193ec0ee6a9203 (diff) |
ZamTube: New Circuit needs signs fixed
-rw-r--r-- | plugins/ZamTube/wdfcircuits.h | 141 |
1 files changed, 94 insertions, 47 deletions
diff --git a/plugins/ZamTube/wdfcircuits.h b/plugins/ZamTube/wdfcircuits.h index acc2b1e..a7b7933 100644 --- a/plugins/ZamTube/wdfcircuits.h +++ b/plugins/ZamTube/wdfcircuits.h @@ -33,7 +33,12 @@ public: S1_3Gamma1 = 1.; S3_3Gamma1 = 1.; P1_3Gamma1 = 1.; + St1_3Gamma1 = 1.; + St2_3Gamma1 = 1.; + Pt_3Gamma1 = 1.; ViE = 0.; + Rda = 0.; + S0_3Gamma1 = 1.; S2_3Gamma1 = 1.; P2_3Gamma1 = 1.; @@ -48,6 +53,7 @@ public: Real RgR = R_Rg; Real RoR = R_Ro; Real RkR = R_Rk; + Real RdR = 2.7e+3; Real CkR = 1.0 / (2.0*C_Ck*sampleRate); Real E500R = R_E500; E500E = E_E500; @@ -60,6 +66,7 @@ public: Real P0_3R = 1.0 /(1.0 / P0_1R + 1.0 / P0_2R); P0_3Gamma1 = 1.0 / P0_1R/(1.0 / P0_1R + 1.0 / P0_2R); Assert(P0_3Gamma1 >= 0.0 && P0_3Gamma1 <= 1.0); + Real S1_3R = (RgR + P0_3R); S1_3Gamma1 = RgR/(RgR + P0_3R); Assert(S1_3Gamma1 >= 0.0 && S1_3Gamma1 <= 1.0); Real P1_1R = CkR; @@ -67,94 +74,130 @@ public: Real P1_3R = 1.0 /(1.0 / P1_1R + 1.0 / P1_2R); P1_3Gamma1 = 1.0 / P1_1R/(1.0 / P1_1R + 1.0 / P1_2R); Assert(P1_3Gamma1 >= 0.0 && P1_3Gamma1 <= 1.0); - Real S3_3R = (CoR + RoR); - S3_3Gamma1 = CoR/(CoR + RoR); + Real S3_3R = (RoR + CoR); + S3_3Gamma1 = RoR/(RoR + CoR); Assert(S3_3Gamma1 >= 0.0 && S3_3Gamma1 <= 1.0); Real P2_1R = S3_3R; Real P2_2R = E500R; Real P2_3R = 1.0 /(1.0 / P2_1R + 1.0 / P2_2R); P2_3Gamma1 = 1.0 / P2_1R/(1.0 / P2_1R + 1.0 / P2_2R); Assert(P2_3Gamma1 >= 0.0 && P2_3Gamma1 <= 1.0); - S2_3Gamma1 = P2_3R/(P2_3R + P1_3R); - Assert(S2_3Gamma1 >= 0.0 && S2_3Gamma1 <= 1.0); + Real St1_3R = (RdR + S1_3R); + St1_3Gamma1 = RdR/(RdR + S1_3R); + Assert(St1_3Gamma1 >= 0.0 && St1_3Gamma1 <= 1.0); + Real Pt_1R = St1_3R; + Real Pt_2R = P1_3R; + Real Pt_3R = 1.0 /(1.0 / Pt_1R + 1.0 / Pt_2R); + Pt_3Gamma1 = 1.0 / Pt_1R/(1.0 / Pt_1R + 1.0 / Pt_2R); + Assert(Pt_3Gamma1 >= 0.0 && Pt_3Gamma1 <= 1.0); + St2_3Gamma1 = Pt_3R/(Pt_3R + P2_3R); + Assert(St2_3Gamma1 >= 0.0 && St2_3Gamma1 <= 1.0); } Real advanc(Real ViE) { //Get Bs - //S2_3GetB + //St2_3GetB + //Pt_3GetB + //St1_3GetB + //RdGetB + //St1_1SetA + //S1_3GetB + //RgGetB + //S1_1SetA + //P0_3GetB + //S0_3GetB + Real Cib = Cia; + //S0_1SetA + //ViGetB + //S0_2SetA + Real S0_3b3 = -(Cib + ViE); + //P0_1SetA + //RiGetB + //P0_2SetA + Real P0_3b3 = -P0_3Gamma1*(-S0_3b3); + //S1_2SetA + Real S1_3b3 = -(P0_3b3); + //St1_2SetA + Real St1_3b3 = -(S1_3b3); + //Pt_1SetA + //P1_3GetB + Real Ckb = Cka; + //P1_1SetA + //RkGetB + //P1_2SetA + Real P1_3b3 = -P1_3Gamma1*(-Ckb); + //Pt_2SetA + Real Pt_3b3 = P1_3b3 - Pt_3Gamma1*(P1_3b3 - St1_3b3); + //St2_1SetA //P2_3GetB //S3_3GetB - Real Cob = Coa; - //S3_1SetA //RoGetB + //S3_1SetA + Real Cob = Coa; //S3_2SetA Real S3_3b3 = -(Cob); //P2_1SetA //E500GetB //P2_2SetA Real P2_3b3 = E500E - P2_3Gamma1*(E500E - S3_3b3); - //S2_1SetA - //P1_3GetB - Real Ckb = Cka; - //P1_1SetA - //RkGetB - //P1_2SetA - Real P1_3b3 = P1_3Gamma1*(-Ckb); - //S2_2SetA - Real S2_3b3 = (P2_3b3 + P1_3b3); + //St2_2SetA + Real St2_3b3 = -(Pt_3b3 + P2_3b3); + //Pt_3GetB + //St1_3GetB + //RdGetB + //St1_1SetA //S1_3GetB //RgGetB //S1_1SetA //P0_3GetB //S0_3GetB - Real Cib = Cia; //S0_1SetA //ViGetB //S0_2SetA - Real S0_3b3 = -(Cib + ViE); //P0_1SetA //RiGetB //P0_2SetA - Real P0_3b3 = -P0_3Gamma1*(-S0_3b3); //S1_2SetA - Real S1_3b3 = -(P0_3b3); - //P1_3GetB - //P1_1SetA - //RkGetB - //P1_2SetA + //St1_2SetA //Call tube model - Vg = -(S1_3b3); - Real Vd = Vk+Vg; - Real Rd = (Vd < 0.) ? 100e+3 : 100e+6; - Vk = -(P1_3b3 - Vg * S1_3Gamma1 / Rd); - Real b = t.compute(S2_3b3, S2_3Gamma1, Vg, Vk); + Vg = -(Rda); + Vk = Pt_3b3; + Real b = t.compute(St2_3b3, St2_3Gamma1, Vg, Vk); //Set As - //S2_3SetA - Real S2_3b1 = P2_3b3 - S2_3Gamma1*(P2_3b3 - (Vk+Vg) + b); - //P2_3SetA - Real P2_3b1 = S2_3b1 + E500E - S3_3b3 - P2_3Gamma1*(E500E - S3_3b3); - //S3_3SetA - Real S3_3b1 = Cob - S3_3Gamma1*(Cob + P2_3b1); - Coa = S3_3b1; - Real S3_3b2 = Cob + P2_3b1 - S3_3Gamma1*(Cob + P2_3b1); - //RoSetA - Real Roa = S3_3b2; - Real S2_3b2 = P2_3b3 + b - S2_3Gamma1*(P2_3b3 - (Vk+Vg) + b); - //P1_3SetA - Real P1_3b1 = S2_3b2 - Ckb - P1_3Gamma1*(-Ckb); - Cka = P1_3b1; - //RkSetA + //St2_3SetA + Real St2_3b1 = Pt_3b3 - St2_3Gamma1*(Pt_3b3 + P2_3b3 + b); + //Pt_3SetA + Real Pt_3b1 = St2_3b1 + P1_3b3 - St1_3b3 - Pt_3Gamma1*(P1_3b3 - St1_3b3); + //St1_3SetA + Real St1_3b1 = -St1_3Gamma1*(S1_3b3 + Pt_3b1); + //RdSetA + Rda = St1_3b1; + Real St1_3b2 = Pt_3b1 - St1_3Gamma1*(S1_3b3 + Pt_3b1); //S1_3SetA //RgSetA - Real S1_3b2 = Vg - S1_3Gamma1*(P0_3b3 + Vg); + Real S1_3b2 = St1_3b2 - S1_3Gamma1*(P0_3b3 + St1_3b2); //P0_3SetA Real P0_3b1 = S1_3b2 - S0_3b3 - P0_3Gamma1*(-S0_3b3); //S0_3SetA Real S0_3b1 = Cib - S0_3Gamma1*(Cib + ViE + P0_3b1); Cia = S0_3b1; //RiSetA - //printf("Vk=%f Vg=%f Vd=%f in=%f out=%f\n", Vk,Vg,Vd, ViE,Roa); - return Roa; + Real Pt_3b2 = St2_3b1 - Pt_3Gamma1*(P1_3b3 - St1_3b3); + //P1_3SetA + Real P1_3b1 = Pt_3b2 - Ckb - P1_3Gamma1*(-Ckb); + Cka = P1_3b1; + //RkSetA + Real St2_3b2 = Pt_3b3 + b - St2_3Gamma1*(Pt_3b3 + P2_3b3 + b); + //P2_3SetA + Real P2_3b1 = St2_3b2 + E500E - S3_3b3 - P2_3Gamma1*(E500E - S3_3b3); + //S3_3SetA + Real S3_3b1 = -S3_3Gamma1*(Cob + P2_3b1); + //RoSetA + Real Roa = S3_3b1; + Real S3_3b2 = P2_3b1 - S3_3Gamma1*(Cob + P2_3b1); + Coa = S3_3b2; + //printf("Vk=%f Vg=%f Vp=%f in=%f out=%f\n", Vk,Vg,St2_3b3, ViE,Roa); + return -(Roa); } private: @@ -162,6 +205,7 @@ private: Real Coa; Real Cia; Real Cka; + Real Rda; Real Vk; Real Vg; @@ -176,6 +220,9 @@ private: Real S2_3Gamma1; Real P2_3Gamma1; Real E500E; + Real St1_3Gamma1; + Real St2_3Gamma1; + Real Pt_3Gamma1; }; #endif |