MCPcopy Create free account
hub / github.com/NanoComp/meep / test_pml

Function test_pml

tests/two_dimensional.cpp:184–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184int test_pml(double eps(const vec &), int splitting) {
185 double a = 10.0;
186
187 grid_volume gv = voltwo(3.0, 2.0, a);
188 structure s1(gv, eps, pml(1.0, X) + pml(1.0, Y, High));
189 structure s(gv, eps, pml(1.0, X) + pml(1.0, Y, High), identity(), splitting);
190
191 master_printf("Testing pml while splitting into %d chunks...\n", splitting);
192 fields f(&s);
193 f.add_point_source(Hz, 0.7, 1.5, 0.0, 4.0, vec(1.5, 0.5), 1.0);
194 f.add_point_source(Ez, 0.8, 1.6, 0.0, 4.0, vec(1.299, 0.401), 1.0);
195 fields f1(&s1);
196 f1.add_point_source(Hz, 0.7, 1.5, 0.0, 4.0, vec(1.5, 0.5), 1.0);
197 f1.add_point_source(Ez, 0.8, 1.6, 0.0, 4.0, vec(1.299, 0.401), 1.0);
198 const double deltaT = 100.0;
199 const double ttot = 3.1 * deltaT;
200 double field_energy_check_time = deltaT;
201
202 while (f.time() < f.last_source_time())
203 f.step();
204 while (f1.time() < f1.last_source_time())
205 f1.step();
206
207 double last_energy = f.field_energy();
208 while (f.time() < ttot) {
209 f.step();
210 f1.step();
211 if (f.time() >= field_energy_check_time) {
212 if (!compare_point(f, f1, vec(0.5, 0.01))) return 0;
213 if (!compare_point(f, f1, vec(0.46, 0.33))) return 0;
214 if (!compare_point(f, f1, vec(1.0, 1.0))) return 0;
215 const double new_energy = f.field_energy();
216 if (!compare(new_energy, f1.field_energy(), " total energy")) return 0;
217 if (new_energy > last_energy * 1e-6) {
218 master_printf("Energy decaying too slowly: from %g to %g (%g)\n", last_energy, new_energy,
219 new_energy / last_energy);
220 return 0;
221 }
222 else { master_printf("Got newE/oldE of %g\n", new_energy / last_energy); }
223 field_energy_check_time += deltaT;
224 }
225 }
226 return 1;
227}
228
229int test_pml_tm(double eps(const vec &), int splitting) {
230 double a = 10.0;

Callers 1

mainFunction · 0.70

Calls 12

voltwoFunction · 0.85
pmlFunction · 0.85
identityFunction · 0.85
master_printfFunction · 0.85
add_point_sourceMethod · 0.80
timeMethod · 0.80
last_source_timeMethod · 0.80
stepMethod · 0.80
field_energyMethod · 0.80
compare_pointFunction · 0.70
compareFunction · 0.70
vecClass · 0.50

Tested by

no test coverage detected