Material

Each voxel of the volume can be assigned a different material. Materials are defined as instances of xopto.mcbase.mcmaterial.Material. The constructor takes several parameters that define the optical properties of the material.

  1. The refractive index is defined by parameter n.

  2. The scattering coefficient is defined by parameter mus (m -1).

  3. The absorption coefficient is defined by parameter mua (m -1).

  4. The scattering phase function is defined by parameter pf that can be any instance of xopto.mcbase.mcpf.pfbase.PfBase.

The following example creates a material with a refractive index 1.33, absorption coefficient 1 cm -1 , scattering coefficient 50 cm -1 and Henyey-Greenstein scattering phase function with anisotropy 0.9.

from xopto.mcvox import mc

material = mc.mcmaterial.Material(n=1.33, mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.9))

All the optical properties of a material that were set through the constructor Material() can be later changed through accessing the instance properties. In case of the scattering phase function, first access the pf material property and from there any of the properties implemented by the scattering phase function model. Note that the Henyey-Greenstein scattering phase function from this example exposes only the anisotropy g.

material.mua = 0.5e2
material.mus = 40.0e2
material.n = 1.452
material.pf.g = 0.9

The individual materials are then combined into a list through Materials(). The constructor takes a list of Material. The created instance manages the transfer of data between the host and the OpenCL device.

materials = mc.mcmaterial.Materials(
    [
        mc.mcmaterial.Material(n=1.0, mua=0.0e2, mus=0.0e2,  pf=mc.mcpf.Hg(0.0)),
        mc.mcmaterial.Material(n=1.3, mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.9)),
        mc.mcmaterial.Material(n=1.2, mua=2.0e2, mus=10.0e2, pf=mc.mcpf.Hg(0.5))
    ]
)

Note that the first material in the list represent the surrounding medium. The absorption coefficient mua, scattering coefficient mus and the scattering phase function pf of the first material are not used in the MC simulations, since the photon packets are not propagated through the surrounding medium. However, the refractive index n of the surrounding medium is used to properly refract/reflect the photon packet at the sample surface when launched by the source or when escaping the sample.

Voxels of the samples can be labeled by a particular material through the corresponding index of the material in the list. A label 0 will set the voxel material to the same material as is used for the surrounding medium.

The properties of materials in the list can be modified at any time through accessing the individual materials and from there the material properties. The number of materials (including the material of the surrounding medium) can be determined through the builtin len(). The individual materials can be accessed using the [] operator or material() method.

materials[1].mua = 0.5e2
materials.material(1).mua = 0.5e2

num_materials = len(materials)

The Material and Materials produce an informative human-readable output when used with the print() builtin.

Applying print() to a material (instance of Material) will produce the following output:

print(materials[1])
Material(n=1.3, mua=100.0, mus=5000.0, pf=Hg(g=0.9)) # id 0x7F15B4CEF820.

Applying print() to a list of materials (instance of Materials) will produce the following output:

print(materials)
Materials([
    Material(n=1.0, mua=0.0, mus=0.0, pf=Hg(g=0.0)), # surrounding medium,
    Material(n=1.3, mua=100.0, mus=5000.0, pf=Hg(g=0.9)),
    Material(n=1.2, mua=200.0, mus=1000.0, pf=Hg(g=0.5))
]) # id 0x7F15B4CEFD30.