KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_coupled_microstrip.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
25
26#include <cmath>
27
31
32
33namespace TC = TRANSLINE_CALCULATIONS;
35
36
37namespace
38{
39// Tightly coupled differential pair on a thin substrate. Geometry is chosen so that
40// Kirschning-Jansen dispersion produces a measurable shift in the odd-mode impedance
41// between 1 MHz and 10 GHz.
42COUPLED_MICROSTRIP MakeFixture( double aFrequencyHz )
43{
44 const double h = 0.2 * TC::UNIT_MM;
45 const double w = 0.15 * TC::UNIT_MM;
46 const double s = 0.2 * TC::UNIT_MM;
47 const double t = 35.0 * TC::UNIT_MICRON;
48
50 calc.SetParameter( TCP::EPSILONR, 4.3 );
51 calc.SetParameter( TCP::TAND, 0.02 );
52 calc.SetParameter( TCP::MURC, 1.0 );
53 calc.SetParameter( TCP::ROUGH, 0.0 );
54 calc.SetParameter( TCP::SIGMA, 5.8e7 );
55 calc.SetParameter( TCP::H, h );
56 calc.SetParameter( TCP::H_T, 1.0e20 );
58 calc.SetParameter( TCP::PHYS_S, s );
59 calc.SetParameter( TCP::T, t );
60 calc.SetParameter( TCP::PHYS_LEN, 100.0 * TC::UNIT_MM );
61 calc.SetParameter( TCP::FREQUENCY, aFrequencyHz );
62 return calc;
63}
64} // namespace
65
66
67BOOST_AUTO_TEST_SUITE( CoupledMicrostripDiffImpedance )
68
69
70BOOST_AUTO_TEST_CASE( ZdiffTracksDispersedOddMode )
71{
72 // diff_impedance() must read the Z0_O value left in the parameter map by
73 // Z0_dispersion(), so Zdiff always equals exactly twice the published odd-mode
74 // impedance regardless of frequency. Before the fix Zdiff was always 2 * Z0_o_0
75 // (the static value), which drifts from 2 * Z0_O as soon as dispersion kicks in.
76 for( double freq : { 1.0e6, 1.0e9, 5.0e9, 10.0e9 } )
77 {
78 COUPLED_MICROSTRIP calc = MakeFixture( freq );
79 calc.Analyse();
80
81 auto& results = calc.GetAnalysisResults();
82 const double Zdiff = results.at(TCP::Z_DIFF).first;
83 const double Z0_o = results.at(TCP::Z0_O).first;
84
85 BOOST_TEST_MESSAGE( "f=" << freq << " Zdiff=" << Zdiff << " Z0_o=" << Z0_o );
86 BOOST_TEST( std::fabs( Zdiff - 2.0 * Z0_o ) < 1.0e-9 );
87 }
88}
89
90
91BOOST_AUTO_TEST_CASE( ZdiffChangesWithFrequency )
92{
93 // If diff_impedance() ignored Z0_dispersion() then Zdiff would be identical at
94 // every frequency. Confirm that the dispersed value actually moves across the
95 // DC-to-10 GHz band on a ~100 Ohm pair. Direction of the shift depends on the
96 // geometry; Kirschning-Jansen can raise or lower Z0_O.
97 COUPLED_MICROSTRIP lo = MakeFixture( 1.0e6 );
98 lo.Analyse();
99
100 COUPLED_MICROSTRIP hi = MakeFixture( 10.0e9 );
101 hi.Analyse();
102
103 const double Zdiff_lo = lo.GetAnalysisResults()[TCP::Z_DIFF].first;
104 const double Zdiff_hi = hi.GetAnalysisResults()[TCP::Z_DIFF].first;
105
106 BOOST_TEST_MESSAGE( "Zdiff@1MHz=" << Zdiff_lo << " Zdiff@10GHz=" << Zdiff_hi );
107 BOOST_TEST( std::fabs( Zdiff_hi - Zdiff_lo ) > 0.1 );
108}
109
110
111BOOST_AUTO_TEST_CASE( LowFrequencyMatchesStaticOddMode )
112{
113 // At 1 MHz Kirschning-Jansen dispersion is negligible, so the dispersed Z0_O stays
114 // within floating-point noise of the static Z0_o_0 and Zdiff therefore still equals
115 // 2 * static odd-mode impedance. Low-frequency behaviour must not regress.
116 COUPLED_MICROSTRIP calc = MakeFixture( 1.0e6 );
117 calc.Analyse();
118
119 auto& results = calc.GetAnalysisResults();
120
121 const double Zdiff = results.at(TCP::Z_DIFF).first;
122 const double Z0_o = results.at(TCP::Z0_O).first;
123
124 BOOST_TEST( std::fabs( Zdiff - 2.0 * Z0_o ) < 0.1 );
125}
126
127
void Analyse() override
Analyse track geometry parameters to output Z0 and Ang_L.
void SetParameter(const TRANSLINE_PARAMETERS aParam, const double aValue)
Sets the given calculation property.
std::unordered_map< TRANSLINE_PARAMETERS, std::pair< double, TRANSLINE_STATUS > > & GetAnalysisResults()
Gets the output parameters following analysis.
TRANSLINE_PARAMETERS TCP
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(ZdiffTracksDispersedOddMode)
BOOST_TEST(contains==c.ExpectedContains)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
TRANSLINE_PARAMETERS
All possible parameters used (as inputs or outputs) by the transmission line calculations.