In this example, we will use Speos and optiSLang to optimize a prismatic lightguide to illuminate a glovebox. The goal is to achieve an evenly distributed light pattern and good efficiency.
[[NOTES:]]Software Prerequisites
To be able to use this example, the following tools and assets need to be installed on your computer:
- Ansys Speos 2022 R2
- Ansys optiSLang 2022 R2
- optiSLang Speos Integration 22 R2.1 (Installer “optiSLang_Speos_22R2.1.exe” located in “.\optiSLang_project_with_reference\”.)
Overview
Understand the simulation workflow and key results
In automotive lighting applications, interior lighting based on LED is standard to light many different parts of the interior. Design Elements in the car Interior need to comply to high standards in terms of homogeneity and appearance. Lightguides and lens systems are used to create these design elements. To perform this optimization, we use a design created with Ansys Speos Optical Part Design. Ansys optiSLang will be used to drive the parameter change and subsequently find the best design.
Step 1: Ansys Speos model
Demonstrate Speos Lightguide simulation with a photometric Radiance map.
Step 2: optiSLang sensitivity study
Demonstrate design exploration capabilities by performing a Sensitivity study to identify important parameters.
Step 3: optiSLang optimization
Demonstrate optimization capabilities by performing optimization based on Metamodels followed by a single objective direct optimization to achieve the best possible design.
Run and results
Instructions for running the model and discussion of key results
Step 1: Ansys Speos model
- Open the Ansys Speos model HMI_optiSLang.scdocx. (located “.\ optiSLang_project_with_reference\01_reference\”).
- Perform a local Compute of the Direct Simulation “Direct.Glove.Box”.
The lightguide used in the simulation was created by Speos Optical Part Design. To understand how to create and modify the lightguide please read the related Knowledge Base Article: Creating a Lightguide.
The radiance map result shown below is used to measure the optical performance in terms of illumination and homogeneity. The radiance along the path defined by the four points is used to assess the homogeneity performance. The goal is to optimize the structure to achieve a maximum average radiance with reduced RMS contrast along the polygon path.
Step 2: optiSLang sensitivity study
-
Open the optiSLang project file (*.opf)
(located in “.\optiSLang_project_with_reference\”).
The “AMOP”-system shows the necessary solver chain to perform the lightguide analysis and is used to run the sensitivity analysis to get a design understanding and to identify important input parameter.
Double-click on the AMOP Module to see the defined sampling method, parameter ranges and optimization criteria.
The system is defined to include pictures and to keep the result files of each simulation. Due to the size these pictures and result files are not delivered with this example. To regenerate them you can rerun the study. -
Optional:
To re-run the sensitivity study right-click on AMOP and select “Start from here”.
HINT: The step-by-step tutorial shows how to create the automated workflow (solver chain) and how to setup the sensitivity analysis. (The tutorial can be found in the download folder: “.\Glove_Box_LightGuide_Optimization_Tutorial_Tutorial.pdf”). - To review the results of the sensitivity analysis, right-click on AMOP and select 'show Postprocessing'. The file already contains the results for the metamodels.
The main concern when working with metamodels is the prediction quality on how good the model predicts the outputs based on new given input values. optiSLang catches this in the Coefficient of Optimal Prognosis, short COP. The best way to review the sensitivity study is to review the COP matrix. The COP matrix shows that all values are well predicted (shown in the column “Total”). The models can be used to optimize for homogeneity. In addition, the COP matrix shows for each result (here average and RMS contrast) the quantitative influence of the input parameter on the variation of the result.
The Metamodel of Optimal Prognosis (MOP) approximates the response as a function of all important input parameters. By clicking on one of the “Total” updates the 3d Response surface plot. This plot is the representation of the Metamodel based on the two main contributors and the remaining ones are set to a fixed value. By using the sliders (see picture below) you can see the influence of the other dimensions.
Step 3: optiSLang optimization
Global multi-objective optimization based on MOP
-
Go Back to the optiSLang Project (*.opf)
Double-click on the “Evolutionary Algorithm” system. Settings including the optimization method, maximum number of samples and the defined criteria are set up for this system. -
Optional:
To re-run the multi-objective analysis right-click on “Evolutionary Algorithm”-system and select “Start from here”.
HINT: The step-by-step tutorial shows how to setup the multi-objective optimization based on sensitivity analysis (The tutorial can be found in the download folder: “.\Glove_Box_LightGuide_Optimization_Tutorial_Tutorial.pdf”). - Go back to optiSLang scenery, right-click on the “Evolutionary Algorithm” system and select “Show Postprocessing”.
The optimization algorithm sampled 10000 designs on the MOP to find the best combination of input parameter values that leads to the best design. The result of the multi-objective optimization is visualized in the “Pareto Plot” (see also picture below). The plot shows the trade-off between the two objectives where the set of best designs are marked with red dots (defined as Pareto front). The workflow validates automatically 20 of the best designs with a real solver call (shown as green dots). The differences between predicted and validated values are acceptable due to the good COP values. You can see the difference is stronger for RMS Contrast than average due to better COPs. By selecting one of the designs the corresponding parameter values and responses are shown in the other plots in the optiSLang Postprocessing.
The picture shows the validated design 4569
To improve the design further it is possible to run a local and single objective optimization by converting one of the objectives to a constraint.
Local single objective optimization
- Go Back to the optiSLang Project (*.opf)
- Double-click on the “ARSM”-system. Settings including the optimization method, maximum number of samples and criteria are set up for this system.
- Optional: To re-run the local single-objective analysis right-click on “ARSM”-system and set “Data flow” to active. Then right-click on the system again and select “Start from here”.
- To review the results right-click on “ARSM” and select 'Show Postprocessing'. The file already contains the results for the optimization.
The single objective optimization took the best tradeoff design from the multi-objective optimization as the start design.
In the picture, you can see the optimization history. The best design (229) is only marginally better than the designfrom the Multi-objective optimization.
Summary optimization
|
Initial design |
Multi Objective Optimization based on MOP |
Local single Objective Optimization |
RMS contrast |
1.09 |
0.64 < 0.74 < 1.03 |
0.72 |
Average Luminance in cd/m² |
0.89 |
9.04 < 12.04 < 14.42 |
12.0 ≥ 12
|
Results |
Initial design
|
best trade off
|
best design
|
Important model settings
Description of important objects and settings used in this model
Speos model settings
Lightguide meshing
A precise meshing of the lightguide is extremely important. The prisms can get extremely small. If this is not accounted for in the meshing, no light will be extracted from the lightguide. Use Local Meshing on important optical geometries.
Maximum number of surface interaction
A lightguide relies on Total internal reflection to guide the light, resulting in a lot of surface interactions. The default value of 100 is often too low.
XML Template
The XML template in the sensor definition is used to export the Measurements to make them usable in optiSLang
Batch automation
If you are facing issues on the script part, it might be helpful to either enable the user interface or manually execute the script to understand the error. There are several Parameters for the automation:
Option |
|
/DefaultOpenDirectory |
Specifies a default file open directory. |
/DefaultSaveDirectory |
Specifies a default file save directory. |
/DefaultUserSettingsFile |
Specifies the full path of a default user settings file. |
/ExitAfterScript |
Specifies if the application should exit when the script (defined by the RunScript options) is finished. |
/Headless |
Boolean value indicating whether to run the application in batch mode, without UI. |
/p |
Override the Primary SpaceClaim license and Alternate license preferences, and specify a different license on application startup. See License options for details on the License preference options available. Example: SpaceClaim.exe /p=ansys |
/RunScript |
Specifies the fully qualified pathname of the script file to run. |
/ScriptAPI |
Specifies the Script API when used with the RunScript option. |
/ScriptArgs |
Specifies the script arguments as a comma separated list (for example, ScriptArgs="arg1, arg2, arg3"). |
/ScriptAsync |
Boolean value indicating whether to run the script asynchronously. |
/ScriptOutput |
Specifies the fully qualified pathname of the script output file. |
/Splash |
Boolean value indicating whether to show the splash screen or not. The default value is True. |
/UseCurrentDirectory |
Use the current directory as the default file open / save directory. |
/Welcome |
Boolean value to indicate whether to open an Empty design or not. The default value is True |
/WindowLocation |
Sets the window location. For example, /WindowLocation=5,5 |
/WindowMaximized |
Sets the window to be maximized, if true. |
/WindowSize |
Sets the window size. For example, /WindowSize=1000,800 |
optiSLang
Solver settings
Double click on the “SpeosCore” node to change the settings:
- number of used cores
- activate solve on GPU
Double click on the “Geometry_creation” node to change the degree of parallel design creation (under additional options):
- Maximum in parallel
Sensitivity settings
Double click on the “AMOP” – system:
- to change the parameter ranges in the “Parameter” tab
- to change constraint limitation in the “Criteria” tab
- to change maximum number of samples in the “Adaption” tab
- to view the results in the “result designs” tab.
Multi-objective optimization
Double click on the “Evolutionary Algorithm” – system:
- to change the constraint limitation in the “Criteria” tab
- to change the maximum number of samples in the “NOA” tab
- to view the results in the “result designs” tab.
Single-objective optimization
Double click on the “Evolutionary Algorithm” – system:
- to change the constraint limitations in the “Criteria” tab
- to view the results in the “result designs” tab.
Updating the model with your parameters
Instructions for updating the model based on your device parameters
Lightguide parameters
By using the API's describe in the automation listing you can add more parameters to the model. You can also use the script recording feature. Below you can find an based on lines 21-31 of the provided script.
LG_Design.TrimmingRatioType = "Control points"
#LG_Design.TrimmingRatioConfigurations[0].Position = 0 # fixed
LG_Design.TrimmingRatioConfigurations[0].Value = 70
LG_Design.TrimmingRatioConfigurations[1].Position = 25
LG_Design.TrimmingRatioConfigurations[1].Value = 60
LG_Design.TrimmingRatioConfigurations[2].Position = 50
LG_Design.TrimmingRatioConfigurations[2].Value = 50
LG_Design.TrimmingRatioConfigurations[3].Position = 75
LG_Design.TrimmingRatioConfigurations[3].Value = 40
#LG_Design.TrimmingRatioConfigurations[4].Position = 100 # fixed
LG_Design.TrimmingRatioConfigurations[4].Value = 20
Add additional parameters to the optiSLang model:
The Text input node is an optiSLang node to adjust text files and place the adjusted version within the design directory for later use. How to do this is shown in the step-by-step-tutorial on the learning hub or in the pdf located in the downloaded data.(“.\Glove_Box_LightGuide_Optimization_Tutorial_Tutorial.pdf”).
Bring your own part
The script opens a specific file, but you can replace this by adjusting the name highlighted in orange . Please note that you should adjust the names of the Speos lightguide feature and Speos direct simulation to edit and/or export, highlighted in green
# Open File
Ansys_SPEOS_file=os.path.join(os.getcwd(),"HMI_optiSLang.scdocx")
importOptions = ImportOptions.Create()
DocumentOpen.Execute(Ansys_SPEOS_file, importOptions)
# Compute LightGuide
LG_Design = SpeosDes.LightGuide.Find("Light Guide")
Setup_LightGuide(LG_Design)
LG_Design.Compute()
# Setup SPEOS Simulation
LG_Sim = SpeosSim.SimulationDirect.Find("Direct.Glove.Box")
Setup_SPEOS_Simulation(LG_Sim)
Add new outputs to the simulation report
To add new outputs, it is needed to add new measurements to the XML-Templates selected in the simulation setup. The easiest way to do this is to replace the existing XML-Templates from the input files or reselecting it in the sensor definition. XML-Templates are created by creating a measurement on the XMP map and then exporting this Measurement to an XML-Template.
By editing the Speos reader node, the outputs will be added to the optiSLang Project.
Taking the model further
Information and tips for users that want to further customize the model
To increase the design understanding, the activation of the result images in the optiSLang postprocessing, as well as the “Parallel coordinates plot” (PCP) can be used. With the PCP it is possible to visualize the dependencies between the input and the output parameter, as well as to identify the trade-offs between the objectives. Furthermore, a coloring of a design set helps to identify the regions where the optimization algorithms search for the best design.
How to do this is shown in the step-by-step tutorial (The tutorial can be found in the download folder: “.\Glove_Box_LightGuide_Optimization_Tutorial_Tutorial.pdf”).
Additional resources
Additional documentation, examples and training material