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
fields instability when combining 2+ mirror symmetries with periodic boundary conditions in 3d #132
Comments
Triggering the bug requires periodic boundary conditions, and more than one mirror symmetry, one of which must be
Also, based on the formulas Steven gave me for converting from 3D points to a 1D array, there appears to be an off-by-one error. For example, with only
Now converting the 3D points into a 1D array with
However, adding |
By any chance, does this patch fix it? --- a/src/structure.cpp
+++ b/src/structure.cpp
@@ -160,7 +160,7 @@ void structure::choose_chunkdivision(const grid_volume &thegv, int desired_num_c
v = gv.surroundings();
// Pad the little cell in any direction that we've shrunk:
for (int d = 0; d < 3; d++)
- if (break_this[d]) gv = gv.pad((direction)d);
+ if (break_this[d] && thegv.num_direction((direction)d) & 1) gv = gv.pad((direction)d);
} |
(In #1045, @oskooi said that the problem arises when the Another thing to check would be this line: it says note that (That comment goes way back to commit 4e8a6d5 … in @droundy's original implementation, symmetries were only supported for an even number of pixels in a given direction. I "fixed" this, but maybe I messed something up at that time?) |
Adding the line resolution = 15
resolution = 20 (fields blow up)
resolution = 30 (fields blow up)
|
I think I have discovered the cause of this bug as well as a potential fix/workaround. First is the cause. The fields blow up whenever three conditions are satisfied: (1) the (The original example in this thread involved an Ez source with an odd mirror-symmetry plane in z. The same bug can also be demonstrated using an Ex or Ey source with an odd mirror-symmetry in x or y, respectively.) The fix: force cell padding in only the direction of the odd mirror-symmetry plane by increasing/decreasing the size of the cell by one pixel (i.e., for an Ej source in a cell with even number of pixels in all directions, add one pixel to the j direction). The key is to modify the cell size so that padding occurs in only the direction of the odd mirror-symmetry plane. This is demonstrated by the following example for an Ey source with the fix shown in Case 2. (set-param! resolution 10)
(define-param sx 1.0)
(define-param sy 1.0)
(define-param sz 1.0)
(set! geometry-lattice (make lattice (size sx sy sz)))
(set! sources (list (src (make source
(src (make gaussian-src (frequency 1) (fwidth 1)))
(component Ey)
(center 0 0 0)))))
(set! k-point (vector3 0 0 0))
(set! symmetries (list (make mirror-sym (direction X) (phase +1))
(make mirror-sym (direction Y) (phase -1))
(make mirror-sym (direction Z) (phase +1))))
(define print-field (lambda ()
(print "ey:, "
(meep-time) ", "
(magnitude (get-field-point Ey (vector3 0 0 0))) "\n")))
(run-until 100 (at-every 3.4 print-field)) Case 1: no padding
result: unstable *** Case 2: padding in y
*** result: stable Case 3: padding in z
result: unstable Case 4: padding in x
result: unstable Case 5: padding in x and y
result: unstable Case 6: padding in y and z
result: unstable Case 6: padding in x, y, and z
result: unstable |
With (set-param! resolution 10)
(define-param sx 1.0)
(define-param sy 1.0)
(define-param sz 1.0)
(set! geometry-lattice (make lattice (size sx sy sz)))
(set! sources (list (src (make source
(src (make gaussian-src (frequency 1) (fwidth 1)))
(component Ey)
(center 0 0 0)))))
(set! k-point (vector3 0.5 0.5 0.5))
(set! symmetries (list (make mirror-sym (direction X) (phase +1))
(make mirror-sym (direction Y) (phase -1))
(make mirror-sym (direction Z) (phase +1))))
(define print-field (lambda ()
(print "ey:, "
(meep-time) ", "
(magnitude (get-field-point Ey (vector3 0 0 0))) "\n")))
(run-until 100 (at-every 3.4 print-field)) |
Might be worth looking at the fields at the edge of the cell (using (Note that if you call the |
As has been already reported on the meep-discuss list, there is a bug which leads to field instabilities when combining 3 mirror-symmetry objects with periodic boundary conditions in 3d.
This is demonstrated by the following simple example of a point source in vacuum:
For this script, the fields begin to blow up early on:
There are no instabilities if the Z mirror-symmetry object is removed:
The text was updated successfully, but these errors were encountered: