19 #ifndef __nec_radiation_pattern__
20 #define __nec_radiation_pattern__
22 #include "nec_results.h"
23 #include "math_util.h"
24 #include "nec_ground.h"
25 #include "c_plot_card.h"
31 enum polarization_norm {
41 enum polarization_sense {
54 nec_float in_theta_start, nec_float in_phi_start,
55 nec_float in_delta_theta, nec_float in_delta_phi,
58 int in_ifar, nec_float in_wavelength,
59 nec_float pinr, nec_float pnlr,
60 int in_rp_output_format,
int in_rp_normalization,
int in_rp_ipd,
int in_rp_power_average,
64 virtual void write_to_file(ostream& os) {
65 write_to_file_aux(os);
68 virtual enum nec_result_type get_result_type() {
69 return RESULT_RADIATION_PATTERN;
74 void write_gain_normalization() {
76 nec_float norm = get_maximum_gain_db();
77 printf(
"Max Gain: %f\n",norm);
89 return _power_gain_vert;
93 return _power_gain_horiz;
97 return _power_gain_tot;
101 return _polarization_axial_ratio;
107 return _polarization_axial_ratio(theta_index, phi_index);
111 return _polarization_tilt;
115 return _polarization_sense_index;
122 return _polarization_sense_index(theta_index, phi_index);
128 return abs(_e_theta(theta_index, phi_index));
134 return arg_degrees(_e_theta(theta_index, phi_index));
146 return abs(_e_phi(theta_index, phi_index));
152 return arg_degrees(_e_phi(theta_index, phi_index));
165 nec_float get_normalization_factor() {
166 return get_gain_normalization_factor(m_rp_gnor);
169 nec_float get_average_power_gain() {
170 return _average_power_gain;
173 nec_float get_average_power_solid_angle() {
174 return _average_power_solid_angle;
181 nec_float get_range() {
185 nec_float get_wavelength() {
192 for (int32_t i=0; i<n_theta; i++)
197 nec_float get_delta_theta() {
201 nec_float get_theta_start() {
202 return m_theta_start;
208 for (int32_t i=0; i<n_phi; i++)
213 nec_float get_delta_phi() {
217 nec_float get_phi_start() {
226 int get_rp_normalization() {
227 return m_rp_normalization;
230 int get_rp_output_format() {
231 return m_rp_output_format;
234 int get_rp_power_average() {
235 return m_rp_power_average;
245 nec_float get_maximum_gain_db() {
246 return get_gain_normalization_factor(0);
255 long rows = pattern.rows();
256 long cols = pattern.cols();
257 for (
long i=0;i<rows;i++) {
258 for (
long j=0;j<cols;j++) {
259 sum += pattern(i,j) * _averaging_scales(i,j);
262 long len = rows*cols;
263 return sum/(len*2.0 / pi());
266 nec_float sd(
const real_matrix& pattern, nec_float _mean)
const {
268 long rows = pattern.rows();
269 long cols = pattern.cols();
271 for (
long i=0;i<rows;i++) {
272 for (
long j=0;j<cols;j++) {
273 nec_float diff = pattern(i,j) - _mean;
274 sum += diff*diff * _averaging_scales(i,j);
277 long len = rows*cols;
278 return std::sqrt(sum/(len*2.0 / pi()));
283 nec_float get_gain_max()
const {
287 nec_float get_gain_min()
const {
291 nec_float get_gain_mean()
const {
292 return mean(_power_gain_tot);
295 nec_float get_gain_sd()
const {
296 nec_float _mean = get_gain_mean();
297 return sd(_power_gain_tot, _mean);
301 nec_float get_gain_rhcp_max()
const {
305 nec_float get_gain_rhcp_min()
const {
309 nec_float get_gain_rhcp_mean()
const {
310 return mean(_power_gain_rhcp);
313 nec_float get_gain_rhcp_sd()
const {
314 nec_float _mean = get_gain_rhcp_mean();
315 return sd(_power_gain_rhcp, _mean);
319 nec_float get_gain_lhcp_max()
const {
323 nec_float get_gain_lhcp_min()
const {
327 nec_float get_gain_lhcp_mean()
const {
328 return mean(_power_gain_lhcp);
331 nec_float get_gain_lhcp_sd()
const {
332 nec_float _mean = get_gain_lhcp_mean();
333 return sd(_power_gain_lhcp, _mean);
343 return (m_theta_start + delta_theta*theta_index);
355 return (m_phi_start + delta_phi*phi_index);
367 return _gain(theta_index, phi_index);
373 return _power_gain_vert(theta_index, phi_index);
379 return _power_gain_horiz(theta_index, phi_index);
385 return _power_gain_tot(theta_index, phi_index);
391 nec_float a = get_pol_axial_ratio(theta_index, phi_index);
396 nec_float f = (1-2*a+a*a)/(2*(1+a*a));
397 return dbi + 10*log10(f);
403 nec_float a = get_pol_axial_ratio(theta_index, phi_index);
408 nec_float f = (1+2*a+a*a)/(2*(1+a*a));
409 return dbi + 10*log10(f);
414 int get_index(
int theta_index,
int phi_index)
const;
416 bool m_analysis_done;
420 nec_float m_theta_start, delta_theta;
421 nec_float m_phi_start, delta_phi;
427 nec_float _wavelength;
431 nec_float _average_power_gain;
432 nec_float _average_power_solid_angle;
433 nec_float _maximum_gain;
435 int m_rp_normalization;
436 int m_rp_output_format;
437 int m_rp_power_average;
457 void write_to_file_aux(ostream& os);
459 nec_float get_gain_normalization_factor(nec_float gnor);
461 void write_normalized_gain(ostream& os);
nec_float get_phi(int phi_index) const
Get the phi angle corresponding to the phi_index.
Definition: nec_radiation_pattern.h:354
nec_float get_power_gain_vert(int theta_index, int phi_index) const
Get a power gain (vertical) from the radiation pattern.
Definition: nec_radiation_pattern.h:372
nec_float get_ephi_magnitude(int theta_index, int phi_index)
Get the magnitude of E(PHI)
Definition: nec_radiation_pattern.h:145
nec_float get_etheta_magnitude(int theta_index, int phi_index)
Get the magnitude of E(THETA)
Definition: nec_radiation_pattern.h:127
real_array get_theta_angles() const
Definition: nec_radiation_pattern.h:190
nec_float get_ephi_phase(int theta_index, int phi_index)
Get the phase (in degrees) of E(PHI)
Definition: nec_radiation_pattern.h:151
nec_float get_theta(int theta_index) const
Get the theta angle corresponding to the theta_index.
Definition: nec_radiation_pattern.h:342
nec_float get_power_gain_horiz(int theta_index, int phi_index) const
Get a power gain (horizontal) from the radiation pattern.
Definition: nec_radiation_pattern.h:378
real_array get_phi_angles() const
Definition: nec_radiation_pattern.h:206
T minCoeff() const
return the largest element of the array
Definition: safe_array.h:148
nec_float get_power_gain(int theta_index, int phi_index) const
Get a total power gain from the radiation pattern.
Definition: nec_radiation_pattern.h:366
nec_float get_power_gain_lhcp(int theta_index, int phi_index) const
Get the power gain if the antenna were receiving LHCP signals.
Definition: nec_radiation_pattern.h:402
complex_array get_e_theta()
Return a complex array for the electric field E(THETA)
Definition: nec_radiation_pattern.h:139
T maxCoeff() const
return the largest element of the array
Definition: safe_array.h:134
Definition: c_plot_card.h:44
void analyze(nec_context *in_context)
Generate the data for the radiation pattern.
Definition: nec_radiation_pattern.cpp:229
nec_float get_power_gain_tot(int theta_index, int phi_index) const
Get a power gain (total dBi) from the radiation pattern.
Definition: nec_radiation_pattern.h:384
Definition: nec_radiation_pattern.h:49
int get_ntheta() const
Get the number of theta angles.
Definition: nec_radiation_pattern.h:348
nec_float get_etheta_phase(int theta_index, int phi_index)
Get the phase (in degrees) of E(THETA)
Definition: nec_radiation_pattern.h:133
complex_array get_e_phi()
Return a complex array for the electric field E(PHI)
Definition: nec_radiation_pattern.h:157
nec_float get_power_gain_rhcp(int theta_index, int phi_index) const
Get the power gain if the antenna were receiving RHCP signals.
Definition: nec_radiation_pattern.h:390
Definition: nec_results.h:230
int get_nphi() const
Get the number of phi angles.
Definition: nec_radiation_pattern.h:360
Container for an nec2++ simulation.
Definition: nec_context.h:60
nec_float get_pol_axial_ratio(int theta_index, int phi_index) const
Get the polarization axial ratio.
Definition: nec_radiation_pattern.h:106
int get_pol_sense(int theta_index, int phi_index) const
Get the polarization sense.
Definition: nec_radiation_pattern.h:121
Definition: nec_ground.h:59