Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing volume member to dft_energy class and Scheme example for computing group velocity #753

Merged
merged 2 commits into from
Mar 6, 2019

Conversation

oskooi
Copy link
Collaborator

@oskooi oskooi commented Mar 4, 2019

Fixes a bug in the dft_energy class from #744 where the volume of the dft object was not being stored as a class member and therefore not used to normalize the energy density values as part of the quadrature.

Also adds a Scheme example demonstrating the equivalence of computing the group velocity of a waveguide mode (from the EigenModeSource tutorial) using two different methods: (1) as the ratio of the Poynting flux to energy density and (2) directly via get-eigenmode-coefficients involving mode decomposition. This example can be ported to Python as part of #747. The test would verify that the relative error in the two values converges monotonically to 0 as the resolution is increased (e..g., 10, 20, and 40).

@oskooi oskooi added the bug label Mar 4, 2019
@@ -1082,6 +1082,7 @@ class dft_energy {
double freq_min, dfreq;
int Nfreq;
dft_chunk *E, *H, *D, *B;
volume where;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed only if you add an fields::output_dft method for dft_energy.

E = add_dft(direction_component(Ex, d), where->v, freq_min, freq_max, Nfreq, true, 1.0, E);
D = add_dft(direction_component(Dx, d), where->v, freq_min, freq_max, Nfreq, false, 1.0, D);
H = add_dft(direction_component(Hx, d), where->v, freq_min, freq_max, Nfreq, true, 1.0, H);
B = add_dft(direction_component(Bx, d), where->v, freq_min, freq_max, Nfreq, false, 1.0, B);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to pass false for two of the fields is what is fixing your dV factor. Adding the where field to dft_energy is unrelated (and is actually unused in this PR).

@stevengj stevengj merged commit b9a1141 into NanoComp:master Mar 6, 2019
@oskooi oskooi deleted the dft_energy_volume_bug branch July 18, 2019 16:22
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
…computing group velocity (NanoComp#753)

* add volume to dft_energy

* add example demonstrating equivalence of computing group velocity using two methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants