KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_dielectric_selector.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
28
29
31
32
33BOOST_AUTO_TEST_SUITE( DielectricSelector )
34
35
36// The default DIELECTRIC_MODEL_SEL value is 0.0 which maps to CONSTANT. Calling
37// UpdateDielectricModel() must leave the DS state empty and the dispersed accessors
38// must return the raw EPSILONR / TAND parameters verbatim.
39BOOST_AUTO_TEST_CASE( ConstantDefault )
40{
41 MICROSTRIP calc;
42 calc.SetParameter( TCP::EPSILONR, 4.4 );
43 calc.SetParameter( TCP::TAND, 0.02 );
44
46
48 BOOST_TEST( calc.GetDispersedTanDelta( 1.0e9 ) == calc.GetParameter( TCP::TAND ) );
49}
50
51
52// Switching DIELECTRIC_MODEL_SEL to DJORDJEVIC_SARKAR with a valid spec frequency must
53// populate the DS model and disperse the permittivity per Djordjevic 2001. Reference
54// value (4.7872 at 1 MHz for FR-4 specified at 1 GHz) matches the DS unit test.
55BOOST_AUTO_TEST_CASE( DjordjevicSarkarActivation )
56{
57 MICROSTRIP calc;
58 calc.SetParameter( TCP::EPSILONR, 4.4 );
59 calc.SetParameter( TCP::TAND, 0.02 );
62 static_cast<double>( DIELECTRIC_MODEL::DJORDJEVIC_SARKAR ) );
63
65
66 BOOST_TEST( calc.GetDispersedEpsilonR( 1.0e6 ) == 4.7872, boost::test_tools::tolerance( 0.01 ) );
67 BOOST_TEST( calc.GetDispersedTanDelta( 1.0e6 ) == 0.01838,
68 boost::test_tools::tolerance( 0.0005 ) );
69}
70
71
72// A non-positive EPSILONR_SPEC_FREQ is an ill-formed user input. UpdateDielectricModel
73// must reject it and fall back to CONSTANT behaviour rather than throwing from Fit().
74BOOST_AUTO_TEST_CASE( InvalidSpecFrequencyFallsBack )
75{
76 MICROSTRIP calc;
77 calc.SetParameter( TCP::EPSILONR, 4.4 );
78 calc.SetParameter( TCP::TAND, 0.02 );
81 static_cast<double>( DIELECTRIC_MODEL::DJORDJEVIC_SARKAR ) );
82
84
85 BOOST_TEST( calc.GetDispersedEpsilonR( 1.0e6 ) == 4.4 );
86 BOOST_TEST( calc.GetDispersedTanDelta( 1.0e6 ) == 0.02 );
87}
88
89
double GetDispersedEpsilonR(double aF) const
Dispersed permittivity at aF. Returns raw EPSILONR when the model is inactive.
double GetDispersedTanDelta(double aF) const
Dispersed loss tangent at aF. Returns raw TAND when the model is inactive.
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.
void UpdateDielectricModel()
Refit the Djordjevic-Sarkar model from the current parameter map.
TRANSLINE_PARAMETERS TCP
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(ConstantDefault)
BOOST_TEST(contains==c.ExpectedContains)
BOOST_AUTO_TEST_SUITE_END()
TRANSLINE_PARAMETERS
All possible parameters used (as inputs or outputs) by the transmission line calculations.