On Wed, Sep 15, 2010 at 09:03:13PM -0400, Steven G. Johnson wrote:
> > I haven't been able to disable the subpixel-averaging in the
> > Scheme interface using (set! eps-averaging? false).
> Putting it anywhere before run or init-params should work.
>
> Are you sure that it's running the subpixel averaging? Maybe you are
> just doing something where initializing the dielectric function is
> extremely expensive for some reason?
I have a moderately complicated function (I'd say, I'm not a Scheme expert, but
it computes a square root and an arctangent and has a couple of conditionals)
as my material-function, and only one block with that function as the material.
I am reporting Meep's output, as it is telling me that
"subpixel-averaging is 13.0526% done, 27.2052 s remaining" so I believe it is
still doing subpixel averaging.
> Or possibly are you running out of RAM and your system is thrashing
> the disk?
It does not seem so, but it might be. Of course, it is not going to
fit in RAM once it starts doing the actual FDTD...
I have attached my CTL file to this email, in case anybody wants to comment.
If I could reduce the resolution, my life would be easier, but the issue is that
the structure is a tube with a diameter on the order of 4 micron, but with some
features on the order of 5 or 10 nm. The worst part is that we want to study
those features, as they seem to be relevant to the optical properties of the
structure. Would subpixel averaging let me get away with a smaller resolution
or do I need to go to a FDTD program supporting a non-uniform grid?
As Ardavan was saying, it might be better if I design the structure with
Meep geometrical objects. Do you think that would work for this case?
Thanks a lot!
Pablo B.
; NOTE: I am taking the base distance unit as a = 1 um.
; Thus, all distances are expressed in microns.
; What to compute.Set "dotime" to 1 to do the full FDTD, and set it to zero
; to compute the static field at wavelength "lcen".
(define-param dotime 1)
; Do 3D or 2D simulation?
(define-param do3d 1)
; How much time to run in CW FDTD?
(define-param runtime 5000)
; Plot fields?
(define-param plotfields 0)
; Wavelength excitation
(define-param lcen 1.550) ; pulse center wavelength (um)
(define-param dl 0.050) ; pulse width (um)
; Tube parameters.
(define-param n 3.433) ; layer index
(define-param n0 1) ; index of outside medium
(define-param r0 2.5) ; inner radius (um)
(define-param d 0.025) ; wall thickness (um)
(define-param turns 5) ; number of turns
(define-param oangle 0) ; angle where the outer layer stops (radian)
(define-param w 2.5) ; belt half-width (um)
(define-param h 0.010) ; belt height (um)
(define l (+ (* 2 w) 1 )) ; The tube length is the belt width + 2 um (one
um on each side).
(define r2 (+ r0 (* turns d))) ; An upper boundary for the radius.
(set! eps-averaging? false)
;(set! subpixel-maxeval 1)
;(set! subpixel-tol 1e-2)
; PMLs and padding
(define-param rpad (/ r2 4)) ; padding around the tube
(define-param zpad 0); ; padding on the tube length
(define-param dpml 3) ; thickness of PML
; Define cell geometry
(define sizex (* 2 (+ r2 rpad dpml))) ; xcell size
(define sizey (* 2 (+ r2 rpad dpml))) ; ycell size
(if (= do3d 0)
(define sizez no-size)
(define sizez (+ l zpad dpml)) ; zcell size
)
(set! geometry-lattice (make lattice (size sizex sizey sizez)))
; Function defining the tube geometry
; (p is a vector3 denoting the position in space)
(define (utube-eps p)
(define pz (vector3-z p))
(define pr (sqrt (+ (* (vector3-x p) (vector3-x p)) (* (vector3-y p)
(vector3-y p))))) ; Calculate the radial coordinate.
(define pp (atan (vector3-y p) (vector3-x p))) ; Calculate the
azimuthal one.
(define rin 0)
(define rout 0)
(define nturns turns)
(set! rin (+ r0 (* (/ d 2 pi) pp))) ; Inside radius at this angular
position.
(if (< pp oangle) ; Check if we need n or n-1 turns.
(set! nturns turns)
(set! nturns (- turns 1))
)
(set! rout (+ rin (* nturns d))) ; The corresponding outside radius.
(if (and (< pz w) (> pz (- w)))
(if (and (< pr rout) (> pr (- rin h))) ; Inside the belt...
(* n n) ; Inside the wall...
(* n0 n0) ; Outside the wall...
)
(if (and (< pr rout) (> pr rin)) ; Outside the belt...
(* n n) ; Inside the wall...
(* n0 n0) ; Outside the wall...
)
)
)
; Define the geometry.
;(set! default-material (make material-function (epsilon-func utube-eps)))
;(make block (center 0 0 0) (size (* 2 r2 ) (* 2 r2) l))
(set! geometry
(list
(make block (center 0 0 0) (size (* 2 r2 ) (* 2 r2) l)
(material (make material-function (epsilon-func utube-eps))))
)
)
; Convert wavelength to MEEP frequency units.
(define fcen (/ 1 lcen)) ; pulse center frequency
(define df (- (/ 1 lcen) (/ 1 (+ lcen dl)))) ; pulse width (in MEEP units)
(print "fcen: " fcen ", df: " df "\n")
; Source location: Inside the tube, in the center, close to the outer wall.
; NOTE: The source MUST be at z=0! (for the symmetry to be right).
(define source-pt (vector3 0 (+ r0 (/ (* d turns) 2)) 0))
; Measurement locations.
; cpl: Right inside the ring.
(define meas-cpl-pt (vector3 (- 0 (+ r0 d)) 0 0))
; Component to excite and measure (TE modes).
(define my-component Ez)
; Set mirror symmetry along the z-axis (even).
(set! symmetries (list (make mirror-sym (direction Z))))
(set! pml-layers (list (make pml (thickness dpml))))
(set-param! resolution 20)
; Function to display the relevant component of the coupled field.
(define (my-output-coupled)
(print "coupled field:\t " (meep-time) "\t "
(get-field-point my-component meas-cpl-pt) "\n")
)
;Do the run.
(cond
((= dotime 0)
(begin
(display "Computing the CW field.\n")
; Set a continuous source.
(set! sources
(list
(make source
(src (make continuous-src (frequency fcen)))
(component my-component) (center source-pt)
)
)
)
(set! force-complex-fields? true)
(init-fields)
(meep-fields-solve-cw fields)
; Plot the result.
(output-efield)
)
)
((= dotime 1)
(begin
(display "Computing the full FDTD evolution with a gaussian
source.\n")
; Set a gaussian source.
(set! sources
(list
(make source
(src (make gaussian-src (frequency fcen) (fwidth df)))
(component my-component) (center source-pt)
)
)
)
(run-sources+
runtime
;(stop-when-fields-decayed (* 1000 (/ 1 fcen)) my-component
meas-cpl-pt 1e-3)
(at-beginning output-epsilon)
(after-sources my-output-coupled)
(after-sources (harminv Ez meas-cpl-pt fcen df))
)
(if (zero? plotfields)
(display "I won't plot the fields.\n")
(begin
(run-until (/ 2 fcen)
(in-volume (volume (center 0) (size (* 2 sizex) (* 2 sizey)
0)))
(at-every (/ 1 fcen 20) (output-png+h5 my-component "-0 -Zc
dkbluered -C $EPS"))
)
)
)
)
)
((= dotime 2)
(begin
(display "Computing FDTD fields with a CW source.\n")
; Set a continuous source.
(set! sources
(list
(make source
(src (make continuous-src (frequency fcen)))
(component my-component) (center source-pt)
)
)
)
(run-until runtime (at-beginning output-epsilon)) ; Run the
simulation.
(if (zero? plotfields)
(display "I won't plot the fields.\n")
(begin
(run-until (/ 2 fcen)
(in-volume (volume (center 0) (size (* 2 sizex) (* 2
sizey) 0)))
(at-every (/ 1 fcen 20) (output-png+h5 my-component "-0
-Zc dkbluered -C $EPS"))
)
)
)
)
)
(else (display "Unknown dotime value! I don't know what to do...\n"))
)
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss