ScatteringSurfaceFile#

class ansys.speos.core.input_files.scattering_surface.ScatteringSurfaceFile(wavelengths=_DEFAULT_WAVELENGTHS, incident_angles=_DEFAULT_INCIDENT_ANGLES, samples=None, description=_DEFAULT_DESCRIPTION)#

Bases: ansys.speos.core.input_files._base.SpeosTextFileFormat

Speos *.scattering file, a scattering surface varying with angle and wavelength.

The file holds one ansys.speos.core.input_files.scattering_surface.ScatteringSurfaceSample per angle of incidence and per wavelength, stored in samples[incidence_index][wavelength_index].

Parameters:
wavelengthsSequence[float], optional

Wavelengths of the samples, in nm, sorted in increasing order. At least two wavelengths are required. By default, [400.0, 550.0, 700.0].

incident_anglesSequence[float], optional

Angles of incidence of the samples, in degrees, sorted in increasing order. 0 and 90 are required. By default, [0.0, 60.0, 90.0].

samplesList[List[ScatteringSurfaceSample]], optional

Contributions, one row per angle of incidence and one column per wavelength. By default, a 3 x 3 grid of independent default ansys.speos.core.input_files.scattering_surface.ScatteringSurfaceSample objects, which specularly reflect all the light.

descriptionstr, optional

Free text written on the second line of the file. By default, "Scattering surface".

Parameters:

Notes

Called without arguments, the constructor creates a 3 x 3 grid of perfect specular reflectors. Pass wavelengths, incident_angles and samples together to describe another grid, since each default only matches the other ones.

Empty lists allow staged construction, but ScatteringSurfaceFile.validate() and save() require a complete surface. Nonempty assignments are checked against the configured axes and grid. To resize a populated grid, clear ScatteringSurfaceFile.samples, assign the new axes, then assign the new grid. List getters return copies of the containers, while sample objects remain shared so their validated properties can be edited directly.

Examples

>>> from ansys.speos.core.input_files.scattering_surface import (
...     ScatteringSurfaceFile,
...     ScatteringSurfaceSample,
... )
>>> grey = ScatteringSurfaceSample(specular_reflection=0.0, lambertian_reflection=50.0)
>>> surface = ScatteringSurfaceFile(
...     wavelengths=[400.0, 700.0],
...     incident_angles=[0.0, 90.0],
...     samples=[[grey, grey], [grey, grey]],
... )
>>> surface.save("grey.scattering")

Overview#

validate

Check the surface against the constraints of the *.scattering format.

wavelengths

Wavelengths in nm, returned as a copy.

incident_angles

Angles of incidence in degrees, returned as a copy.

samples

Sample grid, returned with copied row containers.

description

Free text written on the second line of the file.

EXTENSION

Usual file extension of the format.

HEADER

First line of the file. Empty when the format has no header line.

HEADER_PREFIX

Version-agnostic start of HEADER, used to validate a file being read.

Import detail#

from ansys.speos.core.input_files.scattering_surface import ScatteringSurfaceFile

Property detail#

property ScatteringSurfaceFile.wavelengths: List[float]#

Wavelengths in nm, returned as a copy.

Parameters:
valuesSequence[float]

New wavelengths of the samples, in nm, sorted in increasing order. At least two wavelengths are required.

Returns:
List[float]

Sorted wavelengths. A nonempty assignment requires at least two finite values.

property ScatteringSurfaceFile.incident_angles: List[float]#

Angles of incidence in degrees, returned as a copy.

Parameters:
valuesSequence[float]

New angles of incidence of the samples, in degrees, sorted in increasing order. 0 and 90 are required.

Returns:
List[float]

Sorted angles. A nonempty assignment must include 0 and 90 degrees.

property ScatteringSurfaceFile.samples: List[List[ScatteringSurfaceSample]]#

Sample grid, returned with copied row containers.

Parameters:
valuesList[List[ScatteringSurfaceSample]]

New contributions, one row per angle of incidence and one column per wavelength.

Returns:
List[List[ScatteringSurfaceSample]]

One row per incidence and one column per wavelength. Sample objects remain shared and their properties can be updated through their validated setters.

Notes

Assign the grid back to this property to replace, add, or remove entries.

property ScatteringSurfaceFile.description: str#

Free text written on the second line of the file.

Parameters:
valuestr

New free text written on the second line of the file.

Returns:
str

Description without line separators.

Attribute detail#

ScatteringSurfaceFile.EXTENSION = '.scattering'#

Usual file extension of the format.

ScatteringSurfaceFile.HEADER = 'OPTIS - Scattering surface file v1.0'#

First line of the file. Empty when the format has no header line.

ScatteringSurfaceFile.HEADER_PREFIX = 'OPTIS - Scattering surface file'#

Version-agnostic start of HEADER, used to validate a file being read.

Method detail#

ScatteringSurfaceFile.validate()#

Check the surface against the constraints of the *.scattering format.

Raises:
ValueError

If fewer than two wavelengths are given, the angles of incidence do not span 0 to 90 degrees, the sample grid does not match the wavelengths and angles, or a sample holds invalid contributions.