Skip to content

Commit

Permalink
Fix issue ra3xdh#905
Browse files Browse the repository at this point in the history
As reported in issue ra3xdh#905, the matching network tool gave wrong results when using a conditionally stable S-matrix. In order to have a conjugately match, the device is required to meet the unconditional stability criteria defined in [1] as K > 1 and abs(delta) < 1

A condition was added in the program to filter out these cases and warn the user against this limitation.

[1] Microwave Engineering. David M Pozar. 2012. Eqs 12.28 and 12.29
  • Loading branch information
andresmmera committed Aug 24, 2024
1 parent d5c36a1 commit 779cd56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
30 changes: 26 additions & 4 deletions qucs/dialogs/matchdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,32 @@ void MatchDialog::slotButtCreate() {
S12imag * S21imag;
double DetImag = S11real * S22imag + S11imag * S22real - S12real * S21imag -
S12imag * S21real;
success =
calc2PortMatch(S11real, S11imag, S22real, S22imag, DetReal, DetImag, Z1,
Z2, Freq, micro_syn, SP_block, open_short, Substrate,
order, gamma_MAX, BalancedStubs);

// Check unconditional stability. If the device is not unconditionally stable, it cannot be conjugately matched
std::complex<double> s11 (S11real, S11imag);
std::complex<double> s12 (S12real, S12imag);
std::complex<double> s21 (S21real, S21imag);
std::complex<double> s22 (S22real, S22imag);

double delta = abs(s11*s22 - s12*s21); // Determinant of the S matrix
double K = (1 - abs(s11)*abs(s11) - abs(s22)*abs(s22) + delta*delta) / (2*abs(s12*s21)); // Rollet factor.

if ((K > 1) && (delta < 1)){
// The device is unconditionally stable. It can be conjugately matched
success =
calc2PortMatch(S11real, S11imag, S22real, S22imag, DetReal, DetImag, Z1,
Z2, Freq, micro_syn, SP_block, open_short, Substrate,
order, gamma_MAX, BalancedStubs);
}else{
// The device is not unconditionally stable. Show a message and stop
success = false;
QMessageBox::critical(
0, tr("Error"),
tr("The device is not unconditionally stable:\n\nK = %1\n|%2| = %3\n\nIt is not possible to synthesize a matching network.\n\nConsider adding resistive losses and/or feedback to reach unconditional stability (K > 1 and |%2| < 1)")
.arg(QString::number(K, 'f', 2)).arg(QChar(0x0394)).arg(QString::number(delta, 'f', 2)));
}


} else {
success = calcMatchingCircuit(S11real, S11imag, Z1, Freq, micro_syn,
SP_block, open_short, Substrate, order,
Expand Down
2 changes: 2 additions & 0 deletions qucs/dialogs/matchdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <QDialog>
#include <cmath>

#include <complex>

class Element;
class QLabel;
class QLineEdit;
Expand Down

0 comments on commit 779cd56

Please sign in to comment.