MEEP(Open)
[
Front page
] [
New
|
Page list
|
Search
|
Recent changes
|
Help
|
Log in
]
Start:
[Started by Maruoka and Maeda, 2018/10/24]
[Updated by Maruoka, 2018/01/25]
If you have question about MEEP and send it to maru@flex....
*index [#e16fd6bb]
#contents
*How to install [#ldc78cdd]
First of all, let's install Anaconda.
From [[The websit of Anaconda:https://www.anaconda.com/do...
Since the installer is of the file of .sh, execute it as ...
$ bash [download-folder]/Anaconda3-5.2.0-Linux-x86_64.sh
If you find
bash: conda: command not found
then you need to add PATH for ~/anaconda3/bin .
Following command will add path to anaconda3/bin.
setenv PATH $PATH\:<path to anaconda3/bin>
Do not use relative path which does not work correctly.
Then, let's install pymeep ([https://meep.readthedocs.io/...
Execute the command below.
$ conda create -n mp -c chogan -c conda-forge pymeep
All setup is finished.
*How to execute [#padb0b5f]
Activate the system as below.
$ source activate mp
Execute the file as below.Please rename hogehoge.py as wh...
(mp) $ python hogehoge.py
You can get sample source from Github.[https://github.com...
If you want to deactivate the system, do as below.
(mp) $ source deactivate
*parallelization of MEEP [#h659d054]
***installation([https://meep.readthedocs.io/en/latest/In...
In order to install pymeep which support parallel calcula...
$ conda create -n pmp -c chogan -c conda-forge pymeep-pa...
***Execution [#ld3fff3a]
Activate pymeep which support parallel calculation by fol...
$ source activate pmp
Programs run with following command.
$ mpirun -np 4 python <script_name>
"-np" indicate how many processors will run. In this case...
*Maxwell equation of MEEP [#v15ce75e]
Maxwell equation of MEEP is different from ordinal Maxwel...
For example,
++User define unit length, a.
++Permittivity of vacuum is 1
++Permeability of vacuum is 1
The Maxwell equation of MEEP is in the last line of below...
[https://meep.readthedocs.io/en/latest/Introduction/ Refe...
From ordinal Maxwell equation below,
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
deform it as follows.
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Define x',y',z',t',{\omega}',E',H',{\sigma}' as follows.
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Substitute new defined parameters, and get Maxwell equati...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Here, permittivity of vacuum and permeability of vacuum a...
Unit length is a which user can define freely.
During unit time, the light in vacuum travels by unit len...
The wavelength of light in vacuum of which frequency is f...
*How to edit the HDF5 file ? [#qe50ab81]
The h5py package can be used for editing HDF5 file in pyt...
Install it by the following command.
apt-get install python-h5py
h5py is already installed on flex and tubes.
On maruoka's WSL,
pip install h5py
doesn't work saying
ImportError: No module named h5py
*Useful script for converting hdf5 to mp4 and gif [#b4314...
It is useful to use script below to automatically convert...
function h5mp4(){
mkdir $1
cp $1.h5 $1
cd $1
h5topng $1.h5 -Z -c dkbluered -R -t 0:$2
convert $1*png $1.gif
ffmpeg -i $1.gif -qscale:v 1 $1.mp4
}
For example, if you want to convert hogehoge.h5 which hav...
h5mp4 hogehoge 999
It output hogehoge.gif and hogehoge.mp4 automatically.
If you want to know the number of time indexes,do as foll...
h5ls hogehoge.h5
ez Dataset{100, 200, 1000/Inf}
Here, 1000 is the number of time indexes.
*source for incident light [#r32309cc]
**left-handed circularly polarized light (Scheme)[#u95702...
We can modify the phase of source by the amplitude.
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
(amplitude (exp (* 0+1i 1.570796327)))
)
)
)
**right-handed circularly polarized light (Scheme) [#u957...
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
(amplitude (exp (* 0+1i 1.570796327)))
)
)
)
**the light linearly polarized at x radian (Scheme)[#u957...
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
(amplitude (cos x))
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
(amplitude (sin x))
)
)
)
**the light at oblique incident angle (Scheme)[#y9a5c654]
There are three ways to implement oblique incident light.
***Bloch's periodic boundary with modifying phase of the ...
TM wave just before total internal reflection.
(define (pw-amp k x0) (lambda (x)
(exp (* 0+1i (vector3-dot k (vect...
(define-param theta-deg 48)
(define theta-rad (deg->rad theta-deg))
(define epsilon1 2.25)
(define epsilon2 1.25)
(define-param fcen 0.8) ; pulse center frequency
(define-param df 0.02) ; turn-on bandwidth
(define-param kdir (vector3 (sin theta-rad) 0 (cos theta...
(define k (vector3-scale (* 2 pi fcen (sqrt epsilon1))
(unit-vector3 kdir))) ; k with c...
(set! pml-layers (list (make pml (thickness 2)(direction...
(set! k-point (vector3* (* fcen (sqrt epsilon1) ) (vecto...
(set! geometry
(list
(make block
(center 0 0 -2.5)
(size 10 infinity 5)
(material (make dielectric(epsilon epsilon1)))
)
(make block
(center 0 0 2.5)
(size 10 infinity 5)
(material (make dielectric(epsilon epsilon2)))
)
)
)
(set! sources
(list
(make source
(src (make continuous-src (frequency fcen) (fwi...
(component Ez) (center 0 0 -3) (size 10 0 0)
(amp-func (pw-amp k (vector3 0 0 -3))))))
(define-param T 40) ; run time
(run-until T
(to-appended "ez" (at-every 0.1 output-efield...
(to-appended "ex" (at-every 0.1 output-efield...
)
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
***two sources with modifying phase (Scheme) [#d178c899]
; This example creates an approximate Ez-polarized plane...
; propagating at a 45-degree angle, by using a couple of...
; with amplitude exp(ikx) corresponding to the desired p...
(define-param s 11) ; the size of the computational cell...
(define-param dpml 1) ; thickness of PML layers
(define sxy (+ s (* 2 dpml))) ; cell size, including PML
(set! geometry-lattice (make lattice (size sxy sxy no-si...
(set! pml-layers (list (make pml (thickness dpml))))
(set-param! resolution 10)
; pw-amp is a function that returns the amplitude exp(ik...
; given point x. (We need the x0 because current amplit...
; in Meep are defined relative to the center of the curr...
; whereas we want a fixed origin.) Actually, it is a fu...
; and x0 that returns a function of x ...
(define (pw-amp k x0) (lambda (x)
(exp (* 0+1i (vector3-dot k (vector3+ x x0))))))
(define-param fcen 0.8) ; pulse center frequency
(define-param df 0.02) ; turn-on bandwidth
(define-param kdir (vector3 1 1)) ; direction of k (leng...
(define-param n 1) ; refractive index of material contai...
(define k (vector3-scale (* 2 pi fcen n)
(unit-vector3 kdir))) ; k with ...
(set! sources
(list
; left
(make source
(src (make continuous-src (frequency fcen) (fwidth df)))
(component Ez) (center (* -0.5 s) 0) (size 0 s)
(amp-func (pw-amp k (vector3 (* -0.5 s) 0))))
; bottom
(make source
(src (make continuous-src (frequency fcen) (fwidth df)))
(component Ez) (center 0 (* -0.5 s)) (size s 0)
(amp-func (pw-amp k (vector3 0 (* -0.5 s)))))
))
(define-param T 400) ; run time
(run-until T (at-end output-efield-z))
[https://github.com/stevengj/meep/blob/master/scheme/exam...
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
plot of Ez when there is only one source ( why we need tw...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
***array many point-sources (Scheme)[#bb9694c1]
http://article.gmane.org/gmane.comp.science.electromagnet...
(define-param pi 3.14159265)
(define-param dpml 3.0)
(define-param len (+ 20 dpml))
(define-param wid (+ 20 dpml))
(set! geometry-lattice (make lattice (size len wid no-si...
(define-param beam-waist 2.5) ; beam sigma (gaussian bea...
(define-param rotation-angle (* (/ 22.5 360) 2 pi)) ; De...
(define-param source-points 60) ; should be a big number
(define-param source-size (* 4 beam-waist)) ; should be ...
(define-param src_list (list ))
(do
((
r_0
(/ source-size -2)
(+ r_0 (/ source-size (- source-points 1)))
))
((> r_0 (/ source-size 2)))
;for r_0 = -sour...
(set! src_list (append src_list
(list (make source
(src (make gaussian-src
(wavelength 1)
(width 3)
))
(amplitude (exp (- 0 (/...
(component Ez)
(center (* r_0 (sin rot...
))
))
)
(set! sources src_list)
(set! pml-layers (list (make pml
(thickness dpml)
)))
(set! resolution 10)
(use-output-directory)
(run-until (* 2 len)
(to-appended "ez" (at-every 0.1 output-efield...
)
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
*Plot of Electric field Vector [#b59ce919]
Electric field of Total Internal Reflection
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/e...
Code for simulation
(define-param dx 1); cell size in x axis
(define-param dy 2); cell size along y axis
(define-param fp 1.5)
(define-param tpml 0.1); PML thickness
(define-param deg 48)
(define-param theta (* pi 0.88889)); incident angle of t...
(set! theta (* deg (/ pi 180)))
(set! resolution 40);define the resolution for simulatio...
;define the lattice
(set! geometry-lattice (make lattice (size (+ dx (* 2 tp...
;define PML thickness
(set! pml-layers (list (make pml (thickness tpml))))
;define the blocks
(set! geometry (list
(make block (center 0 (* 0.25 dy))(size infinity (+ tpm...
(material (make dielectric (epsilon 1))))
(make block (center 0 (* -0.25 dy))(size infinity (+ tp...
(material (make dielectric (epsilon 2.25))))
))
(set! pml-layers (list (make pml (thickness tpml))))
;(+ tpml (* 0.5 dy))
;define the wave vector
(define kx (* fp (sqrt 2.25) (sin theta)))
;give the amplitude function
(define (f_amp p) (exp (* 0+2i pi kx (vector3-x p))))
(set! k-point (vector3 kx 0 0))
;define the simulation domain to be complex field
(set! force-complex-fields? true)
;define the Gaussian beam
(set! sources
(list
(make source
(src (make continuous-src (frequency fp)))
(component Ex)
(component Ey)
(center 0 (* dy -0.50))
(size (+ dx (* 2 tpml)) 0 )
(amp-func f_amp))))
(set! pml-layers (list (make pml (thickness tpml) (direc...
;extract the data to .png file
(run-until 40
(at-beginning output-epsilon)
;(at-end output-efield-y)
(to-appended "ey"(at-every 0.05 (in-volume (volume (cent...
(to-appended "ex"(at-every 0.05 (in-volume (volume (cent...
)
If you want to plot electric field vector, you need to pl...
The ax.quiver function of matplotlib is good idea to plot...
*material library [#ba28d968]
**Scheme [#s98e0c37]
To use material library, add
(include "/home/students/maru/meep/scheme/materials.scm")
at the beginning of your program.
This library only works at tube61, 62, 63.
For how to use the material library, check https://meep.r...
You need to specify unit to use material library.
The default is 1000 micro meter.
In order to change the unit to 100 micro meter, add
(set! um-scale (* um-scale 0.1))
**Python [#r0a53c68]
You don't need to load materials.py by yourself like sche...
The default unit length is 1000nm in materials.py.
If you want to use another unit length, you need to rewri...
After the line where um_scale is defined, change the um_s...
For example, if you want to use 100nm for unit length, ad...
um_scale=um_scale*0.1
To modify materials.py, you can check the address of mate...
(pmp) maru@tube60:~$ python
Python 3.6.6 | packaged by conda-forge | (default, Jul 2...
import meep Using MPI version 3.1, 1 processes
meep.__file__
'/home/students/maru/anaconda3/envs/pmp/lib/python3.6/si...
In this case, the address of materials.py is
/home/students/maru/anaconda3/envs/pmp/lib/python3.6/sit...
This modification of materials.py has effect only for pmp.
If you want to change the unit length for mp, please chan...
*User defined relative permittivity of Drude conductivity...
Meep support user defined relative permittivity of Drude ...
\epsilon_\infty is approximately the relative permittivit...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/drude_epsi...
Since the relative permittivity of Drude conductivity is ...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/drude_epsi...
From this formula, f_p and gamma of SI unit and f_p' and ...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/relation_m...
Using f_p', gamma' and epsilon_\infty calculated above,
user_defined_material = mp.Medium(epsilon=epsilon_\infty...
will define the material which have f_p', gamma', epsilon...
In order to use this material, you need to set the option...
*Q&A [#b8d898d0]
**How thick PML should be ?[#l8406a8a]
In the document of PML by one of the the author of MEEP(h...
With PML, however, the constant factor is very good to s...
(Increasing the resolution also increases the resolution...
However, when the light coming at oblique incident angle,...
The reflectivity of PML for incident angle at X can be re...
e^{-2*k*d*cos(X)*G}
for some constant G. d is the thickness of PML. k is the ...
If X approaches to 90 degree, the efficiency of the absor...
**PML shows reflectance. [#o360c5d3]
If you put dielectrics touching to the PML, please confir...
It is implemented by just multiplying tensors on dielectr...
[http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/...
[http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/...
** ERROR: Unbound variable: E-susceptibilities [#qd0361a8]
Following error occurs, when you try to use material libr...
ERROR: Unbound variable: E-susceptibilities
Material library only works at tube61, 62, 63.
Please go to tube61, 62, 63.
** materials.py doesn't work [#cc53b98c]
If the version is lower than 1.6, materials.py doesn't wo...
Check the version of pymeep by
conda list
If you find
pymeep 1.5
then update pymeep from 1.5 to 1.6 as follows.
(mp) maru@flex:~$ conda update -c chogan -c conda-forge ...
Solving environment: done
## Package Plan ##
environment location: /home/students/maru/anaconda3/env...
added / updated specs:
- pymeep
The following packages will be downloaded:
package | build
---------------------------|-----------------
libctl-4.1.4 | 1 ...
libgdsii-0.2.dev | 0 ...
python-3.6.6 | hd21baee_1003 ...
openssl-1.0.2p | h14c3975_1002 ...
mpb-1.7.0 | nomkl_1 ...
pymeep-1.7.0 | py36_nomkl_1 ...
openblas-0.3.5 | h9ac9557_1000 ...
nomkl-3.0 | 0 ...
ca-certificates-2018.11.29 | ha4d7672_0 ...
certifi-2018.11.29 | py36_1000 ...
-----------------------------------------------------...
Total: ...
The following NEW packages will be INSTALLED:
libgdsii: 0.2.dev-0 chogan
nomkl: 3.0-0
The following packages will be UPDATED:
ca-certificates: 2018.03.07-0 --> 20...
certifi: 2018.11.29-py36_0 --> 20...
libctl: 4.1.2-0 chogan --> 4....
mpb: 1.6.2-4 chogan --> 1....
openblas: 0.2.20-8 conda-forge --> 0....
pymeep: 1.5-py36_nomkl_2 chogan [nomkl...
The following packages will be DOWNGRADED:
openssl: 1.1.1a-h7b6447c_0 --> 1....
python: 3.6.8-h0371630_0 --> 3....
Proceed ([y]/n)? y
Downloading and Extracting Packages
libctl-4.1.4 | 97 KB | #####################...
libgdsii-0.2.dev | 800 KB | #####################...
python-3.6.6 | 29.0 MB | #####################...
openssl-1.0.2p | 3.1 MB | #####################...
mpb-1.7.0 | 74 KB | #####################...
pymeep-1.7.0 | 3.3 MB | #####################...
openblas-0.3.5 | 15.8 MB | #####################...
nomkl-3.0 | 48 KB | #####################...
ca-certificates-2018 | 143 KB | #####################...
certifi-2018.11.29 | 145 KB | #####################...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
If you want to use parallel pymeep, then update it also t...
(pmp) maru@tube60:~$ conda update -c chogan -c conda-for...
Solving environment: done
## Package Plan ##
environment location: /home/students/maru/anaconda3/env...
added / updated specs:
- pymeep-parallel
The following packages will be downloaded:
package | build
---------------------------|-----------------
libgcc-ng-7.3.0 | hdf63c60_0 ...
pymeep-parallel-1.7.0 |py36_nomklh39e3cac_1 ...
-----------------------------------------------------...
Total: ...
The following NEW packages will be INSTALLED:
libgdsii: 0.2.dev-0 chogan
nomkl: 3.0-0
The following packages will be UPDATED:
ca-certificates: 2018.8.24-ha4d7672_0 conda-forge...
certifi: 2018.8.24-py36_1 conda-forge...
libctl: 4.1.2-0 chogan ...
libgcc-ng: 7.2.0-hdf63c60_3 conda-forge...
mpb: 1.6.2-4 chogan ...
openssl: 1.0.2p-h470a237_0 conda-forge...
pymeep-parallel: 1.5-py36_nomklh39e3cac_4 chogan ...
Proceed ([y]/n)? y
Downloading and Extracting Packages
libgcc-ng-7.3.0 | 6.1 MB |
########################################################...
pymeep-parallel-1.7. | 3.3 MB |
########################################################...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
**error on line 497 of h5file.cpp: error opening HDF5 out...
If you find error as below, give permission to working di...
Working in 3D dimensions.
Computational cell is 20 x 20 x 20 with resolution 10
block, center = (0,0,0)
size (1,3,1)
axes (1,0,0), (0,1,0), (0,0,1)
dielectric constant epsilon diagonal = (1,1,1)
time for set_epsilon = 11.7491 s
-----------
creating output file "./hogehoge.h5"...
on time step 1 (time=0.05), 14.4708 s/step
HDF5-DIAG: Error detected in HDF5 (1.10.2) MPI-process 0:
#000: H5F.c line 445 in H5Fcreate(): unable to create f...
major: File accessibilty
minor: Unable to open file
meep: error on line 497 of h5file.cpp: error opening HDF...
application called MPI_Abort(MPI_COMM_WORLD, 1) - proces...
**ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `...
The version of GLIBC at flex is old. Go to t70.
**Internal MPI error! Cannot read from remote process [#g...
If you connect to flex from remote place (e.g. Sendai Kos...
(pmp) maeda@tube60:/abinitio2/maeda/pymeep/Rectangle/dru...
python after-Rec-drude-Au.py 45
Working in 3D dimensions.
Computational cell is 20 x 20 x 20 with resolution 10
block, center = (0,0,0)
size (1,3,1)
axes (1,0,0), (0,1,0), (0,0,1)
dielectric constant epsilon diagonal = (1,1,1)
time for set_epsilon = 5.05642 s
lorentzian susceptibility: frequency=3.47141, gamma=2.01...
lorentzian susceptibility: frequency=2.39466, gamma=0.70...
lorentzian susceptibility: frequency=0.66944, gamma=0.27...
lorentzian susceptibility: frequency=0.33472, gamma=0.19...
drude susceptibility: frequency=1e-10, gamma=0.0427474
-----------
creating output file "./after-Rec-drude-Au-ex-surface-45...
creating output file "./after-Rec-drude-Au-ey-surface-45...
creating output file "./after-Rec-drude-Au-ez-inner-45de...
creating output file "./after-Rec-drude-Au-ez-outer-45de...
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=92, ...
status_array=0xc9e3670) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(623).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=85, ...
status_array=0xd21c7f0) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(658).......: fail failed
MPID_nem_handle_pkt(1439).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=85, ...
status_array=0xcc31ed0) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(658).......: fail failed
MPID_nem_handle_pkt(1439).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Following command will resolve this error when you connec...
export I_MPI_SHM_LMT=shm
End:
[Started by Maruoka and Maeda, 2018/10/24]
[Updated by Maruoka, 2018/01/25]
If you have question about MEEP and send it to maru@flex....
*index [#e16fd6bb]
#contents
*How to install [#ldc78cdd]
First of all, let's install Anaconda.
From [[The websit of Anaconda:https://www.anaconda.com/do...
Since the installer is of the file of .sh, execute it as ...
$ bash [download-folder]/Anaconda3-5.2.0-Linux-x86_64.sh
If you find
bash: conda: command not found
then you need to add PATH for ~/anaconda3/bin .
Following command will add path to anaconda3/bin.
setenv PATH $PATH\:<path to anaconda3/bin>
Do not use relative path which does not work correctly.
Then, let's install pymeep ([https://meep.readthedocs.io/...
Execute the command below.
$ conda create -n mp -c chogan -c conda-forge pymeep
All setup is finished.
*How to execute [#padb0b5f]
Activate the system as below.
$ source activate mp
Execute the file as below.Please rename hogehoge.py as wh...
(mp) $ python hogehoge.py
You can get sample source from Github.[https://github.com...
If you want to deactivate the system, do as below.
(mp) $ source deactivate
*parallelization of MEEP [#h659d054]
***installation([https://meep.readthedocs.io/en/latest/In...
In order to install pymeep which support parallel calcula...
$ conda create -n pmp -c chogan -c conda-forge pymeep-pa...
***Execution [#ld3fff3a]
Activate pymeep which support parallel calculation by fol...
$ source activate pmp
Programs run with following command.
$ mpirun -np 4 python <script_name>
"-np" indicate how many processors will run. In this case...
*Maxwell equation of MEEP [#v15ce75e]
Maxwell equation of MEEP is different from ordinal Maxwel...
For example,
++User define unit length, a.
++Permittivity of vacuum is 1
++Permeability of vacuum is 1
The Maxwell equation of MEEP is in the last line of below...
[https://meep.readthedocs.io/en/latest/Introduction/ Refe...
From ordinal Maxwell equation below,
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
deform it as follows.
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Define x',y',z',t',{\omega}',E',H',{\sigma}' as follows.
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Substitute new defined parameters, and get Maxwell equati...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/maxwell_eq...
Here, permittivity of vacuum and permeability of vacuum a...
Unit length is a which user can define freely.
During unit time, the light in vacuum travels by unit len...
The wavelength of light in vacuum of which frequency is f...
*How to edit the HDF5 file ? [#qe50ab81]
The h5py package can be used for editing HDF5 file in pyt...
Install it by the following command.
apt-get install python-h5py
h5py is already installed on flex and tubes.
On maruoka's WSL,
pip install h5py
doesn't work saying
ImportError: No module named h5py
*Useful script for converting hdf5 to mp4 and gif [#b4314...
It is useful to use script below to automatically convert...
function h5mp4(){
mkdir $1
cp $1.h5 $1
cd $1
h5topng $1.h5 -Z -c dkbluered -R -t 0:$2
convert $1*png $1.gif
ffmpeg -i $1.gif -qscale:v 1 $1.mp4
}
For example, if you want to convert hogehoge.h5 which hav...
h5mp4 hogehoge 999
It output hogehoge.gif and hogehoge.mp4 automatically.
If you want to know the number of time indexes,do as foll...
h5ls hogehoge.h5
ez Dataset{100, 200, 1000/Inf}
Here, 1000 is the number of time indexes.
*source for incident light [#r32309cc]
**left-handed circularly polarized light (Scheme)[#u95702...
We can modify the phase of source by the amplitude.
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
(amplitude (exp (* 0+1i 1.570796327)))
)
)
)
**right-handed circularly polarized light (Scheme) [#u957...
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
(amplitude (exp (* 0+1i 1.570796327)))
)
)
)
**the light linearly polarized at x radian (Scheme)[#u957...
(set! sources
(list
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ex)
(center 0 0 8)
(size 50 50 0)
(amplitude (cos x))
)
(make source
(src (make continuous-src (frequency (/ 1 7))))
(component Ey)
(center 0 0 8)
(size 50 50 0)
(amplitude (sin x))
)
)
)
**the light at oblique incident angle (Scheme)[#y9a5c654]
There are three ways to implement oblique incident light.
***Bloch's periodic boundary with modifying phase of the ...
TM wave just before total internal reflection.
(define (pw-amp k x0) (lambda (x)
(exp (* 0+1i (vector3-dot k (vect...
(define-param theta-deg 48)
(define theta-rad (deg->rad theta-deg))
(define epsilon1 2.25)
(define epsilon2 1.25)
(define-param fcen 0.8) ; pulse center frequency
(define-param df 0.02) ; turn-on bandwidth
(define-param kdir (vector3 (sin theta-rad) 0 (cos theta...
(define k (vector3-scale (* 2 pi fcen (sqrt epsilon1))
(unit-vector3 kdir))) ; k with c...
(set! pml-layers (list (make pml (thickness 2)(direction...
(set! k-point (vector3* (* fcen (sqrt epsilon1) ) (vecto...
(set! geometry
(list
(make block
(center 0 0 -2.5)
(size 10 infinity 5)
(material (make dielectric(epsilon epsilon1)))
)
(make block
(center 0 0 2.5)
(size 10 infinity 5)
(material (make dielectric(epsilon epsilon2)))
)
)
)
(set! sources
(list
(make source
(src (make continuous-src (frequency fcen) (fwi...
(component Ez) (center 0 0 -3) (size 10 0 0)
(amp-func (pw-amp k (vector3 0 0 -3))))))
(define-param T 40) ; run time
(run-until T
(to-appended "ez" (at-every 0.1 output-efield...
(to-appended "ex" (at-every 0.1 output-efield...
)
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
***two sources with modifying phase (Scheme) [#d178c899]
; This example creates an approximate Ez-polarized plane...
; propagating at a 45-degree angle, by using a couple of...
; with amplitude exp(ikx) corresponding to the desired p...
(define-param s 11) ; the size of the computational cell...
(define-param dpml 1) ; thickness of PML layers
(define sxy (+ s (* 2 dpml))) ; cell size, including PML
(set! geometry-lattice (make lattice (size sxy sxy no-si...
(set! pml-layers (list (make pml (thickness dpml))))
(set-param! resolution 10)
; pw-amp is a function that returns the amplitude exp(ik...
; given point x. (We need the x0 because current amplit...
; in Meep are defined relative to the center of the curr...
; whereas we want a fixed origin.) Actually, it is a fu...
; and x0 that returns a function of x ...
(define (pw-amp k x0) (lambda (x)
(exp (* 0+1i (vector3-dot k (vector3+ x x0))))))
(define-param fcen 0.8) ; pulse center frequency
(define-param df 0.02) ; turn-on bandwidth
(define-param kdir (vector3 1 1)) ; direction of k (leng...
(define-param n 1) ; refractive index of material contai...
(define k (vector3-scale (* 2 pi fcen n)
(unit-vector3 kdir))) ; k with ...
(set! sources
(list
; left
(make source
(src (make continuous-src (frequency fcen) (fwidth df)))
(component Ez) (center (* -0.5 s) 0) (size 0 s)
(amp-func (pw-amp k (vector3 (* -0.5 s) 0))))
; bottom
(make source
(src (make continuous-src (frequency fcen) (fwidth df)))
(component Ez) (center 0 (* -0.5 s)) (size s 0)
(amp-func (pw-amp k (vector3 0 (* -0.5 s)))))
))
(define-param T 400) ; run time
(run-until T (at-end output-efield-z))
[https://github.com/stevengj/meep/blob/master/scheme/exam...
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
plot of Ez when there is only one source ( why we need tw...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
***array many point-sources (Scheme)[#bb9694c1]
http://article.gmane.org/gmane.comp.science.electromagnet...
(define-param pi 3.14159265)
(define-param dpml 3.0)
(define-param len (+ 20 dpml))
(define-param wid (+ 20 dpml))
(set! geometry-lattice (make lattice (size len wid no-si...
(define-param beam-waist 2.5) ; beam sigma (gaussian bea...
(define-param rotation-angle (* (/ 22.5 360) 2 pi)) ; De...
(define-param source-points 60) ; should be a big number
(define-param source-size (* 4 beam-waist)) ; should be ...
(define-param src_list (list ))
(do
((
r_0
(/ source-size -2)
(+ r_0 (/ source-size (- source-points 1)))
))
((> r_0 (/ source-size 2)))
;for r_0 = -sour...
(set! src_list (append src_list
(list (make source
(src (make gaussian-src
(wavelength 1)
(width 3)
))
(amplitude (exp (- 0 (/...
(component Ez)
(center (* r_0 (sin rot...
))
))
)
(set! sources src_list)
(set! pml-layers (list (make pml
(thickness dpml)
)))
(set! resolution 10)
(use-output-directory)
(run-until (* 2 len)
(to-appended "ez" (at-every 0.1 output-efield...
)
plot of Ez
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/o...
*Plot of Electric field Vector [#b59ce919]
Electric field of Total Internal Reflection
http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/e...
Code for simulation
(define-param dx 1); cell size in x axis
(define-param dy 2); cell size along y axis
(define-param fp 1.5)
(define-param tpml 0.1); PML thickness
(define-param deg 48)
(define-param theta (* pi 0.88889)); incident angle of t...
(set! theta (* deg (/ pi 180)))
(set! resolution 40);define the resolution for simulatio...
;define the lattice
(set! geometry-lattice (make lattice (size (+ dx (* 2 tp...
;define PML thickness
(set! pml-layers (list (make pml (thickness tpml))))
;define the blocks
(set! geometry (list
(make block (center 0 (* 0.25 dy))(size infinity (+ tpm...
(material (make dielectric (epsilon 1))))
(make block (center 0 (* -0.25 dy))(size infinity (+ tp...
(material (make dielectric (epsilon 2.25))))
))
(set! pml-layers (list (make pml (thickness tpml))))
;(+ tpml (* 0.5 dy))
;define the wave vector
(define kx (* fp (sqrt 2.25) (sin theta)))
;give the amplitude function
(define (f_amp p) (exp (* 0+2i pi kx (vector3-x p))))
(set! k-point (vector3 kx 0 0))
;define the simulation domain to be complex field
(set! force-complex-fields? true)
;define the Gaussian beam
(set! sources
(list
(make source
(src (make continuous-src (frequency fp)))
(component Ex)
(component Ey)
(center 0 (* dy -0.50))
(size (+ dx (* 2 tpml)) 0 )
(amp-func f_amp))))
(set! pml-layers (list (make pml (thickness tpml) (direc...
;extract the data to .png file
(run-until 40
(at-beginning output-epsilon)
;(at-end output-efield-y)
(to-appended "ey"(at-every 0.05 (in-volume (volume (cent...
(to-appended "ex"(at-every 0.05 (in-volume (volume (cent...
)
If you want to plot electric field vector, you need to pl...
The ax.quiver function of matplotlib is good idea to plot...
*material library [#ba28d968]
**Scheme [#s98e0c37]
To use material library, add
(include "/home/students/maru/meep/scheme/materials.scm")
at the beginning of your program.
This library only works at tube61, 62, 63.
For how to use the material library, check https://meep.r...
You need to specify unit to use material library.
The default is 1000 micro meter.
In order to change the unit to 100 micro meter, add
(set! um-scale (* um-scale 0.1))
**Python [#r0a53c68]
You don't need to load materials.py by yourself like sche...
The default unit length is 1000nm in materials.py.
If you want to use another unit length, you need to rewri...
After the line where um_scale is defined, change the um_s...
For example, if you want to use 100nm for unit length, ad...
um_scale=um_scale*0.1
To modify materials.py, you can check the address of mate...
(pmp) maru@tube60:~$ python
Python 3.6.6 | packaged by conda-forge | (default, Jul 2...
import meep Using MPI version 3.1, 1 processes
meep.__file__
'/home/students/maru/anaconda3/envs/pmp/lib/python3.6/si...
In this case, the address of materials.py is
/home/students/maru/anaconda3/envs/pmp/lib/python3.6/sit...
This modification of materials.py has effect only for pmp.
If you want to change the unit length for mp, please chan...
*User defined relative permittivity of Drude conductivity...
Meep support user defined relative permittivity of Drude ...
\epsilon_\infty is approximately the relative permittivit...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/drude_epsi...
Since the relative permittivity of Drude conductivity is ...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/drude_epsi...
From this formula, f_p and gamma of SI unit and f_p' and ...
http://flex.phys.tohoku.ac.jp/~maru/drive-open/relation_m...
Using f_p', gamma' and epsilon_\infty calculated above,
user_defined_material = mp.Medium(epsilon=epsilon_\infty...
will define the material which have f_p', gamma', epsilon...
In order to use this material, you need to set the option...
*Q&A [#b8d898d0]
**How thick PML should be ?[#l8406a8a]
In the document of PML by one of the the author of MEEP(h...
With PML, however, the constant factor is very good to s...
(Increasing the resolution also increases the resolution...
However, when the light coming at oblique incident angle,...
The reflectivity of PML for incident angle at X can be re...
e^{-2*k*d*cos(X)*G}
for some constant G. d is the thickness of PML. k is the ...
If X approaches to 90 degree, the efficiency of the absor...
**PML shows reflectance. [#o360c5d3]
If you put dielectrics touching to the PML, please confir...
It is implemented by just multiplying tensors on dielectr...
[http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/...
[http://flex.phys.tohoku.ac.jp/~maru/drive-open/pukiwiki/...
** ERROR: Unbound variable: E-susceptibilities [#qd0361a8]
Following error occurs, when you try to use material libr...
ERROR: Unbound variable: E-susceptibilities
Material library only works at tube61, 62, 63.
Please go to tube61, 62, 63.
** materials.py doesn't work [#cc53b98c]
If the version is lower than 1.6, materials.py doesn't wo...
Check the version of pymeep by
conda list
If you find
pymeep 1.5
then update pymeep from 1.5 to 1.6 as follows.
(mp) maru@flex:~$ conda update -c chogan -c conda-forge ...
Solving environment: done
## Package Plan ##
environment location: /home/students/maru/anaconda3/env...
added / updated specs:
- pymeep
The following packages will be downloaded:
package | build
---------------------------|-----------------
libctl-4.1.4 | 1 ...
libgdsii-0.2.dev | 0 ...
python-3.6.6 | hd21baee_1003 ...
openssl-1.0.2p | h14c3975_1002 ...
mpb-1.7.0 | nomkl_1 ...
pymeep-1.7.0 | py36_nomkl_1 ...
openblas-0.3.5 | h9ac9557_1000 ...
nomkl-3.0 | 0 ...
ca-certificates-2018.11.29 | ha4d7672_0 ...
certifi-2018.11.29 | py36_1000 ...
-----------------------------------------------------...
Total: ...
The following NEW packages will be INSTALLED:
libgdsii: 0.2.dev-0 chogan
nomkl: 3.0-0
The following packages will be UPDATED:
ca-certificates: 2018.03.07-0 --> 20...
certifi: 2018.11.29-py36_0 --> 20...
libctl: 4.1.2-0 chogan --> 4....
mpb: 1.6.2-4 chogan --> 1....
openblas: 0.2.20-8 conda-forge --> 0....
pymeep: 1.5-py36_nomkl_2 chogan [nomkl...
The following packages will be DOWNGRADED:
openssl: 1.1.1a-h7b6447c_0 --> 1....
python: 3.6.8-h0371630_0 --> 3....
Proceed ([y]/n)? y
Downloading and Extracting Packages
libctl-4.1.4 | 97 KB | #####################...
libgdsii-0.2.dev | 800 KB | #####################...
python-3.6.6 | 29.0 MB | #####################...
openssl-1.0.2p | 3.1 MB | #####################...
mpb-1.7.0 | 74 KB | #####################...
pymeep-1.7.0 | 3.3 MB | #####################...
openblas-0.3.5 | 15.8 MB | #####################...
nomkl-3.0 | 48 KB | #####################...
ca-certificates-2018 | 143 KB | #####################...
certifi-2018.11.29 | 145 KB | #####################...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
If you want to use parallel pymeep, then update it also t...
(pmp) maru@tube60:~$ conda update -c chogan -c conda-for...
Solving environment: done
## Package Plan ##
environment location: /home/students/maru/anaconda3/env...
added / updated specs:
- pymeep-parallel
The following packages will be downloaded:
package | build
---------------------------|-----------------
libgcc-ng-7.3.0 | hdf63c60_0 ...
pymeep-parallel-1.7.0 |py36_nomklh39e3cac_1 ...
-----------------------------------------------------...
Total: ...
The following NEW packages will be INSTALLED:
libgdsii: 0.2.dev-0 chogan
nomkl: 3.0-0
The following packages will be UPDATED:
ca-certificates: 2018.8.24-ha4d7672_0 conda-forge...
certifi: 2018.8.24-py36_1 conda-forge...
libctl: 4.1.2-0 chogan ...
libgcc-ng: 7.2.0-hdf63c60_3 conda-forge...
mpb: 1.6.2-4 chogan ...
openssl: 1.0.2p-h470a237_0 conda-forge...
pymeep-parallel: 1.5-py36_nomklh39e3cac_4 chogan ...
Proceed ([y]/n)? y
Downloading and Extracting Packages
libgcc-ng-7.3.0 | 6.1 MB |
########################################################...
pymeep-parallel-1.7. | 3.3 MB |
########################################################...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
**error on line 497 of h5file.cpp: error opening HDF5 out...
If you find error as below, give permission to working di...
Working in 3D dimensions.
Computational cell is 20 x 20 x 20 with resolution 10
block, center = (0,0,0)
size (1,3,1)
axes (1,0,0), (0,1,0), (0,0,1)
dielectric constant epsilon diagonal = (1,1,1)
time for set_epsilon = 11.7491 s
-----------
creating output file "./hogehoge.h5"...
on time step 1 (time=0.05), 14.4708 s/step
HDF5-DIAG: Error detected in HDF5 (1.10.2) MPI-process 0:
#000: H5F.c line 445 in H5Fcreate(): unable to create f...
major: File accessibilty
minor: Unable to open file
meep: error on line 497 of h5file.cpp: error opening HDF...
application called MPI_Abort(MPI_COMM_WORLD, 1) - proces...
**ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `...
The version of GLIBC at flex is old. Go to t70.
**Internal MPI error! Cannot read from remote process [#g...
If you connect to flex from remote place (e.g. Sendai Kos...
(pmp) maeda@tube60:/abinitio2/maeda/pymeep/Rectangle/dru...
python after-Rec-drude-Au.py 45
Working in 3D dimensions.
Computational cell is 20 x 20 x 20 with resolution 10
block, center = (0,0,0)
size (1,3,1)
axes (1,0,0), (0,1,0), (0,0,1)
dielectric constant epsilon diagonal = (1,1,1)
time for set_epsilon = 5.05642 s
lorentzian susceptibility: frequency=3.47141, gamma=2.01...
lorentzian susceptibility: frequency=2.39466, gamma=0.70...
lorentzian susceptibility: frequency=0.66944, gamma=0.27...
lorentzian susceptibility: frequency=0.33472, gamma=0.19...
drude susceptibility: frequency=1e-10, gamma=0.0427474
-----------
creating output file "./after-Rec-drude-Au-ex-surface-45...
creating output file "./after-Rec-drude-Au-ey-surface-45...
creating output file "./after-Rec-drude-Au-ez-inner-45de...
creating output file "./after-Rec-drude-Au-ez-outer-45de...
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=92, ...
status_array=0xc9e3670) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(623).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=85, ...
status_array=0xd21c7f0) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(658).......: fail failed
MPID_nem_handle_pkt(1439).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Fatal error in PMPI_Waitall: Other MPI error, error stack:
PMPI_Waitall(405)...............: MPI_Waitall(count=85, ...
status_array=0xcc31ed0) failed
MPIR_Waitall_impl(221)..........: fail failed
PMPIDI_CH3I_Progress(658).......: fail failed
MPID_nem_handle_pkt(1439).......: fail failed
pkt_RTS_handler(317)............: fail failed
do_cts(662).....................: fail failed
MPID_nem_lmt_dcp_start_recv(302): fail failed
dcp_recv(165)...................: Internal MPI error! C...
process
Two workarounds have been identified for this issue:
1) Enable ptrace for non-root users with:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2) Or, use:
I_MPI_SHM_LMT=shm
Following command will resolve this error when you connec...
export I_MPI_SHM_LMT=shm
Page: