-
Notifications
You must be signed in to change notification settings - Fork 641
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
;; compute group velocity of a waveguide mode using two different methods | ||
;; (1) ratio of Poynting flux to energy density | ||
;; (2) via MPB from get-eigenmode-coefficients | ||
|
||
(set-param! resolution 20) | ||
|
||
(set! geometry-lattice (make lattice (size 10 5 no-size))) | ||
|
||
(set! geometry (list (make block | ||
(center 0 0 0) | ||
(size infinity 1 infinity) | ||
(material (make medium (epsilon 12)))))) | ||
|
||
(set! pml-layers (list (make pml (thickness 1)))) | ||
|
||
(define-param fsrc 0.15) | ||
|
||
(set! sources (list (make eigenmode-source | ||
(src (make gaussian-src (frequency fsrc) (fwidth (* 0.2 fsrc)))) | ||
(center -3 0 0) | ||
(size 0 5 0) | ||
(eig-band 1) | ||
(eig-parity (+ ODD-Z EVEN-Y)) | ||
(eig-match-freq? true)))) | ||
|
||
(define flux (add-flux fsrc 0 1 (make flux-region (center 3 0 0) (size 0 5 0)))) | ||
(define energy (add-energy fsrc 0 1 (make energy-region (center 3 0 0) (size 0 5 0)))) | ||
(run-sources+ 100) | ||
|
||
(define res (get-eigenmode-coefficients flux (list 1) #:eig-parity (+ ODD-Z EVEN-Y))) | ||
(define mode-vg (array-ref (list-ref res 1) 0 0)) | ||
|
||
(define poynting-flux (list-ref (get-fluxes flux) 0)) | ||
(define e-energy (list-ref (get-electric-energy energy) 0)) | ||
(define ratio-vg (/ (* 0.5 poynting-flux) e-energy)) | ||
|
||
(print "group-velocity:, " ratio-vg ", " mode-vg "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1053,7 +1053,7 @@ class dft_flux { | |
class dft_energy { | ||
public: | ||
dft_energy(dft_chunk *E_, dft_chunk *H_, dft_chunk *D_, dft_chunk *B_, | ||
double fmin, double fmax, int Nf); | ||
double fmin, double fmax, int Nf, const volume &where_); | ||
dft_energy(const dft_energy &f); | ||
|
||
double *electric(); | ||
|
@@ -1082,6 +1082,7 @@ class dft_energy { | |
double freq_min, dfreq; | ||
int Nfreq; | ||
dft_chunk *E, *H, *D, *B; | ||
volume where; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needed only if you add an |
||
}; | ||
|
||
// stress.cpp (normally created with fields::add_dft_force) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 thewhere
field todft_energy
is unrelated (and is actually unused in this PR).