[Meep-discuss] reintroducing units in meep
Excellent. If it helps anyone else, here's a new version incorporating Steven's suggestions. Best Regards, Matt (define-param unit 1e-3); base unit in meters (1e-3 = 1 mm) (define-param fh 3e9) ; frequency in hertz (define-param res_ppw 20) ; resolution in pixels per wavelength (define-param num_periods 10) ; number of periods to let simulation run for (define lam (/ 3e8 fh)) ; free space wavelength (meters) (define lamu (/ lam unit)) ; wavelength in base units (define fcen (/ unit lam)) ; source center frequency (define-param csize (* lamu 8)) ; make the cell size 8*lambda (set! geometry-lattice (make lattice (size csize csize no-size))) (set! geometry (list (make block (center 0 0) (size csize csize no-size) (material air (set! pml-layers (list (make pml (thickness 100 (set-param! resolution (/ res_ppw lamu)) ; set temporal width equal to 2 wavelength (set! sources (list (make source (src (make continuous-src (frequency fcen) (width 20))) (component Ez) (center 0 0 (use-output-directory) (run-until (* num_periods lamu) (at-every (/ lamu 10) (output-png Ez -S 2 -Zc dkbluered))) ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
Re: [Meep-discuss] reintroducing units in meep
Your example has numerous problems. First, your computational cell size is too small to really observe the wavelength anyway, since it is only half a wavelength in diameter and your source is at the center, so it only has 1/4 wavelength to propagate before it reaches the edge of the cell. Second, your PML thickness is only 10mm, or 1/10 of your wavelength (100mm), which is probably too thin. Also, note that the PML layer is *inside* the boundary of your cell, which means that your computational cell is even smaller than you think: the region inside the PML is only 30mm by 30mm, or 1/3 of a wavelength. Third, your resolution is far larger than you need. You specified a resolution of 10, and since your units are mm, this means you have 1000 pixels per wavelength. You should see an accurate picture with only 20 pixels per wavelength, or a resolution of 0.2 pixels/mm. Fourth, you are running for a ridiculously short time. Since you have a wavelength of 100, then in Meep units (time = distance since c=1), the period is 100. So, you are running for a time of 200, or only 2 periods. This is not long enough for the fields to reach steady state. Fifth, the default is for the source to turn on suddenly at t=0, which means that over short timescales you will get all sorts of high-frequency transient effects. You can use the width parameter of continuous-src to cause it to turn on gradually. Sixth, you are outputting every 1 time unit, or 100 times per period. This is probably more than you want, since outputting 10 times per period is usually plenty in order to see a nice smooth animation. Seventh, you don't need (exit) at the end. Meep will quit automatically at the end as long as you have at least one run statement, unless you set interactive? to true at the end. Correct these problems, and you should see what you expect. Cordially, Steven G. Johnson ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
[Meep-discuss] reintroducing units in meep
Hello, I'd like to reintroduce units in meep, but I'm not getting the results I'm expecting. Following the description in Units in Meep, let's say it's convenient for me to specify distances in millimeters. For a source frequency of 3 GHz, free space lambda is .1 meters, or 100 mm. The description tells me that I want to set the source frequency to 1/100 = .01. Next I define the cell size to be something large enough that I can see how long a wavelength is, but not so large that it takes a long time to compute. Let's make it half a wavelength. First I convert lambda to the base length I chose (1 mm), then divide by 2. The result I get is appears to have a wavelength which is much smaller than the size of the computation cell. (Also, something else I didn't understand, the source appears to turn off quickly, even though I don't specify a turn off time). Any ideas on where I'm going wrong here? Best Regards, Matt (define unit 1e-3) ; base unit in meters (1e-3 = 1 mm) (define fh 3e9) ; frequency in hertz (define lam (/ 3e8 fh)) ; free space wavelength in meters (define fcen (/ unit lam)) (define-param csize (/ (/ lam unit) 2)) ; make the cell size lam/2 (define-param eps 1) (set! geometry-lattice (make lattice (size csize csize no-size))) (set! geometry (list (make block (center 0 0) (size csize csize no-size) (material air (set! pml-layers (list (make pml (thickness 10 (set-param! resolution 10) (set! sources (list (make source (src (make continuous-src (frequency fcen))) (component Ez) (center 0 0 (use-output-directory) (run-until 200 (at-every 1.0 (output-png Ez -Zc bluered))) (exit) ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss