Skip to content

Commit a18a614

Browse files
akeestekmruehl
andauthored
Body Library Refactoring (WEC-Sim#1474)
* break out body library into 4 files * remove nonhydro body library * remove body type variant subsystems * fix library formatting * update mask initialization commands * update forwarding table for old blocks * working flex and drag bodies * remove simulink GUI from flex body * remove extraneous RM3FromSimulink example * remove run from simulink test * move top level mask init functions to .m files * flex body - restore VH control link * fully remove runFromSimTest * update forwarding table, fix links aross flex body * fix F_rad extrapolation rate transition * updating library files * restructure body library again * refactor and readd run from simulink test * add bodyClass deprecation warning and update instructions for body.nonHydro~=0 * update use of body.nonhydro flag * update documentation on use of body.nonhydro * remove wecsim gui docs * remove wecsim gui functions * revert body library separation and remove nonhydro body * revert mask to m files * remove WS GUI from body library again * add drag body variant subsystem back in again * update body library reference in docs * remove WEC-Sim GUI from all library files * minor revs towards required doc and initializeWecSim updates * documentation fixes * clean up initializeWecSim for no WS GUI and streamlined run from Simulink * remove non-hydro body reference in rigid body mask * minor fix * remove docs note * return to test directory after runFromSimTest * fix body in Flex body CIC Outport naming * remove outdated compilation test, close sim models after each test * close simulink file after every regression test * minor formatting --------- Co-authored-by: Ruehl <kmruehl@sandia.gov>
1 parent af272a1 commit a18a614

51 files changed

Lines changed: 120 additions & 54572 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/developer/library.rst

Lines changed: 0 additions & 335 deletions
Large diffs are not rendered by default.

docs/user/advanced_features.rst

Lines changed: 35 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -62,50 +62,14 @@ or link to another software.
6262
Running from Simulink
6363
"""""""""""""""""""""
6464

65-
WEC-Sim can also be run directly from Simulink.
66-
The Run From Simulink advanced feature allows users to initialize WEC-Sim from the command window and then begin the simulation from Simulink.
67-
This allows greater compatibility with other models or hardware-in-the-loop simulations that must start in Simulink.
68-
The WEC-Sim library contains mask options that allow users to either:
69-
70-
1. Define an standard input file to use in WEC-Sim or
71-
2. Define custom parameters inside the block masks.
72-
73-
The Global Reference Frame mask controls whether an input file or custom
74-
parameters are used for WEC-Sim. Note that when the Custom Parameters options is
75-
selected, WEC-Sim will only use those variable in the block masks. Certain options
76-
become visible when the correct flag is set. For example, ``body.morisonElement.cd``
77-
will not be visible unless ``body.morisonElement.on > 0``. This method of running
78-
WEC-Sim may help some users visualize the interplay between the blocks and classes.
79-
For more information on how the blocks and classes are related, see the
80-
:ref:`user-code-structure` section.
81-
82-
To run WEC-Sim from Simulink, open the Simulink ``.slx`` file and choose whether to
83-
use an input file or custom parameters in the Global Reference Frame. Next type
84-
``initializeWecSim`` in the MATLAB Command Window. Then, run the model from the
85-
Simulink interface. Lastly, after the simulation has completed, type ``stopWecSim``
86-
in the MATLAB Command Window to run post-processing.
87-
88-
* Run from Simulink with a wecSimInputFile.m
89-
* Open the WEC-Sim Simulink file (``.slx``).
90-
* Set the Global Reference Frame to use an input file
91-
* Type ``initializeWecSim`` in the Command Window
92-
* Run the model from Simulink
93-
* Wait for the simulation to complete, then type ``stopWecSim`` in the Command Window
94-
* Run from Simulink with custom parameters
95-
* Open the Simulink file (``.slx``).
96-
* Set the Global Reference Frame to use custom parameters
97-
* (Optional) prefill parameters by loading an input file.
98-
* Edit custom parameters as desired
99-
* Type ``initializeWecSim`` in the Command Window
100-
* Run the model from Simulink
101-
* Wait for the simulation to complete, then type ``stopWecSim`` in the Command Window
102-
103-
After running WEC-Sim from Simulink with custom parameters, a
104-
``wecSimInputFile_simulinkCustomParameters.m`` file is written to the ``$CASE``
105-
directory. This file specifies all non-default WEC-Sim parameters used for the
106-
WEC-Sim simulation. This file serves as a record of how the case was run for
107-
future reference. It may be used in the same manner as other input files when
108-
renamed to ``wecSimInputFile.m``
65+
WEC-Sim can also be run directly from Simulink with the following steps:
66+
67+
* Type ``initializeWecSim`` in the Command Window
68+
* Run the model from Simulink and wait for the simulation to complete
69+
* Type ``stopWecSim`` in the Command Window
70+
71+
This allows users to initialize WEC-Sim from the command window and then start the simulation from Simulink,
72+
allowing for greater compatibility with other models or hardware-in-the-loop simulations.
10973

11074

11175
.. _user-advanced-features-mcr:
@@ -797,8 +761,8 @@ To enable second-order excitation forces in WEC-Sim, use the following flag in y
797761

798762
.. _user-advanced-features-non-hydro-body:
799763

800-
Non-Hydrodynamic Bodies
801-
^^^^^^^^^^^^^^^^^^^^^^^
764+
Drag Bodies
765+
^^^^^^^^^^^
802766

803767
For some simulations, it might be important to model bodies that do not have
804768
hydrodynamic forces acting on them. This could be bodies that are completely
@@ -807,52 +771,32 @@ or it could be bodies deeply submerged to the point where the hydrodynamics may
807771
be neglected. WEC-Sim allows for bodies which have no hydrodynamic forces
808772
acting on them and for which no BEM data is provided.
809773

810-
To do this, use a Body Block from the WEC-Sim Library and initialize it in the
774+
To do this, use the Drag Body block from the WECSim_Lib_Body_Drag Library and initialize it in the
811775
WEC-Sim input file as any other body but leave the name of the ``h5`` file as
812-
an empty string. Specify :code:`body(i).nonHydro = 1;` and specify body name,
776+
an empty string. Specify :code:`body(i).nonHydro;`, body name,
813777
mass, moments of inertia, center of gravity, center of buoyancy, geometry file,
814778
location, and displaced volume. You can also specify visualization options and
815779
initial displacement.
816780

817-
To use non-hydrodynamic bodies, the following body class variable must be
781+
To use drag bodies, the following body class variable must be
818782
defined in the WEC-Sim input file, for example::
819783

820-
body(i).nonHydro = 1
784+
body(i).nonHydro = 1; % or
785+
body(i).nonHydro = 2;
821786

822-
Non-hydrodynamic bodies require the following properties to be defined::
787+
Drag bodies require the following properties to be defined::
823788

824789
body(i).mass
825790
body(i).inertia
826791
body(i).centerGravity
827792
body(i).volume
828-
829-
In the case where only non-hydrodynamic and drag bodies are used, WEC-Sim does
830-
not read an ``*.h5`` file. Users must define these additional parameters to
831-
account for certain wave settings as there is no hydrodynamic body present in
832-
the simulation to define them::
833793

834-
waves.bem.range
835-
waves.waterDepth
836-
837-
838-
For more information, refer to :ref:`webinar2`, and the **Nonhydro_Body**
839-
example on the `WEC-Sim Applications
840-
<https://github.com/WEC-Sim/WEC-Sim_Applications>`_ repository.
841-
842-
Drag Bodies
843-
^^^^^^^^^^^
844-
845-
A body may be subjected to viscous drag or Morison forces, but does not
846-
experience significant wave excitation or radiation. And example may be a
794+
Drag bodies with no additional forces acting on them become non-hydrodynamic, no fluid forces act on them,
795+
but they still couple other bodies together, and influence the multibody simulation.
796+
If a drag body is not subject to wave excitation, but damping, added mass, or viscous drag are still a concern,
797+
viscous drag, linear damping, or Morison element forces may be defined. An example of this body type is a
847798
deeply-submerged heave plate of large surface area tethered to a float. In
848-
these instances, the drag body implementation can be utilized by defining the
849-
following body class variable::
850-
851-
body(i).nonHydro = 2
852-
853-
854-
Drag bodies have zero wave excitation or radiation forces, but viscous forces
855-
can be applied in the same manner as a hydrodynamic body via the parameters::
799+
these instances, the additional forces can be specified by the parameters:
856800

857801
body(i).quadDrag.drag
858802
body(i).quadDrag.cd
@@ -867,17 +811,22 @@ or if using Morison Elements::
867811
body(i).morisonElement.VME
868812
body(i).morisonElement.rgME
869813

870-
which are described in more detail in the forthcoming section. At a minimum, it
871-
is necessary to define::
872-
873-
body(i).mass
874-
body(i).inertia
875-
body(i).centerGravity
876-
body(i).volume
877-
878-
to resolve drag body dynamics. One can additionally describe initial body
814+
One can additionally describe initial body
879815
displacement in the manner of a hydrodynamic body.
880816

817+
In the case where only drag bodies are used, WEC-Sim does
818+
not read an ``*.h5`` file. Users must define these additional parameters to
819+
account for certain wave settings as there is no hydrodynamic body present in
820+
the simulation to define them::
821+
822+
waves.bem.range
823+
waves.waterDepth
824+
825+
For more information, refer to :ref:`webinar2`, and the **Nonhydro_Body**
826+
example on the `WEC-Sim Applications
827+
<https://github.com/WEC-Sim/WEC-Sim_Applications>`_ repository.
828+
829+
881830
.. _user-advanced-features-b2b:
882831

883832
Body-To-Body Interactions

docs/user/code_structure.rst

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -409,44 +409,33 @@ following lines in the WEC-Sim input file, where ``i`` is the body number and
409409
body(i)=bodyClass('<bemData>.h5')
410410
body(i).geometryFile = '<geomFile>.stl';
411411

412-
WEC-Sim bodies may be one of four types\: hydrodynamic, flexible,
413-
drag, or nonhydrodynamic. These types represent varying degrees of complexity
412+
WEC-Sim bodies may be one of three types\: hydrodynamic, drag, or flexible.
413+
These types represent varying degrees of complexity
414414
and require various input parameters and BEM data, detailed in the table below.
415415
The :ref:`user-advanced-features-body` section contains more details on these
416416
important distinctions.
417417

418-
.. TO DO: This table is not rendering properly
419-
420418
+-------------------------+---------------------------------------------+
421419
|**Body Type** |**Description** |
422420
+=========================+=============================================+
423421
|Hydrodynamic Body |``body(i)=bodyClass('<bemData>.h5')`` |
424422
| |``body(i).geometryFile = '<geomFile>.stl'`` |
425423
| |``body(i).mass`` |
426-
| |``body(i).intertia`` |
424+
| |``body(i).inertia`` |
427425
+-------------------------+---------------------------------------------+
428426
|Drag Body |``body(i)=bodyClass('')`` |
429427
| |``body(i).geometryFile = '<geomFile>.stl'`` |
430428
| |``body(i).mass`` |
431-
| |``body(i).intertia`` |
429+
| |``body(i).inertia`` |
432430
| |``body(i).centerGravity`` |
433431
| |``body(i).centerBuoyancy`` |
434432
| |``body(i).volume`` |
435433
| |``body(i).nonHydro=1`` |
436434
+-------------------------+---------------------------------------------+
437-
|Nonhydrodynamic Body |``body(i)=bodyClass('')`` |
438-
| |``body(i).geometryFile = '<geomFile>.stl'`` |
439-
| |``body(i).mass`` |
440-
| |``body(i).intertia`` |
441-
| |``body(i).centerGravity`` |
442-
| |``body(i).centerBuoyancy`` |
443-
| |``body(i).volume`` |
444-
| |``body(i).nonHydro=2`` |
445-
+-------------------------+---------------------------------------------+
446435
|Flexible Body |``body(i)=bodyClass('<bemData>.h5')`` |
447436
| |``body(i).geometryFile = '<geomFile>.stl'`` |
448437
| |``body(i).mass`` |
449-
| |``body(i).intertia`` |
438+
| |``body(i).inertia`` |
450439
+-------------------------+---------------------------------------------+
451440

452441
Users may specify other body class properties using the ``body`` object for
@@ -477,11 +466,10 @@ For more information about application of WEC-Sim's body class, refer to
477466
Body Blocks
478467
""""""""""""""
479468

480-
The Body Class is most closely associated with the Body Elements library.
481-
The Body Elements library shown below contains four body types in two blocks:
469+
The Body Elements library shown below contains two blocks:
482470
the ``Rigid Body`` block and the ``Flex Body`` block. The rigid body block is
483-
used to represent hydrodynamic, nonhydrodynamic, and drag bodies. Each type of
484-
rigid body is a `Variant Sub-system <https://www.mathworks.com/help/simulink/slref/variant-subsystems.html>`_.
471+
used to represent hydrodynamic and drag bodies, each subset being
472+
a `Variant Sub-system <https://www.mathworks.com/help/simulink/slref/variant-subsystems.html>`_ of a Rigid Body.
485473
Before simulation, one variant is activated by a flag in the body object
486474
(body.nonHydro=0,1,2). The flex body block is used to represent hydrodynamic
487475
bodies that contain additional flexible degrees of freedom ('generalized body
-27.7 KB
Binary file not shown.
-3.35 MB
Binary file not shown.

0 commit comments

Comments
 (0)