KiCad PCB EDA Suite
twistedpair.cpp
Go to the documentation of this file.
1 /*
2  * twistedpair.h - twisted pair class definition
3  *
4  * Copyright (C) 2011 Michael Margraf <[email protected]>
5  * Modifications 2011 for Kicad: Jean-Pierre Charras
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or (at
10  * your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this package; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 
25 #include <cmath>
26 #include <cstdio>
27 #include <cstdlib>
28 #include <cstring>
29 
30 #include "twistedpair.h"
31 #include "units.h"
32 
34 {
35  m_Name = "TwistedPair";
36  Init();
37 }
38 
39 
69 {
70 
71  double tw = atan( m_parameters[TWISTEDPAIR_TWIST_PRM] * M_PI
72  * m_parameters[PHYS_DIAM_OUT_PRM] ); // pitch angle
73 
76  + ( 0.25 + 0.0007 * tw * tw )
78 
80  ZF0 / M_PI / sqrt( m_parameters[EPSILON_EFF_PRM] )
82 
84  10.0 / log( 10.0 ) * m_parameters[PHYS_LEN_PRM] / m_parameters[SKIN_DEPTH_PRM]
87 
88  m_parameters[LOSS_DIELECTRIC_PRM] = 20.0 / log( 10.0 ) * m_parameters[PHYS_LEN_PRM] * M_PI / C0
90  * sqrt( m_parameters[EPSILON_EFF_PRM] )
92 
95  / C0; // in radians
96 }
97 
98 
99 // -------------------------------------------------------------------
101 {
103  setResult( 1, m_parameters[LOSS_CONDUCTOR_PRM], wxT( "dB" ) );
104  setResult( 2, m_parameters[LOSS_DIELECTRIC_PRM], wxT( "dB" ) );
105  setResult( 3, m_parameters[SKIN_DEPTH_PRM] / UNIT_MICRON, wxT( "┬Ám" ) );
106 }
107 
109 {
112 
113  // Check for errors
114  if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
116 
117  if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
119 
120  // Find warnings to display - physical parameters
121  if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
123 
124  if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
125  || m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
126  {
128  }
129 
131  {
134  }
135 
136  if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
138 }
139 
141 {
144  else if( isSelected( PHYS_DIAM_OUT_PRM ) )
146 
148 
149  // Check for errors
150  if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
151  {
154  else
156  }
157 
158  if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
159  || m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
160  {
163  else
165  }
166 
168  {
171  else if( isSelected( PHYS_DIAM_OUT_PRM ) )
173  }
174 
175  if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
177 
178  // Check for warnings
179  if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
181 
182  if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
184 }
185 
186 
187 #define MAX_ERROR 0.000001
188 
189 // -------------------------------------------------------------------
191 {
194  else
196 }
bool isSelected(enum PRMS_ID aPrmId)
Definition: transline.cpp:127
void setResult(int, const wxString &)
Definition: transline.cpp:135
bool minimizeZ0Error1D(double *)
@function minimizeZ0Error1D
Definition: transline.cpp:357
void Init()
Definition: transline.cpp:98
void setProperty(enum PRMS_ID aPrmId, double aValue)
Definition: transline.cpp:117
#define ZF0
Definition: units.h:62
void show_results() override
Shows results.
double m_parameters[EXTRA_PRMS_COUNT]
Definition: transline.h:131
void showSynthesize() override
Shows analysis results and checks for errors / warnings.
const char * m_Name
Definition: transline.h:84
#define UNIT_MICRON
Definition: units_scales.h:33
#define C0
Definition: units.h:61
void calcSynthesize() override
Computation for synthesis.
#define TRANSLINE_ERROR
Definition: transline.h:31
void showAnalyze() override
Shows synthesis results and checks for errors / warnings.
void calcAnalyze() override
Definition: twistedpair.cpp:68
double acosh(double x)
Definition: units.h:40
#define TRANSLINE_WARNING
Definition: transline.h:30
void setErrorLevel(PRMS_ID, char)
@function setErrorLevel
Definition: transline.cpp:443