nec2++  1.7.0
RadiationInput.h
1 /*
2  Copyright (C) 2004-2005 Timothy C.A. Molteno
3  tim@molteno.net
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __Radiation_Input__
20 #define __Radiation_Input__
21 
22 #include <vector>
23 
24 #include "BaseInput.h"
25 
26 class RadiationInput : public BaseInput
27 {
28 public:
29  vector<double> theta, phi;
30  vector<double> power_v, power_h, power_t;
31  vector<double> pol_axial_ratio, pol_tilt;
32  string pol_sense; // ignore polarization sense
33  vector<double> E_theta_mag, E_phi_mag;
34  vector<double> E_theta_phase, E_phi_phase;
35 
36  long n_items;
37 
38  RadiationInput(std::string& filename)
39  : BaseInput(filename)
40  {
41  n_items = 0;
42 
43  string searchString("RADIATION PATTERNS");
44  while (m_stream.good())
45  {
46  string line = readline();
47 
48  if (line.find(searchString,0) != string::npos)
49  {
50 
51  while (line.find("VOLTS/M",0) == string::npos)
52  line = readline();
53 
54  /*
55  - - ANGLES - - - POWER GAINS - - - - POLARIZATION - - - - - - E(THETA) - - - - - - E(PHI) - - -
56  THETA PHI VERT. HOR. TOTAL AXIAL TILT SENSE MAGNITUDE PHASE MAGNITUDE PHASE
57  DEGREES DEGREES DB DB DB RATIO DEG. VOLTS/M DEGREES VOLTS/M DEGREES
58  .00 .00 -999.99 -3.23 -3.23 .00000 -90.00 LINEAR 0.00000E+00 -81.39 7.35700E-05 -195.64
59  */
60  line = readline();
61 
62  while (line != "")
63  {
64  stringstream ss(line);
65 
66  theta.push_back(read_fixed(ss));
67  phi.push_back(read_fixed(ss));
68  power_v.push_back(read_fixed(ss));
69  power_h.push_back(read_fixed(ss));
70  power_t.push_back(read_fixed(ss));
71  pol_axial_ratio.push_back(read_fixed(ss));
72  pol_tilt.push_back(read_fixed(ss));
73 
74  ss >> pol_sense;
75 
76  E_theta_mag.push_back(read_sci(ss));
77  E_theta_phase.push_back(read_fixed(ss));
78 
79  E_phi_mag.push_back(read_sci(ss));
80  E_phi_phase.push_back(read_fixed(ss));
81 
82  line = readline();
83  n_items++;
84  }
85  cout << "Radiation pattern: " << n_items << " lines" << endl;
86  }
87  }
88  }
89 
90  bool equalto(const RadiationInput& ai)
91  {
92  if (difference(ai) > 1e-4)
93  return false;
94 
95  return true;
96  }
97 
98  double difference(const RadiationInput& ai)
99  {
100  double ret = 0.0;
101  // compart angles
102  if (n_items != ai.n_items)
103  return 1;
104 
105  for (long i=0; i < n_items;i++)
106  {
107  if (theta[i] != ai.theta[i])
108  return 1;
109  if (phi[i] != ai.phi[i])
110  return 1;
111 
112  try
113  {
114  ret += diff(power_v[i], ai.power_v[i]);
115  ret += diff(power_h[i], ai.power_h[i]);
116  ret += diff(power_t[i], ai.power_t[i]);
117  if (power_v[i] > -999.0)
118  {
119  ret += diff(pol_axial_ratio[i], ai.pol_axial_ratio[i]);
120  ret += diff(pol_tilt[i], ai.pol_tilt[i]);
121 
122  ret += diff(deg_polar(E_theta_mag[i],E_theta_phase[i]), deg_polar(ai.E_theta_mag[i],ai.E_theta_phase[i]));
123  ret += diff(deg_polar(E_phi_mag[i],E_phi_phase[i]), deg_polar(ai.E_phi_mag[i],ai.E_phi_phase[i]));
124  }
125  }
126  catch (string message)
127  {
128  cout << "Diff at [" << theta[i] << "," << phi[i] << "] : " << message << endl;
129  }
130  }
131  return ret;
132  };
133 };
134 
135 #endif /* __Radiation_Input__ */
Definition: BaseInput.h:69
Definition: RadiationInput.h:26