Line data Source code
1 : /** 2 : * \file MunroPiazzaTriodeFunction.h 3 : * From http://www.duncanamps.com/spice/valves/dm12ax7s.inc 4 : */ 5 : 6 : #ifndef ATK_PREAMPLIFIER_MUNROPIAZZATRIODEFUNCTION_H 7 : #define ATK_PREAMPLIFIER_MUNROPIAZZATRIODEFUNCTION_H 8 : 9 : #include <ATK/Utility/fmath.h> 10 : 11 : #include <cmath> 12 : 13 : namespace ATK 14 : { 15 : /// Tube model, used with TriodeFilter from Munro and Piazza 16 : template <typename DataType_> 17 : class MunroPiazzaTriodeFunction 18 : { 19 : private: 20 : const DataType_ mu; 21 : const DataType_ K; 22 : const DataType_ Kp; 23 : const DataType_ Kvb; 24 : const DataType_ Kg; 25 : 26 : public: 27 : /// For non static models 28 : const DataType_ Cpg; 29 : 30 : /// Compute grid current 31 12558 : DataType_ Lb(DataType_ Vbe, DataType_ Vce) 32 : { 33 12558 : if(mu + Vbe > 0) 34 : { 35 7542 : return K * std::sqrt(mu + Vbe) * (mu + Vbe); 36 : } 37 5016 : return 0; 38 : } 39 : 40 : /// Compute grid current derivative relative to the grid cathode voltage 41 12558 : DataType_ Lb_Vbe(DataType_ Vbe, DataType_ Vce) 42 : { 43 12558 : if(mu + Vbe > 0) 44 : { 45 7542 : return K * 1.5F * std::sqrt(mu + Vbe); 46 : } 47 5016 : return 0; 48 : } 49 : 50 : /// Compute grid current derivative relative to the plate cathode voltage 51 12558 : DataType_ Lb_Vce(DataType_ Vbe, DataType_ Vce) 52 : { 53 12558 : return 0; 54 : } 55 : 56 : /// Compute plate current 57 12558 : DataType_ Lc(DataType_ Vbe, DataType_ Vce) 58 : { 59 12558 : auto E1 = Kp + Vce + Kg * Vbe; 60 12558 : if (E1 > 0 && Vbe >= 0 && Vbe <= 5) 61 : { 62 7298 : return Vce / 5 * Kvb * std::sqrt(E1) * E1; 63 : } 64 5260 : return 0; 65 : } 66 : 67 : /// Compute plate current derivative relative to the grid cathode voltage 68 12558 : DataType_ Lc_Vbe(DataType_ Vbe, DataType_ Vce) 69 : { 70 12558 : auto E1 = Kp + Vce + Kg * Vbe; 71 12558 : if (E1 > 0 && Vbe >= 0 && Vbe <= 5) 72 : { 73 7298 : return Kg * Vce / 5 * Kvb * std::sqrt(E1) * 1.5F; 74 : } 75 5260 : return 0; 76 : } 77 : 78 : /// Compute plate current derivative relative to the plate cathode voltage 79 12558 : DataType_ Lc_Vce(DataType_ Vbe, DataType_ Vce) 80 : { 81 12558 : auto E1 = Kp + Vce + Kg * Vbe; 82 12558 : if (E1 > 0 && Vbe >= 0 && Vbe <= 5) 83 : { 84 7298 : return Kvb * std::sqrt(E1) * E1 / 5 + Vce / 5 * Kvb * std::sqrt(E1) * 1.5F; 85 : } 86 5260 : return 0; 87 : } 88 : 89 : /// Constructor 90 1 : MunroPiazzaTriodeFunction(DataType_ mu, DataType_ K, DataType_ Kp, DataType_ Kvb, DataType_ Kg, DataType_ Cpg) 91 1 : :mu(mu), K(K), Kp(Kp), Kvb(Kvb), Kg(Kg), Cpg(Cpg) 92 : { 93 1 : } 94 : 95 : /// Build a new triode function for a filter (12AX7/ECC83) 96 1 : static MunroPiazzaTriodeFunction build_standard_function(DataType_ mu = 0.2, DataType_ K = 5e-6, DataType_ Kp = 45, DataType_ Kvb = 1.147e-6, DataType_ Kg = 95.43, DataType_ Cpg = 1.7e-12) 97 : { 98 1 : return MunroPiazzaTriodeFunction(mu, K, Kp, Kvb, Kg, Cpg); 99 : } 100 : 101 : }; 102 : } 103 : 104 : #endif