Add loss to load standard

This commit is contained in:
Jan Käberich 2022-10-01 02:31:53 +02:00
parent d2f1ca8f95
commit 858e945373
7 changed files with 34 additions and 13 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>349</width> <width>344</width>
<height>355</height> <height>386</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -99,23 +99,33 @@
<widget class="SIUnitEdit" name="delay"/> <widget class="SIUnitEdit" name="delay"/>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset loss [GΩ/s]: </string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="SIUnitEdit" name="loss"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_18"> <widget class="QLabel" name="label_18">
<property name="text"> <property name="text">
<string>Parallel C:</string> <string>Parallel C:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="SIUnitEdit" name="parC"/> <widget class="SIUnitEdit" name="parC"/>
</item> </item>
<item row="4" column="0"> <item row="5" column="0">
<widget class="QLabel" name="label_26"> <widget class="QLabel" name="label_26">
<property name="text"> <property name="text">
<string>Series L:</string> <string>Series L:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="5" column="1">
<widget class="SIUnitEdit" name="serL"/> <widget class="SIUnitEdit" name="serL"/>
</item> </item>
</layout> </layout>
@ -238,7 +248,7 @@
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -58,7 +58,7 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">

View File

@ -1014,6 +1014,11 @@ QString Calibration::descriptiveCalName()
return tmp; return tmp;
} }
bool Calibration::hasUnsavedChanges() const
{
return unsavedChanges;
}
Calkit &Calibration::getKit() Calkit &Calibration::getKit()
{ {
return kit; return kit;

View File

@ -88,7 +88,9 @@ public:
QString getCurrentCalibrationFile(); QString getCurrentCalibrationFile();
double getMinFreq(); double getMinFreq();
double getMaxFreq(); double getMaxFreq();
int getNumPoints(); int getNumPoints();
bool hasUnsavedChanges() const;
public slots: public slots:
// Call once all datapoints of the current span have been added // Call once all datapoints of the current span have been added

View File

@ -293,7 +293,7 @@ Calkit Calkit::fromFile(QString filename)
c.standards.push_back(short_f); c.standards.push_back(short_f);
} }
auto load_m = new CalStandard::Load(SOLT.separate_male_female ? "Default male standard" : "Default standard", SOLT.load_m.Z0, SOLT.load_m.delay, SOLT.load_m.resistance, SOLT.load_m.Cparallel, SOLT.load_m.Lseries, SOLT.loadModelCFirst); auto load_m = new CalStandard::Load(SOLT.separate_male_female ? "Default male standard" : "Default standard", SOLT.load_m.Z0, SOLT.load_m.delay, 0.0, SOLT.load_m.resistance, SOLT.load_m.Cparallel, SOLT.load_m.Lseries, SOLT.loadModelCFirst);
if(SOLT.load_m.useMeasurements) { if(SOLT.load_m.useMeasurements) {
auto ts = Touchstone(1); auto ts = Touchstone(1);
ts.fromFile(SOLT.load_m.file.toStdString()); ts.fromFile(SOLT.load_m.file.toStdString());
@ -301,7 +301,7 @@ Calkit Calkit::fromFile(QString filename)
} }
c.standards.push_back(load_m); c.standards.push_back(load_m);
if(SOLT.separate_male_female) { if(SOLT.separate_male_female) {
auto load_f = new CalStandard::Load("Default female standard", SOLT.load_m.Z0, SOLT.load_f.delay, SOLT.load_f.resistance, SOLT.load_f.Cparallel, SOLT.load_f.Lseries, SOLT.loadModelCFirst); auto load_f = new CalStandard::Load("Default female standard", SOLT.load_m.Z0, SOLT.load_f.delay, 0.0, SOLT.load_f.resistance, SOLT.load_f.Cparallel, SOLT.load_f.Lseries, SOLT.loadModelCFirst);
if(SOLT.load_f.useMeasurements) { if(SOLT.load_f.useMeasurements) {
auto ts = Touchstone(1); auto ts = Touchstone(1);
ts.fromFile(SOLT.load_f.file.toStdString()); ts.fromFile(SOLT.load_f.file.toStdString());

View File

@ -423,7 +423,7 @@ std::complex<double> Load::toS11(double freq)
imp_load += complex<double>(0, freq * 2 * M_PI * Lseries); imp_load += complex<double>(0, freq * 2 * M_PI * Lseries);
} }
complex<double> load = (imp_load - complex<double>(50.0)) / (imp_load + complex<double>(50.0)); complex<double> load = (imp_load - complex<double>(50.0)) / (imp_load + complex<double>(50.0));
return addTransmissionLine(load, Z0, delay*1e-12, 0, freq); return addTransmissionLine(load, Z0, delay*1e-12, loss*1e9, freq);
} }
} }
@ -441,6 +441,7 @@ void Load::edit(std::function<void(void)> finishedCallback)
ui->Z0->setPrecision(2); ui->Z0->setPrecision(2);
ui->Z0->setValue(Z0); ui->Z0->setValue(Z0);
ui->delay->setValue(delay); ui->delay->setValue(delay);
ui->loss->setValue(loss);
ui->parC->setUnit("F"); ui->parC->setUnit("F");
ui->parC->setPrefixes("pnum "); ui->parC->setPrefixes("pnum ");
ui->parC->setPrecision(3); ui->parC->setPrecision(3);
@ -497,6 +498,7 @@ void Load::edit(std::function<void(void)> finishedCallback)
resistance = ui->resistance->value(); resistance = ui->resistance->value();
Z0 = ui->Z0->value(); Z0 = ui->Z0->value();
delay = ui->delay->value(); delay = ui->delay->value();
loss = ui->loss->value();
Cparallel = ui->parC->value(); Cparallel = ui->parC->value();
Lseries = ui->serL->value(); Lseries = ui->serL->value();
Cfirst = ui->C_first->isChecked(); Cfirst = ui->C_first->isChecked();
@ -513,6 +515,7 @@ nlohmann::json Load::toJSON()
auto j = OnePort::toJSON(); auto j = OnePort::toJSON();
j["Z0"] = Z0; j["Z0"] = Z0;
j["delay"] = delay; j["delay"] = delay;
j["loss"] = loss;
j["resistance"] = resistance; j["resistance"] = resistance;
j["Cparallel"] = Cparallel; j["Cparallel"] = Cparallel;
j["Lseries"] = Lseries; j["Lseries"] = Lseries;
@ -525,6 +528,7 @@ void Load::fromJSON(nlohmann::json j)
OnePort::fromJSON(j); OnePort::fromJSON(j);
Z0 = j.value("Z0", 50.0); Z0 = j.value("Z0", 50.0);
delay = j.value("delay", 0.0); delay = j.value("delay", 0.0);
loss = j.value("loss", 0.0);
resistance = j.value("resistance", 0.0); resistance = j.value("resistance", 0.0);
Cparallel = j.value("Cparallel", 0.0); Cparallel = j.value("Cparallel", 0.0);
Lseries = j.value("Lseries", 0.0); Lseries = j.value("Lseries", 0.0);

View File

@ -113,8 +113,8 @@ class Load : public OnePort
{ {
public: public:
Load(); Load();
Load(QString name, double Z0, double delay, double resistance, double Cparallel, double Lseries, bool Cfirst = true) Load(QString name, double Z0, double delay, double loss, double resistance, double Cparallel, double Lseries, bool Cfirst = true)
: OnePort(name), Z0(Z0), delay(delay), resistance(resistance), Cparallel(Cparallel), Lseries(Lseries), Cfirst(Cfirst){} : OnePort(name), Z0(Z0), delay(delay), loss(loss), resistance(resistance), Cparallel(Cparallel), Lseries(Lseries), Cfirst(Cfirst){}
virtual std::complex<double> toS11(double freq) override; virtual std::complex<double> toS11(double freq) override;
virtual void edit(std::function<void(void)> finishedCallback = nullptr) override; virtual void edit(std::function<void(void)> finishedCallback = nullptr) override;
@ -122,7 +122,7 @@ public:
virtual nlohmann::json toJSON() override; virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override; virtual void fromJSON(nlohmann::json j) override;
private: private:
double Z0, delay, resistance, Cparallel, Lseries; double Z0, delay, loss, resistance, Cparallel, Lseries;
bool Cfirst; bool Cfirst;
}; };