These examples cover the basic FRED scripting commands involving materials: "Add" - adds a new material to the existing list, "Append" - appends a wavelength to the table of an existing material, "Find" - used to determine the identifier of an existing material, "Get" - retrieves information from an existing material, "GetIth" - retrieves material parameters at the ith wavelength in its list, "GetGRINMaterialNumWavelengths" - retrieves the number of wavelength entries in a GRIN material definition, "Init" - initializes a structure with default values, "RemoveIth" - removes the ith wavelength from the material list along with the corresponding parameters at that wavelength, "RefractiveIndex"- returns the real or imaginary part of a material refractive index at a specified wavelength, "Set" - sets properties of an existing material, and "SetIth" - sets the ith wavelength and associated parameters for an existing material. The material structures listed below contain the parameters required to fully define material types:
FRED offers types of material models: Sampled Material - user specified a list of wavelengths and corresponding complex refractive indicies. Model Material - user specified refractive index and Abbe number at the He "d" line (0.5875618 mm). Gradient Index - Luneberg, Maxwell, Spherical, SELFOC, Axial, Radial, & scripted. Birefringent/Optically Active - uniaxial crystals with ordinary & extraordinary indicies or Optical Activity.with gyrotopic coefficients. Catalog glasses - Materials from Schott, Ohara, Hoya, CorningSA, Pilkington, Schott Radiation Resistant, or Custom catalogs. "Add" a Material
To "Add" a Sampled material requires at least these four steps:
Declare the appropriate structure. Set the desired parameters of that material structure. "Add" the material. Update FRED.
To "Add" a Sampled material, first declare a T_SAMPLEDMATERIAL structure and assign a name and description to the new material. Declare arrays to hold the wavelength list and the corresponding real and imaginary indicies at those wavelengths. Finally, pass the wavelength and index information to FRED through the AddSampledMaterial command. Finally, Update the material database.
Dim m As T_SAMPLEDMATERIAL Print "The index of the new Sampled material is ", id
To "Add" a Model material requires only four steps: Declare the appropriate structure. Set the desired parameters of that material structure. "Add" the material. Update FRED.
Dim mymat As T_MODELMATERIAL Update Print "The index of the new model material is ", id
To "Add" a Catalog glass, specify the glass name and the catalog name then Update the material database:
Dim gName$,catname$ Print "The index of the new catalog glass is ", id
To "Add" a Maxwell GRIN material, specify a wavelength along with N0 & R0 values at that wavelength. Always Update the material database.:
Dim wv#,N0#,R0# Print "The index of the new Maxwell GRIN material is ", id
To "Add" a SELFOC material, specify a wavelength and populate an array with the N0 & N# values for that wavelength. Finally, Update the material database.:
Dim wave# Update
To add a birefringent material, declare a T_BIREFSAMPLE structure and specify the material name and description. Assign the desired refractive indicies or gyrotropic coefficients then create the material using the AddBirefringentMaterial command. [The default crystal axis is in the z-direction. See SetBirefringentMaterialCrystalAxis below for guidance on setting a different crystal axis direction.] Don't forget to Update the material database.
Dim xtal As T_BIREFSAMPLE bname="mycrystal"
To "Add" a GRIN material defined by a user script, specify the full path of script file. FRED assumes that the file is in your current directory otherwise. Assign a name to the material as well.
scrptid = AddScriptGRINMaterial ("mynewgrin.frs") Dim scrptname As String scrptname="CustomGRIN" SetMaterialName scrptid, scrptname
"Find" a material identifier
Use FindMaterial to retrieve the identifier of an existing material:
lunid=FindMaterial("myluneberg")
"Append" a wavelength and its corresponding data
If additional material data is needed, use an "Append" command to add it. These entries are appended to the end of an existing list.
To append more data to an existing Lundberg material, first determine the identifier of the material with FindMaterial.
lunid=FindMaterial("myluneberg")
"Get" data from an existing material
To "Get" common data from an existing material, first declare a T_GRINCOMMON structure then find the material indentifier.
Dim GCom As T_GRINCOMMON
"GetIth" wavelength and its corresponding data
Use the "GetIth" commands to retrieve data from a GRIN material or Glue at a specific wavelength.
To retrieve the ith wavelength and its corresponding data from an existing SELFOC material, first find its identifier. Since the GetIthSelfocGRINMaterial command returns a wavelength and its corresponding coefficients, declare a wavelength variable and an array to hold the coefficients. After choosing the index of the desired wavelength, issue the GetIthSelfocGRINMaterial command.
sfid=FindMaterial("selfocfiber") "GetGRINMaterialNumWavelengths"
Use this command to retrieve the number of wavelength entries in a GRIN material definition:
gid=FindMaterial("AxRadMat")
"Init" a material
The "Init" commands initialize either Model material or GRIN Common structures. These commands are used to set/return a material to its default set of values.
Dim mat As T_MODELMATERIAL
or
Dim grincom As T_GRINCOMMON InitGRINMaterialCommon grincom Print "step size ", grincom.StepSize
"RemoveIth" wavelength and its corresponding data
The "RemoveIth" commands remove a selected set of material parameters from a material model.
gid=FindMaterial("MaxwellMat") indx=2 'remove the third entry RemoveIthMaxwellGRINMaterial gid, indx nw=GetGRINMaterialNumWavelengths(gid)
"RefractiveIndex" retrieval
Retrieve the real (or imaginary) part of a material refractive index at a specified wavelength:
matid1=FindMaterial("Optical Cement")
"Set" the parameters of a material
Use the "Set" commands to change specific parameters of an existing material, assign a script defining a GRIN material, change the GRIN common parameters, or define a new crystal axis orientation for a birefringent material.
To change the script file defining an existing user scripted GRIN material, specify the new filename:
Dim newscript As String newscript="anothergrin.frs" SetScriptGRINMaterial scrptid, newscript Update
To change the settings of a GRIN common for an existing material, first declare a T_GRINCOMMON structure and initialize its values. Alter the desired values, then use SetGRINMaterialCommon to put the new data into the material definition.
Dim gparm As T_GRINCOMMON
As mentioned earlier, a birefringent material has its crystal axis defined along the z-direction by default. To change the crystal axis direction, define a new direction vector then use SetBirefringentMaterialCrystalAxis to reorient the crystal.
matid=FindMaterial("Mica") SetBirefringentMaterialCrystalAxis matid, X, Y, Z
See Also….
|