This example presents a hybrid simulation methodology that integrates pySpeos, a physics-based optical simulation engine exposed as a Python library, with SimAI, a physics-agnostic machine-learning model trained on historical engineering and simulation data. The combined workflow enables rapid, automated generation of realistic lighting maps while significantly reducing the need for repeated, time-intensive optical simulations. This article outlines the end-to-end process, including setup of the Speos simulation environment, construction of the training dataset, automation of the data-generation workflow, and generate of new lighting predictions for previously unseen designs or boundary-condition inputs.
Note: Software Prerequisites
- Ansys Speos 2025R2 or higher
- Speos RPC 2025R2 or higher
- Python 3.10 or higher
- SimAI
- optiSLang 2025R2 or higher
Overview
Understand the simulation workflow and key results
Adapting to rapidly evolving design requirements and user feedback is crucial in industries where lighting performance, visual perception, and regulatory compliance must be evaluated early and often. Traditionally, developing and assessing optical designs rely heavily on physics-based ray-tracing simulations, a process that demands not only substantial computational resources but also the coordinated expertise of experienced optical design engineers and dedicated simulation specialists. As the model complexity increases, whether due to complex geometries or multiple physics impacts, simulation runtimes can escalate from hours to days. Such bottlenecks slow down prototyping and delay Request for Quotation (RFQ) responses and design evaluations.
Classic optical setups consisting of a target illumination region and illumination optical component(s) that incorporates optical structures, e.g. prism, reflector, lens etc. to generate a light distribution pattern on the illuminated area.
To address these challenges, a new data-driven approach using Ansys Optics, i.e. Speos & pySpeos and SimAI provides an alternative and powerful solution to traditional high-fidelity workflows. In particular, the integration of machine learning models trained on historical optical engineering or simulation data offers a new pathway to accelerate prediction tasks that would otherwise require repeated ray-tracing simulations.
Here are the steps we will follow to prepare training data using Speos and pySpeos, train the model in SimAI, an automated workflow to prepare the data in optiSLang, and predict a lighting map using trained model:
Step 1: Preparing the Optical Model (Speos)
Legacy optical simulation project is fully supported and often advantageous for enriching the training data pool, we will focus on step when there is no or not enough project for training the SimAI model. Speos is used in this step to prepare the optical system and lighting map results which will later trained and predicted in the new conditions.
Step 2: Generate the SimAI Training Dataset (pySpeos)
As SimAI requires training data in format of VTP, pySpeos is used here to compute the prepared simulation and export the simulation data results into VTP files. While SimAI requires multiple training dataset input in order to build its knowledge of understanding the relationship between "variable inputs" and "prediction target outputs". Thus, this step will be repeated multiple times in order to generate a number of training datasets. Generally speaking, the more dataset provided to SimAI, the trained model will be more advanced in regard to prediction.
While each dataset typically consists of: (1) geometric definitions, i.e., VTP meshes as data format required by SimAI, (2) simulation output values mapped to these VTP geometry meshes, and (3) optionally key boundary conditions and parameter settings that define the configuration of the optical system as JSON file. PySpeos produces lighting maps, luminance distributions, and photometric values as a dataset in VTP format from the Speos result files. It is optional to have JSON file if all the related information can be represented as geometrical data and value inside VTP.
In this example, we will focus on the having both VTP and JSON file in each dataset.
Step 3: Automatic Workflow for Dataset Generation (optiSLang)
If the optical system involves multiple CADs, optical parameters that requires complex workflow to sweep the parameter ranges. A automatic workflow in optiSLang can systematically generates combinations of these parameters based on advanced sampling strategies to prepare the data for SimAI.
Step 4: SimAI model Training and optimization (SimAI)
As SimAI is fully physics-agnostic, the platform requires no explicit encoding of optical governing equations; instead, it infers the underlying physical relationships directly from the input–output data pairs. After vtp files are uploaded to the training data pool, user can configure the training model by selecting the variable as inputs, target prediction variable and training duration. Inputs from geometric changes in VTP file and scalar changes in JSON file will be learnt.
SimAI operates as a cloud-based Software as a Service (SaaS) platform, eliminating the need for high-performance local hardware and enabling collaborative workflows, rapid deployment, and scalable compute resources. In addition, the platform offers a Python SDK (PySimAI), allowing users to script model creation, training, and inference for advanced or automated workflows
Step 5: Prediction with New CAD/Boundary Conditions (SimAI)
With the trained SimAI model, users can choose to provide the new geometry (VTP or STP file) or new scalar (JSON) to generate the target prediction result. Via providing new scalars or boundary conditions, SimAI ingests this JSON data, processes the scalar inputs, and generates new 2D/3D lighting predictions corresponding to the updated system state. For the case where relevant design parameters can be encoded within the geometry itself, SimAI can leverage these geometry-embedded parameters to generate accurate lighting predictions directly from updated CAD inputs.
Run and results
Instructions for running the model and discussion of key results
Step 1: Preparing the Optical Model
Open the Speos project provided in the article attachment. This example utilizes the work from Interior Lightguide Optimization .
The optical system in this project contains a prism based lightguide, a LED light source positioned at 1 end side of the lightguide. The prisms are defined using Speos Optical Part Design via driving the parameters of prism end angles. A radiance sensor is used to assess the light illumination from the lightguide towards the button of the illumination surface as shown below.
Illustration of the radiance sensor result
In this work, we will use scalar, i.e. lightguide OPD parameters, as inputs and the lighting map from the radiance sensor XMP result as target prediction.
Illustration of the prism lightguide design parameters
Step 2: Optical Simulation and Dataset Generation
Once the simulation is setup, click export the simulation as *.speos file and execute the script which will compute the simulation and export the result XMP file into VTP format.
As, we will use JSON containing all the required driving inputs, i.e. OPD lightguide parameters, and VTP containing the output targets, i.e. light map. There is no need to include other information like lightguide shape, etc. As a result, in this example, each dataset consists of: (1) VTP file as radiance sensor result values converted to a planner shaped VTP as shown below, and (2) JSON file containing key parameter settings, i.e. OPD lightguide prism parameters.
Users needs to generate a number of such VTP and JSON training datasets from using different lightguide prism design parameters.
Example of VTP file containing a planner shaped surface which has radiance sensor results.
Be aware that, required by SimAI, the exported VTP file for each dataset needs to be named as "surface.vtp" while the JSON file needs to be named as "boundary.json".
Step 3: Automated Data Generation
If legacy data is not available, and users are happy to generate new designs. an automatic data generation workflow can be integrated using optiSLang, a robust platform for design exploration, sensitivity analysis, and optimization.
Automated SimAI data generation - Ansys optiSLang workflow
In this workflow, optical system parameters, such as geometric dimensions, material properties, and light source characteristics are defined as variable design parameters within optiSLang. OptiSLang then systematically generates combinations of these parameters based on advanced sampling strategies, including Latin Hypercube Sampling, Monte Carlo methods, or adaptive design-of-experiment (DoE) techniques. Using python node inside, each generated parameter set is automatically exported to pySpeos for high-fidelity ray-tracing simulations with its outputs converted to VTP and JSON files.
The workflow showcased above contains the following nodes:
- Batch script (Batch node): Verify that the required pySpeos modules are available and install them if they are not.
@echo off
REM Set the path to optislang-python.cmd
SET OPTISLANG_PYTHON="C:\Program Files\ANSYS Inc\v261\optiSLang\optislang-python.cmd"
echo Installing ansys-speos-core...
%OPTISLANG_PYTHON% -m pip install ansys-speos-core -vvv- Script text input node: apply the scalar design variations, e.g. material type, that are not represented as geometrical variations, e.g. shape. In this example, this node is not required.
- CAD node: Connect with the CAD software to apply geometrical parameters and produce an updated CAD design output. In this example, optical component lightguide is created via Speos Optical Part Design, thus not required.
- Ansys Speos node: Automatically import and/or update the Speos model based on a new set(s) of parameter values or CAD files. In this example, the lightguide part is generated in this Ansys Speos node.
- Exporting_VTP_JSON (Python node): Execute pySpeos to get the desired simulation result into SimAI dataset format including VTP and JSON files inside the tmp folder of D drive.
- Ansys Speos output node (optional): Extracts predefined performance metrics from the simulation report file.
Such workflow is easy to modify based on the required process to generate an optical simulation, e.g. updating parameters in CAD software, updating the optical simulation, etc as illustrated above. But, in this example, the lightguide is designed using Speos Optical Part Design, thus CAD node in optiSLang is not required.
Open the optiSLang project provided in the attachment and review the workflow setup as below:
Automated SimAI data generation used in this examp le
The workflow showcased above contains the following nodes:
- Batch script (Batch node): Verify that the required pySpeos modules are available and install them if they are not.
- Ansys Speos node: update Speos optical part design using the new lightguide design parameters.
- Exporting_VTP_JSON (Python node): Execute pySpeos to get the radiance sensor result into VTP and lightguide parameters into JSON file into tmp folder under D drive.
- Ansys Speos output node (optional): Extracts predefined performance metrics from the simulation report file.
Run the sensitivity analysis to repeat the workflow to generate dataset inputs. In the optiSLang project provided, 10 designs are defined, user can choose to increase the value to get more training datasets.
Step 4: Model Training and Optimization
After uploading the training dataset to SimAI, the model needs to be configured to select the input, output, domain of analysis and build duration. In this example, the 5 scalar lightguide parameters are selected to be inputs while radiance photometric result is defined as output. Users then need to decide the build duration which can be debug mode (few hours), less precise (about 24 hours), precise (about 2 days), more precise (about 1 week).
Illustration of the SImAI model configuration setup
Within the SimAI Platform, the collected datasets undergo automated preprocessing and normalization before being utilized to train an AI model tailored to the targeted optical design space. Model development proceeds through a structured pipeline consisting of: (1) Feature Extraction, where geometric, parametric, and photometric characteristics are distilled into representative input features; (2) Model Backpropagations/Optimization, during which neural network parameters are updated iteratively via backpropagation to minimize prediction error; (3) Regularization and Validation, ensuring numerical stability, robustness, and strong generalization performance; and (4) Adaptive Learning, where learning rates and internal hyperparameters are dynamically adjusted to maintain convergence efficiency. This process yields a predictive model capable of accurately replicating the behavior observed in high-fidelity pySpeos simulations.
Schematic illustration of the SimAI model training process
Step 5: AI-Driven Prediction with New Boundary Conditions
Following the model training, by providing updated STL or VTP geometry files and/or a JSON file containing revised system parameters, users can rapidly obtain lighting predictions that closely approximate those produced by physics-based solvers such as pySpeos
- Prediction with New Boundary Conditions
Users can supply updated scalar values in a JSON file representing new boundary conditions/new designs without requiring any modifications to the input CAD geometry. In the following example, 5 key parameters used for designing the lightguide are used to train the SimAI model. Thanks to the trained model, the user does not need to create a new light component, re-mesh, and run the simulation, but instead SimAI is able to directly generate a light illumination pattern based on the parameters provided. This capability enables rapid analysis across a broader design space, avoiding re-meshing, reparametrizing, or rebuilding complex optical setups required by the physics-based simulations.
Illustration of SimAI model prediction based on boundary conditions.
Table. AI predicted (Left) and physics-based simulation results (Right)
|
Optical Design 1 light map with average photometric value as 3.87 |
Optical Design 1 light map with average photometric value as 3.84 |
|
Optical Design 2 light map with average photometric value as 3.21 |
Optical Design 2 light map with average photometric value as 3.22 |
- Prediction with New Boundary Conditions
In other applications, relevant design parameters can be encoded within the geometry itself, for example, lens shapes, reflector contours, housing features, microstructure designs, or mechanical adjustments that directly influence optical behaviour. SimAI automatically extracts the geometric features from the file and generates the corresponding lighting results, replicating the behaviour that would be expected from a full physics-based simulation.
In the example results provided below where all the relevant design parameters are associated within the geometries. As a result, no additional boundary conditions are specified for such SimAI model. At prediction time, users can simply supply a new STL or VTP file representing an updated design iteration as shown below.
Illustration of SimAI model prediction based on geometry.
Table. AI predicted (Left) and physics-based simulation results (Right)
|
Optical Design 3 light map with average photometric value as 4.35 |
Optical Design 3 light map with average photometric value as 4.39 |
|
Optical Design 4 light map with average photometric value as 4.24 |
Optical Design 4 light map with average photometric value as 4.21 |
Important model settings
Description of important objects and settings used in this model
- The fidelity of the lighting map data is determined by the sensor resolution when a 2D sensor is used, or by the 3D mesh resolution when a 3D sensor is employed.
- It is important to ensure that the training data map is constructed with a limited proportion of void or no-value areas.
- Each dataset supports a maximum of one VTP file and one JSON file. In this example, only a single target lighting map is required. When multiple lighting maps are needed, all result VTP files must be merged into a single file prior to submission to SimAI.
- The SimAI model configuration supports training durations of 1 day, 3 days, and 7 days. In general, longer training durations enable higher model precision; however, care must be taken to avoid overfitting to the training dataset.
- A minimum of 35 datasets is recommended for training SimAI. Increasing the number of datasets generally leads to improved model performance.
- Each prediction is accompanied by a confidence metric, which quantifies how familiar this new prediction is to the model. Designs that fall far outside the learned latent shape/physics space yield lower confidence scores, indicating that additional training data or retraining may be required. This mechanism provides practical guidance on the reliability and trustworthiness of the model’s predictions.
Taking the model further
Information and tips for users that want to further customize the model
- In optiSLang, user can increase the number of datasets to be generated and submitted for SimAI
- In Speos, user can change the OPD parameters that driving the design of lightguide. A new SimAI can be trained on the new parameters.
- In SimAI, user can alter the training duration and evaluate the difference using different training time.
Additional resources
Additional documentation, examples and training material
Starting from Ansys 2025 R1 release, PySpeos and PyOptiSLang are available. You can find detailed installation instructions and user guides at the following links: