-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsave_refidx.py
executable file
·43 lines (36 loc) · 1.11 KB
/
save_refidx.py
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
#!/usr/bin/env python
"""Calcluate and save the permittivity and refractive index directly
from Meep mdium class.
"""
import meep as mp
import numpy as np
import math
import cmath
import sys
sys.path.append("/Users/wdai11/python-study")
import MeepMedium.dwt_materials as mym
import MeepMedium.dwt_output as my
import meep.materials as mat
def RefIdx_from_medium(medium,name):
"""Calculate the refractive index and reflection from the medium;
save the result to a file"""
wls=np.arange(0.5,10,0.5)
nref=[mym.get_refractive_index(1/wl,medium) for wl in wls]
n0=3.8
ref=[abs((n-n0)/(n+n0))**2 for n in nref]
nref=np.array(nref)
ref=np.array(ref)
fname='Ref_{}.dat'.format(name)
data=np.column_stack((wls,nref.real,nref.imag,ref))
print('{} Refectlion'.format(name))
my.matrix_output(fname,data,"{:10.5e}",sig=None)
print('-'*30)
#########################
def main(args):
RefIdx_from_medium(mat.Al,'Al')
RefIdx_from_medium(mym.In4p2,'In')
RefIdx_from_medium(mym.lossy_Pd(0.5),'Pd')
#########################
# main function
if __name__=='__main__':
main(sys.argv)