Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
structures.h
1/*
2 * Copyright (C) 2019-2025 Andrés Martínez Mera - andresmmera@protonmail.com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef STRUCTURES_H
19#define STRUCTURES_H
20
21#include <QString>
22#include <QStringList>
23#include <QMap>
24#include <array>
25#include <complex.h>
26#include <complex>
27#include <deque>
28#include <vector>
29
30enum ComponentType {
31 Capacitor,
32 Inductor,
33 Term,
34 GND,
35 ConnectionNodes,
36 Resistor,
37 TransmissionLine,
38 MicrostripLine,
39 MicrostripStep,
40 MicrostripOpen,
41 MicrostripVia,
42 MicrostripCoupledLines,
43 OpenStub,
44 ShortStub,
45 CoupledLines,
46 Coupler,
47 ComplexImpedance,
48 SPAR_Block
49};
50
51// Function for getting the component name as text
52QString ComponentTypeToString(ComponentType type);
53
54enum ResponseType {
55 Butterworth,
56 Chebyshev,
57 Legendre,
58 Gaussian,
59 Elliptic,
60 Blichinkoff,
61 Bessel,
62 LinearPhaseEqError,
63 Gegenbauer
64};
65enum FilterClass { Lowpass, Highpass, Bandpass, Bandstop };
66enum Coupling {
67 CapacitiveCoupledShuntResonators,
68 InductiveCoupledShuntResonators,
69 CapacitiveCoupledSeriesResonators,
70 InductiveCoupledSeriesResonators,
71 QWCoupledShuntResonators
72};
73enum SemiLumpedImplementation { ONLY_INDUCTORS, INDUCTORS_AND_SHUNT_CAPS };
74
75enum TransmissionLineType {
76 Ideal,
77 MLIN, // Microstrip
78 SLIN, // Stripline
79 Lumped
80};
81
82static const double SPEED_OF_LIGHT = 299792458.0;
83
85 QString ID;
86 std::vector<int> N;
87 std::vector<double> Ripple;
88 std::vector<double> RL;
89};
90
91// Microstrip substrate struct
93 // Substrate
94 double height; // substrate height (mm)
95 double er; // relative permittivity
96 double tand; // dissipation factor
97
98 // Metal properties
99 double MetalConductivity; // Metal conductivity
100 double MetalThickness; // Metal thickness
101
102 MS_Substrate(double h = 0.508e-3, double epsilon_r = 3.55,
103 double tand = 0.0027, double MetalConductivity = 58e6,
104 double MetalThickness = 32e-6)
105 : height(h), er(epsilon_r), tand(tand),
106 MetalConductivity(MetalConductivity), MetalThickness(MetalThickness) {
107 } // RO4003C, 20 mils
108};
109
110
111bool operator==(const MS_Substrate& a, const MS_Substrate& b);
112QList<MS_Substrate> removeDuplicates(const QList<MS_Substrate>& list);
113
114
116 FilterClass FilterType; // Lowpass, Highpass, Bandpass, Bandstop
117 ResponseType FilterResponse; // Butterworth, Chebyshev, Cauer, etc...
118 QString Implementation;
119 TransmissionLineType TL_implementation; // Ideal, microstrip, stripline, etc.
120 Coupling DC_Coupling; // Only for bandpass direct coupled filters
121 bool isCLC; // CLC or LCL implementation
122 unsigned int order; // Filter order
123 double Ripple = 0.05; // Ripple (Chebyshev and Cauer)
124 double fc; // Cutoff frequency (lowpass and highpass filters) or center
125 // frequency (bandpass and bandstop)
126 double bw; // Filter bandwidth
127 double ZS; // Source impedance
128 double ZL; // Load impedance
129 double as; // Stopband attenuation
130 QString EllipticType; // Type of elliptic filter
131 bool UseZverevTables;
132 double minZ; // Minimum synthesizable impedance (only for stepped impedance
133 // filters)
134 double maxZ; // Maximum synthesizable impedance (only for stepped impedance
135 // filters)
136 SemiLumpedImplementation SemiLumpedISettings;
137 double ImpedanceRatio;
138
139 MS_Substrate MS_Subs; // Substrate Settings
140
141 ComponentType tunableComponent_DC_Filters;
142 std::vector<double> resonatorValues;
143};
144
145// Contains the information of the matching network topology
147 double Z0;
148 int Topology;
149 TransmissionLineType TL_implementation; // Ideal, microstrip, stripline, etc.
150 int Solution;
151 int OpenShort;
152 int NSections;
153 QString Weigthing;
154 double gamma_MAX;
155
156 // Impedance data
157 double ZL_freq;
158 std::complex<double> ZL; // Load impedance at fmatch
159 QList<double> freq;
160 QList<std::complex<double>>
161 ZL_data; // Impedance vs freq. This is will need to be fixed
162 QString sim_path; // Path to the S-parameter file that models the load.
163 // Required for the simulation engine
164
165 // Substrate Settings
166 MS_Substrate MS_Subs;
167};
168
169// Contains all the information for the matching network design problem
171 struct MatchingNetworkDesignParameters InputNetworkParameters;
172 struct MatchingNetworkDesignParameters OutputNetworkParameters;
173 std::array<std::complex<double>, 4> sparams;
174
175 bool twoPortMode;
176
177 // Match band
178 double f_match; // Target frequency
179};
180
182 std::vector<std::complex<double>> ZS;
183 std::vector<std::complex<double>> ZL;
184 QStringList topology;
185 QList<struct ComponentInfo>
186 Ladder; // Contains the ID of the components and their properties
187};
188
190 QString Type; // Wilkinson, branchlines, Bagley, etc.
191 TransmissionLineType TL_implementation; // Ideal, microstrip, stripline, etc.
192 int Noutputs; // Number of output branches
193 int Nstages; // Number of combiner stages (broadband Wilkinson)
194 std::deque<double> OutputRatio; // Splitting ratio
195 double alpha; // Attenuation constant of the ideal TL
196 QString units; // mm, mil, um
197 double freq; // Center freq
198 double Z0; // Reference impedance
199
200 // Substrate Settings
201 MS_Substrate MS_Subs;
202};
203
205 QString Topology; // Attenuator topology
206 TransmissionLineType TL_implementation; // Ideal, microstrip, stripline, etc.
207 double Zin; // Input impedance
208 double Zout; // Output impedance
209 double Attenuation; // Attenuation in dB
210 double Frequency; // Central frequency of tuned attenuators
211 double Pin; // Input power in W
212
213 // Substrate Settings
214 MS_Substrate MS_Subs;
215};
216
217#endif // STRUCTURES_H
Definition structures.h:204
Definition structures.h:115
std::vector< double > resonatorValues
Direct-Coupled filters only. It indicates which component in the resonator can be adjusted by the use...
Definition structures.h:142
Definition structures.h:92
Definition structures.h:170
Definition structures.h:146
Definition structures.h:181
Definition structures.h:189
Definition structures.h:84