nec2++ 2.1.1
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#pragma once
19
20#include <vector>
21#include "BaseInput.h"
22
23/*
24 - - - ANTENNA INPUT PARAMETERS - - -
25
26 TAG SEG. VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
27 NO. NO. REAL IMAG. REAL IMAG. REAL IMAG. REAL IMAG. (WATTS)
28 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
29
30 --------- ANTENNA INPUT PARAMETERS ---------
31 TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
32 NO. NO. REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)
33 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
34*/
35class AntennaInput : public BaseInput
36{
37public:
38 vector<double> tag, seg, vRe, vIm, iRe, iIm, zRe, zIm, power;
39 long n_items;
40
41 AntennaInput(std::string& filename)
42 : BaseInput(filename)
43 {
44 n_items = 0;
45 string searchString("ANTENNA INPUT PARAMETERS");
46 while (m_stream.good())
47 {
48 string line = readline();
49
50 if (line.find(searchString,0) != string::npos)
51 {
52 while (line.find("(WATTS)",0) == string::npos)
53 line = readline();
54
55 line = readline();
56
57 // get rid of '*' characters
58 if (line.find("*",0) != string::npos)
59 {
60 line.erase(line.find("*",0),1);
61 }
62
63 stringstream ss(line);
64 tag.push_back(read_fixed(ss));
65 seg.push_back(read_fixed(ss));
66 vRe.push_back(read_fixed(ss));
67 vIm.push_back(read_fixed(ss));
68 iRe.push_back(read_fixed(ss));
69 iIm.push_back(read_fixed(ss));
70 zRe.push_back(read_fixed(ss));
71 zIm.push_back(read_fixed(ss));
72 power.push_back(read_fixed(ss));
73
74 cout << "Impedance : " << zRe[n_items] << " " << zIm[n_items] << endl;
75 n_items++;
76 }
77 }
78 }
79
80 bool equalto(const AntennaInput& ai)
81 {
82 if (difference(ai) > 1e-4)
83 return false;
84
85 return true;
86 }
87
88 double difference(const AntennaInput& ai)
89 {
90 double ret = 0;
91
92 if (n_items != ai.n_items)
93 return 1.0;
94
95 try
96 {
97 for (long i=0; i<n_items; i++)
98 {
99 ret += diff(ai.vRe[i],vRe[i]);
100 ret += diff(ai.vIm[i],vIm[i]);
101 ret += diff(ai.iRe[i],iRe[i]);
102 ret += diff(ai.iIm[i],iIm[i]);
103 ret += diff(ai.zRe[i],zRe[i]);
104 ret += diff(ai.zIm[i],zIm[i]);
105 ret += diff(ai.power[i],power[i]);
106 }
107 }
108 catch(string message)
109 {
110 cout << "diff : " << message << endl;
111 }
112 return ret;
113 };
114};
Definition AntennaInput.h:36
Definition BaseInput.h:69