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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <cmath>
23
27
28
29namespace TC = TRANSLINE_CALCULATIONS;
31
32
33namespace
34{
35// Tightly coupled differential pair on a thin substrate. Geometry is chosen so that
36// Kirschning-Jansen dispersion produces a measurable shift in the odd-mode impedance
37// between 1 MHz and 10 GHz.
38COUPLED_MICROSTRIP MakeFixture( double aFrequencyHz )
39{
40 const double h = 0.2 * TC::UNIT_MM;
41 const double w = 0.15 * TC::UNIT_MM;
42 const double s = 0.2 * TC::UNIT_MM;
43 const double t = 35.0 * TC::UNIT_MICRON;
44
46 calc.SetParameter( TCP::EPSILONR, 4.3 );
47 calc.SetParameter( TCP::TAND, 0.02 );
48 calc.SetParameter( TCP::MURC, 1.0 );
49 calc.SetParameter( TCP::ROUGH, 0.0 );
50 calc.SetParameter( TCP::SIGMA, 5.8e7 );
51 calc.SetParameter( TCP::H, h );
52 calc.SetParameter( TCP::H_T, 1.0e20 );
54 calc.SetParameter( TCP::PHYS_S, s );
55 calc.SetParameter( TCP::T, t );
56 calc.SetParameter( TCP::PHYS_LEN, 100.0 * TC::UNIT_MM );
57 calc.SetParameter( TCP::FREQUENCY, aFrequencyHz );
58 return calc;
59}
60} // namespace
61
62
63BOOST_AUTO_TEST_SUITE( CoupledMicrostripDiffImpedance )
64
65
66BOOST_AUTO_TEST_CASE( ZdiffTracksDispersedOddMode )
67{
68 // diff_impedance() must read the Z0_O value left in the parameter map by
69 // Z0_dispersion(), so Zdiff always equals exactly twice the published odd-mode
70 // impedance regardless of frequency. Before the fix Zdiff was always 2 * Z0_o_0
71 // (the static value), which drifts from 2 * Z0_O as soon as dispersion kicks in.
72 for( double freq : { 1.0e6, 1.0e9, 5.0e9, 10.0e9 } )
73 {
74 COUPLED_MICROSTRIP calc = MakeFixture( freq );
75 calc.Analyse();
76
77 auto& results = calc.GetAnalysisResults();
78 const double Zdiff = results.at(TCP::Z_DIFF).first;
79 const double Z0_o = results.at(TCP::Z0_O).first;
80
81 BOOST_TEST_MESSAGE( "f=" << freq << " Zdiff=" << Zdiff << " Z0_o=" << Z0_o );
82 BOOST_TEST( std::fabs( Zdiff - 2.0 * Z0_o ) < 1.0e-9 );
83 }
84}
85
86
87BOOST_AUTO_TEST_CASE( ZdiffChangesWithFrequency )
88{
89 // If diff_impedance() ignored Z0_dispersion() then Zdiff would be identical at
90 // every frequency. Confirm that the dispersed value actually moves across the
91 // DC-to-10 GHz band on a ~100 Ohm pair. Direction of the shift depends on the
92 // geometry; Kirschning-Jansen can raise or lower Z0_O.
93 COUPLED_MICROSTRIP lo = MakeFixture( 1.0e6 );
94 lo.Analyse();
95
96 COUPLED_MICROSTRIP hi = MakeFixture( 10.0e9 );
97 hi.Analyse();
98
99 const double Zdiff_lo = lo.GetAnalysisResults()[TCP::Z_DIFF].first;
100 const double Zdiff_hi = hi.GetAnalysisResults()[TCP::Z_DIFF].first;
101
102 BOOST_TEST_MESSAGE( "Zdiff@1MHz=" << Zdiff_lo << " Zdiff@10GHz=" << Zdiff_hi );
103 BOOST_TEST( std::fabs( Zdiff_hi - Zdiff_lo ) > 0.1 );
104}
105
106
107BOOST_AUTO_TEST_CASE( LowFrequencyMatchesStaticOddMode )
108{
109 // At 1 MHz Kirschning-Jansen dispersion is negligible, so the dispersed Z0_O stays
110 // within floating-point noise of the static Z0_o_0 and Zdiff therefore still equals
111 // 2 * static odd-mode impedance. Low-frequency behaviour must not regress.
112 COUPLED_MICROSTRIP calc = MakeFixture( 1.0e6 );
113 calc.Analyse();
114
115 auto& results = calc.GetAnalysisResults();
116
117 const double Zdiff = results.at(TCP::Z_DIFF).first;
118 const double Z0_o = results.at(TCP::Z0_O).first;
119
120 BOOST_TEST( std::fabs( Zdiff - 2.0 * Z0_o ) < 0.1 );
121}
122
123
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_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
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.