!CLTの藤田1層検算(CCX)
! 弾塑性解析、半解析。
! 境界条件をぴったりに合わせるように変えた。
! 変位計の位置で変位を出力するように変えた。(載荷位置は手動で変えるべし)
implicit none
!#--入力
real    :: b1=3380.d-3    ! m   :x軸(橋軸)方向の長さ1(H形鋼の長さ)
real    :: b2=310.d-3     ! m   :x軸(橋軸)方向の長さ2(両あまり)
real    :: h=240.d-3      ! m   :全層の高さ(y軸)
real    :: ell1=860.d-3   ! m   :z軸(支間)方向の長さ1
real    :: ell2=60.d-3    ! m   :z軸(支間)方向の長さ2(ボルト~ゴム)
real    :: ell3=80.d-3    ! m   :z軸(支間)方向の長さ3(端~ボルト)
integer :: nsou=2         !     :層数
integer :: nx1=50         !     :x軸(橋軸)方向分割数1
integer :: nx2=3          !     :x軸(橋軸)方向分割数2
integer :: ny=12          !     :y軸(高さ)方向分割数
integer :: nz1=50         !     :z軸(支間)方向分割数1
integer :: nz2=3          !     :z軸(支間)方向分割数2
integer :: nz3=3          !     :z軸(支間)方向分割数3
real    :: p=1000.d-3/2   ! MN  :荷重/2
integer :: nstep=100      !     :出力ステップ数
real    :: saikax=200.d-3 ! m   :載荷板の幅(x)
real    :: saikaz=500.d-3 ! m   :載荷板の幅(z)
real    :: itix=2000.d-3  ! m   :橋軸方向(x)の載荷板中心位置
!real    :: itix=1000.d-3  ! m   :橋軸方向(x)の載荷板中心位置
real    :: itiz=0.d-3     ! m   :支間方向(z)の載荷板中心位置
real    :: exx=1.7d3      ! MPa :x軸(橋軸)方向のヤング率
real    :: eyy=5.0d3/25   ! MPa :y軸(高さ)方向のヤング率
real    :: ezz=3.5d3      ! MPa :z軸(支間)方向のヤング率
real    :: poizx=0.4d0    !     :ポアソン比
!---
real poixy,poixz,poiyx,poiyz,poizy,gxy,gxz,gyz
real :: x(1000000),y(1000000),z(1000000) !節点座標
integer :: mesh(1000000,8)               !要素と要素を構成する節点
real :: e66(6,6),b(3,3),dx1,dx2,dy,dz1,dz2,dz3,ts
integer i,j,k,l,nx,nz,nset,nyou,nsaika
!---ポアソン比
poizy=poizx
poixy=poizx*exx/ezz
poixz=poixy
poiyx=poizx*eyy/ezz
poiyz=poiyx
!---せん断弾性係数
gxy=5.0d3/15
gxz=gxy
gyz=gxy
!---要素長さ
dx1=b1/nx1
dx2=b2/nx2
dy=h/(ny*nsou)
dz1=ell1/nz1
dz2=ell2/nz2
dz3=ell3/nz3
nx=nx1+nx2*2
nz=nz1+nz2+nz3
!---節点座標の計算
nset=0
do k=0,nz1
   do j=0,ny*nsou
      do i=0,nx2
         nset=1+nset
         x(nset)=i*dx2
         y(nset)=j*dy
         z(nset)=k*dz1
      enddo
      do i=1,nx1
         nset=1+nset
         x(nset)=b2+i*dx1
         y(nset)=j*dy
         z(nset)=k*dz1
      enddo
      do i=1,nx2
         nset=1+nset
         x(nset)=b1+b2+i*dx2
         y(nset)=j*dy
         z(nset)=k*dz1
      enddo
   enddo
enddo
do k=1,nz2
   do j=0,ny*nsou
      do i=0,nx2
         nset=1+nset
         x(nset)=i*dx2
         y(nset)=j*dy
         z(nset)=ell1+k*dz2
      enddo
      do i=1,nx1
         nset=1+nset
         x(nset)=b2+i*dx1
         y(nset)=j*dy
         z(nset)=ell1+k*dz2
      enddo
      do i=1,nx2
         nset=1+nset
         x(nset)=b1+b2+i*dx2
         y(nset)=j*dy
         z(nset)=ell1+k*dz2
      enddo
   enddo
enddo
do k=1,nz3
   do j=0,ny*nsou
      do i=0,nx2
         nset=1+nset
         x(nset)=i*dx2
         y(nset)=j*dy
         z(nset)=ell1+ell2+k*dz3
      enddo
      do i=1,nx1
         nset=1+nset
         x(nset)=b2+i*dx1
         y(nset)=j*dy
         z(nset)=ell1+ell2+k*dz3
      enddo
      do i=1,nx2
         nset=1+nset
         x(nset)=b1+b2+i*dx2
         y(nset)=j*dy
         z(nset)=ell1+ell2+k*dz3
      enddo
   enddo
enddo
!---要素を構成する節点の計算
nyou=0
do k=0,nz-1
   do j=0,ny*nsou-1
      do i=1,nx
         nyou=1+nyou
         mesh(nyou,1)=i+j*(nx+1)+k*((nx+1)*(ny*nsou+1))
         mesh(nyou,2)=mesh(nyou,1)+(nx+1)
         mesh(nyou,3)=mesh(nyou,2)+(nx+1)*(ny*nsou+1)
         mesh(nyou,4)=mesh(nyou,1)+(nx+1)*(ny*nsou+1)
         mesh(nyou,5)=mesh(nyou,1)+1
         mesh(nyou,6)=mesh(nyou,5)+nx+1
         mesh(nyou,7)=mesh(nyou,6)+(nx+1)*(ny*nsou+1)
         mesh(nyou,8)=mesh(nyou,5)+(nx+1)*(ny*nsou+1)
      enddo
   enddo
enddo
!---節点座標の出力
print'("*NODE, NSET=Nall")'
do i=1,nset
   print'(i6,a,f9.6,a,f9.6,a,f9.6)',&
       &i,',',x(i),',',y(i),',',z(i)
end do
!---要素の出力
do k=0,nsou-1
   print'(A,i1)',"*ELEMENT, TYPE=C3D8, ELSET=E",k+1
   do j=0,nz-1
      do i=1,nx*ny
         l=i+j*(nx*ny*nsou)+k*(nx*ny)
         print'(i6,a,i6,a,i6,a,i6,a,i6,a,i6,a,i6,a,i6,a,i6)',&
             &l,',',&
             &mesh(l,1),',',&
             &mesh(l,2),',',&
             &mesh(l,3),',',&
             &mesh(l,4),',',&
             &mesh(l,5),',',&
             &mesh(l,6),',',&
             &mesh(l,7),',',&
             &mesh(l,8)
      enddo
   enddo
enddo
!#--境界条件の節点群
print'("*NSET,NSET=kotei1")'!H形鋼の全面
do i=nz1+1,nz+1
   do j=nx2+1,nx2+nx1+1
      l=(nx+1)*(ny*nsou+1)*i-(nx+1)+j
      print'(i6,a)',l
   end do
enddo
print'("*NSET,NSET=kotei2")'!H形鋼の半面
do i=nz1+1,nz1+nz2+1
   do j=nx2+1,nx2+nx1+1
      l=(nx+1)*(ny*nsou+1)*i-(nx+1)+j
      print'(i6,a)',l
   end do
enddo
print'("*NSET,NSET=kotei3")'!ボルトの線上
i=nz1+nz2+1
do j=nx2+1,nx2+nx1+1
   l=(nx+1)*(ny*nsou+1)*i-(nx+1)+j
   print'(i6,a)',l
end do
print'("*NSET,NSET=koteiz")'!z軸対称面
do i=1,nset
   if (z(i)>-dz1/2.and.z(i)<dz1/2) then
      print'(i6,a)',i
   endif
end do
!---載荷条件の節点群
print'("*NSET,NSET=saika")'
nsaika=0
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>itiz-saikaz/2-dz1/3.and.z(i)<itiz+saikaz/2+dz1/3.and.&
       &x(i)>itix-saikax/2-dx1/3.and.x(i)<itix+saikax/2+dx1/3) then
      nsaika=nsaika+1
      print'(i6,a)',i
   endif
end do
!#--変位計の節点群
print'("*NSET,NSET=hen1")'!変位計1
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>250.d-3-dx2/2.and.x(i)<250.d-3+dx2/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen2")'!変位計2
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>1000.d-3-dx1/2.and.x(i)<1000.d-3+dx1/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen3")'!変位計3
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>1750.d-3-dx1/2.and.x(i)<1750.d-3+dx1/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen7")'!変位計7
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>2000.d-3-dx1/2.and.x(i)<2000.d-3+dx1/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen4")'!変位計4
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>2250.d-3-dx1/2.and.x(i)<2250.d-3+dx1/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen5")'!変位計5
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>3000.d-3-dx1/2.and.x(i)<3000.d-3+dx1/2) then
      print'(i6,a)',i
   endif
end do
print'("*NSET,NSET=hen6")'!変位計6
do i=1,nset
   if (y(i)>-dy/3.and.y(i)<dy/3.and.&
       &z(i)>-dz1/2.and.z(i)<dz1/2.and.&
       &x(i)>3750.d-3-dx2/2.and.x(i)<3750.d-3+dx2/2) then
      print'(i6,a)',i
   endif
end do
!---境界条件
print'("*BOUNDARY")'
print'("kotei2,1,2")'
print'("koteiz,3")'!z軸対称面
!#--材料設定
print'("*MATERIAL,NAME=ELt")'!引張
print'("*ELASTIC,TYPE=ORTHO")'
call ortho(e66,exx,eyy,ezz,poixy,poixz,poiyz,gyz,&
& gxz,gxy,poiyx,poizx,poizy)
print'(f12.4,a,f12.4,a,f12.4,a,&
     &f12.4,a,f12.4,a,f12.4,a,f12.4,&
     & a ,f12.4,a)',&
     &e66(1,1),',',e66(1,2),',',e66(2,2),',',e66(1,3),','& 
     &,e66(2,3),',',e66(3,3),',',e66(6,6),',',e66(5,5),','
print'(f12.4)',e66(4,4)
print'("*PLASTIC")'
print'("54.88,0.0")'
print'("54.88,0.5")'
print'("*MATERIAL,NAME=ELc")'!圧縮
print'("*ELASTIC,TYPE=ORTHO")'
call ortho(e66,exx,eyy,ezz,poixy,poixz,poiyz,gyz,&
& gxz,gxy,poiyx,poizx,poizy)
print'(f12.4,a,f12.4,a,f12.4,a,&
     &f12.4,a,f12.4,a,f12.4,a,f12.4,&
     & a ,f12.4,a)',&
     &e66(1,1),',',e66(1,2),',',e66(2,2),',',e66(1,3),','& 
     &,e66(2,3),',',e66(3,3),',',e66(6,6),',',e66(5,5),','
print'(f12.4)',e66(4,4)
print'("*PLASTIC")'
print'("22.54,0.0")'
print'("27.44,0.5")'
!#--局所座標系の設定
print'("*ORIENTATION,NAME=OR1,SYSTEM=RECTANGULAR")'
print'("1.,0.,0.,0.,1.,0.")'!全体座標系と一致
print'("*ORIENTATION,NAME=OR2,SYSTEM=RECTANGULAR")'
print'("0.,0.,-1.,0.,1.,0.")'!y軸回りに90度回転
print'("*SOLID SECTION,ELSET=E1,MATERIAL=ELc,ORIENTATION=OR1")'
print'("*SOLID SECTION,ELSET=E2,MATERIAL=ELt,ORIENTATION=OR1")'
!print'("*SOLID SECTION,ELSET=E3,MATERIAL=EL1,ORIENTATION=OR1")'
!print'("*SOLID SECTION,ELSET=E4,MATERIAL=EL1,ORIENTATION=OR2")'
!print'("*SOLID SECTION,ELSET=E5,MATERIAL=EL1,ORIENTATION=OR2")'
!print'("*SOLID SECTION,ELSET=E6,MATERIAL=EL1,ORIENTATION=OR1")'
!print'("*SOLID SECTION,ELSET=E7,MATERIAL=EL1,ORIENTATION=OR2")'
!print'("*SOLID SECTION,ELSET=E8,MATERIAL=EL1,ORIENTATION=OR1")'
!---出力ステップ数
print'("*TIME POINTS,NAME=T1")'
do i=1,nstep
   ts=real(i)/nstep
   print'(f12.4,a)',ts,','
enddo
!---載荷条件
print'("*STEP")'
print'("*STATIC,SOLVER=SPOOLES")'
print'("*CLOAD")'
print'(A,a,i6,a,1pe13.5)','saika',',',2,',',p/nsaika
!print'("*FREQUENCY")'!固有値解析
!print'("10")'!振動モード
!#--datファイルの設定
print'("*NODE PRINT,NSET=hen1,TIMEPOINTS=T1")'!変位計1
print'("U")'
print'("*NODE PRINT,NSET=hen2,TIMEPOINTS=T1")'!変位計2
print'("U")'
print'("*NODE PRINT,NSET=hen3,TIMEPOINTS=T1")'!変位計3
print'("U")'
print'("*NODE PRINT,NSET=hen7,TIMEPOINTS=T1")'!変位計7
print'("U")'
print'("*NODE PRINT,NSET=hen4,TIMEPOINTS=T1")'!変位計4
print'("U")'
print'("*NODE PRINT,NSET=hen5,TIMEPOINTS=T1")'!変位計5
print'("U")'
print'("*NODE PRINT,NSET=hen6,TIMEPOINTS=T1")'!変位計6
print'("U")'
print'("*NODE PRINT,NSET=saika,TIMEPOINTS=T1")'!平均化したほうがいい？
print'("U")'
!print'("*EL PRINT,ELSET=")'
!print'("S")'
print'("*NODE FILE")'
print'("U")'
print'("*EL FILE")'
print'("S")'
print'("*END STEP")'
!
end

!-------- 直交異方性の定数を出すプログラム --------
subroutine ortho(e66,exx,eyy,ezz,poixy,poixz,poiyz,gyz,&
&gxz,gxy,poiyx,poizx,poizy)
implicit none
real :: e66(6,6),b(3,3)
real exx,eyy,ezz,poixy,poixz,poiyz,gyz,gxz,gxy,poiyx,poizx,poizy
real det
integer i,j
!implicit real*8(a-h,o-z)
! e66(6,6),b(3,3)
!応力－ひずみ行列：e66
!do i=1,6
!do j=1,6
!e66(i,j)=0.d0
!end do
!end do
e66=0.d0
e66(1,1)=1.d0/exx
e66(1,2)=-poixy/exx
e66(1,3)=-poixz/exx
e66(2,1)=-poiyx/eyy
e66(2,2)=1.d0/eyy
e66(2,3)=-poiyz/eyy
e66(3,1)=-poizx/ezz
e66(3,2)=-poizy/ezz
e66(3,3)=1.d0/ezz

!****** 逆行列を取って、応力－ひずみ行列に変換する******
det=e66(1,1)*e66(2,2)*e66(3,3)+e66(2,1)*e66(3,2)*e66(1,3)&
&+e66(3,1)*e66(1,2)*e66(2,3)-e66(2,1)*e66(1,2)*e66(3,3)&
&-e66(3,1)*e66(2,2)*e66(1,3)-e66(1,1)*e66(3,2)*e66(2,3)
b(1,1)=(-1.d0)**(1+1)*(e66(2,2)*e66(3,3)-e66(3,2)*e66(2,3))
b(1,2)=(-1.d0)**(1+2)*(e66(2,1)*e66(3,3)-e66(3,1)*e66(2,3))
b(1,3)=(-1.d0)**(1+3)*(e66(2,1)*e66(3,2)-e66(3,1)*e66(2,2))
b(2,1)=(-1.d0)**(2+1)*(e66(1,2)*e66(3,3)-e66(3,2)*e66(1,3))
b(2,2)=(-1.d0)**(2+2)*(e66(1,1)*e66(3,3)-e66(3,1)*e66(1,3))
b(2,3)=(-1.d0)**(2+3)*(e66(1,1)*e66(3,2)-e66(3,1)*e66(1,2))
b(3,1)=(-1.d0)**(3+1)*(e66(1,2)*e66(2,3)-e66(2,2)*e66(1,3))
b(3,2)=(-1.d0)**(3+2)*(e66(1,1)*e66(2,3)-e66(2,1)*e66(1,3))
b(3,3)=(-1.d0)**(3+3)*(e66(1,1)*e66(2,2)-e66(2,1)*e66(1,2))
do i=1,3
do j=1,3
e66(i,j)=b(j,i)/det
end do
end do
!****** せん断補正係数を入力 ******
!print*,'xy面のせん断弾性係数を入れて下さい'
!read*, gxy
e66(4,4)=gyz
!print*,'xz面のせん断弾性係数を入れて下さい'
!read*, gxz
e66(5,5)=gxz
!print*,'yz面のせん断弾性係数を入れて下さい'
!read*, gyz
e66(6,6)=gxy
return
end
