nec2++  1.7.0
AntennaInput.h
1 /*
2  Copyright (C) 2004 Timothy C.A. Molteno
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef __Antenna_Input__
19 #define __Antenna_Input__
20 
21 #include <vector>
22 #include "BaseInput.h"
23 
24 /*
25  - - - ANTENNA INPUT PARAMETERS - - -
26 
27  TAG SEG. VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
28  NO. NO. REAL IMAG. REAL IMAG. REAL IMAG. REAL IMAG. (WATTS)
29  0 * 5 1.00000E+00 0.00000E+00 6.64451E-03-3.86651E-03 1.12429E+02 6.54238E+01 6.64451E-03-3.86651E-03 3.32225E-03
30 
31  --------- ANTENNA INPUT PARAMETERS ---------
32  TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
33  NO. NO. REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)
34  0 5 1.0000E+00 0.0000E+00 6.6443E-03 -3.8666E-03 1.1243E+02 6.5428E+01 6.6443E-03 -3.8666E-03 3.3222E-03
35 */
36 class AntennaInput : public BaseInput
37 {
38 public:
39  vector<double> tag, seg, vRe, vIm, iRe, iIm, zRe, zIm, power;
40  long n_items;
41 
42  AntennaInput(std::string& filename)
43  : BaseInput(filename)
44  {
45  n_items = 0;
46  string searchString("ANTENNA INPUT PARAMETERS");
47  while (m_stream.good())
48  {
49  string line = readline();
50 
51  if (line.find(searchString,0) != string::npos)
52  {
53  while (line.find("(WATTS)",0) == string::npos)
54  line = readline();
55 
56  line = readline();
57 
58  // get rid of '*' characters
59  if (line.find("*",0) != string::npos)
60  {
61  line.erase(line.find("*",0),1);
62  }
63 
64  stringstream ss(line);
65  tag.push_back(read_fixed(ss));
66  seg.push_back(read_fixed(ss));
67  vRe.push_back(read_fixed(ss));
68  vIm.push_back(read_fixed(ss));
69  iRe.push_back(read_fixed(ss));
70  iIm.push_back(read_fixed(ss));
71  zRe.push_back(read_fixed(ss));
72  zIm.push_back(read_fixed(ss));
73  power.push_back(read_fixed(ss));
74 
75  cout << "Impedance : " << zRe[n_items] << " " << zIm[n_items] << endl;
76  n_items++;
77  }
78  }
79  }
80 
81  bool equalto(const AntennaInput& ai)
82  {
83  if (difference(ai) > 1e-4)
84  return false;
85 
86  return true;
87  }
88 
89  double difference(const AntennaInput& ai)
90  {
91  double ret = 0;
92 
93  if (n_items != ai.n_items)
94  return 1.0;
95 
96  try
97  {
98  for (long i=0; i<n_items; i++)
99  {
100  ret += diff(ai.vRe[i],vRe[i]);
101  ret += diff(ai.vIm[i],vIm[i]);
102  ret += diff(ai.iRe[i],iRe[i]);
103  ret += diff(ai.iIm[i],iIm[i]);
104  ret += diff(ai.zRe[i],zRe[i]);
105  ret += diff(ai.zIm[i],zIm[i]);
106  ret += diff(ai.power[i],power[i]);
107  }
108  }
109  catch(string message)
110  {
111  cout << "diff : " << message << endl;
112  }
113  return ret;
114  };
115 };
116 
117 #endif /* __Antenna_Input__ */
Definition: BaseInput.h:69
Definition: AntennaInput.h:36