Skip to content

Commit 382828b

Browse files
jtgrasbakeeste
andauthored
Enable Variable Mass (WEC-Sim#1465)
* refactor radiation CIC calculation * add radiation conv integral surface calc for variable hydro * add CIC surface tests * increase time step to speed up cicTest.m * add cicTest to wecSimTest.m * update ci surface docstring * rename new function to camelCase * create IRF surfaces in the body class * minor clean up * add excitation IRF time to body.variableHydro * clarify where simu.cicDt is used * excitation convolution integral surface calc * add surface calcs and variant subsystems to library * update library tag * remove check preventing VH with userDefinedExcitation * add goto tags for excitation and total forces * fix goto tag name and turn off a warning * comment to explain why a warning is turned off * update excitation CI surface calc to use persistent amplitude * add test for excitationConvolutionIntegralSurface * fix issue template typo * add empty bodies.hydroForceIndex to responseClass * move the adjusted mass used in simulation to body.hydroForce * fix hydroForce.mass definition for all cases * clear persistent functions before simulation * progress on library * working but fundamentally incorrect excitation IRF surface * remove excitation IRF surface function * fix one more bug removing the excitation irf surface * library to r2020b * update post processing added mass force with VH * fix added mass force postprocessing again * docs - comment on added mass treatment with variable hydro * docs - explain IRF surface for variable hydro * update explanation of our handling of added mass * fix reference typo * add figures of an irf surface * updates to bodyClass * remove comments * initialize inertialMass * clarify gravity force in added mass dev docs * resolve some issues * update docs on use of mass vs adjustedMass * updates * Fix indexing * add inertia products option and warning message * amend warning * revise warning * remove extraneous moordyn readme * clarifying comment in docs * add docstring to body.variableHydro * expand warning message * add error to prevent variable hydro and elevationImport * disable nonlinear hydro and variable hydro * update docs and error message * typo * use hydroforce.mass for nonlinear hydro * Revert "use hydroforce.mass for nonlinear hydro" This reverts commit fa7ca47. * storage.mass to mass * fix typos --------- Co-authored-by: akeeste <akeeste@sandia.gov>
1 parent b504699 commit 382828b

6 files changed

Lines changed: 178 additions & 90 deletions

File tree

docs/_include/added_mass.rst

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ shown in the manipulation of the governing equation below:
1515

1616
.. math::
1717
18-
M\ddot{X_i} &= \Sigma F(t,\omega) - A\ddot{X_i} \\
19-
(M+A)\ddot{X_i} &= \Sigma F(t,\omega) \\
20-
M_{adjusted}\ddot{X_i} &= \Sigma F(t,\omega)
18+
M\ddot{X_i} &= \Sigma F(t,\omega) + m\overrightarrow{g} - A\ddot{X_i} \\
19+
(M+A)\ddot{X_i} &= \Sigma F(t,\omega) + m\overrightarrow{g} \\
20+
M_{adjusted}\ddot{X_i} &= \Sigma F(t,\omega) + m\overrightarrow{g}
2121
2222
where :math:`F_{am} = -A\ddot{X_i}` is the added mass component of the radiation force that is pulled out of the force summation for manipulation,
2323
:math:`M` is the mass matrix, :math:`A` is the single frequency or infinite frequency added mass, and subscript :math:`i` represents the timestep being solved for.
@@ -42,6 +42,10 @@ The core issue with this combined mass formulation is that Simscape Multibody, a
4242
For example, a rigid body can't have one mass for surge motion and another mass for heave motion.
4343
Simscape rigid bodies only have one translational mass, a 1x3 moment of inertia matrix, and 1x3 product of inertia matrix.
4444

45+
Note that the body mass used to define the gravitational force is not adjusted as gravity does not act on any added mass contributions.
46+
The gravity force will always depend on the unadjusted body mass.
47+
The gravity force is lumped with the sum of remaining forces in the rest of this section for simplicity.
48+
4549
WEC-Sim's Implementation
4650
^^^^^^^^^^^^^^^^^^^^^^^^^
4751

@@ -54,7 +58,7 @@ There is a 1-1 mapping between the body's inertia tensor and rotational added ma
5458
These added mass coefficients are entirely lumped with the body's inertia.
5559
Additionally, the surge-surge (1,1), sway-sway (2,2), heave-heave (3,3) added mass coefficients correspond to the translational mass of the body, but must be treated identically.
5660

57-
WEC-Sim implements this added mass treatment by adding a change in mass matrix ($$dM$$) to both sides of the equation, creating both a modified added mass matrix and a modified body mass matrix:
61+
WEC-Sim implements this added mass treatment by adding a change in mass matrix (:math:`dM`) to both sides of the equation, creating both a modified added mass matrix and a modified body mass matrix:
5862

5963
.. math::
6064
@@ -121,12 +125,7 @@ This will convert the algebraic loop equation of motion to a solvable one:
121125
M_{adjusted}\ddot{X_i} &= \Sigma F(t,\omega) - A_{adjusted}\ddot{X}_{i - (1 - 10^{-7}/dt)} \\
122126
123127
Body-to-body Interactions
124-
"""""""""""""""""""""""""""
125-
F = A * acc
126-
first dimension/index = down, 2nd = across
127-
non b2b: A = [6x6], acc = [6x1],
128-
b2b: A = [6x12], acc = [12x1] in order of body numbers regardless of the current body number
129-
128+
""""""""""""""""""""""""""
130129
The above implementation extends readily to the case where there are body interactions to account for.
131130
In this example, we assume there are two bodies with body interaction.
132131
Then the right hand side added mass and acceleration matrices above are (without generalized modes)
@@ -154,17 +153,45 @@ Working with the Added Mass Implementation
154153
WEC-Sim's added mass implementation should not affect a user's modeling workflow.
155154
WEC-Sim handles the manipulation and restoration of the mass and forces in the bodyClass functions ``bodyClass.adjustMassMatrix()`` called by ``initializeWecSim`` and ``bodyClass.restoreMassMatrix()``, ``bodyClass.storeForceAddedMass()`` called by ``postProcessWecSim``.
156155
However viewing ``body.hydroForce.hf*.fAddedMass`` between calls to ``initializeWecSim`` and ``postProcessWecSim`` will not show the values from the BEM dataset.
157-
Users can get the adjusted mass, moments of inertia, products of inertia, added mass coefficients, added mass force, and total force from
158-
``body.hydroForce.hf*.mass``, ``body.hydroForce.hf*.inertia``, ``body.hydroForce.hf*.inertiaProducts``, ``body.hydroForce.hf*.storage.hydroForce_fAddedMass``,
159-
``body.hydroForce.hf*.storage.output_forceAddedMass``, and ``body.hydroForce.hf*.storage.output_forceTotal`` respectively after the simulation.
160-
However, in the case that a user wants to view the added mass force *during* a simulation (typically during debugging),
156+
See the following table for the variables containing both unadjusted and adjusted parameters after the simulation:
157+
158+
.. list-table:: Nominal and adjusted mass parameters
159+
:widths: 25 37 37
160+
:header-rows: 1
161+
162+
* - Parameter
163+
- Nominal value
164+
- Adjusted value
165+
* - Mass
166+
- ``body.mass``, ``body.hydroForce.hf*.mass``, ``body.variableHydro.mass``
167+
- ``body.hydroForce.hf*.adjustedMass``
168+
* - Inertia
169+
- ``body.inertia``, ``body.variableHydro.inertia``
170+
- ``body.hydroForce.hf*.adjustedInertia``
171+
* - Inertia Products
172+
- ``body.inertiaProducts``, ``body.variableHydro.inertiaProducts``
173+
- ``body.hydroForce.hf*.adjustedInertiaProducts``
174+
* - Added mass coefficients
175+
- ``body.hydroForce.hf*.hydroForce_fAddedMass``
176+
- ``body.hydroForce.hf*.storage.hydroForce_fAddedMass``
177+
* - Added mass force timeseries
178+
- ``output.bodies(*).forceAddedMass``
179+
- ``body.hydroForce.hf*.storage.output_forceAddedMass``
180+
* - Total force timeseries
181+
- ``output.bodies(*).forceTotal``
182+
- ``body.hydroForce.hf*.storage.output_forceTotal``
183+
184+
The nominal (*unadjusted*) body mass is stored in ``body.hydroForce.hf*.mass``.
185+
This nominal value is retained during the simulation because it is required for the calculation of the gravitational force.
186+
However, in the case that a user wants to view the added mass force *during* a simulation (typically during debugging in a failed simulation),
161187
the change in mass, :math:`dM` above, must be taken into account.
162188
Refer to how ``body.calculateForceAddedMass()`` calculates the entire added mass force in WEC-Sim post-processing.
163189

164-
When using variable hydrodynamics, the added mass matrix can change with the varying state.
165-
However, the body mass matrix cannot vary.
166-
So, :math:`dM` is taken to be constant based on the hydrodynamic dataset specified by `body.variableHydro.hydroForceIndexInitial`.
167-
All added mass datasets within `body.hydroForce` are changed using this consistent definition of :math:`dM`.
190+
When using variable hydrodynamics, the added mass matrix and mass matrix can change with the varying state.
191+
In the above derivation, all values of :math:`dM`, mass matrix, inertia matrix, added mass force, and the resultant
192+
adjusted mass and added mass matrices are calculated for each hydrodynamic dataset.
193+
Note that varying any part of the body mass matrix with variable hydro requires using a special simscape block.
194+
Refer to the variable hydrodynamics applications.
168195

169196
.. Note::
170197
Depending on the wave formulation used, :math:`A` can either be a function of wave frequency :math:`A(\omega)`, or equal to the added mass at infinite wave frequency :math:`A_{\infty}`

docs/_include/variable_hydro.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ User defined logic and user selected signals determine
1818
when the state changes. The Variable Hydrodynamics feature does not determine
1919
a specific scenario, state, signal, or discretization required.
2020

21+
For a case which varies the mass of the body, the body library link in the Simulink
22+
model will need to be broken and the default File Solid : Body Properties block
23+
replaced with the General Variable Mass block. See the variable hydro WEC-Sim
24+
Application.
25+
2126
Example
2227
""""""""
2328

@@ -108,7 +113,7 @@ every body in a simulation. To implement variable hydrodynamics for a given body
108113
* FIR Filter radiation calculations
109114
* Generalized body modes
110115
* Non-hydrodynamic and drag bodies
111-
* Conditions that require a variable mass, center of gravity, or center of buoyancy
116+
* Nonlinear hydrodynamics is not compatible when using a case with variable mass.
112117

113118
Impulse Response Function with Variable Hydrodynamics
114119
"""""""""""""""""""""""""""""""""""""""""""""""""""""

docs/developer/advanced_features.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ structure:
5151

5252
* ``h5File``
5353
* Instead of initializing the body class with one string
54-
(one H5 file name), a cell array of strings can be passed, e.g.
55-
* body(1) = bodyClass({'H5FILE_1.h5','H5FILE_2.h5','H5FILE_3.h5');
54+
(one H5 file name), a cell array of strings can be passed, e.g
55+
``body(1) = bodyClass({'H5FILE_1.h5','H5FILE_2.h5','H5FILE_3.h5');``
5656
* ``hydroData``
5757
* Each H5 file is processed into a hydroData structure. All structs are
5858
concatenated into ``hydroData`` which is now an array of structures instead

source/functions/initializeWecSim.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@
372372
end; clear iW
373373
end
374374

375+
% Check for elevationImport with variable hydro
376+
for ii = 1:simu.numHydroBodies
377+
for iW = 1:length(waves)
378+
if strcmp(waves(iW).type,'elevationImport') && body(ii).variableHydro.option == 1
379+
error('Cannot run WEC-Sim with Variable Hydrodynamics (body(ii).variableHydro.option>0) and "elevationImport" wave type')
380+
end
381+
end; clear iW
382+
end
383+
375384
% Check for morisonElement inputs for body(ii).morisonElement.option == 1 || body(ii).morisonElement.option == 2
376385
for ii = 1:length(body(1,:))
377386
if body(ii).morisonElement.option == 1
@@ -562,7 +571,7 @@
562571
fprintf('\nSimulating the WEC device defined in the SimMechanics model %s... \n',simu.simMechanicsFile)
563572
% Modify some stuff for simulation
564573
for iBod = 1:simu.numHydroBodies
565-
body(iBod).adjustMassMatrix(simu.b2b);
574+
body(iBod).adjustMassMatrix(simu.b2b, simu.rho);
566575
end; clear iBod
567576

568577
% Create the buses for hydroForce
-1.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)