File: 3rd-harm-1d.ctl

package info (click to toggle)
meep-openmpi 1.25.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 64,556 kB
  • sloc: cpp: 32,214; python: 27,958; lisp: 1,225; makefile: 505; sh: 249; ansic: 131; javascript: 5
file content (55 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; 1d simulation of a plane wave propagating through a Kerr medium
; and generating the third-harmonic frequency component.

(define-param sz 100) ; size of cell in z direction
(define-param fcen (/ 1 3)) ; center frequency of source
(define-param df (/ fcen 20)) ; frequency width of source
(define-param amp 1.0) ; amplitude of source
(define-param k 1e-2) ; Kerr susceptibility

(define-param dpml 1.0) ; PML layer thickness

; We'll use an explicitly 1d simulation.  Setting dimensions=1 will actually
; result in faster execution than just using two no-size dimensions.  However,
; in this case Meep requires us to use E in the x direction (and H in y),
; and our one no-size dimension must be z.
(set-param! dimensions 1)
(set! geometry-lattice (make lattice (size no-size no-size sz)))

; to put the same material in all space, we can just set the default material
(set! default-material (make dielectric (index 1) (chi3 k)))

(set! pml-layers (list (make pml (thickness dpml))))
(set-param! resolution 20)

(set! sources (list
               (make source
                 (src (make gaussian-src (frequency fcen) (fwidth df)))
                 (component Ex)
                 (center 0 0 (+ (* -0.5 sz) dpml))
		 (amplitude amp))))

; frequency range for flux calculation
(define-param nfreq 400)
(define-param fmin (/ fcen 2))
(define-param fmax (* fcen 4))

(define trans ; transmitted flux
  (add-flux (* 0.5 (+ fmin fmax)) (- fmax fmin) nfreq
	    (make flux-region (center 0 0 (- (* 0.5 sz) dpml 0.5)))))

; also compute a ''single'' flux point at fcen and 3*fcen
(define trans1 (add-flux fcen 0 1 (make flux-region
				    (center 0 0 (- (* 0.5 sz) dpml 0.5)))))
(define trans3 (add-flux (* 3 fcen) 0 1 (make flux-region
					(center 0 0 (- (* 0.5 sz) dpml 0.5)))))

(run-sources+
 (stop-when-fields-decayed 50 Ex
			   (vector3 0 0 (- (* 0.5 sz) dpml 0.5))
			   1e-6))

(display-fluxes trans)

(print "harmonics:, " k ", " amp ", "
       (first (get-fluxes trans1)) ", " (first (get-fluxes trans3)) "\n")