The layer stack¶
The sample and the surrounding medium are described by a stack of concentric layers. The layers are stacked from the outermost to the innermost layer. The first (outermost) layer in the stack is used to describe the medium that surrounds the sample surface and the remaining layers are used to describe the sample. The outer diameter of the outermost layer is always set to infinity regardless of the value set by the user.
Note
The outer diameters of the layers in the stack must be strictly monotonically decreasing.
The classes that allow definition of individual layers and forming of
layer stacks can be found in the xopto.mccyl.mclayer.layer
module.
The module is for convenience also imported into the main simulator module
xopto.mccyl.mc
.
A layer is an instance of xopto.mccyl.mclayer.layer.Layer
. The
constructor takes several parameters that define the geometry and
optical properties of the layer material.
The outer diameter of the layer is defined by parameter
d
(m).The refractive index is defined by parameter
n
.The scattering coefficient is defined by parameter
mus
(m -1).The absorption coefficient is defined by parameter
mua
(m -1).The scattering phase function is defined by parameter
pf
that can be any instance ofxopto.mcbase.mcpf.pfbase.PfBase
.
The following example creates a layer with a refractive index 1.33, absorption coefficient 1 cm -1 , scattering coefficient 50 cm -1, outer diameter 10 mm and Henyey-Greenstein scattering phase function with anisotropy 0.9.
from xopto.mccyl import mc
layer = mc.mclayer.Layer(d=0.01, n=1.33, mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.9))
All the optical and geometrical properties of a layer that were set
through the constructor xopto.mccyl.mclayer.layer.Layer()
can be
later changed through accessing the instance properties. In case of
the scattering phase function, first access the
pf
layer 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
.
layer.mua = 0.5e2
layer.mus = 40.0e2
layer.d = 0.015
layer.n = 1.452
layer.pf.g = 0.9
The individual layers are then combined into a stack through the
Layers()
. The constructor takes a list
of Layer
. The created instance
manages the transfer of data between the host and the OpenCL device.
layers = mc.mclayer.Layers(
[
mc.mclayer.Layer(d=0.0, n=1.0, mua=0.0e2, mus=0.0e2, pf=mc.mcpf.Hg(0.0)),
mc.mclayer.Layer(d=0.01, n=1.3, mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.9)),
mc.mclayer.Layer(d=0.05, n=1.2, mua=5.0e2, mus=10.0e2, pf=mc.mcpf.Hg(0.5))
]
)
Note
The first layer in the stack represent the surrounding
medium. The absorption coefficient mua
, scattering coefficient
mus
and the scattering phase function pf
of the
outermost layer 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 outermost
layer is used to properly refract/reflect the photon packet at the sample
surface when launched by the source or when escaping the sample.
The properties of layers in the layer stack can be modified at any time
through accessing the individual layers and from there the layer
properties. The number of layers (including the outermost layer of the
surrounding medium) can be determined through the builtin len()
.
The individual layers can be accessed using the []
operator or
layer()
method.
layers[1].mua = 0.5e2
layers.layer(1).mua = 0.5e2
num_layers = len(layers)
The Layers
and
Layer
produce an informative
human-readable output when used with the print()
builtin.
Applying print()
to an individual layer (instances of
Layer
) will produce the following output:
print(layers[1])
Layer(d=0.1, n=1.3, mua=100.0, mus=5000.0, pf=Hg(g=0.9)) # id 0x7F15B4CEF820.
Applying print()
to a layer stack (instance of
Layers
) will produce the following output:
print(layers)
Layers([
Layer(d=0.0, n=1.0, mua=0.0, mus=0.0, pf=Hg(g=0.0)), # surrounding medium,
Layer(d=0.1, n=1.3, mua=100.0, mus=5000.0, pf=Hg(g=0.9)),
Layer(d=0.05, n=1.2, mua=500.0, mus=1000.0, pf=Hg(g=0.5))
]) # id 0x7F15B4CEFD30.