Fortran Coder

查看: 11464|回复: 1
打印 上一主题 下一主题

[流程控制] 新人求帮助,热源模型参数循环加载问题

[复制链接]

2

帖子

2

主题

0

精华

新人

F 币
16 元
贡献
10 点
跳转到指定楼层
楼主
发表于 2014-10-8 15:41:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
2F 币
[Fortran] 纯文本查看 复制代码
TABLE : abc (Medium)
1 / FORTRAN
      FUNCTION F(X)
C
C   F = QC * V1 * V2 * V3 with
C   V1 = exp( -( YY-Y0-VY*TT )^2/AC^2 )
C   V2 = exp( -( XX-X0 )^2/B^2 )
C   V3 = exp( -( ZZ-Z0 )^2/C^2 )
C   if ( -YY + Y0 +VY*TT ) greater than 0
C     QC = QF et AC = AF
C   else
C     QC = QR et AC = AR
C
      DIMENSION X(4)
C
C Input
C
      XX = X(1)   ; X Coordinate
      YY = X(2)   ; Y Coordinate
      ZZ = X(3)   ; Z Coordinate
      TT = X(4)   ; Time
C
C Variables
C
      QF = 72.1725997925    ; Maximal front source intensity
      QR = 36.0862998962    ; Maximal rear  source intensity
      AF = 3    ; Gaussian parameter
      AR = 4    ; Gaussian parameter
      B  = 2    ; Gaussian parameter
      C  = 3    ; Gaussian parameter
      X0 = 0    ; X initial location of source center
      Y0 = 0    ; Y initial location of source center
      Z0 = 0   ; Z initial location of source center
      VY = 0   ; Source displacement velocity
      AY = 0    ; Angle of torch [deg.]
C
C Constant
C
      M1 = -1
      PIDEG = ATAN(1.)
      PIDEG = PIDEG / 45.
      AY = AY * PIDEG
C
C Transformation of global to local coordinates
C
      XD   = XX - X0
      YD   = VY * TT
      YD   = YD + Y0
      ZD   = ZZ - Z0
C
C Source rotation about Y axis 
C
      SA   = SIN( AY )
      SA   = - SA
      CA   = COS( AY )
      A1   = XD * CA
      A2   = ZD * SA
      XL   = A1 + A2
      YL   = YY - YD
      A1   = ZD * CA
      A2   = XD * SA
      ZL   = A1 - A2
C
C Condition computation, QC and AC initialisation
C
      COND = VY * YL
      IF (VY .EQ. 0.) COND = YL
      QC   = QR
      AC   = AR
      IF( COND .GT. 0. ) QC = QF
      IF( COND .GT. 0. ) AC = AF
C
C V1 computation
C
      A1   = YL * YL
      A2   = AC * AC
      A2   = A1 / A2
      A2   = M1 * A2
      V1   = EXP( A2 )
C
C V2 computation
C
      A1   = XL * XL
      A2   = B * B
      A2   = A1 / A2
      A2   = M1 * A2
      V2   = EXP( A2 )
C
C V3 computation
C
      A1   = ZL * ZL
      A2   = C * C
      A2   = A1 / A2
      A2   = M1 * A2
      V3   = EXP( A2 )
C
C F computation
C
      F    = QC * V1
      F    = F * V2
      F    = F * V3
C
      RETURN
      END
FIN TABLE


这是一个双椭球体热源模型,我是用来模焊接过程用的,C Variables下面的那些参数就是双椭球的参数,我想再弄另一组双椭球的参数,让这个程序在第一组参数下运行19ms,然后换到第二组参数下运行4ms,再换到第一组参数下运行19ms,一直循环下去,实现循环加载。

最佳答案

查看完整内容

大体上按照你的意思是这个样子,但是我不知道如何控制你的参数运行情况,实在不懂你们专业的东西。 请根据代码自行修改。 [mw_shl_code=fortran,true]Program www_fcode_cn Implicit None Real(8) :: x(4,2),y Integer :: iDo,i Real(8), External :: F ! ! 设置您的第一个参数 ! x(1,1) = ? x(2,1) = ? x(3,1) = ? x(4,1) = ? ! ! 设置您的第二个参数 ! x(1,2) = ? ...
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

136

帖子

3

主题

0

精华

版主

F 币
1964 元
贡献
1677 点

帅哥勋章管理勋章爱心勋章新人勋章热心勋章元老勋章

沙发
发表于 2014-10-8 15:41:49 | 只看该作者
本帖最后由 aliouying 于 2014-10-8 16:06 编辑

大体上按照你的意思是这个样子,但是我不知道如何控制你的参数运行情况,实在不懂你们专业的东西。
请根据代码自行修改。
[Fortran] 纯文本查看 复制代码
Program www_fcode_cn
    Implicit None
    Real(8) :: x(4,2),y
    Integer :: iDo,i
    Real(8), External   :: F
    !    ! 设置您的第一个参数
    !
    x(1,1) = ?
    x(2,1) = ?
    x(3,1) = ?
    x(4,1) = ?
    !
    ! 设置您的第二个参数
    !
    x(1,2) = ?
    x(2,2) = ?
    x(3,2) = ?
    x(4,2) = ?
    iDo = 0
    Do 
        iDo = iDo + 1
        Do i = 1 , 2
            y = F(X(:,i))
            write(*,*) '第',iDo,'次循环的第',i,'个参数计算结果为:',y
        EndDo
    EndDo  
End Program www_fcode_cn

FUNCTION F(X)
    Implicit None
    real(8), Intent(in) :: X(4)
    real(8) :: XX,YY,ZZ,TT
    real(8) :: QF,QR,AF,AR,B,C,X0,Y0,Z0,VY,AY
    Integer :: M1
    Real(8) :: PIDEG
    Real(8) :: XD,YD,ZD,SA,CA,A1,A2,XL,YL,ZL,F,V1,V2,V3,QC,AC,COND
!
!   F = QC * V1 * V2 * V3 with
!   V1 = exp( -( YY-Y0-VY*TT )^2/AC^2 )
!   V2 = exp( -( XX-X0 )^2/B^2 )
!   V3 = exp( -( ZZ-Z0 )^2/C^2 )
!   if ( -YY + Y0 +VY*TT ) greater than 0
!     QC = QF et AC = AF
!   else
!     QC = QR et AC = AR
!
!
! Input
!
      XX = X(1)   !; X Coordinate
      YY = X(2)   !; Y Coordinate
      ZZ = X(3)   !; Z Coordinate
      TT = X(4)   !; Time
!
! Variables
!
      QF = 72.1725997925    !; Maximal front source intensity
      QR = 36.0862998962    !; Maximal rear  source intensity
      AF = 3    !; Gaussian parameter
      AR = 4    !; Gaussian parameter
      B  = 2    !; Gaussian parameter
      C  = 3    !; Gaussian parameter
      X0 = 0    !; X initial location of source center
      Y0 = 0    !; Y initial location of source center
      Z0 = 0    ! Z initial location of source center
      VY = 0    !; Source displacement velocity
      AY = 0    !; Angle of torch [deg.]
!
! Constant
!
      M1 = -1
      PIDEG = ATAN(1.)
      PIDEG = PIDEG / 45.
      AY = AY * PIDEG
!
! Transformation of global to local coordinates
!
      XD   = XX - X0
      YD   = VY * TT
      YD   = YD + Y0
      ZD   = ZZ - Z0
!
! Source rotation about Y axis 
!
      SA   = SIN( AY )
      SA   = - SA
      CA   = COS( AY )
      A1   = XD * CA
      A2   = ZD * SA
      XL   = A1 + A2
      YL   = YY - YD
      A1   = ZD * CA
      A2   = XD * SA
      ZL   = A1 - A2
!
! Condition computation, QC and AC initialisation
!
      COND = VY * YL
      IF (VY .EQ. 0.) COND = YL
      QC   = QR
      AC   = AR
      IF( COND .GT. 0. ) QC = QF
      IF( COND .GT. 0. ) AC = AF
!
! V1 computation
!
      A1   = YL * YL
      A2   = AC * AC
      A2   = A1 / A2
      A2   = M1 * A2
      V1   = EXP( A2 )
!
! V2 computation
!
      A1   = XL * XL
      A2   = B * B
      A2   = A1 / A2
      A2   = M1 * A2
      V2   = EXP( A2 )
!
! V3 computation
!
      A1   = ZL * ZL
      A2   = C * C
      A2   = A1 / A2
      A2   = M1 * A2
      V3   = EXP( A2 )
!
! F computation
!
      F    = QC * V1
      F    = F * V2
      F    = F * V3
      RETURN
      END

评分

参与人数 1F 币 +22 贡献 +22 收起 理由
fcode + 22 + 22 很给力!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-23 22:18

Powered by Tencent X3.4

© 2013-2024 Tencent

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