This section provides an overview of the WEC-Sim work flow. First, the WEC-Sim file structure is described; then, steps for setting up and running the WEC-Sim code are described. The WEC-Sim workflow diagram is shown below. A description of this workflow is provided in the following sections. For information about the implementation and structure of the WEC-Sim source code, refer to the Code Structure section.
WEC-Sim Model Files¶
All files required for a WEC-Sim simulation must be contained within a case directory referred to as
This directory can be located anywhere on your computer. The table below list the WEC-Sim case directory structure and required files.
|File Type||File Name||Directory|
A WEC-Sim input file (
wecSimInputFile.m) is required for each run.
The input file must be named
wecSimInputFile.m and placed within the case directory.
The main structure of the input file consists of initializing all the objects necessary to run WEC-Sim simulations, and defining any user specified properties for each object.
The input file for each WEC-Sim simulation requires initialization and definition of the simulation and wave classes, at least one instance of the body class, and at least one instance of the constraint or PTO classes.
For details about WEC-Sim’s objects and available properties for each object, refer to the WEC-Sim Objects section.
An example WEC-Sim input file is shown below for the OSWEC Tutorial.
Additional examples are provided in the Tutorials section.
WEC-Sim is an object oriented code and the input file reflects this.
The WEC-Sim input file (
wecSimInputFile.m) for the OSWEC intializes and specifies properties for simulation, body, constraint and pto classes.
%% Simulation Data simu = simulationClass(); % Initialize simulationClass simu.simMechanicsFile = 'OSWEC.slx'; % Specify Simulink Model File simu.startTime = 0; % Simulation Start Time [s] simu.rampTime = 100; % Wave Ramp Time [s] simu.endTime=400; % Simulation End Time [s] simu.dt = 0.01; % Simulation Time-Step [s] simu.CITime = 30; % Specify CI Time [s] %% Wave Information % Regular Waves waves = waveClass('regular'); % Initialize waveClass and Specify Type waves.H = 2.5; % Wave Height [m] waves.T = 8; % Wave Period [s] %% Body Data % Flap body(1) = bodyClass('hydroData/oswec.h5'); % Initialize bodyClass for Flap and Specify *.h5 data body(1).geometryFile = 'geometry/flap.stl'; % Geometry File body(1).mass = 127000; % User-Defined mass [kg] body(1).momOfInertia = [1.85e6 1.85e6 1.85e6]; % Moment of Inertia [kg-m^2] % Base body(2) = bodyClass('hydroData/oswec.h5'); % Initialize bodyClass for Base body(2).geometryFile = 'geometry/base.stl'; % Geometry File body(2).mass = 'fixed'; % Creates Fixed Body %% PTO and Constraint Parameters % Fixed constraint(1)= constraintClass('Constraint1'); % Initialize constraintClass for Constraint1 constraint(1).loc = [0 0 -10]; % Constraint Location [m] % Rotational PTO pto(1) = ptoClass('PTO1'); % Initialize ptoClass for PTO1 pto(1).k = 0; % PTO Stiffness [Nm/rad] pto(1).c = 0; % PTO Damping [Nsm/rad] pto(1).loc = [0 0 -8.9]; % PTO Location [m]
The WEC-Sim code also requires a hydrodynamic data from a BEM soltuion in the form of a
*.h5 hydrodynamic data file can be generated using the BEMIO pre-processor.
BEMIO (Boundary Element Method Input/Output) is a code developed by the WEC-Sim team to process BEM output files from WAMIT, NEMOH, and AQWA into a data structure than can be read by WEC-Sim. For more information about the BEMIO pre-processor, refer to the BEMIO section.
The WEC-Sim code also requires a geometry file in the form of a
*.stl file is used by the WEC-Sim code to generate the Simscape Explorer visualization, and by non-linear hydrodynamics to determine the instantaneous wetted surface at each time step.
When running WEC-Sim with linear hydrodynamics, the
*.stl is only used for visualization.
However, when running WEC-Sim with non-linear hydrodynamics, the quality of the
*.stl mesh is critical, refer to the Non-Linear Hydrodynamics section for more information.
This section provides a description of the steps to run the WEC-Sim code, refer to the WEC-Sim workflow diagram while following the steps to run WEC-Sim.
Step 1: WEC-Sim Pre-Processing¶
In the pre-processing step, users need to create the WEC geometry, run a BEM code to calculate the hydrodynamic coefficients, and convert the hydrodynamic coefficients into the
*.h5 format for WEC-Sim to read:
- WEC Geometry: Create 3D models of the WEC geometry and generate a meshes for each body. Export the WEC geometry file to a
*.stlfiles are used to visualize the WEC response in Simscape Explorer, and they are used for Non-Linear Hydrodynamics.
- Hydrodynamic Data: WEC-Sim requires frequency-domain hydrodynamic coefficients (e.g. added mass, radiation damping, and wave excitation) in the form of a
*.h5file. The hydrodynamic coefficients for each body may be generated using a boundary element method (BEM) code and parsed into a
*.h5data structure using BEMIO. BEMIO was developed by the WEC-Sim team to parse BEM solutions from WAMIT, NEMOH and AQWA into the format required by WEC-Sim.
- WEC-Sim requires that all hydrodynamic coefficients must be given at the center of gravity for each body.
- If WAMIT is used, the center of gravity for each body must be at the origin of the body coordinate system (XBODY). More details on WAMIT setup are given in the WAMIT User Manual.
- Users are able to specify their own hydrodynamic coefficients by creating their own
*.h5file with customized hydrodynamic coefficients following
*.h5format created by BEMIO.
Step 3: Write WEC-Sim Input File¶
The WEC-Sim input file must be located in the
$CASE directory, and named
wecSimInputFile.m. The figure below shows an example of a WEC-Sim input file. The input file specifies the simulation settings, body mass properties, wave conditions, joints, and mooring. Additionally, the WEC-Sim input file must specify the location of the WEC-Sim Simulink model (
*.slx) file, the geometry file(s)
*.stl, and the hydrodynamic data file (
Step 4: Execute WEC-Sim¶
Lastly, execute the WEC-Sim code by typing
wecSim into the MATLAB Command Window.
The WEC-Sim source code is located in the
$Source directory, but
wecSim must be executed from the
WEC-Sim simulations should always be executed from the MATLAB Command Window, not from the Simulink/SimMechanics model.