Overview
When setting up a speos simulation, it is extremely important to apply correct material description inputs in order to achieve a highfidelity simulation result. In many cases, the optical material library provided via the Ansys Customer Portal is able to give accurate and calibrated material files to be used in a speos simulation setup. However, there also are a lot of cases that requiring material files which are not included in the optical material library. Together with our partner, we can provide measurement service with given material samples provided by customers. In addition, a speos material file, e.g. a brdf file or a anisotropicbsdf file, can also be created based on customer’s measurement data input.
Based on the measurement device used, there are numbers of different measurement output formats, e.g. reflection only measurement / reflection with transmission measurement, or 3D measurement / 2D measurement, and etc. Within those different kinds of material file creations, the most challenge one is to create a 3D speos material file based on 2D measurement because of using extrapolation to create 3D data based on 2D information.
Two BRDF example files can be downloaded via the link: one nonencrypted BRDF showing the structure of BRDF file and one encrypted BRDF file.
In this article, the theories and calculation method used to convert a 2d measurement brdf data into a speos 3d BRDF file is explained with the workflow automation script provided via the GitHub Ansys OpticalAutomation Repository.
Run Example
In this section, user will be guided step by step to run an automation script which will convert a 2D BRDF measurement data into Speos 3D BRDF file. Please note, the automation script will require 2D measurement data in a specific format. User can modify measurement data into the same format or modify the automation script to read the input data correctly.
Step 1: Download/Clone GitHub repository
If you are not familiar with Git, you can also run the following commands via a CMD window inside a target folder. Using "pip install e." command will install all the required libraries defined inside the pyproject.toml automatically.
git clone https://github.com/ansys/opticalautomation.git cd opticalautomation precommit install pip install e .
Step 2: Check the input data structure of 2D measurements
An example of CSV is attached in the directory: "..\opticalautomation\tests\workflows\example_models\test_brdf_viewer_2D_data.csv". Users can modify the measurement data into the same format in order to utilise the script directly.
Step 3: Run “example_2d_brdf_measurement.py”
User can find the conversion script at the directory: "D:\Git\opticalautomation\ansys_optical_automation\application\example_2d_brdf_measurement.py". After running the script, user can check the generated BRDF file which is generated at same folder where csv is stored.
Step 4: Apply the interpolation enhancement
Open the converted BRDF file to use Interpolation Enhancement.
Click File, Interpolation enhancement.
Set the Parameters of Interpolation Enhancement.
Click OK and save the file with a different name.
2D Goniometer measurement
2D BRDF Goniometer is able to measure the BSDF response at a number of given incident rays at different receiving angles. This measurement is done under the assumption that the material is isotropic, i.e. rotating the measurement sample will not change the BSDF measurement results. Measurement is usually conducted with a number of fixed incident ray directions (Angle of incidence), a sensor is then placed at different receiving angles, i.e. , to measure the BSDF values at those positions. With a fixed incident ray direction, the wavelength of the ray can be changed to measure the different BSDF values at different wavelengths of an incident ray source.
As a result, in this example, one 2D BRDF goniometer measurement result table can be generated in a format like below: for each incident angle (i.e. vertical list) and each wavelength values (i.e. horizontal list), BRDF values are measured at each measurement angle.
Theory and Calculations
As mentioned in the 2D Goniometer measurement section, 2D measurement is done under the assumption that the material is isotropic, i.e. rotating the measurement sample will not change the BSDF measurement results. Thus, in this knowledge base, rotational symmetry theory is used to calculate the 3D data (BRDF data at any theta and phi angles) based on the 2D measurement data (BRDF data at different theta/incident angles and phi angles at 0 and 180 degrees).
Rotational symmetric: BRDF does not change when surface is rotated about the normal axis. In the following section, the calculation method calculating 3D BRDF value from 2D data using Rotational symmetric theory is introduced.
In the image below, the known data/measurement data is located at the horizontal axis (i.e. phi angles at 0 and 180 degrees). The objective is to calculate all the other data above and below the horizontal axis. For example, at a random position, the BRDF value at the orange point ( \(\theta\) , \(\phi\) ) is to be calculated. The grey and purple points are symmetric rotation intersection for the orange point with horizontal axis when the incident angle at \(\theta_{spec}\). The x and y coordinate for the orange point can be calculated as \(\theta\)*sin(\(\phi\)) and \(\theta\)*cos(\(\phi\)).
Thus, the values at such orange point can be calculated as interpolation values between the grey and purple points: if the orange point is more close to the grey point, its value should be closer to the value at grey. While, it is more close to the purple point, its value should be closer to the that of the purple point. Such weight description can be described using the following below:
$$d=\sqrt{\left(\left(\theta_{spec}\theta*cos\varphi\right)^2+\left(\theta*sin\varphi\right)^2\right)}$$
$$w_1=\frac{\theta_{spec}+d\ \theta\ast\cos{\varphi}}{2d}$$
The weight function equals 1 at the grey point location and 0 at the purple location.
As a result, the BRDF value at the orange point can be calculated using the following method:
$$BRDF=w_1\ast\ GreyData+(1w_1\ )\ast\ PurpleData$$
Which can be further described using the data set at the corresponding incident angle:
$$BRDF=w_1\ast{Data}_{\theta_{inc}d}+\left(1w_1\right)\ast{Data}_{\theta_{inc}+d}$$
Data Fitting with 1D Data.
As the measurement data is discretized with different sampling methods used by different measurement device, it is necessary to get a full continuous data to be used in the rotation symmetric calculation later. In this solution, a liner interpolation method is used provided the scientific calculation package SciPy. It assumes the data between two value points varies linearly. Such method is valid when measurement has a big sampling value at the diffuse area. User can choose to apply a more advanced interpolation method when less measurement values are available and linear interpolation gives poor description with fewer sampling points.
SciPy method used for 1d interpolation: scipy.interpolate.interp1d
interpolate.interp1d(theta_brdf[0], theta_brdf[1], fill_value="extrapolate"), np.max(theta_brdf[0])
which convert the 2d discrete measurement data into a function which can output value at any point along the 2d measurement positions.
With such 1d interpolation method, we can calculate any point at 3d position based on the rotational symmetric theory mentioned above.
SciPy method used for 2d interpolation: interpolate.RectBivariateSpline
interpolate.RectBivariateSpline(phi_rad, theta_rad, integrande, kx=1, ky=1)
Which can output value at any point of the 3D position. This function is then used in integration to find the total reflectance value.
SciPy method used for integration: scipy.integrate.nquad
nquad(f, [[0, math.pi / 2], [0, 2 * math.pi]], opts=[{"epsabs": 0.1}, {"epsabs": 0.1}])
Important Settings
Interpolation Enhancement
In the measurement data, the material BRDF is measured at different incident angles. As a result, the raw converted Speos BRDF file only contains the BRDF data at those measured incident angle. However, in reality, the measure BRDF is continuous which means the BRDF data should contains information at any different incident angles. In addition, during ray propagation simulation, the BRDF data file applied as optical surface property to a given surface contains data that allows Speos to know how a ray arriving with one of the incidence angles at the surface is reflected and diffused. Thus, to manage a ray arriving at intermediate incidence angle, SPEOS requires the BSDF data to be interpolated. As a result, interpolation and extrapolation is required to get the BRDF data which are not measured. Interpolation Enhancement function in the BRDF viewer is designed to full fill this task.
The following example illustrates the BSDF interpolation between 10° and 20° incidence angles. You can see here two specular peaks at 10° and 20° instead of one peak at 15°. After interpolating, the BSDF data for incidence angle 15° appears and is properly oriented. Note, most of the diffuse part stays in place contrary to the specular peak that rotates according to the incidence angle.
Left as BRDF result at 15degree incident without interpolation enhancement. Right as BRDF result at 15degree incident angle with interpolation enhancement.
When applying interpolation enhancement, A white wireframe cone is used to distinguish the specular part (shown inside the cone) from the diffuse part (shown outside the cone). Such operation also helps Speos to distinguish specular and diffuse components. Specular and diffuse components are managed with different algorithms to speed up simulations.
Image shows the cone used to sperate the diffuse and specular part of the BRDF.
As a result, setting up the cone with the correct size is very important. In Cone properties box, you must use Angle and Height of cone sliders to adapt the BSDF. Number of cones depend on whether there is transmission or not, number of incidence angles and number of wavelength or anisotropic angles.
Examples
View Control: Full view Cone properties: Angle: 25°; Height: 47 The height of the cone seems to be correct. It cuts the BSDF at the base of the specular peak. The angle of the cone is too wide compared to the width of the specular peak. This may reduce the calculation speed. 

View Control: Full view Cone properties: Angle: 6°; Height: 47
With an angle reduced download to about 6°. 

View Control: Specular part Cone properties: Angle: 6°; Height: 47  
View Control: Diffuse part Cone properties: Angle: 6°; Height: 47


Examples of Problem 

When the height is too small, you can see a crater in the diffuse part. You must increase the height until the crater disappears. 

When the height is too big, you can see a bump on the diffuse part. You must decrease the height until the bump disappears. 

When the angle is too small in the Full view, the cone totally disappears in the BSDF shape. You must increase the angle to make it only slightly larger than the specular peak. 

It happens the angle is too large. The surface of the base of the cone is large compared to its intersection with the specular peak. This situation does not provide bad results, but you must reduce angle to have faster performances. 

Software performs faster if the base of the cone is only slightly larger than the specular peak. 