Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions Libs/rt-wdf/rt-wdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ std::string wdfRootSimple::getType( ) const {
// P O R T
//==============================================================================
wdfPort::wdfPort( wdfTreeNode *connectedNode ) : Rp( 0 ),
Gp( 0 ),
a( 0 ),
b( 0 ),
connectedNode( connectedNode ) {
Expand Down Expand Up @@ -549,11 +548,12 @@ void wdfTerminatedLeaf::calculateScatterCoeffs( ) {
#pragma mark Terminated Capacitor
//==============================================================================
wdfTerminatedCap::wdfTerminatedCap( double C,
double sampleRate ) : wdfTerminatedLeaf( ),
double sampleRate,
double alpha) : wdfTerminatedLeaf( ),
C( C ),
sampleRate( sampleRate ),
alpha( alpha ),
prevA( 0 ) {

}

//----------------------------------------------------------------------
Expand All @@ -562,7 +562,8 @@ double wdfTerminatedCap::calculateUpRes( double sampleRate ) {
assert(C > 0 && "capacitance must be a nonzero positive number.");

this->sampleRate = sampleRate;
const double R = 1 / ( 2.0 * sampleRate * C );
const double R = 1 / ( (1.0 + alpha) * sampleRate * C );

return R;
}

Expand All @@ -584,9 +585,11 @@ std::string wdfTerminatedCap::getType( ) const {
#pragma mark Terminated Inductor
//==============================================================================
wdfTerminatedInd::wdfTerminatedInd( double L,
double sampleRate ) : wdfTerminatedLeaf( ),
double sampleRate,
double alpha ) : wdfTerminatedLeaf( ),
L( L ),
sampleRate( sampleRate ),
alpha( alpha ),
prevA( 0 ) {

}
Expand All @@ -597,7 +600,8 @@ double wdfTerminatedInd::calculateUpRes( double sampleRate ) {
assert(L > 0 && "inductance must be a nonzero positive number.");

this->sampleRate = sampleRate;
const double R = 2.0 * sampleRate * L ;
const double R = (1.0 + alpha) * sampleRate * L ;

return R;
}

Expand Down Expand Up @@ -761,8 +765,10 @@ std::string wdfUnterminatedSwitch::getType( ) const {
#pragma mark Unterminated Capacitor
//==============================================================================
wdfUnterminatedCap::wdfUnterminatedCap(double C,
double sampleRate ) : wdfRootNode(1),
double sampleRate,
double alpha ) : wdfRootNode(1),
sampleRate(sampleRate),
alpha(alpha),
prevA(0),
prevB(0),
C(C) {
Expand All @@ -787,14 +793,16 @@ std::string wdfUnterminatedCap::getType( ) const {

void wdfUnterminatedCap::setPortResistance( double Rp ) {
this->Rp = Rp;
reflectionCoeff = (Rp - 1 / (2 * sampleRate * C)) / (Rp + (1 / (2 * sampleRate * 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 sampleRate ) : wdfRootNode(1),
double sampleRate,
double alpha ) : wdfRootNode(1),
sampleRate(sampleRate),
alpha(alpha),
prevA(0),
prevB(0),
L(L) {
Expand All @@ -819,7 +827,7 @@ std::string wdfUnterminatedInd::getType( ) const {

void wdfUnterminatedInd::setPortResistance( double Rp ) {
this->Rp = Rp;
reflectionCoeff = (Rp - 2 * sampleRate * L) / (Rp + 2 * sampleRate * L);
reflectionCoeff = (Rp - (1.0 + alpha) * sampleRate * L) / (Rp + (1.0 + alpha) * sampleRate * L);
}


Expand Down Expand Up @@ -858,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;
}
Expand Down Expand Up @@ -897,5 +905,4 @@ std::string wdfIdealCSource::getType( ) const {
//----------------------------------------------------------------------
void wdfIdealCSource::setPortResistance( double Rp ) {
this->Rp = Rp;
}

}
74 changes: 50 additions & 24 deletions Libs/rt-wdf/rt-wdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,6 @@ class wdfPort {
*/
double Rp;

//----------------------------------------------------------------------
/**
The inverse WDF port resistance in Siemens
*/
double Gp;

//----------------------------------------------------------------------
/**
Incident wave (incoming wave)
Expand Down Expand Up @@ -1266,6 +1260,26 @@ class wdfTerminatedLeaf: public wdfTreeNode {
//==============================================================================
class wdfTerminatedCap : public wdfTerminatedLeaf {

protected:
//----------------------------------------------------------------------
/**
Capacitance in Farad
*/
double C;
/**
Sample rate in Hertz
*/
double sampleRate;
/**
Paramter for alpha transform
*/
double alpha;

/**
One sample delay element
*/
double prevA;

public:
//----------------------------------------------------------------------
/**
Expand All @@ -1275,9 +1289,12 @@ class wdfTerminatedCap : public wdfTerminatedLeaf {

@param C physical capacitance of the component in Farads
@param sampleRate sample rate in Hertz
@param alpha parameter in alpha transform, default = 1.0
(Bilinear transform)
*/
wdfTerminatedCap( double C,
double sampleRate );
double sampleRate,
double alpha = 1.0 );

//----------------------------------------------------------------------
/**
Expand Down Expand Up @@ -1327,20 +1344,6 @@ class wdfTerminatedCap : public wdfTerminatedLeaf {
*/
virtual std::string getType( ) const;

//----------------------------------------------------------------------
/**
Capacitance in Farad
*/
double C;
/**
Sample rate in Hertz
*/
double sampleRate;
/**
One sample delay element
*/
double prevA;

};

//==============================================================================
Expand All @@ -1355,9 +1358,12 @@ class wdfTerminatedInd : public wdfTerminatedLeaf {

@param L physical inductance of the component in Henry
@param sampleRate sample rate in Hertz
@param alpha parameter in alpha transform, default = 1.0
(Bilinear transform)
*/
wdfTerminatedInd( double L,
double sampleRate );
double sampleRate,
double alpha = 1.0 );

//----------------------------------------------------------------------
/**
Expand Down Expand Up @@ -1417,6 +1423,10 @@ class wdfTerminatedInd : public wdfTerminatedLeaf {
Sample rate in Hertz
*/
double sampleRate;
/**
Parameter in alpha-transform
*/
double alpha;
/**
One sample delay element
*/
Expand Down Expand Up @@ -1828,9 +1838,12 @@ class wdfUnterminatedCap : public wdfRootNode {

@param C physical capacitance of the component in Farads
@param sampleRate sample rate in Hertz
@param alpha parameter in alpha transform, default = 1.0
(Bilinear transform)
*/
wdfUnterminatedCap( double C,
double sampleRate );
double sampleRate,
double alpha = 1.0 );

//----------------------------------------------------------------------
/**
Expand Down Expand Up @@ -1880,6 +1893,11 @@ class wdfUnterminatedCap : public wdfRootNode {
*/
double C;

//----------------------------------------------------------------------
/**
Parameter in alpha-transform
*/
double alpha;
};

//==============================================================================
Expand Down Expand Up @@ -1916,9 +1934,12 @@ class wdfUnterminatedInd : public wdfRootNode {

@param L physical inductance of the component in Henry
@param sampleRate sample rate in Hertz
@param alpha parameter in alpha transform, default = 1.0
(Bilinear transform)
*/
wdfUnterminatedInd( double L,
double sampleRate );
double sampleRate,
double alpha = 1.0 );

//----------------------------------------------------------------------
/**
Expand Down Expand Up @@ -1965,6 +1986,11 @@ class wdfUnterminatedInd : public wdfRootNode {
Inductance in Henry
*/
double L;
//----------------------------------------------------------------------
/**
Parameter in alpha-transform
*/
double alpha;

};

Expand Down