Imported Upstream version 4.6.0
[debian/atlc] / tools / src / dualcoax.c
1 /*
2 atlc - arbitrary transmission line calculator, for the analysis of
3 transmission lines are directional couplers. 
4
5 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either package_version 2
10 of the License, or (at your option) any later package_version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
20 USA.
21
22 Dr. David Kirkby, e-mail drkirkby at ntlworld.com 
23
24 */
25
26
27 /* dualcoax attempts to find the properties of a coaxial cable with two
28 concentric dielectrics between the inner and outer conductors, and so
29 can be used as a useful test for atlc */
30
31 #include "config.h"
32
33 #ifdef HAVE_STDIO_H
34 #include <stdio.h>
35 #endif
36
37 #ifdef HAVE_STDLIB_H
38 #include <stdlib.h>
39 #endif
40
41 #ifdef HAVE_MATH_H
42 #include <math.h>
43 #endif
44
45 #define MU_0 4*M_PI*1e-7
46 #define EPSILON_0 8.854187817e-12 /* Data taken from NPL */
47
48
49 int main (int argc, char **argv)
50 {
51   double velocity, velocity_factor, r0, r1, r2, er1, er2, c, l, zo;
52
53   if (argc != 6)
54   {
55     fprintf(stderr,"Find properties of a coaxial cable with two different concentric dielectrics.\n\n");
56     fprintf(stderr,"Usage: dualcoax D1 D2 D3 Er1 Er2\n");
57     fprintf(stderr,"dualcoax %s: arguments are:\n",PACKAGE_VERSION);
58     fprintf(stderr,"       D1 is the diameter of the inner conductor\n"); 
59     fprintf(stderr,"       D2 is the outer diameter of the inner dielectic\n"); 
60     fprintf(stderr,"       D3 is the inner diameter of the outer conductor\n"); 
61     fprintf(stderr,"       Er1 is the permittivity of the inner dielectric\n"); 
62     fprintf(stderr,"       Er2 is the permittivity of the outer dielectric\n"); 
63     exit(1);
64   }
65   r0=atof(argv[1])/2.0;
66   r1=atof(argv[2])/2.0;
67   r2=atof(argv[3])/2.0;
68   er1=atof(argv[4]);
69   er2=atof(argv[5]);
70   if ( r0 >= r1){
71     fprintf(stderr,"Sorry, the diameter of the inner conductor (d0) must be\n");
72     fprintf(stderr,"less than the outer diameter of the inner dielectic (d1)\n");
73     exit(1);
74   }
75   if ( r1 >= r2){
76     fprintf(stderr,"Sorry, the diameter of the inner dielectric (d1) must be\n");
77     fprintf(stderr,"less than the inner diameter of the outer conductor (d2)\n");
78     exit(1);
79   }
80   if (er1 < 1.0 ){
81     fprintf(stderr,"Sorry, the permittivity of the inner dielectric Er1 must be >=1");
82     exit(1);
83   }
84   if (er2 < 1.0 ){
85     fprintf(stderr,"Sorry, the permittivity of the outer dielectric Er2 must be >=1");
86     exit(1);
87   }
88   c=2*M_PI*er1*er2*EPSILON_0/(er1*log(r2/r1)+er2*log(r1/r0));
89   l=MU_0*log(r2/r0)/(2*M_PI);
90   zo=sqrt(l/c);
91   velocity_factor=(er1*er2*log(r2/r1))/(er1*log(r2/r1)+er2*log(r1/r0));
92   velocity=1.0/(velocity_factor*sqrt(MU_0 * EPSILON_0));
93   printf("Zo = %8.3f Ohms C= %8.3f pF/m L= %8.3f nH/m v= %g m/s v_f= %8.3f\n", zo,c*1e12,l*1e9, velocity, velocity_factor);
94   return(0);
95
96 }