KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_coupled_stripline.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// Builds a coupled stripline instance with the fixture geometry described in the task spec.
40// b = 20 mil substrate, symmetric (strip centred), W = 8 mil, S = 8 mil, T = 0.7 mil,
41// εr = 4.3, tan δ = 0.02, σ = 5.8e7 S/m, f = 1 GHz, L = 100 mm.
42COUPLED_STRIPLINE MakeFixture()
43{
44 const double b = 20.0 * TC::UNIT_MIL;
45 const double w = 8.0 * TC::UNIT_MIL;
46 const double s = 8.0 * TC::UNIT_MIL;
47 const double t = 0.7 * TC::UNIT_MIL;
48
50 calc.SetParameter( TCP::EPSILONR, 4.3 );
51 calc.SetParameter( TCP::TAND, 0.02 );
52 calc.SetParameter( TCP::MUR, 1.0 );
53 calc.SetParameter( TCP::MURC, 1.0 );
54 calc.SetParameter( TCP::ROUGH, 0.0 );
55 calc.SetParameter( TCP::SIGMA, 5.8e7 );
56 calc.SetParameter( TCP::H, b );
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, 1.0e9 );
62 return calc;
63}
64} // namespace
65
66
67BOOST_AUTO_TEST_SUITE( CoupledStriplineLosses )
68
69
70BOOST_AUTO_TEST_CASE( DielectricLossIsFiniteAndSymmetric )
71{
72 COUPLED_STRIPLINE calc = MakeFixture();
73 calc.Analyse();
74
75 auto& results = calc.GetAnalysisResults();
76 const double loss_d_e = results.at(TCP::ATTEN_DILECTRIC_EVEN).first;
77 const double loss_d_o = results.at(TCP::ATTEN_DILECTRIC_ODD).first;
78
79 BOOST_TEST( loss_d_e > 0.0 );
80 BOOST_TEST( loss_d_o > 0.0 );
81
82 // Homogeneous TEM dielectric means even and odd modes see the same εr_eff
83 BOOST_TEST( std::fabs( loss_d_e - loss_d_o ) / loss_d_e < 0.001 );
84}
85
86
87BOOST_AUTO_TEST_CASE( DielectricLossMatchesClosedForm )
88{
89 COUPLED_STRIPLINE calc = MakeFixture();
90 calc.Analyse();
91
92 auto& results = calc.GetAnalysisResults();
93 const double loss_d_e = results.at(TCP::ATTEN_DILECTRIC_EVEN).first;
94
95 // α_d = π · f · √εr · tan δ / c (Np/m); total loss (dB) = α_d · L · LOG2DB
96 const double alpha_d = ( M_PI * 1.0e9 * std::sqrt( 4.3 ) * 0.02 ) / TC::C0;
97 const double expected_dB = alpha_d * ( 100.0 * TC::UNIT_MM ) * TC::LOG2DB;
98
99 BOOST_TEST( expected_dB == 0.378, boost::test_tools::tolerance( 0.01 ) );
100 BOOST_TEST( loss_d_e == expected_dB, boost::test_tools::tolerance( 0.03 ) );
101}
102
103
104BOOST_AUTO_TEST_CASE( ConductorLossIsPositive )
105{
106 COUPLED_STRIPLINE calc = MakeFixture();
107 calc.Analyse();
108
109 auto& results = calc.GetAnalysisResults();
110 const double loss_c_e = results.at(TCP::ATTEN_COND_EVEN).first;
111 const double loss_c_o = results.at(TCP::ATTEN_COND_ODD).first;
112
113 BOOST_TEST( loss_c_e > 0.0 );
114 BOOST_TEST( loss_c_o > 0.0 );
115
116 // Odd-mode conductor loss is higher than even mode at the same geometry since Z0_o < Z0_e;
117 // current density per conductor is higher in the odd mode.
118 BOOST_TEST( loss_c_o > loss_c_e );
119}
120
121
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(DielectricLossIsFiniteAndSymmetric)
BOOST_TEST(contains==c.ExpectedContains)
BOOST_AUTO_TEST_SUITE_END()
#define M_PI
TRANSLINE_PARAMETERS
All possible parameters used (as inputs or outputs) by the transmission line calculations.