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

Function Run

tests/dft-fields.cpp:36–100  ·  view source on GitHub ↗

/ / /

Source from the content-addressed store, hash-verified

34/***************************************************************/
35/***************************************************************/
36void Run(bool Pulse, double resolution, std::complex<meep::realnum> **field_array = 0,
37 int *array_rank = 0, size_t *array_dims = 0) {
38 /***************************************************************/
39 /* initialize geometry */
40 /***************************************************************/
41 double n = 3.4; // index of waveguide
42 double w = 1.0; // width of waveguide
43 double r = 1.0; // inner radius of ring
44 double pad = 4; // padding between waveguide and edge of PML
45 double dpml = 2; // thickness of PML
46
47 double sxy = 2.0 * (r + w + pad + dpml); // cell size
48 geometry_lattice.size.x = sxy;
49 geometry_lattice.size.y = sxy;
50 geometry_lattice.size.z = 0.0;
51 grid_volume gv = voltwo(sxy, sxy, resolution);
52 gv.center_origin();
53 symmetry sym = identity(); // mirror(Y, gv);
54 structure the_structure(gv, dummy_eps, pml(dpml), sym);
55
56 /***************************************************************/
57 /* add objects */
58 /***************************************************************/
59 meep_geom::material_type dielectric = meep_geom::make_dielectric(n * n);
60 geometric_object objects[2];
61 vector3 v3zero = {0.0, 0.0, 0.0};
62 vector3 zaxis = {0.0, 0.0, 1.0};
63 objects[0] = make_cylinder(dielectric, v3zero, r + w, meep_geom::ENORMOUS, zaxis);
64 objects[1] = make_cylinder(meep_geom::vacuum, v3zero, r, meep_geom::ENORMOUS, zaxis);
65 geometric_object_list g = {2, objects};
66 meep_geom::set_materials_from_geometry(&the_structure, g);
67 fields f(&the_structure);
68 f.step(); // single timestep to trigger internal initialization
69
70 /***************************************************************/
71 /***************************************************************/
72 /***************************************************************/
73 double fcen = 0.118; // ; pulse center frequency
74 double df = 0.1; // ; df
75 vec x0(r + 0.1, 0.0); // ; source location
76 if (Pulse) {
77 f.add_point_source(Ez, gaussian_src_time(fcen, df), x0);
78
79 component components[6] = {Ex, Ey, Ez, Hx, Hy, Hz};
80 dft_fields dftFields = f.add_dft_fields(components, 6, f.v, fcen, fcen, 1);
81 dft_flux dftFlux = f.add_dft_flux(X, f.v, fcen, fcen, 1);
82
83 while (f.round_time() < f.last_source_time() + 100.0)
84 f.step();
85
86 f.output_dft(dftFlux, "dft-flux");
87 f.output_dft(dftFields, "dft-fields");
88
89 *field_array = f.get_dft_array(dftFlux, Ez, 0, array_rank, array_dims);
90 }
91 else {
92 f.add_point_source(Ez, continuous_src_time(fcen, df), x0);
93 f.solve_cw(sizeof(realnum) == sizeof(float) ? 1e-5 : 1e-8, 10000, 10);

Callers 1

mainFunction · 0.85

Calls 15

voltwoFunction · 0.85
identityFunction · 0.85
pmlFunction · 0.85
make_dielectricFunction · 0.85
gaussian_src_timeClass · 0.85
continuous_src_timeClass · 0.85
center_originMethod · 0.80
stepMethod · 0.80
add_point_sourceMethod · 0.80
last_source_timeMethod · 0.80
open_h5fileMethod · 0.80

Tested by

no test coverage detected