1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
3
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 USA.
20
21 Dr. David Kirkby, e-mail drkirkby at gmail.com
22
23 */
24 #include "config.h"
25
26 #ifdef HAVE_STDLIB_H
27 #include <stdlib.h>
28 #endif
29
30 #ifdef HAVE_MATH_H
31 #include <math.h>
32 #endif
33
34 #ifdef HAVE_STRING_H
35 #include <string.h>
36 #endif
37
38 #ifdef HAVE_STRINGS_H
39 #include <strings.h>
40 #endif
41
42 #include "exit_codes.h"
43 #include "definitions.h"
44
45 #ifdef WINDOWS
46 #pragma hrdstop
47 #include <condefs.h>
48 #endif
49
50 double aa, bb, cc, dd, hh, ww, DD, WW, HH, Er1, Er2;
51 int a, b, c, d, h, w, D, W, H;
52
53 int verbose=FALSE;
54 int lowest=50, highest=100;
55
56 /* The following are only needed so that I can link in both
57 convert_create_bmp_for_circ_in_circ_dimensions_to_integers.c
58 and convert_create_bmp_for_rect_in_rect_dimensions_to_integers.c
59 */
60
61
main(int argc,char ** argv)62 int main(int argc, char **argv) /* Read parameters from command line here */
63 {
64 int bmp_size=DEFAULT_BMP_SIZE;
65 int q;
66 FILE *image_data_fp;
67 char *filename;
68 struct transmission_line_properties not_used;
69 double Zo, x;
70 filename=string(0,1010);
71
72 /* The following line just prevents a warning from the compiler (SGI's to
73 be precise). There is not reason to set W=1 */
74 not_used.W=1;
75
76 while((q=get_options(argc,argv,"Cb:v")) != -1)
77 switch (q)
78 {
79 case 'C':
80 print_copyright((char *) "2002");
81 exit_with_msg_and_exit_code("",OKAY);
82 break;
83 case 'b':
84 bmp_size=atol(my_optarg);
85 break;
86 case 'v':
87 verbose=TRUE;
88 break;
89 case '?':
90 break;
91 }
92 if(argc-my_optind == 5)
93 {
94 DD=atof(argv[my_optind]);
95 WW=HH=DD;
96 dd=atof(argv[my_optind+1]);
97 hh=atof(argv[my_optind+2]);
98 Er1=atof(argv[my_optind+3]);
99 if( dd > DD)
100 exit_with_msg_and_exit_code("Error: The Inner conductor is larger than the outer conductor!!!", 1);
101 else if (DD == dd)
102 exit_with_msg_and_exit_code("Error: The inner and outer conductors are of the same size!!!", 1);
103 else if (dd/2 + hh >= DD/2)
104 exit_with_msg_and_exit_code("Error: The inner and outer conductors will touch!!!", 1);
105 filename=strncpy(filename, argv[my_optind+4],1000);
106 if( (image_data_fp=fopen(filename,"wb")) == NULL)
107 exit_with_msg_and_exit_code("Can't open file in create_bmp_for_circ_in_circ.c", CANT_OPEN_FOR_WRITING);
108 check_parameters_of_create_bmp_for_circ_in_circ();
109 convert_create_bmp_for_circ_in_circ_dimensions_to_integers(bmp_size);
110 write_bitmap(image_data_fp, not_used);
111 x=(double) (d*d+D*D-4*h*h)/(2*D*d);
112 Zo=59.9585*log(x+sqrt(x*x-1))/sqrt(Er1);
113 Zo=log(x+sqrt(x*x-1))/(1000*sqrt(EPSILON_0)*sqrt(Er1)*sqrt(10*M_PI));
114
115 if(verbose == TRUE)
116 {
117 printf("DD=%f dd=%f hh=%f x=%f\n",DD, dd, hh, x);
118 printf("D=%d d=%d h=%d x=%f\n",D, d, h, x);
119 printf("Zo is theoretically %f Ohms\n",Zo);
120 }
121 }
122 else
123 usage_create_bmp_for_circ_in_circ();
124 free_string(filename,0,1010);
125 return(OKAY);
126 }
127