Imported Upstream version 4.6.0
[debian/atlc] / src / non_gui / swap_conductor_voltages.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 /* When calculationg the properties of couplers it is necessary to swap
26 around the voltages on the conductors. First we consider the voltages as
27 present, which will be positive and negative. Next the negative pixels
28 must be changed to positive, to calculate the even mode impedance. This
29 routine does the swapping around, based on the value of the parameter
30 oddity, which will be set to CONDUCTOR_PLUS_ONE_V or
31
32 CONDUCTOR_MINUS_ONE_V in definitions.h */
33
34 #include "config.h"
35
36 #include "definitions.h"
37
38 extern int width, height;
39 unsigned char **oddity;
40 extern double **Vij;
41
42 /* This swaps any conductor orignally at -1 V to +1 V. Any
43 dielectric is set to zero volts. This is used in computation
44 of couplers. */
45
46 void swap_conductor_voltages()
47 {
48   int i, j;
49   int pixel;
50   for(i=0;i<width;++i)
51   {
52     for(j=0;j<height;++j)
53     {
54       pixel=oddity[i][j];
55       if(pixel==CONDUCTOR_MINUS_ONE_V){
56         Vij[i][j]=+1.0;
57         oddity[i][j]=CONDUCTOR_PLUS_ONE_V;
58       }
59     }
60   }
61 }