Navigation: Coatings > Coating Types > Script

 

Script

 

Contact Us: fredsupport@photonengr.com

 

 

 

Description


The Script Coating is a general coating model which allows complex reflection and transmission coefficients to be computed based on ray position, angle of incidence, wavelength and the complex index of refraction of the incident and substrate materials, where the ray position is provided in the local coordinate system of the surface being intersected.  The reflection and transmission coefficients are expressed in terms of magnitude and phase for both S-polarization and P-polarization.

 

 

Navigation


The Script Coating can be created in the following ways:

Open a new coating dialog and select "Script Coating (coating defined by user script)" as the coating type.

 

 

Controls


Control

Inputs / Description

Defaults

Name

Name of coating.

Coating n

Description

Description of coating.

 

Type

Coating type.  Select "Script Coating (coating defined by user script)" from the drop-down menu.

Sampled Coating

Script Coating Options

Compile

Checks the script for syntax errors (note: this does not verify that the script is working, simply that it is syntactically correct).

 

Test

Tests the script with the supplied input/output values.

 

Script Editor

The script editor allows a user created script to be written which defines the magnitude and phase of the reflection and transmission coefficients.  The Script Coating can be written in the same manner as any other FRED script.

 

 

OK

Accept settings and close dialog box.

 

Cancel

Discard settings and close dialog box.

 

Apply

Accept settings and keep dialog box open.

 

Help

Access this Help page.

 

 

 

Application Notes


Script requirements

The coating definition MUST be expressed in terms of an IF..THEN statement. Since FRED passes a Boolean into the routine to indicate whether the calculation is being made for a reflected ray or not, g_refl must necessarily act as the condition for this IF..THEN statement. A trivial example setting the reflectance to 0.9 and transmittance to 0.1 is shown here:

 

If g_refl Then

          'reflection magnitudes and phases

           g_magS=Sqr(0.9)  : g_phsS=0

           g_magP=Sqr(0.9)  : g_phsP=0

Else

          'transmission magnitudes

           g_magS=Sqr(0.1)  : g_phsS=0

           g_magP=Sqr(0.1)  : g_phsP=0

End If

 

Definition of script variables

For coating reflectance: g_magS = |r^| and  g_magP = |r|||

For coating transmittance: g_magS = √(ps/pi)·|t^| and g_magP = √(qs/qi)·|t|||,  where ps,i = ns,i cos(qs,i) and qs,i = cos(qs,i)/ns,i. Likewise, the phases for each polarization are derived from the expressions tan(dr) = Im[r] / Re[r] and tan(dt) = Im[t] / Re[t].

 

Example: Radial thickness variation

See the <install directory>\Resources\Samples\Coatings\ directory of your FRED installation for an example of a scripted coating (coatingRadiallyVaryingSingleLayer.frd) which creates a single layer ZnSe coating with radial thickness variation.

 

Script Evaluation

In FRED, coatings and materials store information about the last evaluation that was made.  For coatings, this would be the R and T components for a ray with a given wavelength, position, direction, etc.  For materials, this would be the real and imaginary indices for a ray with a given wavelength, position, direction, etc.  The advantage of storing this information is that if the current incoming ray has the same properties as the last ray, there is no need to re-evaluate the coating or material properties and the raytrace can proceed much quicker.

 

In the case of the scripted coating this implementation can potentially cause problems.  For example, suppose the rays incident on the scripted coating all have the same general properties (position, direction, wavelength).  The first ray will trigger a successful evaluation of the coating, but the subsequent rays, having the same properties as the first, would not trigger a new evaluation of the coating.  If the scripted coating contained any elements of randomness (via a random number generator, for example), only the first ray in the queue would reflect this random modification.  The rays following it would be modified in the same manner as the first ray.

 

When multi-threaded raytracing is used, rays on the same thread will exhibit the behavior described above.

 

At the start of a new raytrace, all coatings are flagged as requiring a new evaluation for the first ray that is encountered.

 

Document Modifications

It is strongly recommended that the script make no modifications to other nodes in the FRED document.

 

If a change is made to the document during the raytrace by way of the scripted entity, the state of the document as seen by each individual thread of the raytrace will be inconsistently defined and the results of the raytrace may not be valid.

 

 

Related Topics


Coatings - Overview

Coatings - General Sampled Coating

Coatings - Polarizer / Waveplate Coating

Coatings - Quarter Wave Single Layer

Coatings - Sampled Coating

Coatings - Thin Film Layered Coating

Coatings - Uncoated

Scripted Coating Test Dialog

Materials - Scripted Volume Scatter

Materials - Scripted Gradient Index Material

Scripted Scatter Model (surface) 

 

 

 

 

 

Copyright © Photon Engineering, LLC