KiCad PCB EDA Suite
coax.cpp
Go to the documentation of this file.
1 /*
2  * coax.cpp - coaxial class implementation
3  *
4  * Copyright (C) 2001 Gopal Narayanan <[email protected]>
5  * Copyright (C) 2002 Claudio Girardi <[email protected]>
6  * Copyright (C) 2005, 2006 Stefan Jahn <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this package; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 
26 /*
27  * coax.c - Puts up window for microstrip and
28  * performs the associated calculations
29  */
30 #include <cmath>
31 
32 #include <wx/string.h>
33 
34 #include "coax.h"
35 #include "units.h"
36 
38 {
39  m_Name = "Coax";
40  Init();
41 }
42 
44 {
45  double ad;
46 
47  ad = ( M_PI / C0 ) * m_parameters[FREQUENCY_PRM] * sqrt( m_parameters[EPSILONR_PRM] )
49  ad = ad * 20.0 / log( 10.0 );
50  return ad;
51 }
52 
53 
55 {
56  double ac, Rs;
57 
58  Rs = sqrt( M_PI * m_parameters[FREQUENCY_PRM] * m_parameters[MURC_PRM] * MU0
60  ac = sqrt( m_parameters[EPSILONR_PRM] )
63  * ( Rs / ZF0 );
64  ac = ac * 20.0 / log( 10.0 );
65  return ac;
66 }
67 
68 
77 {
78  double lambda_g;
79 
80 
82  ( ZF0 / 2 / M_PI / sqrt( m_parameters[EPSILONR_PRM] ) )
84 
85  lambda_g = ( C0 / ( m_parameters[FREQUENCY_PRM] ) )
87  /* calculate electrical angle */
89  ( 2.0 * M_PI * m_parameters[PHYS_LEN_PRM] ) / lambda_g; /* in radians */
90 }
91 
92 
103 {
104  double lambda_g;
105 
107  {
108  /* solve for din */
111  / exp( m_parameters[Z0_PRM] * sqrt( m_parameters[EPSILONR_PRM] ) / ZF0 * 2 * M_PI );
112  }
113  else if( isSelected( PHYS_DIAM_OUT_PRM ) )
114  {
115  /* solve for dout */
118  * exp( m_parameters[Z0_PRM] * sqrt( m_parameters[EPSILONR_PRM] ) / ZF0 * 2 * M_PI );
119  }
120 
121  lambda_g = ( C0 / ( m_parameters[FREQUENCY_PRM] ) )
123  /* calculate physical length */
124  m_parameters[PHYS_LEN_PRM] = ( lambda_g * m_parameters[ANG_L_PRM] ) / ( 2.0 * M_PI ); /* in m */
125 }
126 
127 
129 {
132 
133  // Check for errors
134  if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
136 
137  if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
139 
140  // Find warnings to display - physical parameters
141  if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
143 
144  if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
145  || m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
146  {
148  }
149 
151  {
154  }
155 
156  if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
158 }
159 
161 {
164  else if( isSelected( PHYS_DIAM_OUT_PRM ) )
166 
168 
169  // Check for errors
170  if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
171  {
174  else
176  }
177 
178  if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
179  || m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
180  {
183  else
185  }
186 
188  {
191  else if( isSelected( PHYS_DIAM_OUT_PRM ) )
193  }
194 
195  if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
197 
198  // Check for warnings
199  if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
201 
202  if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
204 }
205 /*
206  * show_results() - show results
207  */
209 {
210  int m, n;
211  wxString text;
212 
215 
217  setResult( 1, m_parameters[LOSS_CONDUCTOR_PRM], wxT( "dB" ) );
218  setResult( 2, m_parameters[LOSS_DIELECTRIC_PRM], wxT( "dB" ) );
219 
220  n = 1;
222  C0
223  / ( M_PI * ( m_parameters[PHYS_DIAM_OUT_PRM] + m_parameters[MUR_PRM] ) / (double) n );
224 
226  {
227  text = wxT( "none" );
228  }
229  else
230  {
231  text = wxT( " H(1,1) " );
232  m = 2;
234  C0
236  / ( m - 1 ) );
237 
238  while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
239  {
240  text << wxString::Format( wxT( "H(n,%d) " ), m );
241  m++;
243  C0
245  / (double) ( m - 1 ) );
246  }
247  }
248  setResult( 3, text );
249 
250  m = 1;
252  C0 / ( 2 * ( m_parameters[PHYS_DIAM_OUT_PRM] - m_parameters[MUR_PRM] ) / (double) m );
254  {
255  text = wxT( "none" );
256  }
257  else
258  {
259  text.Clear();
260 
261  while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
262  {
263  text << wxString::Format( wxT( "E(n,%d) " ), m );
264  m++;
266  C0
268  / (double) m );
269  }
270  }
271  setResult( 4, text );
272 }
bool isSelected(enum PRMS_ID aPrmId)
Definition: transline.cpp:127
double alphad_coax()
Definition: coax.cpp:43
void setResult(int, const wxString &)
Definition: transline.cpp:135
void Init()
Definition: transline.cpp:98
#define MU0
Definition: units.h:60
void calcAnalyze() override
Definition: coax.cpp:76
void setProperty(enum PRMS_ID aPrmId, double aValue)
Definition: transline.cpp:117
#define ZF0
Definition: units.h:62
double m_parameters[EXTRA_PRMS_COUNT]
Definition: transline.h:131
COAX()
Definition: coax.cpp:37
void show_results() override
Shows results.
Definition: coax.cpp:208
void calcSynthesize() override
Definition: coax.cpp:102
void showAnalyze() override
Shows synthesis results and checks for errors / warnings.
Definition: coax.cpp:128
const char * m_Name
Definition: transline.h:84
double alphac_coax()
Definition: coax.cpp:54
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define C0
Definition: units.h:61
#define TRANSLINE_ERROR
Definition: transline.h:31
void showSynthesize() override
Shows analysis results and checks for errors / warnings.
Definition: coax.cpp:160
#define TRANSLINE_WARNING
Definition: transline.h:30
void setErrorLevel(PRMS_ID, char)
@function setErrorLevel
Definition: transline.cpp:443