xopto.mcbase.mcpf.rayleigh module

class Rayleigh(gamma)[source]

Bases: xopto.mcbase.mcpf.pfbase.PfBase

The Rayleigh scattering phase function is defined as:

\frac{3}{8}((1 + 3\gamma) + (1 - \gamma)*\cos^{2}(\theta))/(1 + 2\gamma)

[Anthony Bucholtz, Applied Optics, Vol. 34, No. 15 Rayleigh-scattering calculations for the terrestrial atmosphere]. The scattering angle cosine is sampled/computed by using the Cardans formula to solve x^3 + ax + b = 0, where:

a &= 3 (1 + 3\gamma)/(1 - \gamma)

b &= 4 (1 + 2\gamma)/(1 - \gamma)(1 - 2\xi)

Jeppe Revall Frisvad, Journal of the Optical Society of America A, Vol. 28, Issue 12, pp. 2436-2441 (2011), Importance sampling the Rayleigh phase function.

For a special case when \gamma = 1, i.e. isotropic scattering, the scattering angle cosine becomes 2\xi - 1, where \xi is a random number from [0, 1]. For gamma != 1 the solution (\cos(\theta)) is defined in terms of Cardano formula:

x = \cos(\theta) &= (-b/2 + (b^{2/4} + a^{3/27})^{1/2})^{1/3} +
                      (-b/2 - (b^{2/4} + a^{3/27})^{1/2})^{1/3}

Parameters

gamma (float) – Molecular anisotropy. Scattering is isotropic for gamma = 0.

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

OpenCL declarations of the scattering phase function.

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

OpenCL implementation of the scattering phase function.

cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[xopto.cl.cltypes.Structure] = None)xopto.cl.cltypes.Structure[source]

Fills the OpenCL Structure (target) with the data required by the Monte Carlo simulator. See the cl_type() method for a detailed list of fields.

Parameters
Returns

target – Target structure received as an input argument or a new instance of ClRayleigh if the input argument target is None.

Return type

cltypes.Structure

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

Returns an OpenCL structure that can be passed to the Monte carlo simulator.

Parameters

mc (McObject) – A Monte Carlo simulator instance.

Returns

  • struct (cltypes.Structure) – A structure type that represents the scattering phase function in the Monte Carlo kernel.

  • Fields

  • ——

  • gamma (mc_fp_t) – Parameter of the Rayleigh scattering phase function,

  • a, b (mc_fp_t) – precalculated constants used to speed up the computation.

property gamma: float

Molecular anisotropy factor.

pf()xopto.pf.rayleigh.Rayleigh[source]

Returns a new instance of the related utility scattering phase function class that can be used to compute Legendre moments and other scattering phase function quantifiers.

Returns

pf – Instance of the related utility scattering phase function.

Return type

xopto.pf.Rayleigh

todict()dict[source]

Export object to a dict.