Line data Source code
1 : /** 2 : * \file LeachTriodeFunction.h 3 : */ 4 : 5 : #ifndef ATK_PREAMPLIFIER_LEACHTRIODEFUNCTION_H 6 : #define ATK_PREAMPLIFIER_LEACHTRIODEFUNCTION_H 7 : 8 : #include <ATK/Utility/fmath.h> 9 : 10 : #include <cmath> 11 : 12 : namespace ATK 13 : { 14 : /// A simplified tube model, used with TriodeFilter 15 : template <typename DataType_> 16 : class LeachTriodeFunction 17 : { 18 : private: 19 : const DataType_ mu; 20 : const DataType_ K; 21 : const DataType_ Rgk; 22 : const DataType_ Vgamma; 23 : 24 : public: 25 : /// For non static models 26 : const DataType_ Cpg; 27 : 28 : /// Compute grid current 29 12670 : DataType_ Lb(DataType_ Vbe, DataType_ Vce) 30 : { 31 12670 : if(mu * Vbe + Vce > 0) 32 : { 33 9199 : return K * std::sqrt(mu * Vbe + Vce) * (mu * Vbe + Vce); 34 : } 35 3471 : return 0; 36 : } 37 : 38 : /// Compute grid current derivative relative to the grid cathode voltage 39 12670 : DataType_ Lb_Vbe(DataType_ Vbe, DataType_ Vce) 40 : { 41 12670 : if (mu * Vbe + Vce > 0) 42 : { 43 9199 : return K * mu * 1.5F * std::sqrt(mu * Vbe + Vce); 44 : } 45 3471 : return 0; 46 : } 47 : 48 : /// Compute grid current derivative relative to the plate cathode voltage 49 12670 : DataType_ Lb_Vce(DataType_ Vbe, DataType_ Vce) 50 : { 51 12670 : if (mu * Vbe + Vce > 0) 52 : { 53 9199 : return K * 1.5F * std::sqrt(mu * Vbe + Vce); 54 : } 55 3471 : return 0; 56 : } 57 : 58 : /// Compute plate current 59 12670 : DataType_ Lc(DataType_ Vbe, DataType_ Vce) 60 : { 61 12670 : return (Vbe - Vgamma) / Rgk; 62 : } 63 : 64 : /// Compute plate current derivative relative to the grid cathode voltage 65 12670 : DataType_ Lc_Vbe(DataType_ Vbe, DataType_ Vce) 66 : { 67 12670 : return 1 / Rgk; 68 : } 69 : 70 : /// Compute plate current derivative relative to the plate cathode voltage 71 12670 : DataType_ Lc_Vce(DataType_ Vbe, DataType_ Vce) 72 : { 73 12670 : return 0; 74 : } 75 : protected: 76 : /// Constructor 77 1 : LeachTriodeFunction(DataType_ mu, DataType_ K, DataType_ Rgk, DataType_ Vgamma, DataType_ Cpg) 78 1 : :mu(mu), K(K), Rgk(Rgk), Vgamma(Vgamma), Cpg(Cpg) 79 : { 80 1 : } 81 : public: 82 : /// Build a new triode function for a filter (12AX7/ECC83) 83 1 : static LeachTriodeFunction build_standard_function(DataType_ mu=88.5, DataType_ K=1.73e-6, DataType_ Rgk=20e3, DataType_ Vgamma=0.6, DataType_ Cpg=1.7e-12) 84 : { 85 1 : return LeachTriodeFunction(mu, K, Rgk, Vgamma, Cpg); 86 : } 87 : 88 : }; 89 : } 90 : 91 : #endif