NanoComp / libctl

Guile-based library implementing flexible control files for scientific simulations
GNU General Public License v2.0
19 stars 22 forks source link

bug in find_best_partition #32

Closed stevengj closed 5 years ago

stevengj commented 5 years ago

The following input file gives an error in Meep, which seems to occur due to a bug in libctl:

(define-param offset 0) ; waveguide offset (positive is away from lens)
(set! geometry-lattice (make lattice (size 44.000000 32.000000 no-size)))

; Permittivity of all the materials from refractiveindex.info
(define (square x) (* x x))
(define eps_SiN (square 1.584000))
(define eps_aSi (square 1.775000))
(define eps_SiO2 (square 1.44))

(set! default-material (make dielectric (epsilon eps_SiO2)))
(set! geometry (list
    (make block
      (center (- 5.000000 (/ offset 2)) 0)
      (size (+ 34.000000 offset) 32.000000 )
      (material (make dielectric (epsilon eps_SiN)))) ; waveguide slab
    (make block
      (center 0 0)
      (size 44.000000 1 )
      (material (make dielectric (epsilon eps_SiN)))) ; waveguide
    (make cylinder
      (center 6.000000 0.000000)
      (radius 5.918882)
      (height infinity)
      (material (make dielectric (epsilon eps_aSi))))
    (make cylinder
      (center 1.843100 -4.000000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 2.189500 -4.200000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 2.535900 -4.400000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 2.882300 -4.600000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 3.228700 -4.800000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 3.575100 -5.000000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 3.921500 -5.200000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 4.267900 -5.400000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
    (make cylinder
      (center 4.614400 -5.600000)
      (radius 0.150000)
      (height infinity)
      (material (make dielectric (epsilon eps_SiN))))
))

; Waveguide mode, eigenmode solved by MPB
(change-sources! (list
  (make eigenmode-source
  (src (make continuous-src (wavelength 1.550000) ))
  (component Hz)
  (size no-size 10.000000)
  (center -21.000000 0)
  (eig-match-freq? true)
  (eig-parity ODD-Y))))

(set! pml-layers (list (make pml (thickness 1))))
(set! resolution 30)
(set! symmetries (list (make mirror-sym (direction Y)(phase -1))))

(run-until 500
  (at-beginning output-epsilon)
  (at-end output-hfield-z))

gives

bug 1 in find_best_partition

That is, this assertion is failing.

Thanks to samkim@mit.edu for the bug report.

stevengj commented 5 years ago

This seems to be a compile bug, grr. Changing from -O2 to -O fixes the problem, as well as minor rearrangements of the code. (This is gcc 6.3.0-18+deb9u1 on Debian x86_64.)

I'll check in a workaround.