xopto.mcbase.mcmaterial module

class Material(n: float, mua: float, mus: float, pf: xopto.mcbase.mcpf.pfbase.PfBase)[source]

Bases: xopto.mcbase.mcobject.McObject

Class that represents a single material.

Material object constructor.

Parameters
  • n (float) – Index of refraction.

  • mua (float) – Absorption coefficient (1/m).

  • mus (float) – Scattering (NOT reduced) coefficient (1/m).

  • pf (mcpf.PfBase) – Phase function object.

The physical properties of the material can be read or changed through the member properties:

  • n: float - Index of refraction.

  • mua: float - Absorption coefficient (1/m).

  • mus: float - Scattering (NOT reduced) coefficient (1/m).

  • pf: mcpf.PfBase - Scattering phase function object that is derived from PhBase class.

cl_declaration(mc: xopto.mcbase.mcobject.McObject)str[source]

Structure that defines material in the Monte Carlo simulator and the related API calls. This is a minimal implementation. All the field are required!

cl_implementation(mc: xopto.mcbase.mcobject.McObject)str[source]

OpenCL implementation of the Material type.

cl_options(mc: xopto.mcbase.mcobject.McObject)str[source]

OpenCL options of the Material type.

cl_type(mc: xopto.mcbase.mcobject.McObject)xopto.cl.cltypes.Structure[source]

Returns a structure data type that is used to represent one material instance in the OpenCL kernel of the Monte Carlo simulator.

Parameters

mc (mcobject.McObject) – Monte Carlo simulator instance.

Returns

opencl_t – OpenCL Structure that represents a material.

Return type

ClMaterial

classmethod fromdict(data: dict)xopto.mcbase.mcmaterial.Material[source]

Create a new object from dict. The dict keys must match the parameter names defined by the constructor.

property mua: float

Absorption coefficient (1/m).

property mus: float

Scattering coefficient (1/m).

property n: float

Refractive index.

property pf: xopto.mcbase.mcpf.pfbase.PfBase

Phase function object.

todict()dict[source]

Export object to a dict.

class Materials(materials: List[xopto.mcbase.mcmaterial.Material])[source]

Bases: xopto.mcbase.mcobject.McObject

Class that represents all materials used in the simulator core.

Note

The first material of the stack describes the medium that surrounds the sample. Therefore, at least one material must be always specified.

Constructs a managed list of sample materials.

Note

The first material in the list represents the medium that surrounds the sample.

Note that all materials must use the same scattering phase function model.

Parameters

materials (List[Material] or Materials) – A list of sample materials. At least 1 material is required!

check()[source]

Check if the materials are consistent and using the same scattering phase function model. Raises exception on error.

cl_declaration(mc: xopto.mcbase.mcobject.McObject)str[source]

OpenCL declarations of the scattering phase function.

cl_implementation(mc: xopto.mcbase.mcobject.McObject)str[source]

OpenCL implementation of the scattering phase function.

cl_options(mc: xopto.mcbase.mcobject.McObject)str[source]

OpenCL options of the scattering phase function.

cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[_ctypes.Array] = None)_ctypes.Array[source]

Pack the materials into an OpenCL data type. The OpenCL data type is returned by the Materials.cl_type() method.

Parameters
  • mc (mcobject.McObject) – Monte Carlo simulator instance.

  • target (cltypes.Structure*len(self)) – A structure representing an array of Materials.

Returns

materials – Filled array of ctypes structures received as an input argument or a new instance if the input argument target is None.

Return type

cltypes.Array

cl_type(mc: xopto.mcbase.mcobject.McObject)_ctypes.Array[source]

Returns an OpenCL array of ClMaterial structures that is used to represent one instance of a material stack.

Parameters

mc (mcobject.McObject) – Monte Carlo simulator instance.

Returns

clarray – Array of ClMaterial.

Return type

cltypes.Structure*len(self)

classmethod fromdict(data: dict)xopto.mcbase.mcmaterial.Materials[source]

Create a new instance of Materials from a dict.

Parameters

data (dict) – A dict with instance data.

Returns

instance – A new instance of Materials.

Return type

Materials

material(index: int)xopto.mcbase.mcmaterial.Material[source]

Returns the material at the specified index. Note that the first material (index 0) represents the medium that surrounds the sample.

property material_type

Data type that represents a material.

todict()dict[source]

Export object to a dict.

tolist()List[xopto.mcbase.mcmaterial.Material][source]

Return the list of materials.

Returns

materials – List of materials.

Return type

List[Material]