Allow changing Z0 in through standard
This commit is contained in:
parent
ee16dbc070
commit
ec4828d4c4
@ -72,7 +72,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="SIUnitEdit" name="Z0">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -579,7 +579,13 @@ Sparam Through::toSparam(double freq)
|
||||
double through_att = pow(10.0, -through_att_db / 10.0);
|
||||
auto through = polar<double>(through_att, through_phaseshift);
|
||||
// Assume symmetric and perfectly matched through for other parameters
|
||||
return Sparam(0.0, through, through, 0.0);
|
||||
auto S = Sparam(0.0, through, through, 0.0);
|
||||
// update S parameters if Z0 does not match system impedance exactly
|
||||
if(Z0 != 50.0) {
|
||||
auto abcd = ABCDparam(S, Z0);
|
||||
S = Sparam(abcd, 50.0);
|
||||
}
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,7 @@ SOURCES += \
|
||||
../LibreVNA-GUI/touchstone.cpp \
|
||||
../LibreVNA-GUI/unit.cpp \
|
||||
main.cpp \
|
||||
parametertests.cpp \
|
||||
portextensiontests.cpp \
|
||||
utiltests.cpp
|
||||
|
||||
@ -339,6 +340,7 @@ HEADERS += \
|
||||
../LibreVNA-GUI/tcpserver.h \
|
||||
../LibreVNA-GUI/touchstone.h \
|
||||
../LibreVNA-GUI/unit.h \
|
||||
parametertests.h \
|
||||
portextensiontests.h \
|
||||
utiltests.h
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "utiltests.h"
|
||||
#include "portextensiontests.h"
|
||||
#include "parametertests.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
@ -10,6 +11,7 @@ int main(int argc, char *argv[])
|
||||
int status = 0;
|
||||
status |= QTest::qExec(new UtilTests, argc, argv);
|
||||
status |= QTest::qExec(new PortExtensionTests, argc, argv);
|
||||
status |= QTest::qExec(new ParameterTests, argc, argv);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
63
Software/PC_Application/LibreVNA-Test/parametertests.cpp
Normal file
63
Software/PC_Application/LibreVNA-Test/parametertests.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "parametertests.h"
|
||||
|
||||
#include "Tools/parameters.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
ParameterTests::ParameterTests()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ParameterTests::S2ABCD()
|
||||
{
|
||||
using namespace std::complex_literals;
|
||||
|
||||
std::complex<double> S11 = 0.0038 + 0.0248i;
|
||||
std::complex<double> S12 = 0.9961 - 0.0250i;
|
||||
std::complex<double> S21 = 0.9964 - 0.0254i;
|
||||
std::complex<double> S22 = 0.0037 + 0.0249i;
|
||||
auto S = Sparam(S11, S12, S21, S22);
|
||||
auto abcd = ABCDparam(S, 50.0);
|
||||
|
||||
std::complex<double> A = 0.99988705861501226 + 0.00014900771660107621i;
|
||||
std::complex<double> B = 0.31256891513454765 + 2.5194422425174801i;
|
||||
std::complex<double> C = -2.7673838933081734e-09 + 6.9983236736743502e-06i;
|
||||
std::complex<double> D = 0.99978420576400329 + 0.00024674711602337137i;
|
||||
|
||||
QVERIFY(qFuzzyCompare(abcd.m11.real(), A.real()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m11.imag(), A.imag()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m12.real(), B.real()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m12.imag(), B.imag()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m21.real(), C.real()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m21.imag(), C.imag()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m22.real(), D.real()));
|
||||
QVERIFY(qFuzzyCompare(abcd.m22.imag(), D.imag()));
|
||||
}
|
||||
|
||||
void ParameterTests::ABCD2S()
|
||||
{
|
||||
using namespace std::complex_literals;
|
||||
|
||||
std::complex<double> A = 0.99988705861501226 + 0.00014900771660107621i;
|
||||
std::complex<double> B = 0.31256891513454765 + 2.5194422425174801i;
|
||||
std::complex<double> C = -2.7673838933081734e-09 + 6.9983236736743502e-06i;
|
||||
std::complex<double> D = 0.99978420576400329 + 0.00024674711602337137i;
|
||||
auto abcd = ABCDparam(A, B, C, D);
|
||||
|
||||
auto s = Sparam(abcd, 50.0);
|
||||
|
||||
std::complex<double> S11 = 0.0038 + 0.0248i;
|
||||
std::complex<double> S12 = 0.9961 - 0.0250i;
|
||||
std::complex<double> S21 = 0.9964 - 0.0254i;
|
||||
std::complex<double> S22 = 0.0037 + 0.0249i;
|
||||
|
||||
QVERIFY(qFuzzyCompare(s.m11.real(), S11.real()));
|
||||
QVERIFY(qFuzzyCompare(s.m11.imag(), S11.imag()));
|
||||
QVERIFY(qFuzzyCompare(s.m12.real(), S12.real()));
|
||||
QVERIFY(qFuzzyCompare(s.m12.imag(), S12.imag()));
|
||||
QVERIFY(qFuzzyCompare(s.m21.real(), S21.real()));
|
||||
QVERIFY(qFuzzyCompare(s.m21.imag(), S21.imag()));
|
||||
QVERIFY(qFuzzyCompare(s.m22.real(), S22.real()));
|
||||
QVERIFY(qFuzzyCompare(s.m22.imag(), S22.imag()));
|
||||
}
|
17
Software/PC_Application/LibreVNA-Test/parametertests.h
Normal file
17
Software/PC_Application/LibreVNA-Test/parametertests.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef PARAMETERTESTS_H
|
||||
#define PARAMETERTESTS_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
class ParameterTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParameterTests();
|
||||
|
||||
private slots:
|
||||
void S2ABCD();
|
||||
void ABCD2S();
|
||||
};
|
||||
|
||||
#endif // PARAMETERTESTS_H
|
Loading…
Reference in New Issue
Block a user