SCILAB WORKSHOP Workflow automation
SCILAB TEAM 17th, October 2019 www.esi-group.com 1
Copyright © ESICopyright Group, 2017. © ESI All Group, rights reserved.2017. All rights reserved. Agenda
1. OpenFOAM case set-up with SCILAB Read/Write text files
2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console
3. OpenFOAM results post-processing with SCILAB
4. Advanced post-processing Optimization example
5. Graphical User Interface (GUI) design for simulation application
www.esi-group.com 2
Copyright © ESI Group, 2017. All rights reserved. OpenFOAM case set-up Read/Write text files
www.esi-group.com 3
Copyright © ESI Group, 2017. All rights reserved. 1. REMINDER: OpenFOAM case structure
System directory Simulation parameters
Constant directory Mesh and flow properties
Time directories Initial conditions and results
www.esi-group.com 4
Copyright © ESI Group, 2017. All rights reserved. 2. Basics for string manipulation in SCILAB
• Simple ‘ or double quote ’’ >> ‘Make simulation rocks!’ • Concatenate with + >> ‘SCILAB’ + ‘ & ‘ + ‘OpenFOAM’ • Locate substring strstr, find • Handle part of strings strsplit, strsubst • String conversion into double evstr
• Handle text file mopen, mgetl, mfprintf, mclose, write
www.esi-group.com 5
Copyright © ESI Group, 2017. All rights reserved. 3. Example: Speed and angle of attack change
www.esi-group.com 6
Copyright © ESI Group, 2017. All rights reserved. 4. Example: Mesh change PARSEC parametrization
Screening experiment rle, xup, zte, bte
www.esi-group.com 7
Copyright © ESI Group, 2017. All rights reserved. 4. Example: Mesh change Header
www.esi-group.com 8
Copyright © ESI Group, 2017. All rights reserved. 4. Example: Mesh change Content
www.esi-group.com 9
Copyright © ESI Group, 2017. All rights reserved. 4. Example: Mesh change Generated file & mesh
www.esi-group.com 10
Copyright © ESI Group, 2017. All rights reserved. Simulation automation Run OpenFOAM utilities from SCILAB
www.esi-group.com 11
Copyright © ESI Group, 2017. All rights reserved. 1. REMINDER: OpenFOAM utilities
Access utilities from command line
www.esi-group.com 12
Copyright © ESI Group, 2017. All rights reserved. 2. Basics for utilities manipulation in SCILAB
Windows, Linux or MacOS command execution
unix_g, unix_s, unix_w, unix_x
www.esi-group.com 13
Copyright © ESI Group, 2017. All rights reserved. 3. Example: Generate cases for each run of DoE
1. Clean case 2. Generate new mesh 3. Run simulation
www.esi-group.com 14
Copyright © ESI Group, 2017. All rights reserved. Results post-processing Field and time serie analysis
www.esi-group.com 15
Copyright © ESI Group, 2017. All rights reserved. 1. REMINDER: OpenFOAM results
www.esi-group.com 16
Copyright © ESI Group, 2017. All rights reserved. 2. Basics for results manipulation in SCILAB
csvRead • Range definition • Automatic conversion into doubles • Header remove evstr String conversion into double matrix
www.esi-group.com 17
Copyright © ESI Group, 2017. All rights reserved. Advanced post-processing Airfoil shape optimization
www.esi-group.com 18
Copyright © ESI Group, 2017. All rights reserved. Airfoil shape optimization
www.esi-group.com 19
Copyright © ESI Group, 2017. All rights reserved. 1. Optimization workflow
Parametrization Simulation Post Process Cost Function & Case setup
Cost functions
• Maximize lift ~ min 10 − 퐶퐿 • Minimize drag (CD) ~ min 퐶퐷
www.esi-group.com 20
Copyright © ESI Group, 2017. All rights reserved. 2. Optimization cost function
1/ Clean case
2/ Generate new mesh
3/ Run case
4/ Extract results
5/ Build cost function
www.esi-group.com 21
Copyright © ESI Group, 2017. All rights reserved. 3. Optimization set-up
Genetic Algorithm – Multi-Objective optimization – 20 iterations
www.esi-group.com 22
Copyright © ESI Group, 2017. All rights reserved. 4. Design space exploration – Toward optimum
www.esi-group.com 23
Copyright © ESI Group, 2017. All rights reserved. GUI design Simulation application
www.esi-group.com 24
Copyright © ESI Group, 2017. All rights reserved. 1. SCILAB function for GUI design – uicontrol()
Figure properties
Uicontrol main properties: • Style • Position • Value • Enable • String • Tag • Callback
www.esi-group.com 25
Copyright © ESI Group, 2017. All rights reserved. 2. Locate case - GUI
Locate Case
Components • 1 figure • 1 menu • 1 callback
www.esi-group.com 26
Copyright © ESI Group, 2017. All rights reserved. 3. Locate case - Code
www.esi-group.com 27
Copyright © ESI Group, 2017. All rights reserved. 4. Simulation & Optimization set-up - GUI
Simulation set-up Optimization set-up
• Change Speed • Change max number of iteration • Change AoA • Run optimization
www.esi-group.com 28
Copyright © ESI Group, 2017. All rights reserved. 5. Simulation set-up code
Graphical component
Callback
www.esi-group.com 29
Copyright © ESI Group, 2017. All rights reserved.