KiCad PCB EDA Suite
TRANSLINE Class Reference

#include <transline.h>

Inheritance diagram for TRANSLINE:
COAX COPLANAR C_MICROSTRIP MICROSTRIP RECTWAVEGUIDE STRIPLINE TWISTEDPAIR GROUNDEDCOPLANAR

Public Member Functions

 TRANSLINE ()
 
virtual ~TRANSLINE ()
 
void setProperty (enum PRMS_ID aPrmId, double aValue)
 
double getProperty (enum PRMS_ID aPrmId)
 
void getProperties ()
 @function getProperties More...
 
void checkProperties ()
 @function checkProperties More...
 
void setResult (int, double, const char *)
 
void setResult (int, const char *)
 
bool isSelected (enum PRMS_ID aPrmId)
 
void Init ()
 
virtual void synthesize ()
 
virtual void calc ()
 
virtual void calcAnalyze ()
 Computation for analysis. More...
 
virtual void calcSynthesize ()
 Computation for synthesis. More...
 
virtual void showAnalyze ()
 Shows synthesis results and checks for errors / warnings. More...
 
virtual void showSynthesize ()
 Shows analysis results and checks for errors / warnings. More...
 
virtual void show_results ()
 Shows results. More...
 
void analyze ()
 

Public Attributes

const char * m_Name
 
KIGFX::COLOR4D errCol = KIGFX::COLOR4D( 1, 0.63, 0.63, 1 )
 
KIGFX::COLOR4D warnCol = KIGFX::COLOR4D( 1, 1, 0.57, 1 )
 
KIGFX::COLOR4D okCol = KIGFX::COLOR4D( 1, 1, 1, 1 )
 

Protected Member Functions

bool minimizeZ0Error1D (double *)
 @function minimizeZ0Error1D More...
 
double skin_depth ()
 @function skin_depth calculate skin depth More...
 
void ellipke (double, double &, double &)
 
double ellipk (double)
 
void setErrorLevel (PRMS_ID, char)
 @function setErrorLevel More...
 

Protected Attributes

double m_parameters [EXTRA_PRMS_COUNT]
 

Detailed Description

Definition at line 78 of file transline.h.

Constructor & Destructor Documentation

◆ TRANSLINE()

TRANSLINE::TRANSLINE ( )

Definition at line 73 of file transline.cpp.

74{
76 m_Name = nullptr;
77 Init();
78}
void Init()
Definition: transline.cpp:87
double m_parameters[EXTRA_PRMS_COUNT]
Definition: transline.h:131
const char * m_Name
Definition: transline.h:84
@ MURC_PRM
Definition: transline.h:50

References Init(), m_Name, m_parameters, and MURC_PRM.

◆ ~TRANSLINE()

TRANSLINE::~TRANSLINE ( )
virtual

Definition at line 82 of file transline.cpp.

83{
84}

Member Function Documentation

◆ analyze()

void TRANSLINE::analyze ( )

Definition at line 208 of file transline.cpp.

209{
212 calcAnalyze();
213 showAnalyze();
214 show_results();
215}
void getProperties()
@function getProperties
Definition: transline.cpp:147
void checkProperties()
@function checkProperties
Definition: transline.cpp:166
virtual void showAnalyze()
Shows synthesis results and checks for errors / warnings.
Definition: transline.h:112
virtual void show_results()
Shows results.
Definition: transline.h:122
virtual void calcAnalyze()
Computation for analysis.
Definition: transline.h:102

References calcAnalyze(), checkProperties(), getProperties(), show_results(), and showAnalyze().

Referenced by PANEL_TRANSLINE::OnTranslineAnalyse().

◆ calc()

virtual void TRANSLINE::calc ( )
inlinevirtual

Definition at line 97 of file transline.h.

97{}

◆ calcAnalyze()

virtual void TRANSLINE::calcAnalyze ( )
inlinevirtual

Computation for analysis.

Reimplemented in C_MICROSTRIP, COAX, COPLANAR, MICROSTRIP, RECTWAVEGUIDE, STRIPLINE, and TWISTEDPAIR.

Definition at line 102 of file transline.h.

102{};

Referenced by analyze(), and minimizeZ0Error1D().

◆ calcSynthesize()

virtual void TRANSLINE::calcSynthesize ( )
inlinevirtual

Computation for synthesis.

Reimplemented in C_MICROSTRIP, COAX, COPLANAR, MICROSTRIP, RECTWAVEGUIDE, STRIPLINE, and TWISTEDPAIR.

Definition at line 107 of file transline.h.

107{}

Referenced by synthesize().

◆ checkProperties()

void TRANSLINE::checkProperties ( )

@function checkProperties

Checks the input parameters (ie: negative length). Does not check for incompatibility between values as this depends on the line shape.

Definition at line 166 of file transline.cpp.

167{
168 // Do not check for values that are results of analyzing / synthesizing
169 // Do not check for transline specific incompatibilities ( like " conductor height should be lesser than dielectric height")
170 if( !std::isfinite( m_parameters[EPSILONR_PRM] ) || m_parameters[EPSILONR_PRM] <= 0 )
172
173 if( !std::isfinite( m_parameters[TAND_PRM] ) || m_parameters[TAND_PRM] < 0 )
175
176 if( !std::isfinite( m_parameters[RHO_PRM] ) || m_parameters[RHO_PRM] < 0 )
178
179 if( !std::isfinite( m_parameters[H_PRM] ) || m_parameters[H_PRM] < 0 )
181
182 if( !std::isfinite( m_parameters[TWISTEDPAIR_TWIST_PRM] )
185
186 if( !std::isfinite( m_parameters[STRIPLINE_A_PRM] ) || m_parameters[STRIPLINE_A_PRM] <= 0 )
188
189 if( !std::isfinite( m_parameters[H_T_PRM] ) || m_parameters[H_T_PRM] <= 0 )
191
192 // How can we check ROUGH_PRM ?
193
194 if( !std::isfinite( m_parameters[MUR_PRM] ) || m_parameters[MUR_PRM] < 0 )
196
197 if( !std::isfinite( m_parameters[TWISTEDPAIR_EPSILONR_ENV_PRM] )
200
201 if( !std::isfinite( m_parameters[MURC_PRM] ) || m_parameters[MURC_PRM] < 0 )
203
204 if( !std::isfinite( m_parameters[FREQUENCY_PRM] ) || m_parameters[FREQUENCY_PRM] <= 0 )
206}
void setErrorLevel(PRMS_ID, char)
@function setErrorLevel
Definition: transline.cpp:432
@ TWISTEDPAIR_EPSILONR_ENV_PRM
Definition: transline.h:49
@ FREQUENCY_PRM
Definition: transline.h:51
@ RHO_PRM
Definition: transline.h:41
@ MUR_PRM
Definition: transline.h:48
@ STRIPLINE_A_PRM
Definition: transline.h:45
@ TAND_PRM
Definition: transline.h:40
@ H_T_PRM
Definition: transline.h:44
@ TWISTEDPAIR_TWIST_PRM
Definition: transline.h:43
@ EPSILONR_PRM
Definition: transline.h:39
@ H_PRM
Definition: transline.h:42
#define TRANSLINE_WARNING
Definition: transline.h:30

References EPSILONR_PRM, FREQUENCY_PRM, H_PRM, H_T_PRM, m_parameters, MUR_PRM, MURC_PRM, RHO_PRM, setErrorLevel(), STRIPLINE_A_PRM, TAND_PRM, TRANSLINE_WARNING, TWISTEDPAIR_EPSILONR_ENV_PRM, and TWISTEDPAIR_TWIST_PRM.

Referenced by analyze(), and synthesize().

◆ ellipk()

double TRANSLINE::ellipk ( double  k)
protected

Definition at line 321 of file transline.cpp.

322{
323 double r, lost;
324
325 ellipke( k, r, lost );
326 return r;
327}
void ellipke(double, double &, double &)
Definition: transline.cpp:256

References ellipke().

Referenced by COPLANAR::calcAnalyze().

◆ ellipke()

void TRANSLINE::ellipke ( double  arg,
double &  k,
double &  e 
)
protected

Definition at line 256 of file transline.cpp.

257{
258 int iMax = 16;
259
260 if( arg == 1.0 )
261 {
262 k = INFINITY; // infinite
263 e = 0;
264 }
265 else if( std::isinf( arg ) && arg < 0 )
266 {
267 k = 0;
268 e = INFINITY; // infinite
269 }
270 else
271 {
272 double a, b, c, fr, s, fk = 1, fe = 1, t, da = arg;
273 int i;
274
275 if( arg < 0 )
276 {
277 fk = 1 / sqrt( 1 - arg );
278 fe = sqrt( 1 - arg );
279 da = -arg / ( 1 - arg );
280 }
281
282 a = 1;
283 b = sqrt( 1 - da );
284 c = sqrt( da );
285 fr = 0.5;
286 s = fr * c * c;
287
288 for( i = 0; i < iMax; i++ )
289 {
290 t = ( a + b ) / 2;
291 c = ( a - b ) / 2;
292 b = sqrt( a * b );
293 a = t;
294 fr *= 2;
295 s += fr * c * c;
296
297 if( c / a < NR_EPSI )
298 break;
299 }
300
301 if( i >= iMax )
302 {
303 k = 0;
304 e = 0;
305 }
306 else
307 {
308 k = M_PI_2 / a;
309 e = M_PI_2 * ( 1 - s ) / a;
310 if( arg < 0 )
311 {
312 k *= fk;
313 e *= fe;
314 }
315 }
316 }
317}
#define NR_EPSI
Definition: transline.cpp:250
#define INFINITY
Definition: transline.cpp:35
#define M_PI_2
Definition: transline.cpp:40

References INFINITY, M_PI_2, and NR_EPSI.

Referenced by ellipk().

◆ getProperties()

void TRANSLINE::getProperties ( )

@function getProperties

Get all properties from the UI. Computes some extra ones.

Definition at line 147 of file transline.cpp.

148{
149 for( int i = 0; i < DUMMY_PRM; ++i )
150 {
151 m_parameters[i] = getProperty( (PRMS_ID) i );
153 }
154
158}
double getProperty(enum PRMS_ID aPrmId)
Definition: transline.cpp:137
double skin_depth()
@function skin_depth calculate skin depth
Definition: transline.cpp:234
@ EPSILON_EFF_PRM
Definition: transline.h:74
@ SIGMA_PRM
Definition: transline.h:69
@ SKIN_DEPTH_PRM
Definition: transline.h:70
PRMS_ID
Definition: transline.h:37
@ DUMMY_PRM
Definition: transline.h:61
#define TRANSLINE_OK
Definition: transline.h:29

References DUMMY_PRM, EPSILON_EFF_PRM, getProperty(), m_parameters, RHO_PRM, setErrorLevel(), SIGMA_PRM, skin_depth(), SKIN_DEPTH_PRM, and TRANSLINE_OK.

Referenced by analyze(), and synthesize().

◆ getProperty()

double TRANSLINE::getProperty ( enum PRMS_ID  aPrmId)

◆ Init()

void TRANSLINE::Init ( )

Definition at line 87 of file transline.cpp.

88{
89 wxColour wxcol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
90 okCol = KIGFX::COLOR4D( wxcol );
91 okCol.r = wxcol.Red() / 255.0;
92 okCol.g = wxcol.Green() / 255.0;
93 okCol.b = wxcol.Blue() / 255.0;
94 int i;
95 // Initialize these variables mainly to avoid warnings from a static analyzer
96 for( i = 0; i < EXTRA_PRMS_COUNT; ++i )
97 {
98 m_parameters[i] = 0;
99 }
100}
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
double r
Red component.
Definition: color4d.h:372
double g
Green component.
Definition: color4d.h:373
double b
Blue component.
Definition: color4d.h:374
KIGFX::COLOR4D okCol
Definition: transline.h:128
@ EXTRA_PRMS_COUNT
Definition: transline.h:75

References KIGFX::COLOR4D::b, EXTRA_PRMS_COUNT, KIGFX::COLOR4D::g, m_parameters, okCol, and KIGFX::COLOR4D::r.

Referenced by C_MICROSTRIP::C_MICROSTRIP(), COAX::COAX(), COPLANAR::COPLANAR(), MICROSTRIP::MICROSTRIP(), RECTWAVEGUIDE::RECTWAVEGUIDE(), STRIPLINE::STRIPLINE(), TRANSLINE(), and TWISTEDPAIR::TWISTEDPAIR().

◆ isSelected()

bool TRANSLINE::isSelected ( enum PRMS_ID  aPrmId)

◆ minimizeZ0Error1D()

bool TRANSLINE::minimizeZ0Error1D ( double *  aVar)
protected

@function minimizeZ0Error1D

Tries to find a parameter that minimizes the error ( on Z0 ). This function only works with a single parameter. Calls calcAnalyze several times until the error is acceptable. While the error is unnacceptable, changes slightly the parameter.

This function does not change Z0 / Angl_L.

Parameters
avarParameter to synthesize
Returns
'true' if error < MAX_ERROR, else 'false'

Definition at line 346 of file transline.cpp.

347{
348 double Z0_dest, Z0_current, Z0_result, angl_l_dest, increment, slope, error;
349 int iteration;
350
351 if( !std::isfinite( m_parameters[Z0_PRM] ) )
352 {
353 *aVar = NAN;
354 return false;
355 }
356
357 if( ( !std::isfinite( *aVar ) ) || ( *aVar == 0 ) )
358 *aVar = 0.001;
359
360 /* required value of Z0 */
361 Z0_dest = m_parameters[Z0_PRM];
362
363 /* required value of angl_l */
364 angl_l_dest = m_parameters[ANG_L_PRM];
365
366 /* Newton's method */
367 iteration = 0;
368
369 /* compute parameters */
370 calcAnalyze();
371 Z0_current = m_parameters[Z0_PRM];
372
373 error = fabs( Z0_dest - Z0_current );
374
375 while( error > MAX_ERROR )
376 {
377 iteration++;
378 increment = *aVar / 100.0;
379 *aVar += increment;
380 /* compute parameters */
381 calcAnalyze();
382 Z0_result = m_parameters[Z0_PRM];
383 /* f(w(n)) = Z0 - Z0(w(n)) */
384 /* f'(w(n)) = -f'(Z0(w(n))) */
385 /* f'(Z0(w(n))) = (Z0(w(n)) - Z0(w(n+delw))/delw */
386 /* w(n+1) = w(n) - f(w(n))/f'(w(n)) */
387 slope = ( Z0_result - Z0_current ) / increment;
388 slope = ( Z0_dest - Z0_current ) / slope - increment;
389 *aVar += slope;
390
391 if( *aVar <= 0.0 )
392 *aVar = increment;
393
394 /* find new error */
395 /* compute parameters */
396 calcAnalyze();
397 Z0_current = m_parameters[Z0_PRM];
398 error = fabs( Z0_dest - Z0_current );
399
400 if( iteration > 100 )
401 break;
402 }
403
404 /* Compute one last time, but with correct length */
405 m_parameters[Z0_PRM] = Z0_dest;
406 m_parameters[ANG_L_PRM] = angl_l_dest;
409 / 2.0 / M_PI; /* in m */
410 calcAnalyze();
411
412 /* Restore parameters */
413 m_parameters[Z0_PRM] = Z0_dest;
414 m_parameters[ANG_L_PRM] = angl_l_dest;
417 / 2.0 / M_PI; /* in m */
418 return error <= MAX_ERROR;
419}
#define MAX_ERROR
Definition: transline.cpp:329
@ Z0_PRM
Definition: transline.h:52
@ PHYS_LEN_PRM
Definition: transline.h:60
@ ANG_L_PRM
Definition: transline.h:55
#define C0
Definition: units.h:61

References ANG_L_PRM, C0, calcAnalyze(), EPSILON_EFF_PRM, FREQUENCY_PRM, m_parameters, MAX_ERROR, PHYS_LEN_PRM, and Z0_PRM.

Referenced by COPLANAR::calcSynthesize(), MICROSTRIP::calcSynthesize(), STRIPLINE::calcSynthesize(), and TWISTEDPAIR::calcSynthesize().

◆ setErrorLevel()

void TRANSLINE::setErrorLevel ( PRMS_ID  aP,
char  aErrorLevel 
)
protected

@function setErrorLevel

set an error / warning level for a given parameter.

See also
TRANSLINE_OK
TRANSLINE_WARNING
TRANSLINE_ERROR
Parameters
aPparameter
aErrorLevelError level

Definition at line 432 of file transline.cpp.

433{
434 switch( aErrorLevel )
435 {
438 default: SetPropertyBgColorInDialog( aP, &okCol ); break;
439 }
440}
KIGFX::COLOR4D warnCol
Definition: transline.h:127
KIGFX::COLOR4D errCol
Definition: transline.h:126
void SetPropertyBgColorInDialog(enum PRMS_ID aPrmId, const KIGFX::COLOR4D *aCol)
Function SetPropertyBgColorInDialog Set the background color of a parameter.
#define TRANSLINE_ERROR
Definition: transline.h:31

References errCol, okCol, SetPropertyBgColorInDialog(), TRANSLINE_ERROR, TRANSLINE_WARNING, and warnCol.

Referenced by checkProperties(), getProperties(), C_MICROSTRIP::showAnalyze(), COAX::showAnalyze(), COPLANAR::showAnalyze(), MICROSTRIP::showAnalyze(), RECTWAVEGUIDE::showAnalyze(), STRIPLINE::showAnalyze(), TWISTEDPAIR::showAnalyze(), C_MICROSTRIP::showSynthesize(), COAX::showSynthesize(), COPLANAR::showSynthesize(), MICROSTRIP::showSynthesize(), RECTWAVEGUIDE::showSynthesize(), STRIPLINE::showSynthesize(), and TWISTEDPAIR::showSynthesize().

◆ setProperty()

◆ setResult() [1/2]

void TRANSLINE::setResult ( int  line,
const char *  text 
)

Definition at line 124 of file transline.cpp.

125{
126 SetResultInDialog( line, text );
127}
void SetResultInDialog(int line, const char *text)

References SetResultInDialog(), and text.

◆ setResult() [2/2]

void TRANSLINE::setResult ( int  line,
double  value,
const char *  text 
)

◆ show_results()

virtual void TRANSLINE::show_results ( )
inlinevirtual

Shows results.

Reimplemented in C_MICROSTRIP, COAX, COPLANAR, MICROSTRIP, RECTWAVEGUIDE, STRIPLINE, and TWISTEDPAIR.

Definition at line 122 of file transline.h.

122{}

Referenced by analyze(), and synthesize().

◆ showAnalyze()

virtual void TRANSLINE::showAnalyze ( )
inlinevirtual

Shows synthesis results and checks for errors / warnings.

Reimplemented in C_MICROSTRIP, COAX, COPLANAR, MICROSTRIP, RECTWAVEGUIDE, STRIPLINE, and TWISTEDPAIR.

Definition at line 112 of file transline.h.

112{}

Referenced by analyze().

◆ showSynthesize()

virtual void TRANSLINE::showSynthesize ( )
inlinevirtual

Shows analysis results and checks for errors / warnings.

Reimplemented in C_MICROSTRIP, COAX, COPLANAR, MICROSTRIP, RECTWAVEGUIDE, STRIPLINE, and TWISTEDPAIR.

Definition at line 117 of file transline.h.

117{}

Referenced by synthesize().

◆ skin_depth()

double TRANSLINE::skin_depth ( )
protected

@function skin_depth calculate skin depth

$ \frac{1}{\sqrt{ \pi \cdot f \cdot \mu \cdot \sigma }} $

Definition at line 234 of file transline.cpp.

235{
236 double depth;
237 depth = 1.0
240 return depth;
241}
#define MU0
Definition: units.h:60

References FREQUENCY_PRM, m_parameters, MU0, MURC_PRM, and SIGMA_PRM.

Referenced by C_MICROSTRIP::attenuation(), MICROSTRIP::attenuation(), COPLANAR::calcAnalyze(), STRIPLINE::calcAnalyze(), and getProperties().

◆ synthesize()

void TRANSLINE::synthesize ( )
virtual

Definition at line 217 of file transline.cpp.

218{
223 show_results();
224}
virtual void showSynthesize()
Shows analysis results and checks for errors / warnings.
Definition: transline.h:117
virtual void calcSynthesize()
Computation for synthesis.
Definition: transline.h:107

References calcSynthesize(), checkProperties(), getProperties(), show_results(), and showSynthesize().

Referenced by PANEL_TRANSLINE::OnTranslineSynthetize().

Member Data Documentation

◆ errCol

KIGFX::COLOR4D TRANSLINE::errCol = KIGFX::COLOR4D( 1, 0.63, 0.63, 1 )

Definition at line 126 of file transline.h.

Referenced by setErrorLevel().

◆ m_Name

◆ m_parameters

double TRANSLINE::m_parameters[EXTRA_PRMS_COUNT]
protected

Definition at line 131 of file transline.h.

Referenced by RECTWAVEGUIDE::alphac(), COAX::alphac_coax(), RECTWAVEGUIDE::alphad(), COAX::alphad_coax(), C_MICROSTRIP::attenuation(), MICROSTRIP::attenuation(), COAX::calcAnalyze(), COPLANAR::calcAnalyze(), RECTWAVEGUIDE::calcAnalyze(), STRIPLINE::calcAnalyze(), TWISTEDPAIR::calcAnalyze(), C_MICROSTRIP::calcSynthesize(), COAX::calcSynthesize(), COPLANAR::calcSynthesize(), MICROSTRIP::calcSynthesize(), RECTWAVEGUIDE::calcSynthesize(), STRIPLINE::calcSynthesize(), TWISTEDPAIR::calcSynthesize(), checkProperties(), C_MICROSTRIP::compute_single_line(), C_MICROSTRIP::conductor_losses(), MICROSTRIP::conductor_losses(), C_MICROSTRIP::delta_u_thickness(), C_MICROSTRIP::dielectric_losses(), MICROSTRIP::dielectric_losses(), MICROSTRIP::dispersion(), C_MICROSTRIP::er_eff_freq(), C_MICROSTRIP::er_eff_static(), RECTWAVEGUIDE::fc(), RECTWAVEGUIDE::get_rectwaveguide_comp(), RECTWAVEGUIDE::get_rectwaveguide_elec(), RECTWAVEGUIDE::get_rectwaveguide_phys(), RECTWAVEGUIDE::get_rectwaveguide_sub(), getProperties(), Init(), RECTWAVEGUIDE::kc_square(), RECTWAVEGUIDE::kval_square(), C_MICROSTRIP::line_angle(), MICROSTRIP::line_angle(), STRIPLINE::lineImpedance(), MICROSTRIP::microstrip_Z0(), minimizeZ0Error1D(), MICROSTRIP::mur_eff_ms(), C_MICROSTRIP::show_results(), COAX::show_results(), COPLANAR::show_results(), MICROSTRIP::show_results(), RECTWAVEGUIDE::show_results(), STRIPLINE::show_results(), TWISTEDPAIR::show_results(), C_MICROSTRIP::showAnalyze(), COAX::showAnalyze(), COPLANAR::showAnalyze(), MICROSTRIP::showAnalyze(), RECTWAVEGUIDE::showAnalyze(), STRIPLINE::showAnalyze(), TWISTEDPAIR::showAnalyze(), C_MICROSTRIP::showSynthesize(), COAX::showSynthesize(), COPLANAR::showSynthesize(), MICROSTRIP::showSynthesize(), RECTWAVEGUIDE::showSynthesize(), STRIPLINE::showSynthesize(), TWISTEDPAIR::showSynthesize(), skin_depth(), C_MICROSTRIP::syn_fun(), C_MICROSTRIP::synth_width(), MICROSTRIP::synth_width(), TRANSLINE(), C_MICROSTRIP::Z0_dispersion(), and C_MICROSTRIP::Z0_even_odd().

◆ okCol

KIGFX::COLOR4D TRANSLINE::okCol = KIGFX::COLOR4D( 1, 1, 1, 1 )

Definition at line 128 of file transline.h.

Referenced by Init(), and setErrorLevel().

◆ warnCol

KIGFX::COLOR4D TRANSLINE::warnCol = KIGFX::COLOR4D( 1, 1, 0.57, 1 )

Definition at line 127 of file transline.h.

Referenced by setErrorLevel().


The documentation for this class was generated from the following files: