'FilmStar DESIGN
BASIC GedankenTargetsB.bas
Option Explicit
Const Targs$ =
"C:\Winfilm\TargetsTemp.trw"
Const StdDev! = 0.002
'Noise level
Const bINDEX As Boolean = True
'Using INDEX
piecewise @ 0º only
Const bZeroOnly As Boolean = True
'Targets at 0 only
Const bPpolOnly As Boolean = True
'No S pol targets
Const bView As Boolean = False
'View spectra in FSPlot
Const fThick! = 100
'Film thickness (nm)
Sub Main
AxesDraw
Angle = 0
Pol$ = "P"
Design = CStr(fThick)
& "H" 'H
Linear
index example
If bView Then
PlotActivate
PlotClear
End If
Calculate
If bView Then PlotNext
AddNoise
If bView Then PlotNext
If bINDEX Then 'Using
INDEX piecewise capability
DataCopy
Exit Sub
'Spectra copied.
Click Solve..Paste
Spectrum in INDEX
End If
SpecTargets True, "R", 1, 0, "P"
'True clears targets
SpecTargets False, "T", 1, 0, "P"
If bZeroOnly Then GoTo Cont
Angle = 60
Pol$ = "P": Calculate
'P pol targets
AddNoise
SpecTargets False, "R", 1, 60, "P"
SpecTargets False, "T", 1, 60, "P"
If bPpolOnly Then GoTo Cont
Pol$ = "S": Calculate
'S pol targets
AddNoise
SpecTargets False, "R", 1, 60, "S"
SpecTargets False, "T", 1, 60, "S"
DoEvents
Cont: FileSave Targs$
DoSolve
End Sub
Sub DoSolve
Dim w!, nk$
Design = CStr(fThick) & "J"
'J $NK dispersion
function
SetIndexCoeff 4, 1, 1.6
'Set n starting value
SetIndexCoeff 4, 2, .001
'Set k starting
value
For w = 750 To 400 Step -10
FileOpen Targs$
'Sorts by wavelength
DoEvents
TargetsSelect w
DoEvents
Optimize
nk$ = nk$ & CStr(w) & vbTab &
IndexCoeff(4, 1)& _
vbTab &
IndexCoeff(4,2) & vbCrLf
Next w
Clipboard nk$ 'n,k
array created. Click File..Paste
Table in INDEX
End Sub
Sub AddNoise
Dim j%, k%, nData%, ydata!(), yd!()
If StdDev > 0 Then
ydata = Spectrum_Y
'Get spectrum
nData = UBound(ydata, 1)
For j = 1 To nData
ydata(j, 1) =
ydata(j, 1) + StdDev * RndNorm
'Reflectance
ydata(j, 2) =
ydata(j, 2) + StdDev * RndNorm
'Transmittance
Next j
Spectrum_Y = ydata
End If
End Sub
INDEX 100 nm solutions with noise StdDev = 0.002
Notes
bView=True skips DESIGN
optimization targets and just creates spectra for direct use
in INDEX.
bZeroOnly=True generates 0º targets only
bPpolOnly=True adds 60º P pol targets, skipping 60º S
pol
Start with StdDev = 0. If the solution is not the
original n&k array, there's no point in adding noise.