Skip to content

Commit 6bc8462

Browse files
authored
Merge pull request #2597 from luwang00/f/MD_Bdy_Ext_Ld_Dmpg
MD: User-specified external forces and translational damping for MoorDyn point, rod, and body objects
2 parents 2f7327b + f0cd845 commit 6bc8462

File tree

9 files changed

+490
-52
lines changed

9 files changed

+490
-52
lines changed

modules/moordyn/src/MoorDyn.f90

Lines changed: 208 additions & 15 deletions
Large diffs are not rendered by default.

modules/moordyn/src/MoorDyn_Body.f90

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ SUBROUTINE Body_Setup( Body, tempArray, p, ErrStat, ErrMsg)
7171
! set initial velocity to zero
7272
Body%v6 = 0.0_DbKi
7373

74+
! set external load to zero
75+
Body%FextG = 0.0_DbKi
76+
Body%FextL = 0.0_DbKi
77+
78+
! set external damping to zero
79+
Body%BlinG = 0.0_DbKi
80+
Body%BquadG = 0.0_DbKi
81+
Body%BlinL = 0.0_DbKi
82+
Body%BquadL = 0.0_DbKi
83+
7484
!also set number of attached rods and points to zero initially
7585
Body%nAttachedC = 0
7686
Body%nAttachedR = 0
@@ -428,6 +438,7 @@ SUBROUTINE Body_DoRHS(Body, m, p)
428438
!TYPE(MD_MiscVarType), INTENT(INOUT) :: m ! misc/optimization variables
429439

430440
INTEGER(IntKi) :: l ! index of attached lines
441+
INTEGER(IntKi) :: i ! Generic loop counter
431442

432443
Real(DbKi) :: Fgrav(3) ! body weight force
433444
Real(DbKi) :: body_rCGrotated(3) ! instantaneous vector from body ref point to CG
@@ -442,6 +453,8 @@ SUBROUTINE Body_DoRHS(Body, m, p)
442453
Real(DbKi) :: w(3) ! body angular velocity vector
443454
Real(DbKi) :: Fcentripetal(3) ! centripetal force
444455
Real(DbKi) :: Mcentripetal(3) ! centripetal moment
456+
Real(DbKi) :: v3L(3) ! Body translational velocity in the local body-fixed coordinate system
457+
Real(DbKi) :: FDL(3) ! Part of user-defined damping force defined in the local body-fixed coordinate system
445458

446459

447460
! Initialize variables
@@ -460,6 +473,20 @@ SUBROUTINE Body_DoRHS(Body, m, p)
460473
body_rCGrotated = MATMUL(Body%OrMat, Body%rCG) ! rotateVector3(body_rCG, OrMat, body_rCGrotated); ! relative vector to body CG in inertial orientation
461474
CALL translateForce3to6DOF(body_rCGrotated, Fgrav, Body%F6net) ! gravity forces and moments about body ref point given CG location
462475

476+
! Add user-defined external force and damping on body defined in the global earth-fixed coordinate system (assumed to be applied at the body ref point)
477+
Body%F6net(1:3) = Body%F6net(1:3) + Body%FextG
478+
do i = 1,3
479+
Body%F6net(i) = Body%F6net(i) - Body%BlinG(i) * Body%v6(i) - Body%BquadG(i) * ABS(Body%v6(i)) * Body%v6(i)
480+
end do
481+
482+
! Add user-defined external force and damping on body defined in the local body-fixed coordinate system (assumed to be applied at the body ref point)
483+
Body%F6net(1:3) = Body%F6net(1:3) + MATMUL( Body%OrMat, Body%FextL)
484+
v3L = MATMUL( TRANSPOSE(Body%OrMat), Body%v6(1:3) )
485+
do i = 1,3
486+
FDL(i) = - Body%BlinL(i) * v3L(i) - Body%BquadL(i) * ABS(v3L(i)) * v3L(i)
487+
end do
488+
Body%F6net(1:3) = Body%F6net(1:3) + MATMUL( Body%OrMat, FDL )
489+
463490
! Centripetal force and moment due to COM not being at body origin plus gyroscopic moment
464491
w = Body%v6(4:6)
465492
Fcentripetal = - MATMUL(Body%M(1:3,1:3), CROSS_PRODUCT(w, CROSS_PRODUCT(w, body_rCGrotated)))

modules/moordyn/src/MoorDyn_IO.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ SUBROUTINE MDIO_OpenOutput( MD_ProgDesc, p, m, InitOut, ErrStat, ErrMsg )
873873
! Open the output file, if necessary, and write the header
874874
!-------------------------------------------------------------------------------------------------
875875

876-
IF ( ALLOCATED( p%OutParam ) .AND. p%NumOuts > 0 ) THEN ! Output has been requested so let's open an output file
876+
IF ( ALLOCATED( p%OutParam ) .AND. p%NumOuts > 0 .AND. p%OutSwitch > 0) THEN ! Output has been requested so let's open an output file
877877

878878
! Open the file for output
879879
OutFileName = TRIM(p%RootName)//'.out'
@@ -1580,7 +1580,7 @@ SUBROUTINE MDIO_WriteOutputs( Time, p, m, y, ErrStat, ErrMsg )
15801580
end if
15811581
! What the above does is say if ((dtOut==0) || (t >= (floor((t-dtC)/dtOut) + 1.0)*dtOut)), continue to writing files
15821582

1583-
if ( p%NumOuts > 0_IntKi ) then
1583+
if ( p%NumOuts > 0_IntKi .and. p%MDUnOut > 0 ) then
15841584

15851585
! Write the output parameters to the file
15861586
Frmt = '(F10.4,'//TRIM(Int2LStr(p%NumOuts))//'(A1,ES15.7E2))' ! should evenutally use user specified format?

modules/moordyn/src/MoorDyn_Point.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ SUBROUTINE Point_DoRHS(Point, m, p)
279279
Point%M (J,J) = Point%M (J,J) + Point%pointV*p%rhoW*Point%pointCa; ! add added mass
280280

281281
END DO
282-
282+
283+
! Added user-defined external force and damping on point
284+
Point%Fnet = Point%Fnet + Point%Fext
285+
DO J = 1, 3
286+
Point%Fnet(J) = Point%Fnet(J) - Point%Blin(J) * Point%rd(J) - Point%Bquad(J) * ABS(Point%rd(J)) * Point%rd(J)
287+
END DO
288+
283289
! would this sub ever need to include the m*a inertial term? Is it ever called for coupled points? <<<
284290

285291
END SUBROUTINE Point_DoRHS

modules/moordyn/src/MoorDyn_Registry.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ typedef ^ ^ DbKi Cdn -
8686
typedef ^ ^ DbKi Cdt - - - "tangential drag coefficient"
8787
typedef ^ ^ DbKi CdEnd - - - "drag coefficient for rod end" "[-]"
8888
typedef ^ ^ DbKi CaEnd - - - "added mass coefficient for rod end" "[-]"
89-
typedef ^ ^ DbKi LinDamp - - - "Linear damping, transverse damping for body element" "[N/(m/s)/m]"
90-
typedef ^ ^ LOGICAL isLinDamp - - - "Linear damping, transverse damping for body element is used" "-"
9189

9290
# this is the Body type, which holds data for each body object
9391
typedef ^ MD_Body IntKi IdNum - - - "integer identifier of this Point"
@@ -116,6 +114,12 @@ typedef ^ ^ DbKi M {6}{6}
116114
typedef ^ ^ DbKi M0 {6}{6} - - "body 6-dof mass and inertia matrix in its own frame"
117115
typedef ^ ^ DbKi OrMat {3}{3} - - "DCM for body orientation"
118116
typedef ^ ^ DbKi rCG {3} - - "vector in body frame from ref point to CG (before rods etc..)"
117+
typedef ^ ^ DbKi FextG {3} - - "vector of user-defined external force on the body in the global frame" [N]
118+
typedef ^ ^ DbKi BlinG {3} - - "user-defined linear translational damping on the body in the global frame" [N/(m/s)]
119+
typedef ^ ^ DbKi BquadG {3} - - "user-defined quadratic translational damping on the body in the global frame" [N/(m/s)^2]
120+
typedef ^ ^ DbKi FextL {3} - - "vector of user-defined external force on the body in the local body-fixed frame" [N]
121+
typedef ^ ^ DbKi BlinL {3} - - "user-defined linear translational damping on the body in the local body-fixed frame" [N/(m/s)]
122+
typedef ^ ^ DbKi BquadL {3} - - "user-defined quadratic translational damping on the body in the local body-fixed frame" [N/(m/s)^2]
119123

120124
# this is the Point type, which holds data for each point object
121125
typedef ^ MD_Point IntKi IdNum - - - "integer identifier of this point"
@@ -141,6 +145,9 @@ typedef ^ ^ DbKi zeta -
141145
typedef ^ ^ DbKi PDyn {:} - - "water dynamic pressure at node" "[Pa]"
142146
typedef ^ ^ DbKi Fnet {3} - - "total force on node (excluding inertial loads)"
143147
typedef ^ ^ DbKi M {3}{3} - - "node mass matrix, from attached lines"
148+
typedef ^ ^ DbKi Fext {3} - - "vector of user-defined external force on the point always in the global frame" [N]
149+
typedef ^ ^ DbKi Blin {3} - - "user-defined linear translational damping on the point always in the global frame" [N/(m/s)]
150+
typedef ^ ^ DbKi Bquad {3} - - "user-defined quadratic translational damping on the point always in the global frame" [N/(m/s)^2]
144151

145152
# this is the Rod type, which holds data for each Rod object
146153
typedef ^ MD_Rod IntKi IdNum - - - "integer identifier of this Line"
@@ -167,8 +174,6 @@ typedef ^ ^ DbKi Cdn -
167174
typedef ^ ^ DbKi Cdt - - - "" "[-]"
168175
typedef ^ ^ DbKi CdEnd - - - "drag coefficient for rod end" "[-]"
169176
typedef ^ ^ DbKi CaEnd - - - "added mass coefficient for rod end" "[-]"
170-
typedef ^ ^ DbKi LinDamp - - - "Linear damping, transverse damping for rod element" "[N/(m/s)/m]"
171-
typedef ^ ^ LOGICAL isLinDamp - - - "Linear damping, transverse damping for rod element is used" "-"
172177
typedef ^ ^ DbKi time - - - "current time" "[s]"
173178
typedef ^ ^ DbKi roll - - - "roll relative to vertical" "[rad]"
174179
typedef ^ ^ DbKi pitch - - - "pitch relative to vertical" "[rad]"
@@ -190,6 +195,8 @@ typedef ^ ^ DbKi Dq {:}{:}
190195
typedef ^ ^ DbKi Ap {:}{:} - - "node added mass forcing (transverse)" "[N]"
191196
typedef ^ ^ DbKi Aq {:}{:} - - "node added mass forcing (axial)" "[N]"
192197
typedef ^ ^ DbKi B {:}{:} - - "node bottom contact force" "[N]"
198+
typedef ^ ^ DbKi Bp {:}{:} - - "transverse damping force" "[N]"
199+
typedef ^ ^ DbKi Bq {:}{:} - - "axial damping force" "[N]"
193200
typedef ^ ^ DbKi Fnet {:}{:} - - "total force on node" "[N]"
194201
typedef ^ ^ DbKi M {:}{:}{:} - - "node mass matrix" "[kg]"
195202
typedef ^ ^ DbKi FextA {3} - - "external forces from attached lines on/about end A " -
@@ -204,6 +211,10 @@ typedef ^ ^ DbKi Imat {3}{3}
204211
typedef ^ ^ DbKi OrMat {3}{3} - - "DCM for body orientation"
205212
typedef ^ ^ IntKi RodUnOut - - - "unit number of rod output file"
206213
typedef ^ ^ DbKi RodWrOutput {:} - - "one row of output data for this rod"
214+
typedef ^ ^ DbKi FextU {3} - - "vector of user-defined external force on the rod end A always in the local body-fixed frame" "[N]"
215+
typedef ^ ^ DbKi Blin {2} - - "linear damping, transverse damping for rod element always in the local body-fixed frame" "[N/(m/s)]"
216+
typedef ^ ^ DbKi Bquad {2} - - "quadratic damping, transverse damping for rod element always in the local body-fixed frame" "[N/(m/s)^2]"
217+
207218

208219

209220
# this is the Line type, which holds data for each line object
@@ -275,6 +286,13 @@ typedef ^ ^ DbKi EndMomentB {3}
275286
typedef ^ ^ IntKi LineUnOut - - - "unit number of line output file"
276287
typedef ^ ^ DbKi LineWrOutput {:} - - "one row of output data for this line"
277288

289+
# this is the ExtLd type, which holds data for each external load specification
290+
typedef ^ MD_ExtLd IntKi IdNum - - - "integer identifier of this external load entry"
291+
typedef ^ ^ DbKi Fext {3} - - "user-defined external force on the object" [N]
292+
typedef ^ ^ DbKi Blin {3} - - "user-defined linear translational damping on the object" [N/(m/s)]
293+
typedef ^ ^ DbKi Bquad {3} - - "user-defined quadratic translational damping on the object" [N/(m/s)^2]
294+
typedef ^ ^ LOGICAL isGlobal - - - "external forces and damping to be applied in the global frame of reference" -
295+
278296
# this is the Fail type, which holds data for possible line failure descriptors
279297
typedef ^ MD_Fail IntKi IdNum - - - "integer identifier of this failure" "-"
280298
typedef ^ ^ IntKi attachID - - - "ID of connection or Rod the lines are attached to" "-"
@@ -334,6 +352,7 @@ typedef ^ ^ MD_Body BodyList {:}
334352
typedef ^ ^ MD_Rod RodList {:} - - "array of rod objects" -
335353
typedef ^ ^ MD_Point PointList {:} - - "array of point objects" -
336354
typedef ^ ^ MD_Line LineList {:} - - "array of line objects" -
355+
typedef ^ ^ MD_ExtLd ExtLdList {:} - - "array of external load objects" -
337356
typedef ^ ^ MD_Fail FailList {:} - - "array of line objects" -
338357
typedef ^ ^ IntKi FreePointIs {:} - - "array of free point indices in PointList vector" ""
339358
typedef ^ ^ IntKi CpldPointIs {:}{:} - - "array of coupled/fairlead point indices in PointList vector" ""
@@ -372,6 +391,7 @@ typedef ^ ^ IntKi nPointsExtra - 0
372391
typedef ^ ^ IntKi nBodies - 0 - "number of Body objects" ""
373392
typedef ^ ^ IntKi nRods - 0 - "number of Rod objects" ""
374393
typedef ^ ^ IntKi nLines - 0 - "number of Line objects" ""
394+
typedef ^ ^ IntKi nExtLds - 0 - "number of external loads or damping" ""
375395
typedef ^ ^ IntKi nCtrlChans - 0 - "number of distinct control channels specified for use as inputs" ""
376396
typedef ^ ^ IntKi nFails - 0 - "number of failure conditions" ""
377397
typedef ^ ^ IntKi nFreeBodies - 0 - "" ""
@@ -410,6 +430,7 @@ typedef ^ ^ DbKi mc -
410430
typedef ^ ^ DbKi cv - - - "saturated damping coefficient" "(-)"
411431
typedef ^ ^ IntKi inertialF - 0 - "Indicates MoorDyn returning inertial moments for coupled 6DOF objects. 0: no, 1: yes, 2: yes with ramp to inertialF_rampT" -
412432
typedef ^ ^ R8Ki inertialF_rampT - 30 - "Ramp time for inertial forces" -
433+
typedef ^ ^ IntKi OutSwitch - 1 - "Switch to disable outputs when running with full OF. 0: no MD main outfile, 1: write MD main outfile" "(-)"
413434
# --- parameters for wave and current ---
414435
typedef ^ ^ IntKi nxWave - - - "number of x wave grid points" -
415436
typedef ^ ^ IntKi nyWave - - - "number of y wave grid points" -

0 commit comments

Comments
 (0)