In this example, we will use Speos and optiSLang to optimize a prismatic lightguide to fulfill the automotive Day-Time-Running-Lights regulation and improve the homogeneity of the lightguide to achieve a better lit appearance in an automated way.
[[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 or later
- Ansys optiSLang 2022 R2 or later
- optiSLang Speos Integration 22 R2.1 (Installer “optiSLang_Speos_22R2.1.exe” located in “.\optiSLang_project_with_reference\”.
Overview
In automotive lighting applications, Day-Time-Running-Lights are used to create a unique Lighting signature. These lightguides are nearly all the time on and need to comply to high Homogeneity standards and The Regulation posed by the Government. 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 Colorimetric Radiance map and an Intensity map with regulation check.
Step 2: optiSLang Sensitivity Analysis
Demonstrate design exploration capabilities by performing Sensitivity study to identify important input parameters and to get design understanding by creating Metamodels showing the relationship between input and output parameters.
Step 3: optiSLang Optimization
Demonstrate Optimization capabilities by performing multi-objective optimization based on Metamodels followed by a local and single-objective direct optimization to achieve the best possible design.
Run and results
Step 1: Ansys Speos Model
- Open the Ansys Speos model Headamp_LightGuide.scdocx. (located “.\optiSLang_project_with_reference\01_reference\” ).
- Perform a local Compute of the Direct Simulation “Lightguide”.
The two results, Intensity map and radiance map are used to measure the Optical performance in terms of regulation and Homogeneity.
The grid view of the Intensity map highlights the regulation compliance
Each of the boxes represents a Measurement point of intensity, regulated by the regulation. The center value represents the simulation result, the bottom left represents the minimum limit to pass, the top left value is the Maximum limit to pass the regulation, the right side will represent personally set safety margins. If a regulation fails, it will be highlighted in red if the safety margin is not met, it will be highlighted in yellow, If the regulation is passed, it is highlighted in green.
In the radiance map the measurements for the Homogeneity performance are defined. The Measurements are based on a 18 Point polyline. Along the line the Radiance will be evaluated. This will be used to measure the Average and RMS contrast.
This are the outputs which will be used for the Optimization. The goal is to reduce the RMS contrast and Maximize the Average of the Polyline while maintaining the ECE regulation.
Step 2: optiSLang Sensitivity Analysis
-
Open LG_optimization_AnsysSPEOS.opf.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 in order 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 simulations. 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: “ .\optiSLang_Prismatic_Light_Guide_2022R2_SPEOS_3.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 is able to predict 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 except for the number of failed rules are well predicted (shown in the column “Total”). The models can be used to optimize for homogeneity but not for the validation of the regulation. This needs to be validated with a real solver call.
The Metamodel of Optimal Prognosis (MOP) approximates the response as function of all important input parameter. 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.
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 optimization. -
Optional:
To re-run the multi-objective analysis right-click on “Evolutionary Algorithm”-system and set “Data flow“ to active. Then right-click on system again 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: “.\optiSLang_Prismatic_Light_Guide_2022R2_SPEOS_3.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 in order 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 were the set on 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 dot’s). The differences between predicted and validated value is small due the good COP values. 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 7574
To improve the design further it is possible to run a local and single objective optimization by converting one of the objectives to an constraint.
Local single objective optimization
- Go Back to the optiSLang Project (*.opf)
-
Double click on the “AMOP (1)”-system. Settings including the optimization method, maximum number of samples and criteria are set up for this system.
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 optimization. -
Optional:
To re-run the local single-objective analysis right-click on “AMOP (1)”-system and set “Data flow“ to active. Then right-click on system again and select “Start from here”.
HINT: The step-by-step tutorial shows how to setup the single-objective optimization based on sensitivity analysis (The tutorial can be found in the download folder: “.\optiSLang_Prismatic_Light_Guide_2022R2_SPEOS_3.pdf”). - To review the results right-click on “AMOP (1)” and select 'Show Postprocessing'. The file already contains the results for the optimization.
The single objective optimization take all design from the sensitivity study (black) and sample iterative additional designs (colored) in the regions of the best design based on the response surface.
The best design is highlighted in red (Design 329). The result provides good homogeneity and fulfills all regulations from the government.
Summary optimization
Initial Design | Multi-Objective Optimization based on MOP | Local-single-Objective Optimization | |
RMS contrast | 0.75 | 0.30 < 0.35 < 0.97 | 0.116 |
Average Luminance in kcd/m² | 184 | 180 < 184 < 195 |
171 >165 constrain fulfilled |
Number of failed rule (regulation) | 0/42 (constraint fulfilled, regulation passed) | ||
Results |
initial design |
best trade off |
best design |
Important model settings
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 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 Total internal reflection to guide the light this results in a lot of surface interaction. 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 |
Description |
/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 weather to open a 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 change the maximum number of samples in the “Adaption” tab
- to view the results in the “result designs” tab.
Updating the model with your parameter
Lightguide parameters:
By adjusting the script with other lightguide parameter you can adjust any parameter of the lightguide. Add the necessary lines in the script. You can use lines 33- 45 as example, you can use the automation listing or Speos recording feature to understand the API better.
LG_Design.EndAngleType = "Control points"
#LG_Design.EndAngleConfigurations[0].Position = 0 # fixed
LG_Design.EndAngleConfigurations[0].Value = 10
LG_Design.EndAngleConfigurations[1].Position = 5
LG_Design.EndAngleConfigurations[1].Value = 10
LG_Design.EndAngleConfigurations[2].Position = 10
LG_Design.EndAngleConfigurations[2].Value = 12
LG_Design.EndAngleConfigurations[3].Position = 30
LG_Design.EndAngleConfigurations[3].Value = 14
LG_Design.EndAngleConfigurations[4].Position = 65
LG_Design.EndAngleConfigurations[4].Value = 16
#LG_Design.EndAngleConfigurations[5].Position = 100 # fixed
LG_Design.EndAngleConfigurations[5].Value = 18
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. You can find a detailed step by step guide within the Ansys Learning Hub and we added the Step-by-step guide in the reference folder.
Bring your own part
The script opens a specific file you can replace this by adjusting the name in line 61. Please note that you should adjust line 66 and 71 which are the names of the Speos lightguide feature and Speos direct simulation to edit and/or export
# Open File
Ansys_SPEOS_file=os.path.join(os.getcwd(),"Headlamp_LightGuide.scdocx")
importOptions = ImportOptions.Create()
DocumentOpen.Execute(Ansys_SPEOS_file, importOptions)
# Compute LightGuide
LG_Design = SpeosDes.LightGuide.Find("Light Guide.1")
Setup_LightGuide(LG_Design)
LG_Design.Compute()
# Setup SPEOS Simulation
LG_Sim = SpeosSim.SimulationDirect.Find("Lightguide")
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 a XML-Template.
By editing the Speos reader node the outputs will be added to the optiSLang Project. You can find a detailed step by step guide within the Ansys Learning Hub and we added the Step-by-step guide in the reference folder.
Taking the model further
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 visualization 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 a best design.
How to do this is shown in the step-by-step tutorial. (The tutorial can be found in the download folder: “.\optiSLang_Prismatic_Light_Guide_2022R2_SPEOS_3.pdf”).
Additional resources
Related KB pages:
Related Ansys Courses: