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#include <cstdio>
32#include <cstdlib>
33#include <cstring>
34
35#include "coax.h"
36#include "units.h"
37
39{
40 m_Name = "Coax";
41 Init();
42}
43
45{
46 double ad;
47
48 ad = ( M_PI / C0 ) * m_parameters[FREQUENCY_PRM] * sqrt( m_parameters[EPSILONR_PRM] )
50 ad = ad * 20.0 / log( 10.0 );
51 return ad;
52}
53
54
56{
57 double ac, Rs;
58
59 Rs = sqrt( M_PI * m_parameters[FREQUENCY_PRM] * m_parameters[MURC_PRM] * MU0
61 ac = sqrt( m_parameters[EPSILONR_PRM] )
64 * ( Rs / ZF0 );
65 ac = ac * 20.0 / log( 10.0 );
66 return ac;
67}
68
69
78{
79 double lambda_g;
80
81
83 ( ZF0 / 2 / M_PI / sqrt( m_parameters[EPSILONR_PRM] ) )
85
86 lambda_g = ( C0 / ( m_parameters[FREQUENCY_PRM] ) )
88 /* calculate electrical angle */
90 ( 2.0 * M_PI * m_parameters[PHYS_LEN_PRM] ) / lambda_g; /* in radians */
91}
92
93
104{
105 double lambda_g;
106
108 {
109 /* solve for din */
112 / exp( m_parameters[Z0_PRM] * sqrt( m_parameters[EPSILONR_PRM] ) / ZF0 * 2 * M_PI );
113 }
114 else if( isSelected( PHYS_DIAM_OUT_PRM ) )
115 {
116 /* solve for dout */
119 * exp( m_parameters[Z0_PRM] * sqrt( m_parameters[EPSILONR_PRM] ) / ZF0 * 2 * M_PI );
120 }
121
122 lambda_g = ( C0 / ( m_parameters[FREQUENCY_PRM] ) )
124 /* calculate physical length */
125 m_parameters[PHYS_LEN_PRM] = ( lambda_g * m_parameters[ANG_L_PRM] ) / ( 2.0 * M_PI ); /* in m */
126}
127
128
130{
133
134 // Check for errors
135 if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
137
138 if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
140
141 // Find warnings to display - physical parameters
142 if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
144
145 if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
147 {
149 }
150
152 {
155 }
156
157 if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
159}
160
162{
165 else if( isSelected( PHYS_DIAM_OUT_PRM ) )
167
169
170 // Check for errors
171 if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
172 {
175 else
177 }
178
179 if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
181 {
184 else
186 }
187
189 {
192 else if( isSelected( PHYS_DIAM_OUT_PRM ) )
194 }
195
196 if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
198
199 // Check for warnings
200 if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
202
203 if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
205}
206/*
207 * show_results() - show results
208 */
210{
211 int m, n;
212 char text[256], txt[256];
213
216
220
221 n = 1;
223 C0
224 / ( M_PI * ( m_parameters[PHYS_DIAM_OUT_PRM] + m_parameters[MUR_PRM] ) / (double) n );
225
227 {
228 strcpy( text, "none" );
229 }
230 else
231 {
232 strcpy( text, "H(1,1) " );
233 m = 2;
235 C0
237 / (double) ( m - 1 ) );
238
239 while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
240 {
241 sprintf( txt, "H(n,%d) ", m );
242 strcat( text, txt );
243 m++;
245 C0
247 / (double) ( m - 1 ) );
248 }
249 }
250 setResult( 3, text );
251
252 m = 1;
254 C0 / ( 2 * ( m_parameters[PHYS_DIAM_OUT_PRM] - m_parameters[MUR_PRM] ) / (double) m );
256 {
257 strcpy( text, "none" );
258 }
259 else
260 {
261 strcpy( text, "" );
262
263 while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
264 {
265 sprintf( txt, "E(n,%d) ", m );
266 strcat( text, txt );
267 m++;
269 C0
271 / (double) m );
272 }
273 }
274 setResult( 4, text );
275}
void calcSynthesize() override
Definition: coax.cpp:103
void calcAnalyze() override
Definition: coax.cpp:77
double alphac_coax()
Definition: coax.cpp:55
double alphad_coax()
Definition: coax.cpp:44
void showAnalyze() override
Shows synthesis results and checks for errors / warnings.
Definition: coax.cpp:129
void showSynthesize() override
Shows analysis results and checks for errors / warnings.
Definition: coax.cpp:161
void show_results() override
Shows results.
Definition: coax.cpp:209
COAX()
Definition: coax.cpp:38
bool isSelected(enum PRMS_ID aPrmId)
Definition: transline.cpp:119
void Init()
Definition: transline.cpp:90
void setResult(int, double, const char *)
Definition: transline.cpp:133
double m_parameters[EXTRA_PRMS_COUNT]
Definition: transline.h:131
const char * m_Name
Definition: transline.h:84
void setProperty(enum PRMS_ID aPrmId, double aValue)
Definition: transline.cpp:109
void setErrorLevel(PRMS_ID, char)
@function setErrorLevel
Definition: transline.cpp:435
@ LOSS_DIELECTRIC_PRM
Definition: transline.h:71
@ LOSS_CONDUCTOR_PRM
Definition: transline.h:72
@ SIGMA_PRM
Definition: transline.h:69
@ CUTOFF_FREQUENCY_PRM
Definition: transline.h:73
@ FREQUENCY_PRM
Definition: transline.h:51
@ PHYS_DIAM_OUT_PRM
Definition: transline.h:59
@ MURC_PRM
Definition: transline.h:50
@ MUR_PRM
Definition: transline.h:48
@ Z0_PRM
Definition: transline.h:52
@ TAND_PRM
Definition: transline.h:40
@ PHYS_LEN_PRM
Definition: transline.h:60
@ ANG_L_PRM
Definition: transline.h:55
@ PHYS_DIAM_IN_PRM
Definition: transline.h:57
@ EPSILONR_PRM
Definition: transline.h:39
#define TRANSLINE_WARNING
Definition: transline.h:30
#define TRANSLINE_ERROR
Definition: transline.h:31
#define ZF0
Definition: units.h:62
#define MU0
Definition: units.h:60
#define C0
Definition: units.h:61