Graded Material File

This page describes the basic steps to create a graded material file through the example of a gradient refractive index material, and provides the python script to dot it.

Graded material file relies on filling a data model describing the spectral variation of refractive index and/or absorption.

Download the speos_GradedIndexMaterial.zip containing the following python scripts:
  • speos_GradedIndexMaterial.py
  • speos_GradientRefractiveIndexTable.py
  • GradientRefractiveIndexMaterial_example.py

Library Script Files

GradedIndexMaterial

Speos provides you with a python script file speos_GradedIndexMaterial.py library which includes the GradedIndexMaterial generic class to:

  • access the content of an existing material (openFile, parseFile)
  • create the data model and save a new file (createDataModel, SaveFile)
  • GradientIndexMaterial class is an example that fills the data model with a gradient index refractive index variation.

GradientRefractiveIndexTable

Speos provides you with a python script file speos_GradientRefractiveIndexTable.py library which includes the GradientRefractiveIndexTable class to:

  • generate the table with the gradient refractive index variation (GetGradiantRefractiveIndexTable)
  • get the refractive indexes with their position (GetRefractiveIndex)

General Workflow

To create a graded material file:

  1. You need the refractive index variation and/or the absorption variation that directly comes from Fluent. To be processed, the variation must be set as a list.
  2. Once you have your list of refractive index and/or absorption, create the python script to generate the graded material thanks to the GradedIndexMaterial class and the GradientIndexMaterial class if you want a gradient material.
Note: When defining the sampling of refractive index or absorption, the value must be strictly greater than 1.

Graded Material File Example

Speos provides you with a python script sample file GradientRefractiveIndexMaterial_example.py. In this example, the graded material is created with the following characteristics:

  • 3 wavelengths:468, 532 and 643nm
  • Refractive index and absorption do not vary spectrally
  • Refractive index follows a gradient refractive index distribution
  • Absorption is null

This example covers a specific type of graded material file: gradient material.

Gradient material is a graded material whose variation is constant. Thus, the script uses the GradientIndexMaterial class and the GradientRefractiveIndexTable class to generate the graded material file.

Workflow Example

  1. Define the dimensions of the material and the sampling.

    # Dimensions
    xSize = 1 # size along X direction in mm
    ySize = 1 # size along Y direction in mm
    zSize = 10 # size along Z direction in mm
    xSampling = int(xSize / 0.1)
    ySampling = int(ySize / 0.1) 
    zSampling = int(zSize / 0.1)
  2. Create the absorption table.

    • A list is used in python and corresponds to a "first level" list describing the absorption variation along Z.
    • Each sample along Z contains a "second level" list describing the absorption variation along Y.
    • Each sample along Y contains a "third level" list describing the absorption variation along X.

    In the example, since the absorption is null, the minimum number of samples (2) to define the table is used.

    absorptionTable = [[[0.0, 0.0], [0.0, 0.0]], [[0.0, 0.0], [0.0, 0.0]]]
  3. For a gradient material, to create the refractive index table, use the dedicated GradientRefractiveIndexTable class from speos_GradientRefractiveIndexTable.py.

    Note: The GradientRefractiveIndexTable class permits you to create a TableMulti_double_3 table.
    • As you can see in the GetGradientRefractiveIndexTable function, the table must be sized:

      dimensions = IllumineCore.Extent_uint_3()
      dimensions.Set(0, nb_x)  # sampling value along X direction
      dimensions.Set(1, nb_y)  # sampling value along Y direction
      dimensions.Set(2, nb_z)  # sampling value along Z direction
      
      tableMulti3.Allocate(dimensions)  # allocate memory
    • Then, you loop to populate the table:

      • along Z
      • for each Z, you loop along Y
      • for each Y, you loop along X
      # create position extent
      pos.Set(0, ix)
      pos.Set(1, iy)
      pos.Set(2, iz)
      tableMulti3.Set(pos, self.GetRefractiveIndex(xPosition, yPosition))
  4. Since the refractive index and absorption do not vary with the wavelengths, duplicate the different tables:

    spectrumTable = [468.0, 532.0, 643.0]
    spectralRefractiveIndexTable = [refractiveIndexTable, refractiveIndexTable, refractiveIndexTable]
    spectralAbsorptionTable = [absorptionTable[:], absorptionTable[:], absorptionTable[:]]
  5. Use GradedIndexMaterial class to create the data model and save the new file:

    materialTest = speos_GradedIndexMaterial.GradedIndexMaterial()
    materialTest.createDataModel(refractiveIndexDimensions, absorptionDimensions, spectrumTable, spectralRefractiveIndexTable, spectralAbsorptionTable)
    materialTest.saveFile(filepath)