18 #ifndef __nec_results__
19 #define __nec_results__
27 #include "math_util.h"
31 RESULT_FORMAT_NEC = 1,
32 RESULT_FORMAT_XML = 2,
45 enum RESULT_FORMAT m_format;
51 : os(in_os), m_format(in_format), m_in_section(
false)
61 inline void separator()
65 case RESULT_FORMAT_CSV:
69 case RESULT_FORMAT_NEC:
76 inline void start_record()
80 case RESULT_FORMAT_XML:
89 inline void end_record()
93 case RESULT_FORMAT_XML:
94 os <<
"</record>" << endl;
103 inline void padding(
const char* s)
107 case RESULT_FORMAT_NEC:
116 void center_text(
const std::string& text,
const string& border)
118 size_t len = text.length() + 2*(border.length() + 1);
119 size_t offset = 40 - len/2;
120 for (
size_t i=0;i<offset;i++)
122 os << border <<
" " << text <<
" " << border << endl;
125 inline void section_start(
const std::string& section_name)
132 case RESULT_FORMAT_NEC:
133 os << endl << endl << endl;
134 center_text(section_name,
"-----");
137 case RESULT_FORMAT_XML:
138 os <<
"<section name=\"" << section_name <<
"\">" << endl;
142 os << endl << endl << endl;
148 inline void section_end()
150 m_in_section =
false;
154 case RESULT_FORMAT_NEC:
155 os << endl << endl << endl;
158 case RESULT_FORMAT_XML:
159 os <<
"</section>" << endl;
163 os << endl << endl << endl;
168 inline void int_out(
int w,
int i)
173 inline void string_out(
int w,
const std::string& s)
175 os << right << setw(w) << s;
177 inline void string_out(
int w,
const char* s)
179 os << right << setw(w) << s;
182 inline void real_out(
int w,
int p, nec_float f,
bool sci =
true)
184 ios::fmtflags flags = ios::showpoint | ios::uppercase | ios::right;
186 flags |= ios::scientific;
190 os.unsetf(ios::adjustfield | ios::basefield | ios::floatfield);
197 inline void complex_out(
int w,
int p, nec_complex c,
bool sci =
true)
199 real_out(w,p,real(c),sci);
201 real_out(w,p,imag(c),sci);
204 inline void polar_out(
int w,
int p, nec_complex c,
bool sci =
true)
206 real_out(w,p,abs(c),sci);
208 real_out(w,p,arg_degrees(c),sci);
216 enum nec_result_type {
217 RESULT_NORMALIZED_RECEIVING_PATTERN = 1,
218 RESULT_STRUCTURE_EXCITATION = 2,
219 RESULT_ANTENNA_INPUT = 3,
220 RESULT_RADIATION_PATTERN = 4,
221 RESULT_NEAR_FIELD_PATTERN = 5,
222 RESULT_STRUCTURE_CURRENTS = 6
233 nec_float _frequency;
236 enum RESULT_FORMAT _result_format;
239 virtual void write_to_file(ostream& os) = 0;
240 virtual enum nec_result_type get_result_type() = 0;
243 : _write_file(
true), _result_format(RESULT_FORMAT_NEC)
250 inline bool write_file()
const {
254 inline void set_write_file(
bool f) {
258 inline void set_frequency(nec_float f) {
262 nec_float get_frequency() {
266 inline void set_result_format(
enum RESULT_FORMAT f) {
277 nec_float _eta, _axial_ratio;
283 nec_float _theta0, _theta_step;
284 nec_float _phi0, _phi_step;
290 int in_n_theta,
int in_n_phi,
292 nec_float theta0, nec_float theta_step,
293 nec_float phi0, nec_float phi_step,
295 nec_float in_axial_ratio,
296 int in_segment_number,
299 n_theta = in_n_theta;
303 _mag.resize(n_theta, n_phi);
306 _theta_step = theta_step;
309 _phi_step = phi_step;
312 _axial_ratio = in_axial_ratio;
313 _segment_number = in_segment_number;
316 _mag.resize(n_theta, n_phi);
322 virtual enum nec_result_type get_result_type() {
323 return RESULT_NORMALIZED_RECEIVING_PATTERN;
326 void set_input(
int theta_index,
int phi_index, nec_float mag) {
327 _mag(theta_index,phi_index) = mag;
341 nec_float get_theta_start() {
345 nec_float get_phi_start() {
349 nec_float get_delta_theta() {
353 nec_float get_delta_phi() {
357 nec_float get_eta() {
361 nec_float get_axial_ratio() {
365 int get_segment_number() {
366 return _segment_number;
379 nec_float get_mag(
int theta_index,
int phi_index) {
380 return _mag(theta_index, phi_index);
383 nec_float get_norm_factor() {
387 virtual void write_to_file(ostream& os) {
393 nec_float norm_factor = get_norm_factor();
397 oh.section_start(
"NORMALIZED RECEIVING PATTERN");
398 os <<
" NORMALIZATION FACTOR: ";oh.real_out(11,4,norm_factor);os << endl;
399 os <<
" ETA: ";oh.real_out(7,2,_eta,
false); os <<
" DEGREES" << endl;
400 os <<
" TYPE: " << _type << endl;
401 os <<
" AXIAL RATIO: "; oh.real_out(6,3,_axial_ratio,
false); os << endl;
402 os <<
" SEGMENT No: ";oh.int_out( 5, _segment_number); os << endl << endl;
403 os <<
" THETA PHI ---- PATTERN ----" << endl;
404 os <<
" (DEG) (DEG) DB MAGNITUDE" << endl;
406 nec_float theta = _theta0;
408 for (
int t=0; t<n_theta; t++) {
409 nec_float phi = _phi0;
411 for (
int p=0; p<n_phi;p++) {
412 nec_float magnitude = _mag(t,p) / norm_factor;
413 nec_float gain = db20(magnitude);
417 oh.real_out(7,2, theta,
false); oh.separator();
418 oh.real_out(7,2, phi,
false); oh.separator();
419 oh.padding(
" "); oh.real_out(7,2, gain,
false); oh.separator();
420 oh.padding(
" "); oh.real_out(11,4, magnitude);
425 theta += _theta_step;
435 int m_segment_number, m_segment_tag;
436 nec_complex m_voltage, m_current;
440 structure_excitation_data(
int segment_number,
int segment_tag, nec_complex voltage, nec_complex current, nec_float power)
442 m_segment_number = segment_number;
443 m_segment_tag = segment_tag;
451 nec_complex admittance = m_current / m_voltage;
452 nec_complex impedance = m_voltage / m_current;
459 oh.int_out(4, m_segment_tag); oh.separator();
460 oh.int_out(5, m_segment_number); oh.separator();
461 oh.complex_out(11,4, m_voltage); oh.separator();
462 oh.complex_out(11,4, m_current); oh.separator();
463 oh.complex_out(11,4, impedance); oh.separator();
464 oh.complex_out(11,4, admittance); oh.separator();
465 oh.real_out(11,4, m_power);
477 vector<int> _tag, _segment;
478 vector<nec_complex> _voltage, _current, _impedance, _admittance;
479 vector<nec_float> _power;
481 nec_complex voli, curi;
493 virtual enum nec_result_type get_result_type()
495 return RESULT_STRUCTURE_EXCITATION;
521 void add(
int segment,
int tag, nec_complex voltage, nec_complex current, nec_float power)
525 _segment.push_back(segment);
526 _voltage.push_back(voltage);
527 _current.push_back(current);
528 _impedance.push_back(voltage/current);
529 _admittance.push_back(current/voltage);
530 _power.push_back(power);
534 virtual void write_to_file(ostream& os)
537 oh.section_start(
"STRUCTURE EXCITATION DATA AT NETWORK CONNECTION POINTS");
538 os <<
" TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER" << endl;
539 os <<
" No: No: REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)" << endl;
541 for (
int i=0; i<n_items; i++)
544 oh.int_out(4, _tag[i]); oh.separator();
545 oh.int_out(5, _segment[i]); oh.separator();
546 oh.complex_out(11,4, _voltage[i]); oh.separator();
547 oh.complex_out(11,4, _current[i]); oh.separator();
548 oh.complex_out(11,4, _impedance[i]); oh.separator();
549 oh.complex_out(11,4, _admittance[i]); oh.separator();
550 oh.real_out(11,4, _power[i]);
557 vector<int> get_tag()
562 vector<int> get_segment()
567 vector<nec_complex> get_current()
572 vector<nec_complex> get_voltage()
577 vector<nec_float> get_power()
591 vector<int> _tag, _segment;
592 vector<nec_float> _power;
593 vector<nec_complex> _voltage, _current, _impedance, _admittance;
606 virtual enum nec_result_type get_result_type()
608 return RESULT_ANTENNA_INPUT;
611 void set_input(
int tag,
int segment, nec_complex voltage, nec_complex current, nec_complex impedance, nec_complex admittance, nec_float power);
613 virtual void write_to_file(ostream& os)
619 oh.section_start(
"ANTENNA INPUT PARAMETERS");
620 os <<
" TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER" << endl;
621 os <<
" NO. NO. REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)" << endl;
622 for (
int i=0; i<n_items; i++)
625 oh.int_out(4, _tag[i]); oh.separator();
626 oh.int_out(5, _segment[i]); oh.separator();
627 oh.complex_out(11,4, _voltage[i]); oh.separator();
628 oh.complex_out(11,4, _current[i]); oh.separator();
629 oh.complex_out(11,4, _impedance[i]); oh.separator();
630 oh.complex_out(11,4, _admittance[i]); oh.separator();
631 oh.real_out(11,4, _power[i]);
638 vector<int> get_tag()
643 vector<int> get_segment()
648 vector<nec_complex> get_current()
653 vector<nec_complex> get_voltage()
658 vector<nec_complex>& get_impedance();
660 vector<nec_float> get_power()
676 vector<nec_float> _x, _y, _z;
677 vector<nec_complex> _field_x, _field_y, _field_z;
691 virtual enum nec_result_type get_result_type()
693 return RESULT_NEAR_FIELD_PATTERN;
696 void set_input(nec_float x, nec_float y, nec_float z, nec_complex field_x, nec_complex field_y, nec_complex field_z);
698 virtual void write_to_file(ostream& os)
707 oh.section_start(
"NEAR ELECTRIC FIELDS");
708 os <<
" ------- LOCATION ------- ------- EX ------ ------- EY ------ ------- EZ ------" << endl;
709 os <<
" X Y Z MAGNITUDE PHASE MAGNITUDE PHASE MAGNITUDE PHASE" << endl;
710 os <<
" METERS METERS METERS VOLTS/M DEGREES VOLTS/M DEGREES VOLTS/M DEGREES" << endl;
714 oh.section_start(
"NEAR MAGNETIC FIELDS");
715 os <<
" ------- LOCATION ------- ------- HX ------ ------- HY ------ ------- HZ ------" << endl;
716 os <<
" X Y Z MAGNITUDE PHASE MAGNITUDE PHASE MAGNITUDE PHASE" << endl;
717 os <<
" METERS METERS METERS AMPS/M DEGREES AMPS/M DEGREES AMPS/M DEGREES" << endl;
719 for (
int i=0; i<n_items; i++)
723 oh.real_out(9, 4, _x[i],
false); oh.separator();
724 oh.real_out(9, 4, _y[i],
false); oh.separator();
725 oh.real_out(9, 4, _z[i],
false); oh.separator();
727 oh.real_out(11, 4, abs(_field_x[i]),
true); oh.separator();
728 oh.real_out(7, 2, arg_degrees(_field_x[i]),
false); oh.separator();
730 oh.real_out(11, 4, abs(_field_y[i]),
true); oh.separator();
731 oh.real_out(7, 2, arg_degrees(_field_y[i]),
false); oh.separator();
733 oh.real_out(11, 4, abs(_field_z[i]),
true); oh.separator();
734 oh.real_out(7, 2, arg_degrees(_field_z[i]),
false); oh.separator();
746 vector<nec_float> get_x()
751 vector<nec_float> get_y()
756 vector<nec_float> get_z()
761 vector<nec_complex> get_field_x()
766 vector<nec_complex> get_field_y()
771 vector<nec_complex> get_field_z()
799 vector<nec_base_result*> _results;
805 enum RESULT_FORMAT m_result_format;
809 m_result_format = RESULT_FORMAT_NEC;
819 for (
int i=0;i<_n;i++)
828 br->set_result_format(m_result_format);
829 _results.push_back(br);
843 for (
int i=0;i<_n;i++)
845 if (_results[i]->get_result_type() == result_type)
847 if (index == counter++)
915 void write(ostream& os)
917 for (
int i=0;i<_n;i++)
919 if (_results[i]->write_file())
921 _results[i]->write_to_file(os);
922 _results[i]->set_write_file(
false);
nec_near_field_pattern * get_near_field_pattern(const long index)
Get near field pattern results.
Definition: nec_results.h:900
nec_radiation_pattern * get_radiation_pattern(const long index)
Get radiation pattern results.
Definition: nec_results.h:870
nec_structure_excitation * get_structure_excitation(const long index)
Get structure excitation results.
Definition: nec_results.h:890
nec_norm_rx_pattern * get_norm_rx_pattern(const long index)
Get normalized receiving pattern results.
Definition: nec_results.h:860
Definition: nec_structure_currents.h:30
Definition: nec_results.h:432
nec_structure_currents * get_structure_currents(const long index)
Get structure currents results.
Definition: nec_results.h:910
A class that handles various standard output functions for the results.
Definition: nec_results.h:41
Definition: nec_results.h:797
nec_antenna_input * get_antenna_input(const long index)
Get antenna input parameter results.
Definition: nec_results.h:880
T maxCoeff() const
return the largest element of the array
Definition: safe_array.h:134
Definition: nec_results.h:671
Definition: nec_results.h:274
Definition: nec_radiation_pattern.h:49
nec_base_result * get_result(const long index, const enum nec_result_type result_type)
Get the nth result that matches the specified result type.
Definition: nec_results.h:839
Definition: CurrentInput.h:26
Holds structure excitation data at network connection points.
Definition: nec_results.h:474
Definition: nec_results.h:230