-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtesting_beam.py
More file actions
175 lines (122 loc) · 5.06 KB
/
Copy pathtesting_beam.py
File metadata and controls
175 lines (122 loc) · 5.06 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
from meep_optics import OpticalSystem, AsphericLens, ApertureStop, ImagePlane, TelescopeTube, Absorber, Sim, Analysis
import meep as mp
import numpy as np
import matplotlib.pyplot as plt
import argparse as ap
import h5py
from scipy import optimize
from mpi4py import MPI
coeff = 10
lens1 = AsphericLens(name = 'Lens 1',
r1 = 327.365*coeff,
r2 = np.inf,
c1 = -0.66067,
c2 = 0,
thick = 40*coeff,
x = (130.+10.)*coeff,
y = 0.,
diameter = 300*coeff)
lens2 = AsphericLens(name = 'Lens 2',
r1 = 269.190*coeff,
r2 = 6398.02*coeff,
c1 = -2.4029,
c2 = 1770.36,
thick = 40*coeff,
diameter = 300*coeff,
x = (40.+130.+369.408+10.)*coeff,
y = 0.)
aperture_stop = ApertureStop(name = 'Aperture Stop',
pos_x = 10*coeff,
diameter = 200*coeff,
thickness = 5*coeff,
n_refr = 1.,
conductivity = 1e7)
image_plane = ImagePlane(name = 'Image Plane',
pos_x = (10+714.704)*coeff,
diameter = 300*coeff,
thickness = 2*coeff,
n_refr = 1,
conductivity = 0)
tube = TelescopeTube('Tube')
absorber = Absorber('Absorber')
def system_assembly(lens1, lens2, aperture_stop, image_plane, res, dpml):
opt_sys = OpticalSystem('test')
opt_sys.set_size(750*coeff,300*coeff)
opt_sys.add_component(lens1)
opt_sys.add_component(lens2)
opt_sys.add_component(aperture_stop)
opt_sys.add_component(image_plane)
opt_sys.assemble_system(dpml = dpml, resolution = res)
opt_sys.write_h5file(parallel = True)
return opt_sys
#PARAMS
wvl = 10
resolution = 3
dpml = 5
"""
FFT_list = []
opt_sys = system_assembly(lens1, lens2, aperture_stop, image_plane, resolution, dpml)
w0_list = [10., 30., 50.] #np.linspace(10,50,5)
legend = ['1', '3', '5']
for k in range(len(w0_list)):
#RUN SIM
sim = Sim(opt_sys)
analysis = Analysis(sim)
analysis.image_plane_beams(wavelength = wvl, runtime = 800*coeff,
sim_resolution = resolution, beam_w0 = w0_list[k],
plot_amp = True, plotname = 'w0_{}_wvl1'.format(int(w0_list[k])),
aperture_size = 200*coeff)
#PLOT FIELD
analysis.sim.plot_efield()
#freq, fft = analysis.beam_FT(precision_factor = 15)
#FFT_list.append(fft[0])
"""
opt_sys = system_assembly(lens1, lens2, aperture_stop, image_plane, resolution, dpml)
sim = Sim(opt_sys)
analysis = Analysis(sim)
analysis.image_plane_beams(wavelength = 10, runtime = 800*coeff, sim_resolution = 3, beam_w0 = 30, plotname = 'FF_w0_3x_wvl1_res3')
analysis.sim.plot_efield('test_FF_wvl3_res033')
#TEST N2FAR
"""
opt_sys = system_assembly(lens1, lens2, aperture_stop, image_plane, resolution, dpml)
w0 = 30
w0_list = [30., 90., 150.,300.] #np.linspace(10,50,5)
wvls = [10,30,50,100]
legend = ['1', '3', '5']
for k in range(len(w0_list)):
sim = Sim(opt_sys)
analysis = Analysis(sim)
analysis.image_plane_beams(wavelength = wvls[k], runtime = 800*coeff, sim_resolution = resolution, beam_w0 = w0_list[k], plotname = 'FF_w0_3x_wvl{}'.format(int(wvls[k]/10)))
analysis.sim.plot_efield('test_FF_{}'.format(int(wvls[k]/10)))
"""
#freq, fft = analysis.beam_FT(precision_factor = 15)
#analysis.plotting(freq, fft, wvl, deg_range= 40, print_fwhm = True, savefig = True, path_name = 'hey')
#PLOT BEAM
#analysis.plotting(freq, FFT_list, wvl, deg_range= 40, print_fwhm = True, savefig = True, path_name = 'testing_w0', legend = legend)
"""
w0_list_precise = np.linspace(8,13,11)
legend = ['8', '8.5', '9', '9.5', '10','10.5','11', '11.5', '12', '12.5', '13']
for k in range(11):
#RUN SIM
sim = Sim(opt_sys)
analysis = Analysis(sim)
analysis.image_plane_beams(wavelength = wvl, sim_resolution = resolution, beam_w0 = w0_list_precise[k])
#PLOT FIELD
analysis.sim.plot_efield()
freq, fft = analysis.beam_FT(precision_factor = 15)
FFT_list.append(fft[0])
#PLOT BEAM
analysis.plotting(freq, FFT_list, wvl, deg_range= 40, print_fwhm = True, savefig = True, path_name = 'testing_w0_precise', legend = legend)
"""
### TEST SINGLE VALUE
"""
w0 = 40
sim = Sim(opt_sys)
analysis = Analysis(sim)
analysis.image_plane_beams(wavelength = wvl, sim_resolution = resolution, beam_w0 = w0, plot_amp = True, plotname = 'test')
#PLOT FIELD
analysis.sim.plot_efield()
#freq, fft = analysis.beam_FT(precision_factor = 15)
#FFT_list.append(fft[0])
#analysis.plotting(freq, FFT_list, wvl, deg_range= 40, print_fwhm = True, savefig = True, path_name = 'w0_8dot5')
"""