API Reference
This page documents the Python API for GOAD.
Simulation Classes
These are the main classes for running light scattering simulations.
Problem
Single-orientation scattering simulation.
Problem
MultiProblem
Multi-orientation averaging simulation.
MultiProblem
Multi-orientation light scattering simulation for a single geometry.
Computes orientation-averaged scattering properties by running multiple single-orientation simulations and averaging the results. Supports both random and systematic orientation sampling schemes. Results include Mueller matrices, cross-sections, and derived optical parameters.
Examples
import goad_py as goad
# Create orientation scheme and settings
orientations = goad.create_uniform_orientation(100)
settings = goad.Settings("particle.obj", orientation=orientations)
# Run multi-orientation simulation
mp = goad.MultiProblem(settings)
mp.py_solve()
# Access averaged results
results = mp.results
print(f"Scattering cross-section: {results.scat_cross}")
num_orientations
property
num_orientations: int
Get the number of orientations
results
property
results: Results
Access the orientation-averaged simulation results.
Returns the complete Results object containing Mueller matrices, amplitude matrices, power distributions, and derived parameters averaged over all orientations.
Returns
Results - Complete scattering simulation results
save
method descriptor
save(directory: Optional[str] = None) -> None
Save simulation results to disk.
Writes Mueller matrices, parameters, and other output files to the specified directory (or the directory configured in settings).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Optional[str]
|
Optional output directory path. If not provided, uses the directory from settings. |
None
|
solve
method descriptor
solve() -> None
Solve the multi-orientation scattering problem.
Computes scattering properties averaged over all orientations using parallel processing. The Global Interpreter Lock (GIL) is released during computation to allow concurrent Python operations.
Returns
PyResult<()> - Success or error if computation fails
Convergence
Adaptive convergence-based simulation.
Convergence
count
property
count: int
Get the max orientations (safety cap).
max_orientations
property
max_orientations: int
add_target
method descriptor
add_target(param: Param, relative_error: float) -> None
Add a convergence target for a parameter (Python API). Solver terminates when ALL targets are satisfied.
clear_targets
method descriptor
clear_targets() -> None
Clear all convergence targets (Python API).
save
method descriptor
save(directory: Optional[str] = None) -> None
Save simulation results to disk.
Writes Mueller matrices, parameters, and other output files to the specified directory (or the directory configured in settings).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Optional[str]
|
Optional output directory path. If not provided, uses the directory from settings. |
None
|
solve
method descriptor
solve() -> None
Solve the multi-orientation scattering problem using work-stealing. Periodically checks for Python signals (Ctrl-C) and interrupts if needed.
Configuration
Classes for configuring simulations.
Settings
Main configuration object for simulations.
Settings
Runtime configuration for the application.
beam_power_threshold
property
beam_power_threshold: float
Set the beam power threshold
cutoff
property
cutoff: float
Set the cutoff
distortion
property
distortion: Optional[float]
Set the distortion factor
eulers
property
eulers: list[float]
Set the euler angles
fov_factor
property
fov_factor: Optional[float]
Set the field of view factor
geom_scale
property
geom_scale: Optional[list[float]]
Set the per-axis geometry scaling [x, y, z]
max_rec
property
max_rec: int
Set the max recursion depth
max_tir
property
max_tir: int
Set the max TIR bounces
medium_refr_index_im
property
medium_refr_index_im: float
Set the medium refractive index (imaginary part)
medium_refr_index_re
property
medium_refr_index_re: float
Set the medium refractive index (real part)
quiet
property
quiet: bool
Set quiet mode (suppress progress bars)
seed
property
seed: Optional[int]
Set the seed for random number generation
wavelength
property
wavelength: float
Set the wavelength
Orientation
Particle orientation configuration.
Orientation
Euler
Euler angle representation.
Euler
alpha
property
alpha: float
beta
property
beta: float
gamma
property
gamma: float
BinningScheme
Angular binning configuration.
BinningScheme
Angular binning scheme for scattering calculations.
Defines how to discretize the scattering sphere into angular bins for Mueller matrix and amplitude computations. Supports simple regular grids, custom intervals, and arbitrary bin arrangements.
bins
method descriptor
bins() -> NDArray[float32]
Returns all 2D bins as a numpy array of shape (n_bins, 2) with columns [theta, phi]
bins_1d
method descriptor
bins_1d() -> NDArray[float32]
Returns unique 1D theta bins as a numpy array
custom
staticmethod
custom(bins: Sequence[Sequence[Sequence[float]]]) -> BinningScheme
Create a custom binning scheme with explicit bin edges Each bin is specified as [[theta_min, theta_max], [phi_min, phi_max]]
interval
staticmethod
interval(thetas: Sequence[float], theta_spacings: Sequence[float], phis: Sequence[float], phi_spacings: Sequence[float]) -> BinningScheme
Create an interval binning scheme with variable spacing
num_bins
method descriptor
num_bins() -> int
Returns the number of bins
phis
method descriptor
phis() -> list[float]
Returns a list of all phi bin centre values
simple
staticmethod
simple(num_theta: int, num_phi: int) -> BinningScheme
Create a simple binning scheme with uniform theta and phi spacing
thetas
method descriptor
thetas() -> list[float]
Returns a list of all theta bin centre values
ZoneConfig
Zone configuration for multi-zone simulations.
ZoneConfig
Configuration for a zone, as specified in TOML or via CLI.
label
property
label: Optional[str]
Get the zone label
Results
Classes for accessing simulation results.
Results
Complete simulation results container.
Results
Complete results from a GOAD light scattering simulation.
Contains all computed scattering data including Mueller matrices, amplitude matrices, power distributions, and derived parameters. Supports both 2D angular distributions and 1D integrated results.
albedo
property
albedo
Get the albedo
asymmetry
property
asymmetry
Get the asymmetry parameter
backward_zone
property
backward_zone
Get the backward zone (convenience method)
bins
property
bins
Get the bins as a numpy array of shape (n_bins, 2) with columns [theta, phi]
bins_1d
property
bins_1d
Get the 1D bins (theta values) as a numpy array
ext_cross
property
ext_cross
Get the extinction cross section
forward_zone
property
forward_zone
Get the forward zone (convenience method)
full_zone
property
full_zone
Get the full zone (convenience method)
mueller
property
mueller
Get the Mueller matrix as a numpy array
mueller_1d
property
mueller_1d
Get the 1D Mueller matrix as a numpy array
mueller_1d_beam
property
mueller_1d_beam
Get the 1D beam Mueller matrix as a numpy array
mueller_1d_ext
property
mueller_1d_ext
Get the 1D external diffraction Mueller matrix as a numpy array
mueller_beam
property
mueller_beam
Get the beam Mueller matrix as a numpy array
mueller_ext
property
mueller_ext
Get the external diffraction Mueller matrix as a numpy array
powers
property
powers
Get the powers as a dictionary
scat_cross
property
scat_cross
Get the scattering cross section
zones
property
zones
Get the zones collection
Zone
A single angular zone with its results.
Zone
A zone represents a region of the scattering sphere with its own binning, results, and computed parameters.
bins
property
bins: NDArray[float32]
Get the bins as a numpy array of shape (n_bins, 2) with columns [theta, phi]
bins_1d
property
bins_1d: Optional[NDArray[float32]]
Get the 1D theta bins as a numpy array (if available)
label
property
label: Optional[str]
Get the zone label
mueller
property
mueller: NDArray[float32]
Get the Mueller matrix as a numpy array of shape (n_bins, 16)
mueller_1d
property
mueller_1d: Optional[NDArray[float32]]
Get the 1D Mueller matrix as a numpy array (if available)
name
property
name: str
Get the display name for this zone
num_bins
property
num_bins: int
Get the number of bins in this zone
params
property
params: Any
Get zone-specific parameters as a dict
Zones
Collection of zones.
Zones
A collection of zones for a simulation.
Geometry
Classes for defining particle geometry.
Geom
Complete particle geometry (collection of shapes).
Geom
first_shape_vertices
property
first_shape_vertices: list[tuple[float, float, float]]
Getter for the vertices of the first shape
num_shapes
property
num_shapes: int
Number of shapes in the geometry.
shapes
property
shapes: list[Shape]
All shapes (cloned). Mutating an element of this list does NOT update
the parent Geom — use set_refr_index(idx, n) for that.
children_of
method descriptor
children_of(parent_id: int) -> list[int]
Shape indices directly contained by parent_id.
containment_tree
method descriptor
containment_tree(medium: Optional[complex] = None) -> str
Render the containment graph as an indented tree. medium defaults to
vacuum (1+0j).
from_file
staticmethod
from_file(filename: str, refr_indices: Sequence[complex]) -> list[Geom]
Load geometry from an OBJ file (or a directory of OBJ files), assigning
each shape a refractive index from refr_indices.
refr_indices must either have one entry per shape in the loaded
geometry, or a single entry that is broadcast to every shape.
parent_of
method descriptor
parent_of(shape_id: int) -> Optional[int]
Parent shape index for shape_id in the containment graph, if any.
refr_index
method descriptor
refr_index(idx: int) -> complex
Refractive index of shape idx as a Python complex.
roots
method descriptor
roots() -> list[int]
Shape indices with no parent.
set_refr_index
method descriptor
set_refr_index(idx: int, value: complex) -> None
Set the refractive index of shape idx from a Python complex.
Shape
A single 3D surface mesh.
Shape
Represents a 3D surface mesh.
id
property
id: Optional[int]
Shape id, if assigned.
refr_index
property
refr_index: complex
Refractive index of this shape as a Python complex number.
Enumerations
Param
Available scattering parameters for convergence targets.
Param
__eq__
method descriptor
__eq__(value)
Return self==value.
__ge__
method descriptor
__ge__(value)
Return self>=value.
__gt__
method descriptor
__gt__(value)
Return self>value.
__int__
method descriptor
__int__()
int(self)
__le__
method descriptor
__le__(value)
Return self<=value.
__lt__
method descriptor
__lt__(value)
Return self<value.
__ne__
method descriptor
__ne__(value)
Return self!=value.
__repr__
method descriptor
__repr__()
Return repr(self).
ZoneType
Types of angular zones.
ZoneType
The type of zone, which determines what parameters can be computed.
Backward
class-attribute
Backward = ZoneType.Backward
The type of zone, which determines what parameters can be computed.
Custom
class-attribute
Custom = ZoneType.Custom
The type of zone, which determines what parameters can be computed.
Forward
class-attribute
Forward = ZoneType.Forward
The type of zone, which determines what parameters can be computed.
Full
class-attribute
Full = ZoneType.Full
The type of zone, which determines what parameters can be computed.
__eq__
method descriptor
__eq__(value)
Return self==value.
__ge__
method descriptor
__ge__(value)
Return self>=value.
__gt__
method descriptor
__gt__(value)
Return self>value.
__int__
method descriptor
__int__()
int(self)
__le__
method descriptor
__le__(value)
Return self<=value.
__lt__
method descriptor
__lt__(value)
Return self<value.
__ne__
method descriptor
__ne__(value)
Return self!=value.
__repr__
method descriptor
__repr__()
Return repr(self).
Mapping
Near-to-far field mapping methods.
Mapping
Enum representing different mapping methods from near to far field.
ApertureDiffraction
class-attribute
ApertureDiffraction = Mapping.ApertureDiffraction
Enum representing different mapping methods from near to far field.
GeometricOptics
class-attribute
GeometricOptics = Mapping.GeometricOptics
Enum representing different mapping methods from near to far field.
__int__
method descriptor
__int__()
int(self)
__new__
builtin
__new__(*args, **kwargs)
Create and return a new object. See help(type) for accurate signature.
__repr__
method descriptor
__repr__()
Return repr(self).
EulerConvention
Euler angle conventions.
EulerConvention
Euler angle order for the discrete orientation scheme.
XYX
class-attribute
XYX = EulerConvention.XYX
Euler angle order for the discrete orientation scheme.
XYZ
class-attribute
XYZ = EulerConvention.XYZ
Euler angle order for the discrete orientation scheme.
XZX
class-attribute
XZX = EulerConvention.XZX
Euler angle order for the discrete orientation scheme.
XZY
class-attribute
XZY = EulerConvention.XZY
Euler angle order for the discrete orientation scheme.
YXY
class-attribute
YXY = EulerConvention.YXY
Euler angle order for the discrete orientation scheme.
YXZ
class-attribute
YXZ = EulerConvention.YXZ
Euler angle order for the discrete orientation scheme.
YZX
class-attribute
YZX = EulerConvention.YZX
Euler angle order for the discrete orientation scheme.
YZY
class-attribute
YZY = EulerConvention.YZY
Euler angle order for the discrete orientation scheme.
ZXY
class-attribute
ZXY = EulerConvention.ZXY
Euler angle order for the discrete orientation scheme.
ZXZ
class-attribute
ZXZ = EulerConvention.ZXZ
Euler angle order for the discrete orientation scheme.
ZYX
class-attribute
ZYX = EulerConvention.ZYX
Euler angle order for the discrete orientation scheme.
ZYZ
class-attribute
ZYZ = EulerConvention.ZYZ
Euler angle order for the discrete orientation scheme.
__int__
method descriptor
__int__()
int(self)
__new__
builtin
__new__(*args, **kwargs)
Create and return a new object. See help(type) for accurate signature.
__repr__
method descriptor
__repr__()
Return repr(self).
Scheme
Orientation sampling schemes.
Scheme
Discrete
class-attribute
instance-attribute
Discrete = ...
Solve the problem by averaging over a discrete set of angles (in degrees).
Example: discrete 0,0,0 20,30,40
Halton
class-attribute
instance-attribute
Halton = ...
Solve the problem using Halton quasi-random sequence for faster convergence.
Example: halton 100
Sobol
class-attribute
instance-attribute
Sobol = ...
Solve the problem using Sobol quasi-random sequence for faster convergence.
Example: sobol 100
Uniform
class-attribute
instance-attribute
Uniform = ...
Solve the problem by averaging over a uniform distribution of angles.
Example: uniform 100
Helper Functions
create_uniform_orientation
create_uniform_orientation
builtin
create_uniform_orientation(num_orients: int, euler_convention: Optional[EulerConvention] = None) -> Orientation
Create an Orientation with uniform scheme and default convention
create_discrete_orientation
create_discrete_orientation
builtin
create_discrete_orientation(eulers: Sequence[Euler], euler_convention: Optional[EulerConvention] = None) -> Orientation
Create an Orientation with discrete scheme and default convention