1 | /*
|
---|
2 | * GratingCoupler Class
|
---|
3 | *
|
---|
4 | * Methods for:
|
---|
5 | * determining the refractive index of a waveguiding thin film
|
---|
6 | * in an asymmetric slab waveguide from the grating coupling angle and the core layer thickness
|
---|
7 | * and for obtaining the normalised propagation vector versus guiding layer thickness
|
---|
8 | *
|
---|
9 | * determinimg the refractive index of the superstrate [analyte solution in a grating coupler sensor]
|
---|
10 | *
|
---|
11 | * obtaining the normalised propagation vector versus guiding layer thickness
|
---|
12 | * dispersion curve for an asymmetric slab waveguide
|
---|
13 | *
|
---|
14 | * This is a subclass of the superclasses PlanarWaveguideCoupler
|
---|
15 | *
|
---|
16 | * Author: Dr Michael Thomas Flanagan.
|
---|
17 | *
|
---|
18 | * Created: 28 April 2006
|
---|
19 | *
|
---|
20 | * DOCUMENTATION:
|
---|
21 | * See Michael Thomas Flanagan's Java library on-line web page:
|
---|
22 | * http://www.ee.ucl.ac.uk/~mflanaga/java/GratingCoupler.html
|
---|
23 | * http://www.ee.ucl.ac.uk/~mflanaga/java/
|
---|
24 | *
|
---|
25 | * Copyright (c) April 2006 Michael Thomas Flanagan
|
---|
26 | *
|
---|
27 | * PERMISSION TO COPY:
|
---|
28 | * Permission to use, copy and modify this software and its documentation for
|
---|
29 | * NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement
|
---|
30 | * to the author, Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies.
|
---|
31 | *
|
---|
32 | * Dr Michael Thomas Flanagan makes no representations about the suitability
|
---|
33 | * or fitness of the software for any or for a particular purpose.
|
---|
34 | * Michael Thomas Flanagan shall not be liable for any damages suffered
|
---|
35 | * as a result of using, modifying or distributing this software or its derivatives.
|
---|
36 | *
|
---|
37 | ***************************************************************************************/
|
---|
38 |
|
---|
39 | package agents.anac.y2015.agentBuyogV2.flanagan.optics;
|
---|
40 |
|
---|
41 | import agents.anac.y2015.agentBuyogV2.flanagan.analysis.ErrorProp;
|
---|
42 | import agents.anac.y2015.agentBuyogV2.flanagan.math.Fmath;
|
---|
43 | import agents.anac.y2015.agentBuyogV2.flanagan.optics.*;
|
---|
44 | import agents.anac.y2015.agentBuyogV2.flanagan.plot.*;
|
---|
45 |
|
---|
46 | public class GratingCoupler extends PlanarWaveguide{
|
---|
47 |
|
---|
48 | // CLASS VARIABLES
|
---|
49 |
|
---|
50 | private double[] thicknessesTE = null; // thicknesses for experimental TE mode thimeasurements
|
---|
51 | private double[] anglesDegTE = null; // coupling angles, in degrees, for experimental TE mode measurements
|
---|
52 | private double[] anglesRadTE = null; // coupling angles, in radians, for experimental TE mode measurements
|
---|
53 | private double[] errorsDegTE = null; // errors in coupling angles, in degrees, for experimental TE mode measurements
|
---|
54 | private double[] errorsRadTE = null; // errors in coupling angles, in radians, for experimental TE mode measurements
|
---|
55 | private double[] modeNumbersTE = null; // mode numbers for experimental TE mode measurements
|
---|
56 | private double[] effectiveRefractiveIndicesTE = null; // effective refractive indices for TE mode measurements
|
---|
57 | private double[] effectiveErrorsTE = null; // propagated errors for effective refractive indices for TE mode measurements
|
---|
58 | private int numberOfTEmeasurementsGrating = 0; // number of TE mode thickness measurement
|
---|
59 | private boolean setMeasurementsTEgrating = false; // = true when TE mode measurements entered
|
---|
60 | private boolean setTEerrors = false; // = true if TE mode errors are set
|
---|
61 |
|
---|
62 | private boolean calcEffectiveDone = false; // = true when effective refractive indices calculated
|
---|
63 |
|
---|
64 | private double[] thicknessesTM = null; // thicknesses for experimental TM mode thimeasurements
|
---|
65 | private double[] anglesDegTM = null; // coupling angles, in degrees, for experimental TM mode measurements
|
---|
66 | private double[] anglesRadTM = null; // coupling angles, in radians, for experimental TM mode measurements
|
---|
67 | private double[] errorsDegTM = null; // errors in coupling angles, in degrees, for experimental TM mode measurements
|
---|
68 | private double[] errorsRadTM = null; // errors in coupling angles, in radians, for experimental TM mode measurements
|
---|
69 | private double[] modeNumbersTM = null; // mode numbers for experimental TM mode measurements
|
---|
70 | private double[] effectiveRefractiveIndicesTM = null; // effective refractive indices for TM mode measurements
|
---|
71 | private double[] effectiveErrorsTM = null; // propagated errors for effective refractive indices for TM mode measurements
|
---|
72 | private int numberOfTMmeasurementsGrating = 0; // number of TM mode thickness measurement
|
---|
73 | private boolean setMeasurementsTMgrating = false; // = true when TM mode measurements entered
|
---|
74 | private boolean setTMerrors = false; // = true if TM mode errors are set
|
---|
75 |
|
---|
76 | private int numberOfMeasurementsGrating = 0; // total number of thickness measurements entered
|
---|
77 | private boolean setMeasurementsGrating = false; // = true when TE and/or TM mode measurements entered
|
---|
78 |
|
---|
79 | private double gratingPitch = 0.0D; // Grating pitch, metres
|
---|
80 | private boolean setGratingPitch = false; // = true when grating pitch entered
|
---|
81 | private int[] gratingOrderTE = null; // Grating order for each TE mode measurement, default value = 1
|
---|
82 | private boolean setGratingOrderTE = false; // = true when TE mode grating orders entered
|
---|
83 | private int[] gratingOrderTM = null; // Grating order for each TM mode measurement, default value = 1
|
---|
84 | private boolean setGratingOrderTM = false; // = true when TM mode grating orders entered
|
---|
85 |
|
---|
86 | private double superstrateRI = 0.0; // Superstrate refractive index
|
---|
87 | private boolean setSuperstrateRI = false; // equals true when superstrate refractice index entered
|
---|
88 |
|
---|
89 | // CONSTRUCTOR
|
---|
90 | public GratingCoupler(){
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | // GRATING
|
---|
95 | // Enter pitch
|
---|
96 | public void setGratingPitch(double pitch){
|
---|
97 | this.gratingPitch = pitch;
|
---|
98 | this.setGratingPitch = true;
|
---|
99 | if(this.setMeasurementsGrating && super.setWavelength)this.calcEffectiveRefractiveIndices();
|
---|
100 | }
|
---|
101 |
|
---|
102 | // Enter grating orders for TE measurements
|
---|
103 | public void setSetTEmodeGratingOrder(int[] order){
|
---|
104 | this.gratingOrderTE = order;
|
---|
105 | int m = order.length;
|
---|
106 | if(this.setMeasurementsTEgrating)if(m!=this.numberOfTEmeasurementsGrating)throw new IllegalArgumentException("Number of grating orders entered, " + m + ", is not equal to the number of measurements previously entered, " + this.numberOfTEmeasurementsGrating);
|
---|
107 | if(this.setMeasurementsGrating && this.setGratingPitch && super.setWavelength)this.calcEffectiveRefractiveIndices();
|
---|
108 | }
|
---|
109 |
|
---|
110 | // Enter grating orders for TM measurements
|
---|
111 | public void setSetTMmodeGratingOrder(int[] order){
|
---|
112 | this.gratingOrderTM = order;
|
---|
113 | int m = order.length;
|
---|
114 | if(this.setMeasurementsTMgrating)if(m!=this.numberOfTMmeasurementsGrating)throw new IllegalArgumentException("Number of grating orders entered, " + m + ", is not equal to the number of measurements previously entered, " + this.numberOfTEmeasurementsGrating);
|
---|
115 | if(this.setMeasurementsGrating && this.setGratingPitch && super.setWavelength)this.calcEffectiveRefractiveIndices();
|
---|
116 | }
|
---|
117 |
|
---|
118 | // Enter superstrate refractive index (overrides superclass method)
|
---|
119 | public void setSuperstrateRefractiveIndex(double index){
|
---|
120 | if(this.calcEffectiveDone)this.clearData();
|
---|
121 | this.superstrateRI = index;
|
---|
122 | super.superstrateRefractiveIndex = index;
|
---|
123 | this.setSuperstrateRI = true;
|
---|
124 | if(this.setMeasurementsGrating && this.setGratingPitch && super.setWavelength)this.calcEffectiveRefractiveIndices();
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | // Return analyte solution refractive index
|
---|
129 | public double getAnalyteSolutionRefractiveIndex(){
|
---|
130 | return super.getSuperstrateRefractiveIndex();
|
---|
131 | }
|
---|
132 |
|
---|
133 | // Return analyte solution refractive index
|
---|
134 | public double getStandardDeviationAnalyteSolutionRefractiveIndex(){
|
---|
135 | return super.getStandardDeviationSuperstrateRefractiveIndex();
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | // THICKNESS (metres), COUPLING ANGLE (degrees) AND MODE NUMBER DATA
|
---|
140 | // Enter TE mode data for a single measurement without error
|
---|
141 | public void enterTEmodeData(double thickness, double angle, double modeNumber){
|
---|
142 | if(this.setMeasurementsTEgrating){
|
---|
143 | if(this.setTEerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
144 | int nNew = this.numberOfTEmeasurementsGrating + 1;
|
---|
145 | double[] hold = new double[nNew];
|
---|
146 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.thicknessesTE[i];
|
---|
147 | hold[this.numberOfTEmeasurementsGrating] = thickness;
|
---|
148 | this.thicknessesTE = hold;
|
---|
149 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.anglesDegTE[i];
|
---|
150 | hold[this.numberOfTEmeasurementsGrating] = angle;
|
---|
151 | this.anglesDegTE = hold;
|
---|
152 | this.anglesRadTE = hold;
|
---|
153 | this.errorsDegTE = hold;
|
---|
154 | this.errorsRadTE = hold;
|
---|
155 | for(int i=0; i<nNew; i++){
|
---|
156 | this.anglesRadTE[i] = Math.toRadians(this.anglesDegTE[i]);
|
---|
157 | this.errorsDegTE[i] = 0.0D;
|
---|
158 | this.errorsRadTE[i] = 0.0D;
|
---|
159 | }
|
---|
160 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.modeNumbersTE[i];
|
---|
161 | hold[this.numberOfTEmeasurementsGrating] = modeNumber;
|
---|
162 | this.numberOfTEmeasurementsGrating = nNew;
|
---|
163 | }
|
---|
164 | else{
|
---|
165 | this.thicknessesTE = new double[1];
|
---|
166 | this.thicknessesTE[0] = thickness;
|
---|
167 | this.anglesDegTE = new double[1];
|
---|
168 | this.anglesDegTE[0] = angle;
|
---|
169 | this.anglesRadTE = new double[1];
|
---|
170 | this.anglesRadTE[0] = Math.toRadians(angle);
|
---|
171 | this.errorsDegTE = new double[1];
|
---|
172 | this.errorsDegTE[0] = 0.0D;
|
---|
173 | this.errorsRadTE = new double[1];
|
---|
174 | this.errorsRadTE[0] = 0.0D;
|
---|
175 | this.modeNumbersTE = new double[1];
|
---|
176 | this.modeNumbersTE[0] = modeNumber;
|
---|
177 | this.numberOfTEmeasurementsGrating = 1;
|
---|
178 | }
|
---|
179 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
180 | this.setMeasurementsTEgrating = true;
|
---|
181 | this.setMeasurementsGrating = true;
|
---|
182 | if(this.setGratingPitch && super.setWavelength)this.calcTEmodeEffectiveRefractiveIndices();
|
---|
183 | }
|
---|
184 |
|
---|
185 |
|
---|
186 |
|
---|
187 | // Enter TM mode data for a single measurement without error
|
---|
188 | public void enterTMmodeData(double thickness, double angle, double modeNumber){
|
---|
189 | if(this.setMeasurementsTMgrating){
|
---|
190 | if(this.setTMerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
191 | int nNew = this.numberOfTMmeasurementsGrating + 1;
|
---|
192 | double[] hold = new double[nNew];
|
---|
193 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.thicknessesTM[i];
|
---|
194 | hold[this.numberOfTMmeasurementsGrating] = thickness;
|
---|
195 | this.thicknessesTM = hold;
|
---|
196 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.anglesDegTM[i];
|
---|
197 | hold[this.numberOfTMmeasurementsGrating] = angle;
|
---|
198 | this.anglesDegTM = hold;
|
---|
199 | this.anglesRadTM = hold;
|
---|
200 | this.errorsDegTM = hold;
|
---|
201 | this.errorsRadTM = hold;
|
---|
202 | for(int i=0; i<nNew; i++){
|
---|
203 | this.anglesRadTM[i] = Math.toRadians(this.anglesDegTM[i]);
|
---|
204 | this.errorsDegTM[i] = 0.0D;
|
---|
205 | this.errorsRadTM[i] = 0.0D;
|
---|
206 | }
|
---|
207 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.modeNumbersTM[i];
|
---|
208 | hold[this.numberOfTMmeasurementsGrating] = modeNumber;
|
---|
209 | this.numberOfTMmeasurementsGrating = nNew;
|
---|
210 | }
|
---|
211 | else{
|
---|
212 | this.thicknessesTM = new double[1];
|
---|
213 | this.thicknessesTM[0] = thickness;
|
---|
214 | this.anglesDegTM = new double[1];
|
---|
215 | this.anglesDegTM[0] = angle;
|
---|
216 | this.anglesRadTM = new double[1];
|
---|
217 | this.anglesRadTM[0] = Math.toRadians(angle);
|
---|
218 | this.errorsDegTM = new double[1];
|
---|
219 | this.errorsDegTM[0] = 0.0D;
|
---|
220 | this.errorsRadTM = new double[1];
|
---|
221 | this.errorsRadTM[0] = 0.0D;
|
---|
222 | this.modeNumbersTM = new double[1];
|
---|
223 | this.modeNumbersTM[0] = modeNumber;
|
---|
224 | this.numberOfTMmeasurementsGrating = 1;
|
---|
225 | }
|
---|
226 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
227 | this.setMeasurementsTMgrating = true;
|
---|
228 | this.setMeasurementsGrating = true;
|
---|
229 | if(this.setGratingPitch && super.setWavelength)this.calcTMmodeEffectiveRefractiveIndices();
|
---|
230 |
|
---|
231 | }
|
---|
232 |
|
---|
233 | // Enter TE mode data for a range of measurements without errors
|
---|
234 | public void enterTEmodeData(double[] thicknesses, double[] angles, double[] modeNumbers){
|
---|
235 | int o = thicknesses.length;
|
---|
236 | int n = angles.length;
|
---|
237 | if(n!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of coupling angles, " + n);
|
---|
238 | int m = modeNumbers.length;
|
---|
239 | if(m!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of mode numbers, " + m);
|
---|
240 |
|
---|
241 | if(this.setMeasurementsTEgrating){
|
---|
242 | if(this.setTEerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
243 | int nNew = this.numberOfTEmeasurementsGrating + o;
|
---|
244 | double[] hold = new double[nNew];
|
---|
245 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.thicknessesTE[i];
|
---|
246 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = thicknesses[i];
|
---|
247 | this.thicknessesTE = hold;
|
---|
248 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.anglesDegTE[i];
|
---|
249 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = angles[i];
|
---|
250 | this.anglesDegTE = hold;
|
---|
251 | this.anglesRadTE = hold;
|
---|
252 | this.errorsDegTE = hold;
|
---|
253 | this.errorsRadTE = hold;
|
---|
254 | for(int i=0; i<nNew; i++){
|
---|
255 | this.anglesRadTE[i] = Math.toRadians(this.anglesDegTE[i]);
|
---|
256 | this.errorsDegTE[i] = 0.0D;
|
---|
257 | this.errorsRadTE[i] = 0.0D;
|
---|
258 | }
|
---|
259 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.modeNumbersTE[i];
|
---|
260 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = modeNumbers[i];
|
---|
261 | this.numberOfTEmeasurementsGrating = nNew;
|
---|
262 | }
|
---|
263 | else{
|
---|
264 | this.numberOfTEmeasurementsGrating = o;
|
---|
265 | this.thicknessesTE = thicknesses;
|
---|
266 | this.anglesDegTE = angles;
|
---|
267 | this.anglesRadTE = new double[o];
|
---|
268 | this.errorsDegTE = new double[o];
|
---|
269 | this.errorsRadTE = new double[o];
|
---|
270 | for(int i=0; i<o; i++){
|
---|
271 | this.anglesRadTE[i] = Math.toRadians(angles[i]);
|
---|
272 | this.errorsDegTE[i] = 0.0D;
|
---|
273 | this.errorsRadTE[i] = 0.0D;
|
---|
274 | }
|
---|
275 | this.modeNumbersTE = modeNumbers;
|
---|
276 | }
|
---|
277 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
278 | this.setMeasurementsTEgrating = true;
|
---|
279 | this.setMeasurementsGrating = true;
|
---|
280 | if(this.setGratingPitch && super.setWavelength)this.calcTEmodeEffectiveRefractiveIndices();
|
---|
281 |
|
---|
282 | }
|
---|
283 |
|
---|
284 | // Enter TM mode data for a range of measurements without errors
|
---|
285 | public void enterTMmodeData(double[] thicknesses, double[] angles, double[] modeNumbers){
|
---|
286 | int o = thicknesses.length;
|
---|
287 | int n = angles.length;
|
---|
288 | if(n!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of coupling angles, " + n);
|
---|
289 | int m = modeNumbers.length;
|
---|
290 | if(m!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of mode numbers, " + m);
|
---|
291 |
|
---|
292 | if(this.setMeasurementsTMgrating){
|
---|
293 | if(this.setTMerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
294 | int nNew = this.numberOfTMmeasurementsGrating + o;
|
---|
295 | double[] hold = new double[nNew];
|
---|
296 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.thicknessesTM[i];
|
---|
297 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = thicknesses[i];
|
---|
298 | this.thicknessesTM = hold;
|
---|
299 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.anglesDegTM[i];
|
---|
300 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = angles[i];
|
---|
301 | this.anglesDegTM = hold;
|
---|
302 | this.anglesRadTM = hold;
|
---|
303 | this.errorsDegTM = hold;
|
---|
304 | this.errorsRadTM = hold;
|
---|
305 | for(int i=0; i<nNew; i++){
|
---|
306 | this.anglesRadTM[i] = Math.toRadians(this.anglesDegTM[i]);
|
---|
307 | this.errorsDegTM[i] = 0.0D;
|
---|
308 | this.errorsRadTM[i] = 0.0D;
|
---|
309 | }
|
---|
310 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.modeNumbersTM[i];
|
---|
311 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = modeNumbers[i];
|
---|
312 | this.numberOfTMmeasurementsGrating = nNew;
|
---|
313 | }
|
---|
314 | else{
|
---|
315 | this.numberOfTMmeasurementsGrating = o;
|
---|
316 | this.thicknessesTM = thicknesses;
|
---|
317 | this.anglesDegTM = angles;
|
---|
318 | this.anglesRadTM = new double[o];
|
---|
319 | this.errorsDegTM = new double[o];
|
---|
320 | this.errorsRadTM = new double[o];
|
---|
321 | for(int i=0; i<o; i++){
|
---|
322 | this.anglesRadTM[i] = Math.toRadians(angles[i]);
|
---|
323 | this.errorsDegTM[i] = 0.0D;
|
---|
324 | this.errorsRadTM[i] = 0.0D;
|
---|
325 | }
|
---|
326 | this.modeNumbersTM = modeNumbers;
|
---|
327 | }
|
---|
328 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
329 | this.setMeasurementsTMgrating = true;
|
---|
330 | this.setMeasurementsGrating = true;
|
---|
331 | if(this.setGratingPitch && super.setWavelength)this.calcTMmodeEffectiveRefractiveIndices();
|
---|
332 | }
|
---|
333 |
|
---|
334 | // Enter TE mode data for a single measurement with error
|
---|
335 | public void enterTEmodeData(double thickness, double angle, double error, double modeNumber){
|
---|
336 | if(this.setMeasurementsTEgrating){
|
---|
337 | if(!this.setTEerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
338 | int nNew = this.numberOfTEmeasurementsGrating + 1;
|
---|
339 | double[] hold = new double[nNew];
|
---|
340 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.thicknessesTE[i];
|
---|
341 | hold[this.numberOfTEmeasurementsGrating] = thickness;
|
---|
342 | this.thicknessesTE = hold;
|
---|
343 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.anglesDegTE[i];
|
---|
344 | hold[this.numberOfTEmeasurementsGrating] = angle;
|
---|
345 | this.anglesDegTE = hold;
|
---|
346 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.errorsDegTE[i];
|
---|
347 | hold[this.numberOfTEmeasurementsGrating] = error;
|
---|
348 | this.errorsDegTE = hold;
|
---|
349 | this.anglesRadTE = hold;
|
---|
350 | this.errorsRadTE = hold;
|
---|
351 | for(int i=0; i<nNew; i++){
|
---|
352 | this.anglesRadTE[i] = Math.toRadians(this.anglesDegTE[i]);
|
---|
353 | this.errorsRadTE[i] = Math.toRadians(this.errorsDegTE[i]);
|
---|
354 | }
|
---|
355 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.modeNumbersTE[i];
|
---|
356 | hold[this.numberOfTEmeasurementsGrating] = modeNumber;
|
---|
357 | this.numberOfTEmeasurementsGrating = nNew;
|
---|
358 | }
|
---|
359 | else{
|
---|
360 | this.thicknessesTE = new double[1];
|
---|
361 | this.thicknessesTE[0] = thickness;
|
---|
362 | this.anglesDegTE = new double[1];
|
---|
363 | this.anglesDegTE[0] = angle;
|
---|
364 | this.anglesRadTE = new double[1];
|
---|
365 | this.anglesRadTE[0] = Math.toRadians(angle);
|
---|
366 | this.errorsDegTE = new double[1];
|
---|
367 | this.errorsDegTE[0] = error;
|
---|
368 | this.errorsRadTE = new double[1];
|
---|
369 | this.errorsRadTE[0] = Math.toRadians(error);
|
---|
370 | this.modeNumbersTE = new double[1];
|
---|
371 | this.modeNumbersTE[0] = modeNumber;
|
---|
372 | this.numberOfTEmeasurementsGrating = 1;
|
---|
373 | }
|
---|
374 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
375 | this.setMeasurementsTEgrating = true;
|
---|
376 | this.setTEerrors = true;
|
---|
377 | this.setMeasurementsGrating = true;
|
---|
378 | if(this.setGratingPitch && super.setWavelength)this.calcTEmodeEffectiveRefractiveIndices();
|
---|
379 | }
|
---|
380 |
|
---|
381 |
|
---|
382 |
|
---|
383 | // Enter TM mode data for a single measurement with error
|
---|
384 | public void enterTMmodeData(double thickness, double angle, double error, double modeNumber){
|
---|
385 | if(this.setMeasurementsTMgrating){
|
---|
386 | if(!this.setTMerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
387 | int nNew = this.numberOfTMmeasurementsGrating + 1;
|
---|
388 | double[] hold = new double[nNew];
|
---|
389 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.thicknessesTM[i];
|
---|
390 | hold[this.numberOfTMmeasurementsGrating] = thickness;
|
---|
391 | this.thicknessesTM = hold;
|
---|
392 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.anglesDegTM[i];
|
---|
393 | hold[this.numberOfTMmeasurementsGrating] = angle;
|
---|
394 | this.anglesDegTM = hold;
|
---|
395 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.errorsDegTM[i];
|
---|
396 | hold[this.numberOfTMmeasurementsGrating] = error;
|
---|
397 | this.errorsDegTM = hold;
|
---|
398 | this.anglesRadTM = hold;
|
---|
399 | this.errorsRadTM = hold;
|
---|
400 | for(int i=0; i<nNew; i++){
|
---|
401 | this.anglesRadTM[i] = Math.toRadians(this.anglesDegTM[i]);
|
---|
402 | this.errorsRadTM[i] = Math.toRadians(this.errorsDegTM[i]);
|
---|
403 | }
|
---|
404 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.modeNumbersTM[i];
|
---|
405 | hold[this.numberOfTMmeasurementsGrating] = modeNumber;
|
---|
406 | this.numberOfTMmeasurementsGrating = nNew;
|
---|
407 | }
|
---|
408 | else{
|
---|
409 | this.thicknessesTM = new double[1];
|
---|
410 | this.thicknessesTM[0] = thickness;
|
---|
411 | this.anglesDegTM = new double[1];
|
---|
412 | this.anglesDegTM[0] = angle;
|
---|
413 | this.anglesRadTM = new double[1];
|
---|
414 | this.anglesDegTM[0] = Math.toRadians(angle);
|
---|
415 | this.errorsDegTM = new double[1];
|
---|
416 | this.errorsDegTM[0] = error;
|
---|
417 | this.errorsRadTM = new double[1];
|
---|
418 | this.errorsDegTM[0] = Math.toRadians(error);
|
---|
419 | this.modeNumbersTM = new double[1];
|
---|
420 | this.modeNumbersTM[0] = modeNumber;
|
---|
421 | this.numberOfTMmeasurementsGrating = 1;
|
---|
422 | }
|
---|
423 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
424 | this.setMeasurementsTMgrating = true;
|
---|
425 | this.setTMerrors = true;
|
---|
426 | this.setMeasurementsGrating = true;
|
---|
427 | if(this.setGratingPitch && super.setWavelength)this.calcTMmodeEffectiveRefractiveIndices();
|
---|
428 | }
|
---|
429 |
|
---|
430 | // Enter TE mode data for a range of measurements with errors
|
---|
431 | public void enterTEmodeData(double[] thicknesses, double[] angles, double[] errors, double[] modeNumbers){
|
---|
432 | int o = thicknesses.length;
|
---|
433 | int n = angles.length;
|
---|
434 | if(n!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of coupling angles, " + n);
|
---|
435 | int m = modeNumbers.length;
|
---|
436 | if(m!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of mode numbers, " + m);
|
---|
437 |
|
---|
438 | if(this.setMeasurementsTEgrating){
|
---|
439 | if(!this.setTEerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
440 | int nNew = this.numberOfTEmeasurementsGrating + o;
|
---|
441 | double[] hold = new double[nNew];
|
---|
442 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.thicknessesTE[i];
|
---|
443 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = thicknesses[i];
|
---|
444 | this.thicknessesTE = hold;
|
---|
445 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.anglesDegTE[i];
|
---|
446 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = angles[i];
|
---|
447 | this.anglesDegTE = hold;
|
---|
448 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.errorsDegTE[i];
|
---|
449 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = errors[i];
|
---|
450 | this.errorsDegTE = hold;
|
---|
451 | this.anglesRadTE = hold;
|
---|
452 | this.errorsRadTE = hold;
|
---|
453 | for(int i=0; i<nNew; i++){
|
---|
454 | this.anglesRadTE[i] = Math.toRadians(this.anglesDegTE[i]);
|
---|
455 | this.errorsRadTE[i] = Math.toRadians(this.errorsDegTE[i]);
|
---|
456 | }
|
---|
457 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++)hold[i] = this.modeNumbersTE[i];
|
---|
458 | for(int i=0; i<o; i++)hold[this.numberOfTEmeasurementsGrating+i] = modeNumbers[i];
|
---|
459 | this.numberOfTEmeasurementsGrating = nNew;
|
---|
460 | }
|
---|
461 | else{
|
---|
462 | this.numberOfTEmeasurementsGrating = o;
|
---|
463 | this.thicknessesTE = thicknesses;
|
---|
464 | this.anglesDegTE = angles;
|
---|
465 | this.anglesRadTE = new double[o];
|
---|
466 | this.errorsDegTE = errors;
|
---|
467 | this.errorsRadTE = new double[o];
|
---|
468 | for(int i=0; i<o; i++){
|
---|
469 | this.anglesRadTE[i] = Math.toRadians(angles[i]);
|
---|
470 | this.errorsRadTE[i] = Math.toRadians(errors[i]);
|
---|
471 | }
|
---|
472 | this.modeNumbersTE = modeNumbers;
|
---|
473 | }
|
---|
474 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
475 | this.setMeasurementsTEgrating = true;
|
---|
476 | this.setTEerrors = true;
|
---|
477 | this.setMeasurementsGrating = true;
|
---|
478 | if(this.setGratingPitch && super.setWavelength)this.calcTEmodeEffectiveRefractiveIndices();
|
---|
479 | }
|
---|
480 |
|
---|
481 | // Enter TM mode data for a range of measurements without errors
|
---|
482 | public void enterTMmodeData(double[] thicknesses, double[] angles, double[] errors, double[] modeNumbers){
|
---|
483 | int o = thicknesses.length;
|
---|
484 | int n = angles.length;
|
---|
485 | if(n!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of coupling angles, " + n);
|
---|
486 | int m = modeNumbers.length;
|
---|
487 | if(m!=o)throw new IllegalArgumentException("number of thicknesses, " + o + ", does not equal the number of mode numbers, " + m);
|
---|
488 |
|
---|
489 | if(this.setMeasurementsTMgrating){
|
---|
490 | if(!this.setTMerrors)throw new IllegalArgumentException("All Entered data must either all have associated errors entered or all have no associated errors entered");
|
---|
491 | int nNew = this.numberOfTMmeasurementsGrating + o;
|
---|
492 | double[] hold = new double[nNew];
|
---|
493 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.thicknessesTM[i];
|
---|
494 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = thicknesses[i];
|
---|
495 | this.thicknessesTM = hold;
|
---|
496 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.anglesDegTM[i];
|
---|
497 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = angles[i];
|
---|
498 | this.anglesDegTM = hold;
|
---|
499 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.errorsDegTM[i];
|
---|
500 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = errors[i];
|
---|
501 | this.errorsDegTM = hold;
|
---|
502 | this.anglesRadTM = hold;
|
---|
503 | this.errorsRadTM = hold;
|
---|
504 | for(int i=0; i<nNew; i++){
|
---|
505 | this.anglesRadTM[i] = Math.toRadians(this.anglesDegTM[i]);
|
---|
506 | this.errorsRadTM[i] = Math.toRadians(this.errorsDegTM[i]);
|
---|
507 | }
|
---|
508 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++)hold[i] = this.modeNumbersTM[i];
|
---|
509 | for(int i=0; i<o; i++)hold[this.numberOfTMmeasurementsGrating+i] = modeNumbers[i];
|
---|
510 | this.numberOfTMmeasurementsGrating = nNew;
|
---|
511 | }
|
---|
512 | else{
|
---|
513 | this.numberOfTMmeasurementsGrating = o;
|
---|
514 | this.thicknessesTM = thicknesses;
|
---|
515 | this.anglesDegTM = angles;
|
---|
516 | this.errorsDegTM = errors;
|
---|
517 | this.anglesRadTM = new double[o];
|
---|
518 | this.errorsRadTM = new double[o];
|
---|
519 | for(int i=0; i<o; i++){
|
---|
520 | this.anglesRadTM[i] = Math.toRadians(angles[i]);
|
---|
521 | this.errorsRadTM[i] = Math.toRadians(errors[i]);
|
---|
522 | }
|
---|
523 | this.modeNumbersTM = modeNumbers;
|
---|
524 | }
|
---|
525 | this.numberOfMeasurementsGrating = this.numberOfTEmeasurementsGrating + this.numberOfTMmeasurementsGrating;
|
---|
526 | this.setMeasurementsTMgrating = true;
|
---|
527 | this.setTMerrors = true;
|
---|
528 | this.setMeasurementsGrating = true;
|
---|
529 | if(this.setGratingPitch && super.setWavelength)this.calcTMmodeEffectiveRefractiveIndices();
|
---|
530 | }
|
---|
531 |
|
---|
532 |
|
---|
533 | // Clear entered thickness, effective refractive index and mode number data
|
---|
534 | // so new dat may be entered without it being appended to the existing data
|
---|
535 | public void clearData(){
|
---|
536 | this.numberOfTEmeasurementsGrating = 0;
|
---|
537 | this.setMeasurementsTEgrating = false;
|
---|
538 |
|
---|
539 | this.numberOfTMmeasurementsGrating = 0;
|
---|
540 | this.setMeasurementsTMgrating = false;
|
---|
541 |
|
---|
542 | super.numberOfMeasurements = 0;
|
---|
543 | super.setMeasurements = false;
|
---|
544 | super.setWeights = false;
|
---|
545 |
|
---|
546 | super.numberOfTEmeasurements = 0;
|
---|
547 | super.setMeasurementsTE = false;
|
---|
548 |
|
---|
549 | super.numberOfTMmeasurements = 0;
|
---|
550 | super.setMeasurementsTM = false;
|
---|
551 | }
|
---|
552 |
|
---|
553 | // CALCULATION OF THE EFFECTIVE REFRACTIVE INDEX/INDICES
|
---|
554 | // Calculate all effective refractive indices
|
---|
555 | public void calcEffectiveRefractiveIndices(){
|
---|
556 | if(this.setMeasurementsTEgrating)this.calcTEmodeEffectiveRefractiveIndices();
|
---|
557 | if(this.setMeasurementsTMgrating)this.calcTMmodeEffectiveRefractiveIndices();
|
---|
558 | }
|
---|
559 |
|
---|
560 | // Calculate TE mode effective refractive indices
|
---|
561 | public void calcTEmodeEffectiveRefractiveIndices(){
|
---|
562 | this.effectiveRefractiveIndicesTE = new double[this.numberOfTEmeasurementsGrating];
|
---|
563 | this.effectiveErrorsTE = new double[this.numberOfTEmeasurementsGrating];
|
---|
564 |
|
---|
565 | if(!this.setSuperstrateRI){
|
---|
566 | this.superstrateRI = RefractiveIndex.air(super.wavelength);
|
---|
567 | super.superstrateRefractiveIndex = RefractiveIndex.air(super.wavelength);
|
---|
568 | }
|
---|
569 |
|
---|
570 | if(this.setTEerrors){
|
---|
571 | ErrorProp superRI = new ErrorProp(super.superstrateRefractiveIndex, 0.0D);
|
---|
572 | ErrorProp pitch = new ErrorProp(this.gratingPitch, 0.0D);
|
---|
573 | ErrorProp lambda = new ErrorProp(super.wavelength, 0.0D);
|
---|
574 |
|
---|
575 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++){
|
---|
576 | ErrorProp theta = new ErrorProp(this.anglesRadTM[i], this.errorsRadTM[i]);
|
---|
577 | ErrorProp order = new ErrorProp((double)this.gratingOrderTE[i], 0.0D);
|
---|
578 | ErrorProp calc = ErrorProp.sin(theta);
|
---|
579 | calc = calc.times(superRI);
|
---|
580 | calc = calc.plus(lambda.times(order).over(pitch));
|
---|
581 | this.effectiveRefractiveIndicesTE[i] = calc.getValue();
|
---|
582 | this.effectiveErrorsTE[i] = calc.getError();
|
---|
583 | }
|
---|
584 | super.enterTEmodeData(this.thicknessesTE, this.effectiveRefractiveIndicesTE, this.effectiveErrorsTE, this.modeNumbersTE);
|
---|
585 | }
|
---|
586 | else{
|
---|
587 | for(int i=0; i<this.numberOfTEmeasurementsGrating; i++){
|
---|
588 | this.effectiveRefractiveIndicesTE[i] = this.superstrateRI*Math.sin(this.anglesRadTE[i]) + super.wavelength*this.gratingOrderTE[i]/this.gratingPitch;
|
---|
589 | }
|
---|
590 | super.enterTEmodeData(this.thicknessesTE, this.effectiveRefractiveIndicesTE, this.modeNumbersTE);
|
---|
591 | }
|
---|
592 | this.calcEffectiveDone = true;
|
---|
593 | }
|
---|
594 |
|
---|
595 | // Calculate TM mode effective refractive indices
|
---|
596 | public void calcTMmodeEffectiveRefractiveIndices(){
|
---|
597 | this.effectiveRefractiveIndicesTM = new double[this.numberOfTMmeasurementsGrating];
|
---|
598 | this.effectiveErrorsTM = new double[this.numberOfTMmeasurementsGrating];
|
---|
599 |
|
---|
600 | if(!this.setSuperstrateRI){
|
---|
601 | this.superstrateRI = RefractiveIndex.air(super.wavelength);
|
---|
602 | super.superstrateRefractiveIndex = RefractiveIndex.air(super.wavelength);
|
---|
603 | }
|
---|
604 |
|
---|
605 | if(this.setTMerrors){
|
---|
606 | ErrorProp superRI = new ErrorProp(super.superstrateRefractiveIndex, 0.0D);
|
---|
607 | ErrorProp pitch = new ErrorProp(this.gratingPitch, 0.0D);
|
---|
608 | ErrorProp lambda = new ErrorProp(super.wavelength, 0.0D);
|
---|
609 |
|
---|
610 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++){
|
---|
611 | ErrorProp theta = new ErrorProp(this.anglesRadTM[i], this.errorsRadTM[i]);
|
---|
612 | ErrorProp order = new ErrorProp((double)this.gratingOrderTM[i], 0.0D);
|
---|
613 | ErrorProp calc = ErrorProp.sin(theta);
|
---|
614 | calc = calc.times(superRI);
|
---|
615 | calc = calc.plus(lambda.times(order).over(pitch));
|
---|
616 | this.effectiveRefractiveIndicesTM[i] = calc.getValue();
|
---|
617 | this.effectiveErrorsTM[i] = calc.getError();
|
---|
618 | }
|
---|
619 | super.enterTMmodeData(this.thicknessesTM, this.effectiveRefractiveIndicesTM, this.effectiveErrorsTM, this.modeNumbersTM);
|
---|
620 | }
|
---|
621 | else{
|
---|
622 | for(int i=0; i<this.numberOfTMmeasurementsGrating; i++){
|
---|
623 | this.effectiveRefractiveIndicesTM[i] = this.superstrateRI*Math.sin(this.anglesRadTM[i]) + super.wavelength*this.gratingOrderTM[i]/this.gratingPitch;
|
---|
624 | }
|
---|
625 | super.enterTMmodeData(this.thicknessesTM, this.effectiveRefractiveIndicesTM, this.modeNumbersTM);
|
---|
626 | }
|
---|
627 | this.calcEffectiveDone = true;
|
---|
628 | }
|
---|
629 | } |
---|