Fortran Coder

查看: 2599|回复: 4
打印 上一主题 下一主题

[有限元] 在AQWA中添加Fortran subroutine user_force

[复制链接]

5

帖子

1

主题

0

精华

新人

F 币
22 元
贡献
11 点
跳转到指定楼层
楼主
发表于 2023-2-15 10:12:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
这个代码是我在ansys help里找到的例子,标红部分是自己写的,FORCE 函数是POSITION函数前后差值取绝对值的累加,但是在AQWA中计算出来的结果数据不对,正确的应该相邻前后两次的FORCE和POSITION的差值相等才对。
很急很急,可以有偿解决,希望有相关经验的大佬回复!!!!!谢谢谢谢!!


SUBROUTINE USER_FORCE(MODE,I_CONTROL,R_CONTROL,NSTRUC,TIME,TIMESTEP,STAGE, &
                       POSITION,VELOCITY,COG, &
                       FORCE,ADDMASS,ERRORFLAG)

!DECLARATION TO MAKE USER_FORCE PUBLIC WITH UN-MANGLED NAME

!DEC$ attributes dllexport , STDCALL , ALIAS : "USER_FORCE" :: user_force

!DEC$ ATTRIBUTES REFERENCE :: I_CONTROL, R_CONTROL
!DEC$ ATTRIBUTES REFERENCE :: POSITION, VELOCITY, COG, FORCE, ADDMASS
!DEC$ ATTRIBUTES REFERENCE :: MODE, NSTRUC, TIME, TIMESTEP, STAGE
!DEC$ ATTRIBUTES REFERENCE :: ERRORFLAG


IMPLICIT NONE

INTEGER MODE, NSTRUC, STAGE, ERRORFLAG, n
REAL TIME, TIMESTEP
INTEGER, DIMENSION (100) :: I_CONTROL
REAL, DIMENSION (100) :: R_CONTROL
REAL, DIMENSION (3,NSTRUC) :: COG
REAL, DIMENSION (6,NSTRUC) :: POSITION, VELOCITY, FORCE
REAL, DIMENSION (6,6,NSTRUC) :: ADDMASS


real :: dx=0.0, a1=0.0, x=0.0


IF (MODE.EQ.0) THEN
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

5

帖子

1

主题

0

精华

新人

F 币
22 元
贡献
11 点
沙发
 楼主| 发表于 2023-2-15 10:14:14 | 只看该作者
咋没显示全,我把剩余代码和仿真截图放这里

5

帖子

1

主题

0

精华

新人

F 币
22 元
贡献
11 点
板凳
 楼主| 发表于 2023-2-15 10:14:57 | 只看该作者
IF (MODE.EQ.0) THEN
        CONTINUE
       
ELSEIF (MODE.EQ.1) THEN
   
        dx = abs(POSITION(3,1) - x)
    a1 = a1 + dx
        x = POSITION(3,1)
        FORCE(3,1) = a1
       
       
        ADDMASS = 0
        ERRORFLAG = 0
       
       
ENDIF
RETURN

END SUBROUTINE USER_FORCE
       

!
! Input Parameter Description:
!
! MODE(Int)     - 0 = Initialisation. This routine is called once with mode 0
!                     before the simulation. All parameters are as described
!                     below except for STAGE, which is undefined. FORCES and
!                     ADDMASS are assumed undefined on exit.
!                     IERR if set to > 0 on exit will cause
!                     the simulation to stop.
!
!                 1 = Called during the simulation. FORCE/ADDMASS output expected.
!
!                99 = Termination. This routine is called once with mode 99
!                     at the end of the simulation.
!
! I_CONTROL(100)- User-defined integer control parameters input in .DAT file.
! R_CONTROL(100)- User-defined real control parameters input in .DAT file.
!
! NSTRUC(Int)   - Number of structures in the simulation
!
! TIME          - The current time (see STAGE below)
!
! TIMESTEP      - The timestep size (DT, see STAGE below)
!
! STAGE(Int)    - The stage of the integration scheme. AQWA time integration is
!                 based on a 2-stage predictor corrector method. This routine is
!                 therefore called twice at each timestep, once with STAGE=1 and
!                 once with STAGE=2. On stage 2 the position and velocity are
!                 predictions of the position and velocity at TIME+DT.
!                 e.g. if the initial time is 0.0 and the step 1.0 seconds then
!                 calls are as follows for the 1st 3 integration steps:
!
!                 CALL USER_FORCE(.....,TIME=0.0,TIMESTEP=1.0,STAGE=1 ...)
!                 CALL USER_FORCE(.....,TIME=0.0,TIMESTEP=1.0,STAGE=2 ...)
!                 CALL USER_FORCE(.....,TIME=1.0,TIMESTEP=1.0,STAGE=1 ...)
!                 CALL USER_FORCE(.....,TIME=1.0,TIMESTEP=1.0,STAGE=2 ...)
!                 CALL USER_FORCE(.....,TIME=2.0,TIMESTEP=1.0,STAGE=1 ...)
!                 CALL USER_FORCE(.....,TIME=2.0,TIMESTEP=1.0,STAGE=2 ...)
!
! COG(3,NSTRUC) - Position of the Centre of Gravity in the Definition axes.
!
! POSITION(6,NSTRUC) - Position of the structure in the FRA - angles in radians
!
! VELOCITY(6,NSTRUC) - Velocity of the structure in the FRA
!                      angular velocity in rad/s
!
!
! Output Parameter Description:
!
! FORCE(6,NSTRUC) - Force on the Centre of gravity of the structure. NB: these
!                   forces are applied in the Fixed Reference axis e.g.
!                   the surge(X) force is ALWAYS IN THE SAME DIRECTION i.e. in
!                   the direction of the X fixed reference axis.
!
! ADDMASS(6,6,NSTRUC)
!                 - Added mass matrix for each structure. As the value of the
!                   acceleration is dependent on FORCES, this matrix may be used
!                   to apply inertia type forces to the structure. This mass
!                   will be added to the total added mass of the structure at
!                   each timestep at each stage.
!
! ERRORFLAG       - Error flag. The program will abort at any time if this
!                   error flag is non-zero. The values of the error flag will
!                   be output in the abort message.

!------------------------------------------------------------------------
! MODE=0 - Initialise any summing variables/open/create files.
!          This mode is executed once before the simulation begins.
!------------------------------------------------------------------------


!------------------------------------------------------------------------
! MODE=1 - On-going - calculation of forces/mass
!------------------------------------------------------------------------


!------------------------------------------------------------------------
! MODE=99 - Termination - Output/print any summaries required/Close Files
!           This mode is executed once at the end of the simulation
!------------------------------------------------------------------------

      !ELSEIF (MODE.EQ.99) THEN
         
         
         
         


!------------------------------------------------------------------------
! MODE# ERROR - OUTPUT ERROR MESSAGE
!------------------------------------------------------------------------

5

帖子

1

主题

0

精华

新人

F 币
22 元
贡献
11 点
地板
 楼主| 发表于 2023-2-15 10:17:16 | 只看该作者
[img][/img]

5

帖子

1

主题

0

精华

新人

F 币
22 元
贡献
11 点
5#
 楼主| 发表于 2023-2-15 10:19:10 | 只看该作者

您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-12-25 17:21

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表