SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files...

Preview:

Citation preview

1www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.Copyright © ESI Group, 2017. All rights reserved.

www.esi-group.com

SCILAB WORKSHOP

Workflow automation

SCILAB TEAM

17th, October 2019

2www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Agenda

1. OpenFOAM case set-up with SCILABRead/Write text files

2. OpenFOAM simulation automation with SCILABRun utilities from SCILAB console

3. OpenFOAM results post-processing with SCILAB

4. Advanced post-processingOptimization example

5. Graphical User Interface (GUI) design for simulation application

3www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

OpenFOAM case set-upRead/Write text files

4www.esi-group.com

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

5www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

• 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

2. Basics for string manipulation in SCILAB

6www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Example: Speed and angle of attack change

7www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

PARSEC parametrization

4. Example: Mesh change

Screening experiment

rle, xup, zte, bte

8www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Header

9www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Content

10www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Generated file & mesh

11www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Simulation automationRun OpenFOAM utilities from SCILAB

12www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. REMINDER: OpenFOAM utilities

Access utilities fromcommand line

13www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Windows, Linux or MacOScommand execution

unix_g, unix_s, unix_w, unix_x

2. Basics for utilities manipulation in SCILAB

14www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. Clean case

2. Generate new mesh

3. Run simulation

3. Example: Generate cases for each run of DoE

15www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Results post-processingField and time serie analysis

16www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. REMINDER: OpenFOAM results

17www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

csvRead

• Range definition

• Automatic conversioninto doubles

• Header remove

evstr

String conversion intodouble matrix

2. Basics for results manipulation in SCILAB

18www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Advanced post-processingAirfoil shape optimization

19www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Airfoil shape optimization

20www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. Optimization workflow

Parametrization

& Case setupSimulation Post Process Cost Function

Cost functions

• Maximize lift ~ min 10 − 𝐶𝐿• Minimize drag (CD) ~ min𝐶𝐷

21www.esi-group.com

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

22www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Optimization set-up

Genetic Algorithm – Multi-Objective optimization – 20 iterations

23www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Design space exploration – Toward optimum

24www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

GUI designSimulation application

25www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Figure properties

Uicontrol main properties:

• Style

• Position

• Value

• Enable

• String

• Tag

• Callback

1. SCILAB function for GUI design – uicontrol()

26www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

2. Locate case - GUI

Locate Case

Components

• 1 figure

• 1 menu

• 1 callback

27www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Locate case - Code

28www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Simulation & Optimization set-up - GUI

Simulation set-up

• Change Speed

• Change AoA

Optimization set-up

• Change max number of iteration

• Run optimization

29www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

5. Simulation set-up code

Graphical component

Callback

Recommended