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

Function test_metal

tests/two_dimensional.cpp:71–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71int test_metal(double eps(const vec &), int splitting) {
72 double a = 10.0;
73 double ttot = 17.0;
74
75 grid_volume gv = voltwo(3.0, 2.0, a);
76 structure s1(gv, eps);
77 structure s(gv, eps, no_pml(), identity(), splitting);
78
79 s.add_susceptibility(one, E_stuff, lorentzian_susceptibility(0.3, 0.1));
80 s1.add_susceptibility(one, E_stuff, lorentzian_susceptibility(0.3, 0.1));
81
82 master_printf("Metal+dispersion test using %d chunks...\n", splitting);
83 fields f(&s);
84 f.add_point_source(Hz, 0.7, 2.5, 0.0, 4.0, vec(0.3, 0.5), 1.0);
85 f.add_point_source(Ez, 0.8, 0.6, 0.0, 4.0, vec(1.299, 0.401), 1.0);
86 fields f1(&s1);
87 f1.add_point_source(Hz, 0.7, 2.5, 0.0, 4.0, vec(0.3, 0.5), 1.0);
88 f1.add_point_source(Ez, 0.8, 0.6, 0.0, 4.0, vec(1.299, 0.401), 1.0);
89 double field_energy_check_time = 8.0;
90 while (f.time() < ttot) {
91 f.step();
92 f1.step();
93 if (!compare_point(f, f1, vec(0.5, 0.01))) return 0;
94 if (!compare_point(f, f1, vec(0.46, 0.33))) return 0;
95 if (!compare_point(f, f1, vec(1.0, 1.0))) return 0;
96 if (f.time() >= field_energy_check_time) {
97 if (!compare(f.field_energy(), f1.field_energy(), " total energy")) return 0;
98 if (!compare(f.electric_energy_in_box(gv.surroundings()),
99 f1.electric_energy_in_box(gv.surroundings()), "electric energy"))
100 return 0;
101 if (!compare(f.magnetic_energy_in_box(gv.surroundings()),
102 f1.magnetic_energy_in_box(gv.surroundings()), "magnetic energy"))
103 return 0;
104 field_energy_check_time += 5.0;
105 }
106 }
107 return 1;
108}
109
110int test_periodic(double eps(const vec &), int splitting) {
111 double a = 10.0;

Callers 1

mainFunction · 0.70

Calls 15

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

Tested by

no test coverage detected