KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_microstrip_cover.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <cmath>
21
23
28
29
30namespace TC = TRANSLINE_CALCULATIONS;
32
33
34namespace
35{
36
37// Reference geometry for the covered-microstrip tests. Substrate eps_r = 4.4, h = 1 mm,
38// W = 1.875 mm (u = W/h = 1.875), T = 35 um (1 oz copper). Driving f at 1 MHz keeps the
39// Kirschning-Jansen dispersion term negligible (f_n = FREQ*H/1e6 << 1) so Z0 and eps_eff
40// match the static values computed directly from the closed-form expressions.
41constexpr double FIXTURE_EPS_R = 4.4;
42constexpr double FIXTURE_TAND = 0.02;
43constexpr double FIXTURE_H = 1.0 * TC::UNIT_MM;
44constexpr double FIXTURE_W = 1.875 * TC::UNIT_MM;
45constexpr double FIXTURE_T = 35.0 * TC::UNIT_MICRON;
46constexpr double FIXTURE_FREQ = 1.0 * TC::UNIT_MHZ;
47constexpr double FIXTURE_SIGMA = 5.8e7;
48constexpr double OPEN_COVER = 1.0e20;
49
50
51MICROSTRIP MakeFixture( double aHTop )
52{
53 MICROSTRIP calc;
54 calc.SetParameter( TCP::EPSILONR, FIXTURE_EPS_R );
55 calc.SetParameter( TCP::TAND, FIXTURE_TAND );
56 calc.SetParameter( TCP::H, FIXTURE_H );
57 calc.SetParameter( TCP::H_T, aHTop );
58 calc.SetParameter( TCP::PHYS_WIDTH, FIXTURE_W );
59 calc.SetParameter( TCP::T, FIXTURE_T );
60 calc.SetParameter( TCP::MUR, 1.0 );
61 calc.SetParameter( TCP::MURC, 1.0 );
62 calc.SetParameter( TCP::SIGMA, FIXTURE_SIGMA );
63 calc.SetParameter( TCP::ROUGH, 0.0 );
64 calc.SetParameter( TCP::FREQUENCY, FIXTURE_FREQ );
65 calc.SetParameter( TCP::PHYS_LEN, 100.0 * TC::UNIT_MM );
66 return calc;
67}
68
69} // namespace
70
71
72BOOST_AUTO_TEST_SUITE( MicrostripCover )
73
74
75// Baseline without a cover reproduces the well-known open-microstrip impedance. Reference
76// Z0 ~ 49.6 ohm, eps_eff ~ 3.33 for u = 1.875, eps_r = 4.4, T/h = 0.035.
78{
79 MICROSTRIP calc = MakeFixture( OPEN_COVER );
80 calc.Analyse();
81
82 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 49.6, 0.03 );
83 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 3.33, 0.03 );
84}
85
86
88{
89 MICROSTRIP calc = MakeFixture( 2.0 * FIXTURE_H );
90 calc.Analyse();
91
92 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 47.3, 0.03 );
93 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 3.12, 0.03 );
94}
95
96
97// Cover at H_T = h (tight shielding, air gap equal to substrate thickness). h'/h = 1 is
98// the lower boundary of GBB Eq. (2.128) stated validity (1 < h'/h < infty) so we accept a
99// 5 percent Z0 tolerance. checkProperties also flags this regime in the UI via the
100// T + 0.1*h air-gap warning.
102{
103 MICROSTRIP calc = MakeFixture( FIXTURE_H );
104 calc.Analyse();
105
106 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 41.2, 0.05 );
107 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 2.70, 0.03 );
108}
109
110
111// At H_T = 10h the cover contribution is already within a fraction of a percent of the
112// open case. Verifies the asymptotic behaviour of the cover correction as h'/h -> infty.
113BOOST_AUTO_TEST_CASE( CoverAt10HIsAsymptoticallyOpen )
114{
115 MICROSTRIP open = MakeFixture( OPEN_COVER );
116 open.Analyse();
117 const double openZ0 = open.GetParameter( TCP::Z0 );
118 const double openEps = open.GetParameter( TCP::EPSILON_EFF );
119
120 MICROSTRIP tenH = MakeFixture( 10.0 * FIXTURE_H );
121 tenH.Analyse();
122
123 BOOST_CHECK_CLOSE_FRACTION( tenH.GetParameter( TCP::Z0 ), openZ0, 0.01 );
124 BOOST_CHECK_CLOSE_FRACTION( tenH.GetParameter( TCP::EPSILON_EFF ), openEps, 0.01 );
125}
126
127
128// A lower cover must produce a lower static impedance because the added parallel
129// capacitance to the cover plane can only increase line capacitance. Verified only in
130// the regime where GBB's P is non-negligible; at h'/h >= 10 the P correction is below
131// 0.1 percent of Z0 and rides the floor of the independent filling-factor fit's accuracy,
132// so we do not assert strict ordering between open and 10h.
133BOOST_AUTO_TEST_CASE( Z0MonotonicInH_T )
134{
135 MICROSTRIP twoH = MakeFixture( 2.0 * FIXTURE_H );
136 twoH.Analyse();
137
138 MICROSTRIP oneH = MakeFixture( FIXTURE_H );
139 oneH.Analyse();
140
142}
143
144
145// Exercises the out-of-validity fallback in delta_Z0_cover: wide trace + low cover
146// saturates the Q argument, so the P-only branch keeps Z0 finite.
147BOOST_AUTO_TEST_CASE( WideTraceWithCloseCoverDoesNotProduceNaN )
148{
149 MICROSTRIP calc = MakeFixture( 2.0 * FIXTURE_H );
150 calc.SetParameter( TCP::PHYS_WIDTH, 10.0 * FIXTURE_H );
151 calc.Analyse();
152
153 BOOST_TEST( std::isfinite( calc.GetParameter( TCP::Z0 ) ) );
154 BOOST_TEST( std::isfinite( calc.GetParameter( TCP::EPSILON_EFF ) ) );
155}
156
157
void Analyse() override
Analyse track geometry parameters to output Z0 and Ang_L.
double GetParameter(const TRANSLINE_PARAMETERS aParam) const
Gets the given calculation property.
void SetParameter(const TRANSLINE_PARAMETERS aParam, const double aValue)
Sets the given calculation property.
TRANSLINE_PARAMETERS TCP
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
BOOST_AUTO_TEST_CASE(NoCover)
TRANSLINE_PARAMETERS
All possible parameters used (as inputs or outputs) by the transmission line calculations.