Creates a new fit parameter in the list of fit parameters. The parameters passed to this procedure have the following meaning:
list: the CODE list with the object the fit parameter of which is to be created
1 Materials
2 | Layer stacks |
3 | Spectra list |
4 Master parameter list
object: the index of the object in the list. The objects are counted 1, 2, 3, ...
subobject: if the object has subobjects this parameter specifies the index of the wanted subobject. This can be, for example, a susceptibility in the list of susceptibilities of a dielectric function model.
subsubobject: if the subobject has again subobjects of its own, this is the index of the wanted subobject.
parameter: the index of the parameter to be selected as fit parameter. If you are not sure about the index of a parameter you can drag the object to the fit parameter list and see which parameters are created in which order. The 'create_fit_parameter' OLE command uses exactly the same number and sequence of parameters.
Here is a simple example making use of the create_fit_parameter command:
'Excel VisualBasic demo of a remote fitting procedure using OLE automation
'This object is the SCOUT automation object
Public wcd As Object
Public Sub fit()
'Create the OLE server
Set wcd = CreateObject("code.colors")
'Load a pre-configured configuration with a suitable reflectance spectrum and spectral range
wcd.configuration_file = "c:\test\ole_test.wcd"
'Show SCOUT on the screen
wcd.Show
'Clear the layer stack - we will build up a new one in a moment
wcd.clear_layer_stack (1)
'Clear the list of materials - materials will be taken from the database
wcd.clear_material_list
'Create a thick layer with 2 mm thickness and fill it with BK7 glass, a material named "Glass Type BK7" must be in the database
Call wcd.add_layer_definition_on_top(1, "Thick layer" + Chr(9) + "Glass Type BK7" + Chr(9) + "0.2")
'Create a thin silver filme on top of the glass substrate, take the material "Ag model" from the database
Call wcd.add_layer_definition_on_top(1, "Thin film" + Chr(9) + "Ag model" + Chr(9) + "0.000001")
'Load a measured spectrum into the first spectrum object, using standard format
Call wcd.load_experiment(1, "C:\test\ag_10.std", 1)
'Clear the list of fitparameters
wcd.clear_fit_parameters
'From the list of layer stacks, take the first object
'and then the second subobject. This is the silver layer.
'Select parameter 1 as fit parameter (this is the thickness)
Call wcd.create_fit_parameter(2, 1, 2, 0, 1)
'From the list of materials, take the 3rd object which is the silver model
'(initially there was vacuum, then glass has been taken from the database,
'and finally, as 3rd object, the Ag model was loaded).
'Take the first susceptibility which is the Drude model.
'Take the 2nd parameter of the Drude model which is the damping constant and select
'it as fit parameter.
Call wcd.create_fit_parameter(1, 3, 1, 0, 2)
'Set boundaries for the damping constant which is fit parameter 2 now (after the layer thickness).
wcd.fit_parameter_value_min(2) = 100
wcd.fit_parameter_value_max(2) = 10000
'The silver model contains several Brendel oscillators in the list of susceptibilities.
'Take the 2nd, 3rd, 4th and 5th susceptibility and select for each one parameter
'2 as fit parameter, i.e. the oscillator strength.
'This is just for demonstration - it is not really reasonable to vary these parameters in the fit.
Call wcd.create_fit_parameter(1, 3, 2, 0, 2)
Call wcd.create_fit_parameter(1, 3, 3, 0, 2)
Call wcd.create_fit_parameter(1, 3, 4, 0, 2)
Call wcd.create_fit_parameter(1, 3, 5, 0, 2)
'Select - just for demonstration - parameter #1 of the first spectrum in the list of spectra.
'This is the angle of incidence of the reflectance spectrum.
Call wcd.create_fit_parameter(3, 1, 0, 0, 1)
'Select - also for demonstration only - the first master parameter as fitparameter.
Call wcd.create_fit_parameter(4, 1, 0, 0, 1)
'Re-compute the model and update the main view
wcd.update_data
wcd.update_plot
'Start the fit
wcd.start
'Start a waiting loop which will finish when SCOUT stops its fit (or you as a user
'press the STOP button in SCOUT.
While wcd.fitting = True
'Wait for 1 second
Application.Wait Now + TimeSerial(0, 0, 1)
Wend
'Write results to a worksheet range
'fit parameter #1 is the thickness
Range("results").Offset(1, 1) = wcd.fit_parameter_value(1)
'export the real part of the refractive index of the Ag model at 1000 nm wavelength
Range("results").Offset(1, 2) = wcd.refractive_index(3, 10000000 / 1000)
'export the imaginary part of the refractive index of the Ag model at 1000 nm wavelength
Range("results").Offset(1, 3) = wcd.kappa(3, 10000000 / 1000)
End Sub