From 550ea95af97e8f8421e7b5bf915a07293fca46e3 Mon Sep 17 00:00:00 2001 From: Olafur Bogason Date: Sun, 26 Nov 2017 17:16:13 +0000 Subject: [PATCH 1/4] Added alpha transform parameter such that numerical scheme can be chosen easilly. --- Libs/rt-wdf/rt-wdf.cpp | 25 ++++++++++++++++--------- Libs/rt-wdf/rt-wdf.h | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Libs/rt-wdf/rt-wdf.cpp b/Libs/rt-wdf/rt-wdf.cpp index a63375b..1c3a329 100644 --- a/Libs/rt-wdf/rt-wdf.cpp +++ b/Libs/rt-wdf/rt-wdf.cpp @@ -548,17 +548,18 @@ void wdfTerminatedLeaf::calculateScatterCoeffs( ) { #pragma mark Terminated Capacitor //============================================================================== wdfTerminatedCap::wdfTerminatedCap( double C, - double T ) : wdfTerminatedLeaf( ), + double T, + double alpha = 1 ) : wdfTerminatedLeaf( ), C( C ), T( T ), + alpha( alpha ), prevA( 0 ) { - } //---------------------------------------------------------------------- double wdfTerminatedCap::calculateUpRes( double T ) { this->T = T; - const double R = T / ( 2.0 * C ); + const double R = T / ( (1.0 + alpha) * C ); return R; } @@ -580,9 +581,11 @@ std::string wdfTerminatedCap::getType( ) const { #pragma mark Terminated Inductor //============================================================================== wdfTerminatedInd::wdfTerminatedInd( double L, - double T ) : wdfTerminatedLeaf( ), + double T, + double alpha = 1.0 ) : wdfTerminatedLeaf( ), L( L ), T( T ), + alpha( alpha ), prevA( 0 ) { } @@ -590,7 +593,7 @@ wdfTerminatedInd::wdfTerminatedInd( double L, //---------------------------------------------------------------------- double wdfTerminatedInd::calculateUpRes( double T ) { this->T = T; - const double R = ( 2.0 * L ) / T; + const double R = ( (1 + alpha) * L ) / T; return R; } @@ -754,8 +757,10 @@ std::string wdfUnterminatedSwitch::getType( ) const { #pragma mark Unterminated Capacitor //============================================================================== wdfUnterminatedCap::wdfUnterminatedCap(double C, - double T ) : wdfRootNode(1), + double T, + double alpha = 1.0 ) : wdfRootNode(1), T(T), + alpha(alpha), prevA(0), prevB(0), C(C) { @@ -780,14 +785,16 @@ std::string wdfUnterminatedCap::getType( ) const { void wdfUnterminatedCap::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - T / (2 * C)) / (Rp + (T / (2 * C))); + reflectionCoeff = (Rp - T / ((1 + alpha) * C)) / (Rp + (T / ((1 + alpha) * C))); } #pragma mark Unterminated Inductor //============================================================================== wdfUnterminatedInd::wdfUnterminatedInd( double L, - double T ) : wdfRootNode(1), + double T, + double alpha ) : wdfRootNode(1), T(T), + alpha(alpha), prevA(0), prevB(0), L(L) { @@ -812,7 +819,7 @@ std::string wdfUnterminatedInd::getType( ) const { void wdfUnterminatedInd::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - 2 * L/T) / (Rp + 2 * L/T); + reflectionCoeff = (Rp - (1 + alpha) * L/T) / (Rp + (1 + alpha) * L/T); } diff --git a/Libs/rt-wdf/rt-wdf.h b/Libs/rt-wdf/rt-wdf.h index d1fcab3..e880165 100644 --- a/Libs/rt-wdf/rt-wdf.h +++ b/Libs/rt-wdf/rt-wdf.h @@ -1281,9 +1281,12 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { @param C physical capacitance of the component in Farads @param T sample period T = 1/fs in seconds + @param alpha parameter in alpha transform, default = 1.0 + (Bilinear transform) */ wdfTerminatedCap( double C, - double T ); + double T, + double alpha); //---------------------------------------------------------------------- /** @@ -1342,6 +1345,11 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { Sample period in seconds */ double T; + /** + Paramter for alpha transform + */ + double alpha; + /** One sample delay element */ @@ -1361,9 +1369,12 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { @param L physical inductance of the component in Henry @param T sample period T = 1/fs in seconds + @param alpha parameter in alpha transform, default = 1.0 + (Bilinear transform) */ wdfTerminatedInd( double L, - double T ); + double T, + double alpha ); //---------------------------------------------------------------------- /** @@ -1423,6 +1434,10 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { Sample period in seconds */ double T; + /** + Parameter in alpha-transform + */ + double alpha; /** One sample delay element */ @@ -1834,9 +1849,12 @@ class wdfUnterminatedCap : public wdfRootNode { @param C physical capacitance of the component in Farads @param T sample period T = 1/fs in seconds + @param alpha parameter in alpha transform, default = 1.0 + (Bilinear transform) */ wdfUnterminatedCap( double C, - double T ); + double T, + double alpha ); //---------------------------------------------------------------------- /** @@ -1886,6 +1904,11 @@ class wdfUnterminatedCap : public wdfRootNode { */ double C; + //---------------------------------------------------------------------- + /** + Parameter in alpha-transform + */ + double alpha; }; //============================================================================== @@ -1922,9 +1945,12 @@ class wdfUnterminatedInd : public wdfRootNode { @param L physical inductance of the component in Henry @param T sample period T = 1/fs in seconds + @param alpha parameter in alpha transform, default = 1.0 + (Bilinear transform) */ wdfUnterminatedInd( double L, - double T ); + double T, + double alpha ); //---------------------------------------------------------------------- /** @@ -1971,6 +1997,11 @@ class wdfUnterminatedInd : public wdfRootNode { Inductance in Henry */ double L; + //---------------------------------------------------------------------- + /** + Parameter in alpha-transform + */ + double alpha; }; From 4760ec5eead85d63353d91c2cccdec587eb229f3 Mon Sep 17 00:00:00 2001 From: Olafur Bogason Date: Sun, 26 Nov 2017 18:03:48 +0000 Subject: [PATCH 2/4] Moved default values from definition to declaration. Otherwise the compiler will exit with an error at compile time. --- Libs/rt-wdf/rt-wdf.cpp | 12 ++++++------ Libs/rt-wdf/rt-wdf.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Libs/rt-wdf/rt-wdf.cpp b/Libs/rt-wdf/rt-wdf.cpp index 1c3a329..ccdb3e2 100644 --- a/Libs/rt-wdf/rt-wdf.cpp +++ b/Libs/rt-wdf/rt-wdf.cpp @@ -549,7 +549,7 @@ void wdfTerminatedLeaf::calculateScatterCoeffs( ) { //============================================================================== wdfTerminatedCap::wdfTerminatedCap( double C, double T, - double alpha = 1 ) : wdfTerminatedLeaf( ), + double alpha) : wdfTerminatedLeaf( ), C( C ), T( T ), alpha( alpha ), @@ -582,7 +582,7 @@ std::string wdfTerminatedCap::getType( ) const { //============================================================================== wdfTerminatedInd::wdfTerminatedInd( double L, double T, - double alpha = 1.0 ) : wdfTerminatedLeaf( ), + double alpha ) : wdfTerminatedLeaf( ), L( L ), T( T ), alpha( alpha ), @@ -593,7 +593,7 @@ wdfTerminatedInd::wdfTerminatedInd( double L, //---------------------------------------------------------------------- double wdfTerminatedInd::calculateUpRes( double T ) { this->T = T; - const double R = ( (1 + alpha) * L ) / T; + const double R = ( (1.0 + alpha) * L ) / T; return R; } @@ -758,7 +758,7 @@ std::string wdfUnterminatedSwitch::getType( ) const { //============================================================================== wdfUnterminatedCap::wdfUnterminatedCap(double C, double T, - double alpha = 1.0 ) : wdfRootNode(1), + double alpha ) : wdfRootNode(1), T(T), alpha(alpha), prevA(0), @@ -785,7 +785,7 @@ std::string wdfUnterminatedCap::getType( ) const { void wdfUnterminatedCap::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - T / ((1 + alpha) * C)) / (Rp + (T / ((1 + alpha) * C))); + reflectionCoeff = (Rp - T / ((1.0 + alpha) * C)) / (Rp + (T / ((1.0 + alpha) * C))); } #pragma mark Unterminated Inductor @@ -819,7 +819,7 @@ std::string wdfUnterminatedInd::getType( ) const { void wdfUnterminatedInd::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - (1 + alpha) * L/T) / (Rp + (1 + alpha) * L/T); + reflectionCoeff = (Rp - (1.0 + alpha) * L/T) / (Rp + (1.0 + alpha) * L/T); } diff --git a/Libs/rt-wdf/rt-wdf.h b/Libs/rt-wdf/rt-wdf.h index e880165..bd485e7 100644 --- a/Libs/rt-wdf/rt-wdf.h +++ b/Libs/rt-wdf/rt-wdf.h @@ -1286,7 +1286,7 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { */ wdfTerminatedCap( double C, double T, - double alpha); + double alpha = 1.0 ); //---------------------------------------------------------------------- /** @@ -1374,7 +1374,7 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { */ wdfTerminatedInd( double L, double T, - double alpha ); + double alpha = 1.0 ); //---------------------------------------------------------------------- /** @@ -1854,7 +1854,7 @@ class wdfUnterminatedCap : public wdfRootNode { */ wdfUnterminatedCap( double C, double T, - double alpha ); + double alpha = 1.0 ); //---------------------------------------------------------------------- /** @@ -1950,7 +1950,7 @@ class wdfUnterminatedInd : public wdfRootNode { */ wdfUnterminatedInd( double L, double T, - double alpha ); + double alpha = 1.0 ); //---------------------------------------------------------------------- /** From acb7e0fd355edd7fcc966a646b836b62ed3eaa85 Mon Sep 17 00:00:00 2001 From: Olafur Bogason Date: Sun, 26 Nov 2017 18:22:02 +0000 Subject: [PATCH 3/4] Removed Gp parameter from wdfPort as it is redundant and not used anywhere --- Libs/rt-wdf/rt-wdf.cpp | 1 - Libs/rt-wdf/rt-wdf.h | 45 +++++++++++++++++++----------------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Libs/rt-wdf/rt-wdf.cpp b/Libs/rt-wdf/rt-wdf.cpp index ccdb3e2..52d0f46 100644 --- a/Libs/rt-wdf/rt-wdf.cpp +++ b/Libs/rt-wdf/rt-wdf.cpp @@ -231,7 +231,6 @@ std::string wdfRootSimple::getType( ) const { // P O R T //============================================================================== wdfPort::wdfPort( wdfTreeNode *connectedNode ) : Rp( 0 ), - Gp( 0 ), a( 0 ), b( 0 ), connectedNode( connectedNode ) { diff --git a/Libs/rt-wdf/rt-wdf.h b/Libs/rt-wdf/rt-wdf.h index bd485e7..e2c2f1b 100644 --- a/Libs/rt-wdf/rt-wdf.h +++ b/Libs/rt-wdf/rt-wdf.h @@ -625,12 +625,6 @@ class wdfPort { */ double Rp; - //---------------------------------------------------------------------- - /** - The inverse WDF port resistance in Siemens - */ - double Gp; - //---------------------------------------------------------------------- /** Incident wave (incoming wave) @@ -1272,6 +1266,26 @@ class wdfTerminatedLeaf: public wdfTreeNode { //============================================================================== class wdfTerminatedCap : public wdfTerminatedLeaf { +protected: + //---------------------------------------------------------------------- + /** + Capacitance in Farad + */ + double C; + /** + Sample period in seconds + */ + double T; + /** + Paramter for alpha transform + */ + double alpha; + + /** + One sample delay element + */ + double prevA; + public: //---------------------------------------------------------------------- /** @@ -1336,25 +1350,6 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { */ virtual std::string getType( ) const; - //---------------------------------------------------------------------- - /** - Capacitance in Farad - */ - double C; - /** - Sample period in seconds - */ - double T; - /** - Paramter for alpha transform - */ - double alpha; - - /** - One sample delay element - */ - double prevA; - }; //============================================================================== From e04a15ff6d8259f83c844d878e2a822fec096a0b Mon Sep 17 00:00:00 2001 From: Olafur Bogason Date: Tue, 5 Dec 2017 10:25:33 +0000 Subject: [PATCH 4/4] Resolved conflicts with rt-wdf_lib master branch --- Libs/rt-wdf/rt-wdf.cpp | 80 ++++++++++++++++++++----------------- Libs/rt-wdf/rt-wdf.h | 90 ++++++++++++++++++++---------------------- 2 files changed, 86 insertions(+), 84 deletions(-) diff --git a/Libs/rt-wdf/rt-wdf.cpp b/Libs/rt-wdf/rt-wdf.cpp index 52d0f46..412135a 100644 --- a/Libs/rt-wdf/rt-wdf.cpp +++ b/Libs/rt-wdf/rt-wdf.cpp @@ -28,8 +28,7 @@ //============================================================================== #include "rt-wdf.h" - - +#include #pragma mark - Tree //============================================================================== @@ -40,7 +39,6 @@ wdfTree::wdfTree( ) { ascendingWaves.reset(); descendingWaves.reset(); treeSampleRate = 1; - T = 1; } wdfTree::~wdfTree( ) { @@ -75,7 +73,6 @@ void wdfTree::initTree( ) { //---------------------------------------------------------------------- void wdfTree::setSamplerate( double fs ) { treeSampleRate = fs; - T = 1.0f / treeSampleRate; } //---------------------------------------------------------------------- @@ -86,7 +83,7 @@ double wdfTree::getSamplerate( ) { //---------------------------------------------------------------------- int wdfTree::adaptTree( ) { for( unsigned int i = 0; i < subtreeCount; i++ ) { - subtreeEntryNodes[i]->adaptPorts( T ); + subtreeEntryNodes[i]->adaptPorts( treeSampleRate ); Rp[i] = subtreeEntryNodes[i]->upPort->Rp; subtreeEntryNodes[i]->calculateScatterCoeffs( ); } @@ -290,12 +287,12 @@ void wdfTreeNode::createPorts( ) { } //---------------------------------------------------------------------- -double wdfTreeNode::adaptPorts( double T ) { +double wdfTreeNode::adaptPorts( double sampleRate ) { for( wdfPort* downPort : downPorts ) { - downPort->Rp = downPort->connectedNode->adaptPorts( T ); + downPort->Rp = downPort->connectedNode->adaptPorts( sampleRate ); } - upPort->Rp = calculateUpRes( T ); + upPort->Rp = calculateUpRes( sampleRate ); return upPort->Rp; } @@ -345,7 +342,7 @@ wdfTerminatedRtype::~wdfTerminatedRtype( ) { // IMPLEMET THESE METHODS IN THE CIRCUIT TREE // //---------------------------------------------------------------------- -// double wdfTerminatedRtype::calculateUpRes( double T ) +// double wdfTerminatedRtype::calculateUpRes( double sampleRate ) // { // const double Rup = YOUR CODE HERE // return ( Rup ); @@ -410,7 +407,7 @@ wdfTerminatedSeries::wdfTerminatedSeries( wdfTreeNode *left, } //---------------------------------------------------------------------- -double wdfTerminatedSeries::calculateUpRes( double T ) { +double wdfTerminatedSeries::calculateUpRes( double sampleRate ) { const double Rleft = downPorts[0]->Rp; const double Rright = downPorts[1]->Rp; const double Rser = Rleft + Rright; @@ -461,11 +458,15 @@ wdfTerminatedParallel::wdfTerminatedParallel( wdfTreeNode *left, } //---------------------------------------------------------------------- -double wdfTerminatedParallel::calculateUpRes( double T ) { +double wdfTerminatedParallel::calculateUpRes( double sampleRate ) { const double Rleft = downPorts[0]->Rp; const double Rright = downPorts[1]->Rp; + + assert(Rleft > 0 && "Port resistance must be a nonzero positive number."); + assert(Rright > 0 && "Port resistance must be a nonzero positive number."); + const double Rpar = ( Rleft * Rright ) / ( Rleft + Rright ); - return ( Rpar ); + return Rpar; } //---------------------------------------------------------------------- @@ -505,7 +506,7 @@ wdfInverter::wdfInverter( wdfTreeNode *child ) : wdfTerminatedAdapter( { child } //---------------------------------------------------------------------- -double wdfInverter::calculateUpRes( double T ) { +double wdfInverter::calculateUpRes( double sampleRate ) { return downPorts[0]->Rp; } @@ -547,18 +548,22 @@ void wdfTerminatedLeaf::calculateScatterCoeffs( ) { #pragma mark Terminated Capacitor //============================================================================== wdfTerminatedCap::wdfTerminatedCap( double C, - double T, + double sampleRate, double alpha) : wdfTerminatedLeaf( ), C( C ), - T( T ), + sampleRate( sampleRate ), alpha( alpha ), prevA( 0 ) { } //---------------------------------------------------------------------- -double wdfTerminatedCap::calculateUpRes( double T ) { - this->T = T; - const double R = T / ( (1.0 + alpha) * C ); +double wdfTerminatedCap::calculateUpRes( double sampleRate ) { + assert(sampleRate > 0 && "sampleRate must be a nonzero positive number."); + assert(C > 0 && "capacitance must be a nonzero positive number."); + + this->sampleRate = sampleRate; + const double R = 1 / ( (1.0 + alpha) * sampleRate * C ); + return R; } @@ -580,19 +585,23 @@ std::string wdfTerminatedCap::getType( ) const { #pragma mark Terminated Inductor //============================================================================== wdfTerminatedInd::wdfTerminatedInd( double L, - double T, + double sampleRate, double alpha ) : wdfTerminatedLeaf( ), L( L ), - T( T ), + sampleRate( sampleRate ), alpha( alpha ), prevA( 0 ) { } //---------------------------------------------------------------------- -double wdfTerminatedInd::calculateUpRes( double T ) { - this->T = T; - const double R = ( (1.0 + alpha) * L ) / T; +double wdfTerminatedInd::calculateUpRes( double sampleRate ) { + assert(sampleRate > 0 && "sampleRate must be a nonzero positive number."); + assert(L > 0 && "inductance must be a nonzero positive number."); + + this->sampleRate = sampleRate; + const double R = (1.0 + alpha) * sampleRate * L ; + return R; } @@ -619,7 +628,7 @@ wdfTerminatedRes::wdfTerminatedRes( double R ) : wdfTerminatedLeaf( ), } //---------------------------------------------------------------------- -double wdfTerminatedRes::calculateUpRes( double T ) { +double wdfTerminatedRes::calculateUpRes( double sampleRate ) { return R; } @@ -648,7 +657,7 @@ wdfTerminatedResVSource::wdfTerminatedResVSource( double Vs, } //---------------------------------------------------------------------- -double wdfTerminatedResVSource::calculateUpRes( double T ) { +double wdfTerminatedResVSource::calculateUpRes( double sampleRate ) { return RSer; } @@ -677,7 +686,7 @@ wdfTerminatedResCSource::wdfTerminatedResCSource( double Is, } //---------------------------------------------------------------------- -double wdfTerminatedResCSource::calculateUpRes( double T ) { +double wdfTerminatedResCSource::calculateUpRes( double sampleRate ) { return RPar; } @@ -756,9 +765,9 @@ std::string wdfUnterminatedSwitch::getType( ) const { #pragma mark Unterminated Capacitor //============================================================================== wdfUnterminatedCap::wdfUnterminatedCap(double C, - double T, + double sampleRate, double alpha ) : wdfRootNode(1), - T(T), + sampleRate(sampleRate), alpha(alpha), prevA(0), prevB(0), @@ -784,15 +793,15 @@ std::string wdfUnterminatedCap::getType( ) const { void wdfUnterminatedCap::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - T / ((1.0 + alpha) * C)) / (Rp + (T / ((1.0 + alpha) * C))); + reflectionCoeff = (Rp - 1 / ((1.0 + alpha) * sampleRate * C)) / (Rp + (1 / ((1.0 + alpha) * sampleRate * C))); } #pragma mark Unterminated Inductor //============================================================================== wdfUnterminatedInd::wdfUnterminatedInd( double L, - double T, + double sampleRate, double alpha ) : wdfRootNode(1), - T(T), + sampleRate(sampleRate), alpha(alpha), prevA(0), prevB(0), @@ -818,7 +827,7 @@ std::string wdfUnterminatedInd::getType( ) const { void wdfUnterminatedInd::setPortResistance( double Rp ) { this->Rp = Rp; - reflectionCoeff = (Rp - (1.0 + alpha) * L/T) / (Rp + (1.0 + alpha) * L/T); + reflectionCoeff = (Rp - (1.0 + alpha) * sampleRate * L) / (Rp + (1.0 + alpha) * sampleRate * L); } @@ -857,8 +866,8 @@ wdfIdealVSource::wdfIdealVSource( double Vs ) : wdfRootNode(1), //---------------------------------------------------------------------- void wdfIdealVSource::calculateDownB( vec* ascendingWaves, - vec* descendingWaves, - size_t* portIndex) { + vec* descendingWaves, + size_t* portIndex) { descendingWaves->at(*portIndex) = 2 * Vs - ascendingWaves->at(*portIndex); (*portIndex) += numPorts; } @@ -896,5 +905,4 @@ std::string wdfIdealCSource::getType( ) const { //---------------------------------------------------------------------- void wdfIdealCSource::setPortResistance( double Rp ) { this->Rp = Rp; -} - +} \ No newline at end of file diff --git a/Libs/rt-wdf/rt-wdf.h b/Libs/rt-wdf/rt-wdf.h index e2c2f1b..4eb6048 100644 --- a/Libs/rt-wdf/rt-wdf.h +++ b/Libs/rt-wdf/rt-wdf.h @@ -137,12 +137,6 @@ class wdfTree { */ double treeSampleRate; - //---------------------------------------------------------------------- - /** - Inverse of treeSampleRate - */ - double T; - //---------------------------------------------------------------------- /** Number of subtrees @@ -196,8 +190,8 @@ class wdfTree { /** High level function to adapt all ports in subtrees. - Recursively adapts all subtrees towards the root according to sample - period T. Updates root matrix data afterwards if applicable to take + Recursively adapts all subtrees towards the root according to sampleRate. + Updates root matrix data afterwards if applicable to take new port resistances into account. */ int adaptTree( ); @@ -723,11 +717,11 @@ class wdfTreeNode { and/or adaptation rules and copies it onto connected downfacing ports in the parent. - @param T sample period as specified by setSamplerate() + @param sampleRate sample rate as specified by setSamplerate() @returns a double type up-facing port resistance of that WDF element */ - double adaptPorts( double T ); + double adaptPorts( double sampleRate ); //---------------------------------------------------------------------- /** @@ -738,12 +732,12 @@ class wdfTreeNode { port resistance of a tree node to fulfill adaptation according to the respective adaptation law of this node. - @param T sample period T = 1/fs as needed to adapt + @param sampleRate sample rate as needed to adapt capacitors/inductors @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ) = 0; + virtual double calculateUpRes( double sampleRate ) = 0; //---------------------------------------------------------------------- /** @@ -909,12 +903,12 @@ class wdfTerminatedRtype: public wdfTerminatedAdapter { Must be implemented in the user-defined subclass of wdfTerminatedRtype in the WDF application tree. - @param T sample period T = 1/fs as needed to adapt + @param sampleRate sample rate as needed to adapt capacitors/inductors @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ) = 0; + virtual double calculateUpRes( double sampleRate ) = 0; //---------------------------------------------------------------------- /** @@ -1016,12 +1010,12 @@ class wdfTerminatedSeries : public wdfTerminatedAdapter { port resistance of the node to fulfill termination according to the series adaptation law Rup = Rleft + Rright. - @param T sample period T = 1/fs as needed to adapt + @param sampleRate sample rate as needed to adapt capacitors/inductors @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1109,12 +1103,12 @@ class wdfTerminatedParallel : public wdfTerminatedAdapter { port resistance of the node to fulfill termination according to the series adaptation law Gup = Gleft + Gright. - @param T sample period T = 1/fs as needed to adapt + @param sampleRate sample rate as needed to adapt capacitors/inductors @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1184,12 +1178,12 @@ class wdfInverter : public wdfTerminatedAdapter { port resistance of the node to fulfill termination according to the inverters adaptation law Rup = Rchild. - @param T sample period T = 1/fs as needed to adapt + @param sampleRate sample rate as needed to adapt capacitors/inductors @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1273,9 +1267,9 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { */ double C; /** - Sample period in seconds + Sample rate in Hertz */ - double T; + double sampleRate; /** Paramter for alpha transform */ @@ -1294,12 +1288,12 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { Creates a capacitor with capacitance C. @param C physical capacitance of the component in Farads - @param T sample period T = 1/fs in seconds + @param sampleRate sample rate in Hertz @param alpha parameter in alpha transform, default = 1.0 (Bilinear transform) */ wdfTerminatedCap( double C, - double T, + double sampleRate, double alpha = 1.0 ); //---------------------------------------------------------------------- @@ -1308,14 +1302,14 @@ class wdfTerminatedCap : public wdfTerminatedLeaf { This function is called from adaptPorts(). It returns the upfacing port resistance of the node to fulfill termination according to - the capacitors adaptation law Rup = T / ( 2.0 * C ). + the capacitors adaptation law Rup = 1 / ( 2.0 * sampleRate * C ). - @param T sample period T = 1/fs in seconds as needed to + @param sampleRate sample rate in Hertz as needed to adapt the capacitor @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1363,12 +1357,12 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { Creates an inductor with inductance L. @param L physical inductance of the component in Henry - @param T sample period T = 1/fs in seconds + @param sampleRate sample rate in Hertz @param alpha parameter in alpha transform, default = 1.0 (Bilinear transform) */ wdfTerminatedInd( double L, - double T, + double sampleRate, double alpha = 1.0 ); //---------------------------------------------------------------------- @@ -1377,14 +1371,14 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { This function is called from adaptPorts(). It returns the upfacing port resistance of the node to fulfill termination according to - the inverters adaptation law Rup = R = ( 2.0 * L ) / T. + the inverters adaptation law Rup = R = 2.0 * sampleRate L. - @param T sample period T = 1/fs in seconds as needed to + @param sampleRate sample rate in Hertz as needed to adapt the capacitor @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1426,9 +1420,9 @@ class wdfTerminatedInd : public wdfTerminatedLeaf { */ double L; /** - Sample period in seconds + Sample rate in Hertz */ - double T; + double sampleRate; /** Parameter in alpha-transform */ @@ -1462,12 +1456,12 @@ class wdfTerminatedRes : public wdfTerminatedLeaf { port resistance of the node to fulfill termination according to the resistors adaptation law Rup = R. - @param T sample period T = 1/fs in seconds as needed to + @param sampleRate sample rate in Hertz as needed to adapt the capacitor @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1534,12 +1528,12 @@ class wdfTerminatedResVSource : public wdfTerminatedLeaf { port resistance of the node to fulfill termination according to the adaptation law Rup = Rser. - @param T sample period T = 1/fs in seconds as needed to + @param sampleRate sample rate in Hertz as needed to adapt the capacitor @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1611,12 +1605,12 @@ class wdfTerminatedResCSource : public wdfTerminatedLeaf port resistance of the node to fulfill termination according to the adaptation law Rup = Rpar. - @param T sample period T = 1/fs in seconds as needed to + @param sampleRate sample rate in Hertz as needed to adapt the element @returns a double type port resistance of that element in Ohms */ - virtual double calculateUpRes( double T ); + virtual double calculateUpRes( double sampleRate ); //---------------------------------------------------------------------- /** @@ -1816,9 +1810,9 @@ class wdfUnterminatedCap : public wdfRootNode { protected: //---------------------------------------------------------------------- /** - Sample period in seconds + Sample rate in Hertz */ - double T; + double sampleRate; /** Place to store the previous incident wave component. */ @@ -1843,12 +1837,12 @@ class wdfUnterminatedCap : public wdfRootNode { Creates an unadapted capacitor with capacitance C. @param C physical capacitance of the component in Farads - @param T sample period T = 1/fs in seconds + @param sampleRate sample rate in Hertz @param alpha parameter in alpha transform, default = 1.0 (Bilinear transform) */ wdfUnterminatedCap( double C, - double T, + double sampleRate, double alpha = 1.0 ); //---------------------------------------------------------------------- @@ -1912,9 +1906,9 @@ class wdfUnterminatedInd : public wdfRootNode { protected: //---------------------------------------------------------------------- /** - Sample period in seconds + Sample rate in Hertz */ - double T; + double sampleRate; /** Place to store the previous incident wave component. */ @@ -1939,12 +1933,12 @@ class wdfUnterminatedInd : public wdfRootNode { Creates an unadapted inductor with capacitance L. @param L physical inductance of the component in Henry - @param T sample period T = 1/fs in seconds + @param sampleRate sample rate in Hertz @param alpha parameter in alpha transform, default = 1.0 (Bilinear transform) */ wdfUnterminatedInd( double L, - double T, + double sampleRate, double alpha = 1.0 ); //----------------------------------------------------------------------