Skip to content

Commit

Permalink
Merge pull request #2597 from luwang00/f/MD_Bdy_Ext_Ld_Dmpg
Browse files Browse the repository at this point in the history
MD: User-specified external forces and translational damping for MoorDyn point, rod, and body objects
  • Loading branch information
andrew-platt authored Jan 30, 2025
2 parents 2f7327b + f0cd845 commit 6bc8462
Show file tree
Hide file tree
Showing 9 changed files with 490 additions and 52 deletions.
223 changes: 208 additions & 15 deletions modules/moordyn/src/MoorDyn.f90

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions modules/moordyn/src/MoorDyn_Body.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ SUBROUTINE Body_Setup( Body, tempArray, p, ErrStat, ErrMsg)
! set initial velocity to zero
Body%v6 = 0.0_DbKi

! set external load to zero
Body%FextG = 0.0_DbKi
Body%FextL = 0.0_DbKi

! set external damping to zero
Body%BlinG = 0.0_DbKi
Body%BquadG = 0.0_DbKi
Body%BlinL = 0.0_DbKi
Body%BquadL = 0.0_DbKi

!also set number of attached rods and points to zero initially
Body%nAttachedC = 0
Body%nAttachedR = 0
Expand Down Expand Up @@ -428,6 +438,7 @@ SUBROUTINE Body_DoRHS(Body, m, p)
!TYPE(MD_MiscVarType), INTENT(INOUT) :: m ! misc/optimization variables

INTEGER(IntKi) :: l ! index of attached lines
INTEGER(IntKi) :: i ! Generic loop counter

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


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

! 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)
Body%F6net(1:3) = Body%F6net(1:3) + Body%FextG
do i = 1,3
Body%F6net(i) = Body%F6net(i) - Body%BlinG(i) * Body%v6(i) - Body%BquadG(i) * ABS(Body%v6(i)) * Body%v6(i)
end do

! 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)
Body%F6net(1:3) = Body%F6net(1:3) + MATMUL( Body%OrMat, Body%FextL)
v3L = MATMUL( TRANSPOSE(Body%OrMat), Body%v6(1:3) )
do i = 1,3
FDL(i) = - Body%BlinL(i) * v3L(i) - Body%BquadL(i) * ABS(v3L(i)) * v3L(i)
end do
Body%F6net(1:3) = Body%F6net(1:3) + MATMUL( Body%OrMat, FDL )

! Centripetal force and moment due to COM not being at body origin plus gyroscopic moment
w = Body%v6(4:6)
Fcentripetal = - MATMUL(Body%M(1:3,1:3), CROSS_PRODUCT(w, CROSS_PRODUCT(w, body_rCGrotated)))
Expand Down
4 changes: 2 additions & 2 deletions modules/moordyn/src/MoorDyn_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ SUBROUTINE MDIO_OpenOutput( MD_ProgDesc, p, m, InitOut, ErrStat, ErrMsg )
! Open the output file, if necessary, and write the header
!-------------------------------------------------------------------------------------------------

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

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

if ( p%NumOuts > 0_IntKi ) then
if ( p%NumOuts > 0_IntKi .and. p%MDUnOut > 0 ) then

! Write the output parameters to the file
Frmt = '(F10.4,'//TRIM(Int2LStr(p%NumOuts))//'(A1,ES15.7E2))' ! should evenutally use user specified format?
Expand Down
8 changes: 7 additions & 1 deletion modules/moordyn/src/MoorDyn_Point.f90
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ SUBROUTINE Point_DoRHS(Point, m, p)
Point%M (J,J) = Point%M (J,J) + Point%pointV*p%rhoW*Point%pointCa; ! add added mass

END DO


! Added user-defined external force and damping on point
Point%Fnet = Point%Fnet + Point%Fext
DO J = 1, 3
Point%Fnet(J) = Point%Fnet(J) - Point%Blin(J) * Point%rd(J) - Point%Bquad(J) * ABS(Point%rd(J)) * Point%rd(J)
END DO

! would this sub ever need to include the m*a inertial term? Is it ever called for coupled points? <<<

END SUBROUTINE Point_DoRHS
Expand Down
29 changes: 25 additions & 4 deletions modules/moordyn/src/MoorDyn_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ typedef ^ ^ DbKi Cdn -
typedef ^ ^ DbKi Cdt - - - "tangential drag coefficient"
typedef ^ ^ DbKi CdEnd - - - "drag coefficient for rod end" "[-]"
typedef ^ ^ DbKi CaEnd - - - "added mass coefficient for rod end" "[-]"
typedef ^ ^ DbKi LinDamp - - - "Linear damping, transverse damping for body element" "[N/(m/s)/m]"
typedef ^ ^ LOGICAL isLinDamp - - - "Linear damping, transverse damping for body element is used" "-"

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

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

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



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

# this is the ExtLd type, which holds data for each external load specification
typedef ^ MD_ExtLd IntKi IdNum - - - "integer identifier of this external load entry"
typedef ^ ^ DbKi Fext {3} - - "user-defined external force on the object" [N]
typedef ^ ^ DbKi Blin {3} - - "user-defined linear translational damping on the object" [N/(m/s)]
typedef ^ ^ DbKi Bquad {3} - - "user-defined quadratic translational damping on the object" [N/(m/s)^2]
typedef ^ ^ LOGICAL isGlobal - - - "external forces and damping to be applied in the global frame of reference" -

# this is the Fail type, which holds data for possible line failure descriptors
typedef ^ MD_Fail IntKi IdNum - - - "integer identifier of this failure" "-"
typedef ^ ^ IntKi attachID - - - "ID of connection or Rod the lines are attached to" "-"
Expand Down Expand Up @@ -334,6 +352,7 @@ typedef ^ ^ MD_Body BodyList {:}
typedef ^ ^ MD_Rod RodList {:} - - "array of rod objects" -
typedef ^ ^ MD_Point PointList {:} - - "array of point objects" -
typedef ^ ^ MD_Line LineList {:} - - "array of line objects" -
typedef ^ ^ MD_ExtLd ExtLdList {:} - - "array of external load objects" -
typedef ^ ^ MD_Fail FailList {:} - - "array of line objects" -
typedef ^ ^ IntKi FreePointIs {:} - - "array of free point indices in PointList vector" ""
typedef ^ ^ IntKi CpldPointIs {:}{:} - - "array of coupled/fairlead point indices in PointList vector" ""
Expand Down Expand Up @@ -372,6 +391,7 @@ typedef ^ ^ IntKi nPointsExtra - 0
typedef ^ ^ IntKi nBodies - 0 - "number of Body objects" ""
typedef ^ ^ IntKi nRods - 0 - "number of Rod objects" ""
typedef ^ ^ IntKi nLines - 0 - "number of Line objects" ""
typedef ^ ^ IntKi nExtLds - 0 - "number of external loads or damping" ""
typedef ^ ^ IntKi nCtrlChans - 0 - "number of distinct control channels specified for use as inputs" ""
typedef ^ ^ IntKi nFails - 0 - "number of failure conditions" ""
typedef ^ ^ IntKi nFreeBodies - 0 - "" ""
Expand Down Expand Up @@ -410,6 +430,7 @@ typedef ^ ^ DbKi mc -
typedef ^ ^ DbKi cv - - - "saturated damping coefficient" "(-)"
typedef ^ ^ IntKi inertialF - 0 - "Indicates MoorDyn returning inertial moments for coupled 6DOF objects. 0: no, 1: yes, 2: yes with ramp to inertialF_rampT" -
typedef ^ ^ R8Ki inertialF_rampT - 30 - "Ramp time for inertial forces" -
typedef ^ ^ IntKi OutSwitch - 1 - "Switch to disable outputs when running with full OF. 0: no MD main outfile, 1: write MD main outfile" "(-)"
# --- parameters for wave and current ---
typedef ^ ^ IntKi nxWave - - - "number of x wave grid points" -
typedef ^ ^ IntKi nyWave - - - "number of y wave grid points" -
Expand Down
Loading

0 comments on commit 6bc8462

Please sign in to comment.