-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathnec_context_tb.cpp
More file actions
146 lines (117 loc) · 4.67 KB
/
Copy pathnec_context_tb.cpp
File metadata and controls
146 lines (117 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "catch.hpp"
#include "nec_context.h"
#include "nec_results.h"
#include "c_geometry.h"
#include <iostream>
#define REQUIRE_APPROX_EQUAL(a, b) { \
static nec_float eps = 3e-4; \
REQUIRE(std::abs(a - b) < eps); }
TEST_CASE( "Example 1", "[example_1]") {
/**
CE EXAMPLE 1. CENTER FED LINEAR ANTENNA
GW 0 7 0. 0. -.25 0. 0. .25 .001
GE
EX 0 0 4 0 1.
XQ
ld 0 0 4 4 10. 3.000E-09 5.300E-11
PQ
NE 0 1 1 15 .001 0 0 0. 0. .01786
EN
*/
nec_context nec;
nec.initialize();
c_geometry* geo = nec.get_geometry();
geo->wire(0, 7, 0.0, 0.0, -0.25, 0.0, 0.0, 0.25, 0.001, 1.0, 1.0);
nec.geometry_complete(0);
nec.ex_card(EXCITATION_VOLTAGE, 0, 4, 0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
nec.xq_card(0);
nec.ld_card(0, 0, 4, 4, 10.0, 3.0e-9,5.3e-11);
nec.pq_card(0,0,0,0);
nec.ne_card(0, 1, 1, 15, 0.001, 0.0, 0.0, 0.0, 0.0, 0.01786);
/* TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
NO. NO. REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)
0 4 1.0000E+00 0.0000E+00 9.2058E-03 -5.1547E-03 8.2698E+01 4.6306E+01 9.2058E-03 -5.1547E-03 4.6029E-03
*/
REQUIRE_APPROX_EQUAL(nec.get_impedance_real(0), 8.2698E+01 );
REQUIRE_APPROX_EQUAL(nec.get_impedance_imag(0), 4.6306E+01 );
nec_antenna_input* ai = nec.get_input_parameters(0);
REQUIRE(ai->get_segment()[0] == 4 );
/*
----- ANTENNA INPUT PARAMETERS -----
TAG SEG VOLTAGE (VOLTS) CURRENT (AMPS) IMPEDANCE (OHMS) ADMITTANCE (MHOS) POWER
NO. NO. REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY REAL IMAGINARY (WATTS)
0 4 1.0000E+00 0.0000E+00 8.9547E-03 -4.0515E-03 9.2698E+01 4.1941E+01 8.9547E-03 -4.0515E-03 4.4773E-03
*/
REQUIRE_APPROX_EQUAL(nec.get_impedance_real(1), 9.2698E+01 );
REQUIRE_APPROX_EQUAL(nec.get_impedance_imag(1), 4.1941E+01 );
ai = nec.get_input_parameters(1);
REQUIRE(ai->get_segment()[0] == 4 );
REQUIRE_APPROX_EQUAL(ai->get_current()[0], nec_complex(8.9547E-03, -4.0515E-03) );
}
TEST_CASE( "Voltage Excitation", "[voltage_excitation]") {
/**
CM A simple structure excited by a plane wave, and at multiple frequencies.
CE go blue !
GW 0 36 0 0 0 -0.042 0.008 0.017 0.001
GE 0
GN -1
LD 5 0 0 0 3.720E+07
FR 0 1 0 0 2400
PT -1
EX 1 1 1 0 0 0 0 0 0 0 0
RP 0 1 1 0500 90 90 0 0
EN
*/
nec_context nec;
nec.initialize();
int n_freq = 10;
c_geometry* geo = nec.get_geometry();
geo->wire(0, 36, 0.0, 0.0, 0.0, -0.042, 0.008, 0.017, 0.001, 1.0, 1.0);
nec.geometry_complete(0);
nec.gn_card(-1, 0, 0, 0, 0, 0, 0, 0);
nec.ld_card(5, 0, 0, 0, 3.72e7, 0, 0);
nec.fr_card(0, n_freq, 2400.0, 10.0);
nec.pt_card(-1, 0, 0, 0);
nec.ex_card(EXCITATION_VOLTAGE, 0, 1, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
nec.rp_card(0, 10, 10, 0,5,0,0, 0.0, 0.0, 9.0, 9.0, 0.0, 0.0);
//nec.xq_card(0);
// Check that we get n_freq radiation patterns
for (int freq_index = 0; freq_index < n_freq; freq_index++) {
nec_radiation_pattern* rp = nec.get_radiation_pattern(freq_index);
REQUIRE(rp->get_theta_start() == 0.0 );
// REQUIRE_APPROX_EQUAL(rp->get_rp_power_average(), 12.0);
}
}
TEST_CASE( "Plane Wave Excitation", "[plane_wave]") {
/**
CE A simple structure excited by a plane wave, and at multiple frequencies.
GW 0 36 0 0 0 -0.042 0.008 0.017 0.001
GE 0
GN -1
LD 5 0 0 0 3.720E+07
FR 0 10 0 0 2400.0 10.0
PT -1
EX 1 0 1 0 0 0 0 0 0 0 0
RP 0 1 1 0500 90 90 0 0
EN
*/
nec_context nec;
nec.initialize();
int n_freq = 10;
c_geometry* geo = nec.get_geometry();
geo->wire(0, 36, 0.0, 0.0, 0.0, -0.042, 0.008, 0.017, 0.001, 1.0, 1.0);
nec.geometry_complete(0);
nec.gn_card(-1, 0, 0, 0, 0, 0, 0, 0);
nec.ld_card(5, 0, 0, 0, 3.72e7, 0, 0);
nec.fr_card(0, n_freq, 2400.0, 10.0);
nec.pt_card(-1, 0, 0, 0);
nec.ex_card(EXCITATION_LINEAR, 0, 1, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
nec.rp_card(0, 10, 10, 0,5,0,0, 0.0, 0.0, 9.0, 9.0, 0.0, 0.0);
//nec.xq_card(0);
// Check that we get n_freq radiation patterns
for (int freq_index = 0; freq_index < n_freq; freq_index++) {
nec_radiation_pattern* rp = nec.get_radiation_pattern(freq_index);
REQUIRE(rp->get_theta_start() == 0.0 );
// REQUIRE_APPROX_EQUAL(rp->get_rp_power_average(), 12.0);
}
}