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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <cmath>
25
27
32
33
34namespace TC = TRANSLINE_CALCULATIONS;
36
37
38namespace
39{
40
41// Reference geometry for the covered-microstrip tests. Substrate eps_r = 4.4, h = 1 mm,
42// W = 1.875 mm (u = W/h = 1.875), T = 35 um (1 oz copper). Driving f at 1 MHz keeps the
43// Kirschning-Jansen dispersion term negligible (f_n = FREQ*H/1e6 << 1) so Z0 and eps_eff
44// match the static values computed directly from the closed-form expressions.
45constexpr double FIXTURE_EPS_R = 4.4;
46constexpr double FIXTURE_TAND = 0.02;
47constexpr double FIXTURE_H = 1.0 * TC::UNIT_MM;
48constexpr double FIXTURE_W = 1.875 * TC::UNIT_MM;
49constexpr double FIXTURE_T = 35.0 * TC::UNIT_MICRON;
50constexpr double FIXTURE_FREQ = 1.0 * TC::UNIT_MHZ;
51constexpr double FIXTURE_SIGMA = 5.8e7;
52constexpr double OPEN_COVER = 1.0e20;
53
54
55MICROSTRIP MakeFixture( double aHTop )
56{
57 MICROSTRIP calc;
58 calc.SetParameter( TCP::EPSILONR, FIXTURE_EPS_R );
59 calc.SetParameter( TCP::TAND, FIXTURE_TAND );
60 calc.SetParameter( TCP::H, FIXTURE_H );
61 calc.SetParameter( TCP::H_T, aHTop );
62 calc.SetParameter( TCP::PHYS_WIDTH, FIXTURE_W );
63 calc.SetParameter( TCP::T, FIXTURE_T );
64 calc.SetParameter( TCP::MUR, 1.0 );
65 calc.SetParameter( TCP::MURC, 1.0 );
66 calc.SetParameter( TCP::SIGMA, FIXTURE_SIGMA );
67 calc.SetParameter( TCP::ROUGH, 0.0 );
68 calc.SetParameter( TCP::FREQUENCY, FIXTURE_FREQ );
69 calc.SetParameter( TCP::PHYS_LEN, 100.0 * TC::UNIT_MM );
70 return calc;
71}
72
73} // namespace
74
75
76BOOST_AUTO_TEST_SUITE( MicrostripCover )
77
78
79// Baseline without a cover reproduces the well-known open-microstrip impedance. Reference
80// Z0 ~ 49.6 ohm, eps_eff ~ 3.33 for u = 1.875, eps_r = 4.4, T/h = 0.035.
82{
83 MICROSTRIP calc = MakeFixture( OPEN_COVER );
84 calc.Analyse();
85
86 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 49.6, 0.03 );
87 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 3.33, 0.03 );
88}
89
90
92{
93 MICROSTRIP calc = MakeFixture( 2.0 * FIXTURE_H );
94 calc.Analyse();
95
96 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 47.3, 0.03 );
97 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 3.12, 0.03 );
98}
99
100
101// Cover at H_T = h (tight shielding, air gap equal to substrate thickness). h'/h = 1 is
102// the lower boundary of GBB Eq. (2.128) stated validity (1 < h'/h < infty) so we accept a
103// 5 percent Z0 tolerance. checkProperties also flags this regime in the UI via the
104// T + 0.1*h air-gap warning.
106{
107 MICROSTRIP calc = MakeFixture( FIXTURE_H );
108 calc.Analyse();
109
110 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::Z0 ), 41.2, 0.05 );
111 BOOST_CHECK_CLOSE_FRACTION( calc.GetParameter( TCP::EPSILON_EFF ), 2.70, 0.03 );
112}
113
114
115// At H_T = 10h the cover contribution is already within a fraction of a percent of the
116// open case. Verifies the asymptotic behaviour of the cover correction as h'/h -> infty.
117BOOST_AUTO_TEST_CASE( CoverAt10HIsAsymptoticallyOpen )
118{
119 MICROSTRIP open = MakeFixture( OPEN_COVER );
120 open.Analyse();
121 const double openZ0 = open.GetParameter( TCP::Z0 );
122 const double openEps = open.GetParameter( TCP::EPSILON_EFF );
123
124 MICROSTRIP tenH = MakeFixture( 10.0 * FIXTURE_H );
125 tenH.Analyse();
126
127 BOOST_CHECK_CLOSE_FRACTION( tenH.GetParameter( TCP::Z0 ), openZ0, 0.01 );
128 BOOST_CHECK_CLOSE_FRACTION( tenH.GetParameter( TCP::EPSILON_EFF ), openEps, 0.01 );
129}
130
131
132// A lower cover must produce a lower static impedance because the added parallel
133// capacitance to the cover plane can only increase line capacitance. Verified only in
134// the regime where GBB's P is non-negligible; at h'/h >= 10 the P correction is below
135// 0.1 percent of Z0 and rides the floor of the independent filling-factor fit's accuracy,
136// so we do not assert strict ordering between open and 10h.
137BOOST_AUTO_TEST_CASE( Z0MonotonicInH_T )
138{
139 MICROSTRIP twoH = MakeFixture( 2.0 * FIXTURE_H );
140 twoH.Analyse();
141
142 MICROSTRIP oneH = MakeFixture( FIXTURE_H );
143 oneH.Analyse();
144
146}
147
148
149// Exercises the out-of-validity fallback in delta_Z0_cover: wide trace + low cover
150// saturates the Q argument, so the P-only branch keeps Z0 finite.
151BOOST_AUTO_TEST_CASE( WideTraceWithCloseCoverDoesNotProduceNaN )
152{
153 MICROSTRIP calc = MakeFixture( 2.0 * FIXTURE_H );
154 calc.SetParameter( TCP::PHYS_WIDTH, 10.0 * FIXTURE_H );
155 calc.Analyse();
156
157 BOOST_TEST( std::isfinite( calc.GetParameter( TCP::Z0 ) ) );
158 BOOST_TEST( std::isfinite( calc.GetParameter( TCP::EPSILON_EFF ) ) );
159}
160
161
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_TEST(contains==c.ExpectedContains)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(NoCover)
TRANSLINE_PARAMETERS
All possible parameters used (as inputs or outputs) by the transmission line calculations.