46
WEC-Sim Training Course for users and developers FOSWEC wave tank testing and WEC-Sim simulation August 17, 2017 Yi-Hsiang Yu (NREL) Kelley Ruehl (Sandia)

August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

  • Upload
    others

  • View
    5

  • Download
    1

Embed Size (px)

Citation preview

Page 1: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

1 | Program Name or Ancillary Text eere.energy.gov

WEC-Sim Training Coursefor users and developers

FOSWEC wave tank testing and WEC-Sim simulation

August 17, 2017Yi-Hsiang Yu (NREL)Kelley Ruehl (Sandia)

Page 2: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

2 | Water Program Technologies Office eere.energy.gov

Course Agenda

Page 3: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

3 | Water Program Technologies Office eere.energy.gov

Time (MT) Topic (~Duration) Description11:00 am WEC-Sim Code Structure

~1hr total• Code Structure Overview: ~10min

• WEC-Sim source code• WEC-Sim models: input files and Simulink models

• WEC-Sim Objects (.m): ~30min• Object oriented programming: objects, properties, methods, etc.• High level overview of: bodyClass, waveClass, simulationClass, ptoClass,

constraintClass, mooring, etc• WEC-Sim Library Blocks (.slx): ~20min

• body, constraint, pto, frame• what simulink blocks are available, how are they defined• what is a mask, how to go under a mask• variant subsystems and how to define them

Code Structure Topics

Page 4: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

4 | Program Name or Ancillary Text eere.energy.gov

WEC-Sim Code Structure Kelley Ruehl (Sandia)

Page 5: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

5 | Water Program Technologies Office eere.energy.gov

WEC-Sim source code consists of:

WEC-SimWEC-Sim/source/

WEC-Sim model files consist of: Case Directory

Page 6: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

6 | Water Program Technologies Office eere.energy.gov

WEC-Sim Source Code

Page 7: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

7 | Water Program Technologies Office eere.energy.gov

WEC-Sim Source Code

WEC-Sim source code consists of:

– Source code is included in the MATLAB path– Can be executed from any directory

Page 8: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

8 | Water Program Technologies Office eere.energy.gov

• Executing wecSim.m– parses the WEC-Sim input file– performs preprocessing calculations in each of the classes– selects and initializes variant subsystems in the Simulink model– runs the time-domain simulation in WEC-Sim

• View wecSim.m from MATLAB Command Window>>open wecSim

WEC-Sim ExecutableWEC-Sim/source/WEC-Sim/source/wecSim.m

Page 9: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

9 | Water Program Technologies Office eere.energy.gov

• Define classes in the WEC-Sim input file– wecSimInputFile.m

• The following classes create the WEC-Sim objects– simulationClass.m, waveClass.m, bodyClass.m,

constraintClass.m, ptoClass.m, mooringClass.m• WEC-Sim objects are required to run WEC-Sim simulations

– simu, waves, body(i), pto(i), constraint(i), mooring(i) • View properties or open classes from MATLAB Command Window

>> doc className>> open className

WEC-Sim Objects

WEC-Sim/source

WEC-Sim/source/objects

WEC-Sim/source/objects/

Page 10: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

10 | Water Program Technologies Office eere.energy.gov

• WEC-Sim source code includes WEC-Sim library blocks:– Body Elements, Constraints, Frames, Moorings, PTOs

• Define WEC dynamics in WEC-Sim Simulink model using WEC-Sim Library Blocks– <Simulink_modelname>.slx

• View properties by double clicking on blocks– displays description and block parameters

• There should be a one-to-one between the objects defined in the input file and the blocks used in the Simulink model.

WEC-Sim Library BlocksWEC-Sim/source/lib/ WEC-Sim/source

Page 11: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

11 | Water Program Technologies Office eere.energy.gov

WEC-Sim Model Files

Page 12: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

12 | Water Program Technologies Office eere.energy.gov

WEC-Sim Model Files

WEC-Sim model files consist of:

• Model files are located in the case directory• WEC-Sim models must be executed from the case directory

Page 13: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

13 | Water Program Technologies Office eere.energy.gov

wecSimInputFile.m

WEC-Sim Input FileCase Directory

• Located in the case directory• Initialize and define classes in the WEC-Sim input file

– wecSimInputFile.m• WEC-Sim objects are required to run WEC-Sim simulations

– simu, waves, body(i), pto(i), constraint(i), mooring(i)

Page 14: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

14 | Water Program Technologies Office eere.energy.gov

– Initialize Simulation Class– Set Properties of Simulation Class

WEC-Sim Input File

wecSimInputFile.m

– Initialize Constraint Class– Set Properties of Constraint Class– Initialize PTO Class– Set Properties of PTO Class

– Initialize Wave Class– Set Properties of Wave Class

– Initialize Body Class Instances– Set Properties of Body Class Instances

Page 15: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

15 | Water Program Technologies Office eere.energy.gov

<Simulink_model_name>.slx

WEC-Sim Simulink File

Case Directory

• Located in the case directory• Define model file using WEC-Sim Library Blocks

• <Simulink_model_name>.slx

Page 16: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

16 | Water Program Technologies Office eere.energy.gov

WEC-Sim Simulink File

– Body Block

<Sim

ulin

k_m

odel

_nam

e>.s

lx

– Translation PTO Block

– Body Block

– Floating (3DOF) Block

– Global Reference Fram

Page 17: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

17 | Water Program Technologies Office eere.energy.gov

WEC-Sim Objects

Page 18: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

18 | Water Program Technologies Office eere.energy.gov

• Define classes in the WEC-Sim input file– wecSimInputFile.m

• The following classes create the WEC-Sim objects– simulationClass.m, waveClass.m, bodyClass.m,

constraintClass.m, ptoClass.m, mooringClass.m• WEC-Sim objects are required to run WEC-Sim simulations

– simu, waves, body(i), pto(i), constraint(i), mooring(i)

WEC-Sim Objects

WEC-Sim/source

WEC-Sim/source/objects

WEC-Sim/source/objects/

Page 19: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

19 | Water Program Technologies Office eere.energy.gov

• WEC-Sim has several different classes– simulationClass.m– waveClass.m– bodyClass.m– constraintClass.m– ptoClass.m– mooringClass.m– responseClass.m

• Each class contains:– Properties that can be defined– Methods (aka functions) that can be executed

• WEC-Sim input file determines which properties are defined and methods are executed

WEC-Sim Objects

OBJECT

PROPERTIES METHODS

INITIALIZATION OTHER

Page 20: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

20 | Water Program Technologies Office eere.energy.gov

• Each class creates a corresponding object– simulationClass.m simu– waveClass.m waves– bodyClass.m body(i) – constraintClass.m constraint(i) – ptoClass.m pto(i) – mooringClass.m mooring(i) – responseClass.m output

• Properties defined in the WEC-Sim input fie used initialize variant subsystems in the WEC-Sim Library Blocks– simu.b2b = 1;– body(i).nhBody = 1;– waves = waveClass('regular');

WEC-Sim Objects

OBJECT

PROPERTIES METHODS

INITIALIZATION OTHER

Page 21: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

21 | Water Program Technologies Office eere.energy.gov

• WEC-Sim Classes– simulationClass.m– waveClass.m– bodyClass.m– constraintClass.m– ptoClass.m– mooringClass.m– responseClass.m

WEC-Sim Objects

OBJECT

PROPERTIES METHODS

INITIALIZATION OTHER

>> doc ptoClass

Page 22: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

22 | Water Program Technologies Office eere.energy.gov

• WEC-Sim Classes– simulationClass.m– waveClass.m– bodyClass.m– constraintClass.m– ptoClass.m– mooringClass.m– responseClass.m

WEC-Sim Objects

OBJECT

PROPERTIES METHODS

INITIALIZATION OTHER

>> open ptoClass

Page 23: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

23 | Water Program Technologies Office eere.energy.gov

WEC-Sim Class Descriptions

Page 24: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

24 | Water Program Technologies Office eere.energy.gov

Simulation Class

The simulation class contains the simulation parameters and solver settings necessary to execute the WEC-Sim code.• Required Properties:

– simMechanicsFile– startTime, endTime, dt, rampTime, CITime– (many have default values)

• Optional Properties:– ssCalc, nlHydro– mode, solver– explorer, paraview, domainSize– rho, g

• Contains all simulation options (time, fluid properties, solver, visualization, etc.)

• Contains flags for different options (state space, non-linear hydro, etc.)

simulationClass.m >>simu

Page 25: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

25 | Water Program Technologies Office eere.energy.gov

Wave Class

The wave class contains all wave information necessary to define the incident wave condition for the WEC-Sim time-domain simulation. • Required Properties:

– type– Each wave ‘type’ has different required properties

waveClass.m >>waves

Page 26: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

26 | Water Program Technologies Office eere.energy.gov

Body Class

The body class contains the mass and hydrodynamic properties of each body that comprises the WEC being simulated.• Required Properties:

– mass: value, ‘equilibrium’, ‘fixed’– momOfInertia (except for ‘fixed’ mass)– geometryFile– h5File

• Optional Properties:– viscDrag– initDisp– linearDamping– Viz

• Useful input information:– hydroData (BEM data)– hydroForce (force time-series)

bodyClass.m >>body(1)

Page 27: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

27 | Water Program Technologies Office eere.energy.gov

Constraint and PTO Classes

Constraint blocks connect WEC bodies to on one another (and possibly to the seabed) by constraining DOFs. • Constraint Class Properties

– name– Loc

constraintClass.m

ptoClass.mPower Take-Off (PTO) blocks connect WEC bodies to one other (and possibly to the seabed) by constraining DOFs and applying linear damping and stiffness• PTO Class Properties

• name• loc• k• c

• NOTE: loc required for rotational PTOs & Constraints

>>constraint >>pto

Page 28: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

28 | Water Program Technologies Office eere.energy.gov

Mooring Class

Mooring class contains all information about definition of the mooring system• Mooring types:

– Matrices– MoorDyn

• Properties:– name– ref– matrix– initDisp– moorDynLines

mooringClass.m >>mooring

Page 29: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

29 | Water Program Technologies Office eere.energy.gov

Response Class (Output Structure)

‘output’ created at the end of a WEC-Sim simulation. It contains all the output time-series and methods to plot and interact with the results. • `output` variable = responseClass instance

– Contains all time series from simulation– Contains all time-series calculations– methods for quick plotting

• Properties:– bodies– ptos– constraints– ptosim

$Case/output/RM3_matlabWorkspace.mathttp://wec-sim.github.io/WEC-Sim/code_structure.html#output-structure

responseClass.m>>output

Page 30: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

30 | Water Program Technologies Office eere.energy.gov

WEC-Sim Library

Page 31: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

31 | Water Program Technologies Office eere.energy.gov

• WEC-Sim source code includes WEC-Sim library blocks:– Body Elements, Constraints, Frames, Moorings, PTOs

• Define WEC dynamics in WEC-Sim Simulink model using WEC-Sim Library Blocks– <Simulink_modelname>.slx

• View properties by double clicking on blocks– displays description and block parameters

• There should be a one-to-one between the objects defined in the input file and the blocks used in the Simulink model.

WEC-Sim Library BlocksWEC-Sim/source/lib/ WEC-Sim/source

Page 32: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

32 | Water Program Technologies Office eere.energy.gov

WEC-Sim Library

• WEC-Sim Library– Drag & Drop library – Mask

• Simulink Model– Made of WEC-Sim library blocks– Body Elements, PTOs,

Constraints need to be numbered

WEC-Sim/source/lib/

Page 33: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

33 | Water Program Technologies Office eere.energy.gov

Masks

• Simulink Masks– A mask is a custom user interface for a

block.– By masking a block you encapsulate the

block diagram to have its own parameter dialog box with its own block description, parameter prompts, and help texts.

• Denoted by down arrow• Double clicking on mask opens

dialog box• Clicking on down arrow (Ctrl+U)

goes under the mask

WEC-Sim/source/lib/

https://www.mathworks.com/help/simulink/block-masks.html

Page 34: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

34 | Water Program Technologies Office eere.energy.gov

Variant Subsystems

• Variant Subsystems– Variant subsystems let you provide

multiple implementations for a subsystem where only one implementation is active during simulation.

– You can programmatically swap out the active implementation and replace it with one of the other implementations without modifying the model.

• Denoted by double squares• Double click on subsystem to view

variant subsystem (unless masked)

WEC-Sim/source/lib/

https://www.mathworks.com/help/simulink/examples/variant-subsystems.html

Page 35: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

35 | Water Program Technologies Office eere.energy.gov

Variant Subsystems

• WEC-Sim Library Blocks contain many variant subsystems which are activated by WEC-Sim input file, wecSimInputFile.m in wecSim.m

• Right click on block with variant subsystem and select ‘Block Parameters (Subsystem)’ to see variant control variables

WEC-Sim/source/lib/

https://www.mathworks.com/help/simulink/examples/variant-subsystems.html

Page 36: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

36 | Water Program Technologies Office eere.energy.gov

Variant Subsystem and Mask Example

Page 37: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

37 | Water Program Technologies Office eere.energy.gov

WEC-Sim Library Block Types

Page 38: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

38 | Water Program Technologies Office eere.energy.gov

Body Elements

Page 39: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

39 | Water Program Technologies Office eere.energy.gov

Constraints

Page 40: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

40 | Water Program Technologies Office eere.energy.gov

Frames

Page 41: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

41 | Water Program Technologies Office eere.energy.gov

Moorings

Page 42: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

42 | Water Program Technologies Office eere.energy.gov

PTOs

Page 43: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

43 | Water Program Technologies Office eere.energy.gov

WEC-Sim Simulink Model– Created with WEC-Sim Simulink Library Blocks– Body Elements, Constraints, Frames, Moorings, PTOs

WEC-Sim Simulink File<Simulink_model_name>.slx

Page 44: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

44 | Water Program Technologies Office eere.energy.gov

In conclusion…

Page 45: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

CAD Mesh

BEM Solver (WAMIT, AQWA,

NEMOH)

BEMIO

PTO-Sim Input File

ptoSimClass

wecSim.m

User defined function

hdf5 file

WEC-Sim Input file

Simulation

Body

Waves

Constraint

PTO

Mooring

Non-linear hydro

Visualization

Runs Simulink model, calls user-defined functions for output processing

SimulinkModel

Reference frame block

Body block(s)

Constraint block(s)

PTO block(s)

Mooring block

PTO-Sim Block

Position, velocity,

acceleration, forces, etc. time series

Processes outputs, plots specified

variables

Variant sub-system

triggers

Output

MoorDyn

= External

= WEC-Sim distribution

= Required input= Optional input

stl file

Page 46: August 17, 2017 WEC-Sim Training Course · 2021. 1. 8. · 1 | Program Name or Ancillary Text eere.energy.gov WEC-Sim Training Course. for users and developers. FOSWEC wave tank testing

46 | Program Name or Ancillary Text eere.energy.gov

All the webinar materials and recordings are available online: http://wec-sim.github.io/WEC-Sim/webinars.html

Thank you!

Sandia National Laboratories is a multi-mission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly ownedsubsidiary of Honeywell International, Inc., for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-NA0003525.