找回密码
 注册
Simdroid-非首页
查看: 822|回复: 15

[F. 求解器/误差] 最简单的Newton-Raphson法求解程序

[复制链接]
发表于 2007-12-21 07:26:01 | 显示全部楼层 |阅读模式 来自 加拿大
Newton-Raphson法是有限元非线性分析的基础。
下面的这个FORTRAN程序是最简单的非线性求解演示,一个单自由度的非线性材料桁架用N-R法求解。
很有参考价值。

PROGRAM truss_box_1_2
! -------------------------------------------------------------------------
! Newton-Raphson solver for 1 d.o.f. nonlinear truss example
! Input:
!  d        = horizontal span
!  x_0      = initial height
!  area_0   = initial area
!  E        = Young's modulus
!  n_incr   = number of load increments
!  f_incr   = force increment
!  c_norm   = residual force convergence norm
!  m_iter   = max number of Newton-Raphson iterations
! -------------------------------------------------------------------------
IMPLICIT none
INTEGER,   PARAMETER :: D_P = kind (1.d0) ! machine portable
INTEGER,   PARAMETER :: n_incr = 5, m_iter = 20
REAL(D_P), PARAMETER :: d = 2.5d3, x_0 = 2.5d3, area_0 = 1.d2,     &
                         E = 5.d5, f_incr = 0.3d7, c_norm = 1.d-20, &
                         tolerence = TINY (1.d0)
INTEGER   :: incrm            ! current increment
INTEGER   :: n_iter           ! current N-R iteration number
REAL(D_P) :: force = 0.d0     ! current force
REAL(D_P) :: vertical         ! current vertical truss force
REAL(D_P) :: residual = 0.d0  ! current residual
REAL(D_P) :: r_norm           ! current norm of residual
REAL(D_P) :: length, length_0 ! current and initial length
REAL(D_P) :: stiff            ! current stiffness
REAL(D_P) :: stress           ! current stress
REAL(D_P) :: x, area          ! current height and area
REAL(D_P) :: volume           ! current volume
REAL(D_P) :: u                ! current displacement increment
!  initialize geometry and stiffness
  x = x_0 ; area = area_0
  length_0 = sqrt ( x **2 + d **2 )
  volume   = area_0 * length_0
  stiff    = (area / length_0) * E * (x / length_0 ) **2
!  start load increments
  DO incrm = 1, n_incr
    force    = force + f_incr
    residual = residual - f_incr
!  Newton-Raphson iteration
    r_norm = c_norm * 2 ; n_iter = 0  ! initialize
    DO WHILE ( (r_norm > c_norm) .and. &
               (n_iter < m_iter)       )
      n_iter = n_iter + 1
!     Find geometry increment
      u      = -residual / stiff      ! displacement increment
      x      = x + u                  ! update height
      length = sqrt ( x **2 + d **2 ) ! update length
      area   = volume / length        ! update area
      
!     Find stresses and residual forces
      stress   = E * log (length / length_0)  ! axial stress
      vertical = stress * area * x / length   ! vertical force
      residual = vertical - force
      r_norm   = abs (residual / force)
      print "('increment = ', i3, ' iteration = ', i3,     &
      &       ' residual = ', g10.4, ' x = ', g10.4,       &
      &       ' force = ', g10.4)", incrm, n_iter, r_norm, &
      &       x, force
!     Find stiffness and check stability
      stiff = (area/length) * (E - 2 * stress) * (x/length) **2 &
            + (stress * area / length)
      IF ( abs ( stiff) < tolerence )  THEN
        print *, 'Near zero stiffness'
        STOP     'Near zero stiffness'
      END IF ! unstable
    END DO ! Newton-Raphson iteration
  END DO ! incrm
END PROGRAM truss_box_1_2
!
! Running with parameters E = 5.d5, f_incr = 1.5d7, c_norm = 1.d-20:
! increment = 1 iteration = 1 residual = 0.2184     x = 4621. force = 0.1500E+08
! increment = 1 iteration = 2 residual = 0.4239E-01 x = 5540. force = 0.1500E+08
! increment = 1 iteration = 3 residual = 0.2973E-02 x = 5822. force = 0.1500E+08
! increment = 1 iteration = 4 residual = 0.1806E-04 x = 5844. force = 0.1500E+08
! increment = 1 iteration = 5 residual = 0.6780E-09 x = 5845. force = 0.1500E+08
! increment = 1 iteration = 6 residual = 0.1242E-15 x = 5845. force = 0.1500E+08
! increment = 1 iteration = 7 residual =  0.000     x = 5845. force = 0.1500E+08

[ 本帖最后由 molen 于 2007-12-21 07:28 编辑 ]
发表于 2010-6-15 13:52:56 | 显示全部楼层 来自 北京
Simdroid开发平台
什么语言哈?楼主还不如给各伪语言格式的更加的通用
回复 不支持

使用道具 举报

发表于 2010-6-26 19:36:08 | 显示全部楼层 来自 江苏南京
楼主你能用汉语给一点一点解释一下吗?十分感谢
回复 不支持

使用道具 举报

发表于 2010-6-26 20:01:41 | 显示全部楼层 来自 山东青岛
本帖最后由 苦雨孤鸿 于 2010-6-27 20:53 编辑

楼主一开始不就说了嘛 ,是Fortran的
回复 不支持

使用道具 举报

发表于 2010-6-30 18:51:42 | 显示全部楼层 来自 浙江杭州
3# jian4dan
楼主都把源程序给出了,还叫人家解释,有点过分了,有点Fortran基础的应该都能看懂的
回复 不支持

使用道具 举报

发表于 2010-7-1 04:48:07 | 显示全部楼层 来自 美国
quadratic convergence, NICE!
回复 不支持

使用道具 举报

发表于 2010-7-12 12:04:53 | 显示全部楼层 来自 天津
对自己编程进行非线性计算,彻底掌握Newton-Raphson方法大有裨益,顶版主提供的程序。要是能将弧长法以简单实例展示出来就更完美了!
回复 不支持

使用道具 举报

发表于 2010-7-15 13:04:11 | 显示全部楼层 来自 北京
fortran 语言呢,无需解释了吧,玩有限元的,这个必须的呀
回复 不支持

使用道具 举报

发表于 2010-7-19 23:15:21 | 显示全部楼层 来自 河北石家庄
FORTRAN语言不大懂,解释一下就好了
回复 不支持

使用道具 举报

发表于 2010-7-28 16:12:24 | 显示全部楼层 来自 大连理工大学
确实很有有参考价值
回复 不支持

使用道具 举报

发表于 2010-8-27 12:51:35 | 显示全部楼层 来自 上海
没有看出来是Fortran语言啊
回复 不支持

使用道具 举报

发表于 2010-8-28 14:42:11 | 显示全部楼层 来自 陕西西安
谢谢楼主分享,让我省事多了
回复 不支持

使用道具 举报

发表于 2010-8-30 22:45:22 | 显示全部楼层 来自 江苏南京
谢谢楼主分享
回复 不支持

使用道具 举报

发表于 2010-11-9 16:04:52 | 显示全部楼层 来自 哈尔滨工业大学一校区
是用Fortran编写的,多谢多谢
回复 不支持

使用道具 举报

发表于 2010-11-14 23:19:52 | 显示全部楼层 来自 广东深圳
看不懂,没有学过Fortran
回复 不支持

使用道具 举报

发表于 2012-3-16 18:10:37 | 显示全部楼层 来自 江苏南京
刚度表达式 看不懂啥意思
回复 不支持

使用道具 举报

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

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-6-8 17:18 , Processed in 0.047393 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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