Navigation: Scripting Reference Manual > Script Examples > Example - Coatings

 

Example - Coatings

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the basic FRED scripting commands involving coatings:

"Add" - add coatings or coating data,

"Delete" - delete a coating or coating data,

"Evaluate" - compute transmittance or reflectance of a coating,

"Find" - find a coating identifier,

"Get" - retrieve coating data,

"Init" - initialize a coating structure,

"Set" - set coating data.

 

The following structures are required for some coating commands:

T_GENERALCOATINGITEM

T_JONESMATRIX

 

 


 

"Add" a coating or coating property

The user can add "Uncoated", "Jones Matrix", "Sampled", "General", "Thin Film" or "Quaterwave" coatings. In this example, a quarterwave coating of an existing MgF2 material is added to each optical surface of Edmund catalog lenses in the system.

 

cid = AddQuarterWaveCoating ( "QW MgF2", .587, 0, FindMaterial("MgF2") )

For i=0 To GetEntityCount()-1
 If InStr(1, GetFullName(i), "Edmund") > 0 And InStr(1, GetFullName(i), "Surface") > 0 Then
  SetSurfCoating i, cid
 End If
Next i

 

In this example, a new thin film coating with two layers is added . This film has a design wavelength of 0.6328 mm, a design angle of zero degrees, its layer thicknesses expressed in waves, and the substrate in contact with the last layer. Note that the individual layers are added as separate commands.

 

tfid = AddThinFilmCoating ( "MyThinFilm", 0.6328, 0, "Waves", True )
number = AddThinFilmLayer ( tfid, 0.4, 7, 0 )
number = AddThinFilmLayer ( tfid, 0.15, 9, 0 )


 

"Delete" a coating or coating property

Use the "Delete" commands to remove wavelength or angle specifications from a coating. In this example, FRED removes the 0.487 mm entry in the Sampled coating "SampCoat1" if it exists.

 

wave=0.487

cid = FindCoating ("SampCoat1" )

If DeleteSampledCoatingWavelength ( cid, wave ) Then

 Print "wavelength ", wave, " removed"

Else

 Print "wavelength ", wave, " not found in coating list"

End If


 

"Evaluate" a coating

The "Evaluate" commands return the real and imaginary parts of the reflectance or transmittance coefficient for an existing coating given the incident and substrate indices, a wavelength and angle of incidence.

 

Dim real#, imag#, rp#, dummy#
success = EvaluateCoatingReflP ( 5, 1, 1.9044, 0.587, 0, real, imag )

CmpxMult ( real, imag, real, -imag, rp, dummy ) 
Print "Coating p-reflectance is ", rp


 

"Find" a coating

The FindCoating command returns the coating identifier for named coating:

 

cid=FindCoating("Uncoated")


 

"Get" a coating or coating property

Retrieve the attributes of a coating using the "Get" commands. For instance, FRED returns the number of layers in a specified coating:

 

coatid=FindCoating("Dewar Coating")

count = GetThinFilmLayerCount ( coatid )

 

The General Sampled coating requires a structure be declared before its attributes can be retrieved or set. Here, the attributes of "GenCoat" for the wavelength 0.587 mm at zero incident angle are loaded into the declared structure coating.

 

Dim coating As T_GENERALCOATINGITEM
gid=FindCoating("GenCoat")
success = GetGeneralCoatingCoefficients ( gid, .587, 0, coating )
Print coating.RS, coating.RP, coating.TS, coating.TP


 

"Init" a coating

The only coating requiring initialization is the Jones matrix coating. All structure values are initialized to zero except J00real=1. This represents a linear horizontal polarizer.

 

Dim jm as T_JONESMATRIX

InitMatrixCoating jm

 


 

"Set" coating property

The "Set" commands allow the individual parameters of coating to be relayed to FRED.

 

For example, the above initialized structure is used to create a new matrix coating then altered to represent a quarterwave plate with its axis in the y-direction:

 

Dim jm As T_JONESMATRIX

InitMatrixCoating jm

mcid = AddMatrixCoating ("Jones QW vert", jm )

jm.J00real=1/Sqr(2)

jm.J00imag=1/Sqr(2)

jm.J11real=1/Sqr(2)

jm.J11imag=-1/Sqr(2)

SetMatrixCoating mcid, jm

 

A more compact method of achieving the same result is shown below using SetMatrixCoatingType:

 

Dim jm As T_JONESMATRIX

InitMatrixCoating jm

mcid = AddMatrixCoating ("Jones QW vert", jm )

SetMatrixCoatingType mcid,"1/4 wave Fast Axis Y"

 

In this example, the 3rd layer in the thin film "LensAR" is set to 0.45 waves of ZnSe. Recommended practice is to confirm that the thickness setting for this specific coating is "wavelength".

 

Dim wave#, angle#, units$

Dim last As Boolean

tfid=FindCoating("LensAR")

success = GetThinFilmCoatingParameters ( tfid, wave, angle, units, last )

 

If units="wavelength" Then

 success = SetThinFilmIthLayer ( tfid, 2, 0.45, FindMaterial("ZnSe"), 0 )

Else

 Print "Wrong thickness type, expecting wavelength, found ",units

End If


 

See Also….

Advanced Raytrace

Basic Raytrace

Curves

Elements

Entity Info

General Ray Data

Gratings

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Scatter

Sources

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC