Imported Upstream version 4.6.0
[debian/atlc] / src / non_gui / calculate_Zodd_and_Zeven.c
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 ntlworld.com 
22
23 */
24
25 /* The following calculates the odd and even mode impedances between two
26 zero thickness strips of width w, spaced a distance s between two
27 groundplanes of spacing h. */
28
29 #include "config.h"
30
31 #include "gsl_types.h"
32 #include "gsl_definitions.h"
33 #include "definitions.h"
34
35 #ifdef HAVE_STDLIB_H
36 #include <stdlib.h>
37 #endif
38
39 #ifdef HAVE_MATH_H
40 #include <math.h>
41 #endif
42
43 #include "exit_codes.h"
44 /* formuals taken from Matthaei, Young and Jones, Microwave Filters, Impedance Matching
45 Networks and Coupling Structures, Artech House, Dedham, MA., 1980. , but I've substituted
46 29.97924580105028, as its clear 30 is just a close approximation */
47
48 void calculate_Zodd_and_Zeven(double *Zodd, double *Zeven, double *Zo, double w, double H, double s, double er)
49 {
50   double ke, ko, ko_dash, ke_dash;
51   ke=(tanh((M_PI/2)*(w/H)))*tanh((M_PI/2)*(w+s)/H);
52   ko=(tanh((M_PI/2)*(w/H)))/tanh((M_PI/2)*(w+s)/H);
53
54   ke_dash=sqrt(1-ke*ke);
55   ko_dash=sqrt(1-ko*ko);
56
57   *Zeven=29.9792458010502837*M_PI*gsl_sf_ellint_Kcomp(ke_dash, GSL_PREC_DOUBLE)/(gsl_sf_ellint_Kcomp(ke,GSL_PREC_DOUBLE)*sqrt(er));
58   *Zodd= 29.9792458010502837*M_PI*gsl_sf_ellint_Kcomp(ko_dash, GSL_PREC_DOUBLE)/(gsl_sf_ellint_Kcomp(ko,GSL_PREC_DOUBLE)*sqrt(er));
59   *Zo=sqrt( (*Zodd)*(*Zeven));
60 }