29
1 www.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

SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

  • Upload
    others

  • View
    31

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 2: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 3: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

3www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

OpenFOAM case set-upRead/Write text files

Page 4: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 5: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 6: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

6www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Example: Speed and angle of attack change

Page 7: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

7www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

PARSEC parametrization

4. Example: Mesh change

Screening experiment

rle, xup, zte, bte

Page 8: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

8www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Header

Page 9: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

9www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Content

Page 10: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

10www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Example: Mesh change

Generated file & mesh

Page 11: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

11www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Simulation automationRun OpenFOAM utilities from SCILAB

Page 12: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

12www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. REMINDER: OpenFOAM utilities

Access utilities fromcommand line

Page 13: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 14: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 15: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

15www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Results post-processingField and time serie analysis

Page 16: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

16www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

1. REMINDER: OpenFOAM results

Page 17: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 18: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

18www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Advanced post-processingAirfoil shape optimization

Page 19: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

19www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

Airfoil shape optimization

Page 20: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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𝐶𝐷

Page 21: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 22: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

22www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Optimization set-up

Genetic Algorithm – Multi-Objective optimization – 20 iterations

Page 23: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

23www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

4. Design space exploration – Toward optimum

Page 24: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

24www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

GUI designSimulation application

Page 25: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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()

Page 26: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

26www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

2. Locate case - GUI

Locate Case

Components

• 1 figure

• 1 menu

• 1 callback

Page 27: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

27www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

3. Locate case - Code

Page 28: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

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

Page 29: SCILAB WORKSHOPOPENFOAM_Workflow.pdf · 1. OpenFOAM case set-up with SCILAB Read/Write text files 2. OpenFOAM simulation automation with SCILAB Run utilities from SCILAB console 3

29www.esi-group.com

Copyright © ESI Group, 2017. All rights reserved.

5. Simulation set-up code

Graphical component

Callback