1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
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.
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.
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,
21 Dr. David Kirkby, e-mail drkirkby at gmail.com
26 #include "definitions.h"
28 extern int width, height;
29 extern unsigned char **oddity;
30 extern double **Er, **Vij;
32 void find_maximum_values(struct max_values *maximum_values, int zero_elementsQ)
34 double U, V, Ex, Ey, E, permittivity;
37 /* It makes sense to draw the even and odd mode images on the same
38 scale, so if its a coupler, they elements are not zeroed if the
39 function is called when doing the even mode, which is done
42 if(zero_elementsQ==ZERO_ELEMENTS_FIRST)
44 maximum_values->E_max=0.0;
45 maximum_values->Ex_or_Ey_max=0.0;
46 maximum_values->V_max=0.0;
47 maximum_values->U_max=0.0;
48 maximum_values->permittivity_max=0.0;
55 U=find_energy_per_metre(i,j);
59 Ex=2*Er[i+1][j]*(Vij[i][j]-Vij[i+1][j])/(Er[i+1][j]+Er[i][j]);
61 Ex=2*Er[i-1][j]*(Vij[i-1][j]-Vij[i][j])/(Er[i-1][j]+Er[i][j]);
62 else /* This is the best estimate, but can't be done on boundary */
64 Ex=Er[i-1][j]*(Vij[i-1][j]-Vij[i][j])/(Er[i-1][j]+Er[i][j]);
65 Ex+=Er[i+1][j]*(Vij[i][j]-Vij[i+1][j])/(Er[i+1][j]+Er[i][j]);
68 Ey=2*Er[i][j+1]*(Vij[i][j]-Vij[i][j+1])/(Er[i][j+1]+Er[i][j]);
70 Ey=2*Er[i][j-1]*(Vij[i][j-1]-Vij[i][j])/(Er[i][j-1]+Er[i][j]);
73 Ey=Er[i][j-1]*(Vij[i][j-1]-Vij[i][j])/(Er[i][j-1]+Er[i][j]);
74 Ey+=Er[i][j+1]*(Vij[i][j]-Vij[i][j+1])/(Er[i][j+1]+Er[i][j]);
77 permittivity=Er[i][j];
87 printf("U=%f v=%f Er=%f at %d %d\n",U,V,Er[i][j],i, j);
89 if(E>maximum_values->E_max)
90 maximum_values->E_max=E;
93 if(fabs(Ex)>maximum_values->Ex_or_Ey_max)
94 maximum_values->Ex_or_Ey_max=fabs(Ex);
96 if(fabs(Ey)>maximum_values->Ex_or_Ey_max)
97 maximum_values->Ex_or_Ey_max=fabs(Ey);
99 if(fabs(E)>maximum_values->E_max)
100 maximum_values->E_max=fabs(E);
102 if(fabs(V) > maximum_values->V_max)
103 maximum_values->V_max=fabs(V);
105 if(U > maximum_values->U_max)
106 maximum_values->U_max=U;
108 if(permittivity >maximum_values->permittivity_max )
109 maximum_values->permittivity_max=permittivity;
110 /* printf("Ex_or_Ey_max=%g E_max=%g V_max=%g U_max=%g Er_max=%g\n",maximum_values->Ex_or_Ey_max, maximum_values->E_max, maximum_values->V_max, maximum_values->U_max, maximum_values->permittivity_max); */