Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subroutine solver(iaba,nnode,inode,coord,& nelem,ielem,inelem,kpn,kp,istat)
- implicit double precision (a-h,o-z)
- parameter (NN=10000)
- dimension inode(*),coord(2,*)
- dimension ielem(4,*),inelem(4,*)
- dimension kp(*)
- dimension t(NN),told(NN),f(NN),fold(NN)
- dimension x(2,4),x_g(2,4,nelem),nef(2,4)
- dimension am_e(4),hg_e(4),n_e(4),al_e(4)
- dimension cond(NN),conv(NN),hg(NN)
- dimension am(NN),al(NN),radi(NN)
- dimension ael(4,NN),stiff(4,4,NN)
- dimension ctime(4,11),crate(11),t_kp_max(NN)
- dimension ttmax(NN),cctime(11)
- real*8 time, time_new
- data ((nef(i,j),i=1,2),j=1,4)/1,2,2,3,3,4,4,1/
- REAL*8 XFE1,XPE1,xfe2,xpe2,fc1,pc1,bc1,fc2,pc2,bc2
- REAL*8 AC1_,AC3_1,TDISS1,AE4_1,AE3_1,AE1_1,TBS1,TMS1,as1_1& ,Tliquid1,Tsolid1
- real*8 AC1_2,AC3_2,TDISS2,AE4_2,AE3_2,AE1_2,TBS2,TMS2,as1_2& ,Tliquid2,Tsolid2
- dimension PEAK(NN),VR(NN),Tfaren(NN)
- REAL*8 XA(NN),XF(NN),XP(NN),XB(NN),XM(NN),GS(NN),G(NN),HV(NN)& ,XL(NN)
- INTEGER NMICRO, IMICRO
- REAL*8 TMICRO(NN), TIME_MICRO, TIME_PRINT
- REAL*8 TEMP_HIST(NN,10), TIMES(10), TEMP_4_CR1(NN), TEMP_4_CR2(NN)
- dimension nodeflag(nn)
- COMMON/TEMPS/AC1_1,AC3_1,TDISS1,AE4_1,AE3_1,AE1_1,TBS1,TMS1,as1_1& ,Tliquid1,Tsolid1
- COMMON/TEMPS2/AC1_2,AC3_2,TDISS2,AE4_2,AE3_2,AE1_2,TBS2,TMS2,as1_2& ,Tliquid2,Tsolid2
- COMMON/STRUCT/XA,XF,XP,XB,XM,GS,G,HV,XL
- COMMON/KCONST/fc1,pc1,bc1
- COMMON/KCONST2/fc2,pc2,bc2
- COMMON/BASELINE/XFE1,XPE1
- COMMON/BASELINE2/XFE2,XPE2
- include 'common.f'
- common/nodetype/nodeflag
- factor_t = 0.5
- itmax = 1000000 ! maximum number of iterations
- cnv = 0.050
- zero = 0.0d0
- one = 1.0d0
- three = 3.0d0
- pi = dacos(-1.0d0)
- if (iaba .eq. 1) then
- open(101,file='temp.dat')
- open(103,file='t-hist.dat')
- OPEN (104,FILE ='TEMP_PRINT.DAT')
- write(103,*) "time", 1,55,140,699
- endif
- call init(nelem,ielem,inelem, & nnode,t,told,f,fold)
- DO I = 1, NNODE
- COND(I) = 0.0D0
- CONV(I)= 0.0D0
- AM(I) = 0.0D0
- AL(I) = 0.0D0
- HG(I) = 0.0D0
- RADI(I) = 0.0D0
- END DO
- NMICRO = 50
- IMICRO = 0
- DO I = 1, NNODE
- TMICRO(I) = TOLD(I)
- END DO
- TIME_MICRO=0.0D0
- TIME_PRINT = 1.0D1
- IPRINT = 0
- call assemble(nnode,inode,coord,nelem,ielem,& inelem,ael,x_g,stiff)
- if (id_conf .gt. 0) then
- if (id_m(3) .eq. 1) then
- anc = 3.0
- elseif (id_m(3) .eq. 2) then
- anc = 5.0
- else
- anc = 4.0
- endif
- pmax = 2*heat_in*sqrt(three/pi)/area_w/((one+anc)*r_cc)
- incp = 1000
- weldtime = (1+anc)*r_cc/speed
- deltmx = 15.0
- write(6,2) 'Estimated maximum heating time =',weldtime,& 'seconds.'
- else
- deltmx = 5.0d0
- weldtime = 60.
- incp = 100
- endif
- do i=1,nnode
- ttmax(i) = t(i)
- enddo
- do i=1,kpn
- ctime(1,i) = zero
- ctime(2,i) = zero
- ctime(3,i) = zero
- ctime(4,i) = zero
- crate(i) = zero
- t_kp_max(i) = t(kp(i))
- enddo
- inc = 0 ! iteration count for printing out
- itc = 0 ! iteration count for the analysis
- time = 0.0d0
- hmesh = 1.0d8
- do i=1,nelem
- if ((ielem(2,i) .eq. 3) .or. (id_conf .eq. 0)) then
- x1 = coord(1,inelem(1,i))
- y1 = coord(2,inelem(1,i))
- x2 = coord(1,inelem(2,i))
- y2 = coord(2,inelem(2,i))
- x3 = coord(1,inelem(3,i))
- y3 = coord(2,inelem(3,i))
- x4 = coord(1,inelem(4,i))
- y4 = coord(2,inelem(4,i))
- dist1 = (x2-x1)**2 + (y2-y1)**2
- dist2 = (x3-x2)**2 + (y3-y2)**2
- dist3 = (x4-x3)**2 + (y4-y3)**2
- dist4 = (x1-x4)**2 + (y1-y4)**2
- hmesh = min(hmesh,dist1,dist2,dist3,dist4)
- endif
- enddo
- if (id_conf .eq. 0) then
- tk_w = tk(tcr1,id_m(1))
- cp_w = cp(tcr1,id_m(1))
- dens_w = dens(id_m(1))
- else
- t_weld = t0_p
- tk_w = tk(t_weld,id_m(3))
- cp_w = cp(t_weld,id_m(3))
- dens_w = dens(id_m(3))
- endif
- vmu = tk_w/dens_w/cp_w
- dtmax = 2.0D0*factor_t*hmesh/vmu
- dtmin = dtmax*1.0d-4
- write(6,2) 'Minumun element size =',hmesh,'mm'
- write(6,2) 'Maximum time increment =',dtmax,'sec'
- write(6,2) 'Minimum time increment =',dtmin,'sec'
- write(6,2) 'Analysis in progress!'
- write(6,'(1x,A,A)') ' TIME TEMP. CHANGE DTIME',& ' MAX. TEMP ITERATIONS'
- 2 format(1x,A,1x,G8.2,1x,A)
- dtime = 1.5d0*dtmax
- z_blayer_old = -500.0D0
- 100 inc = inc+1
- 200 z_blayer = -500.0D0
- itc = itc+1
- time_new = time + dtime ! trial time for this time increment
- do i=1,nnode
- am(i) = zero
- hg(i) = zero
- al(i) = zero
- cond(i) = zero
- conv(i) = zero
- radi(i) = zero
- enddo
- do 300 i=1,nelem
- id = ielem(2,i) ! material ID of the element
- do ii=1,4
- n_e(ii) = inelem(ii,i)
- enddo
- tavg = zero
- do ii=1,4
- tavg = tavg + 0.25d0*told(n_e(ii))
- enddo
- tk_e = tk(tavg,id_m(id))
- cp_e = cp(tavg,id_m(id))
- dens_e = dens(id_m(id))
- xcenter = zero
- ycenter = zero
- do jj=1,4
- do ii=1,2
- x(ii,jj) = coord(ii,n_e(jj))
- enddo
- xcenter = xcenter + 0.25d0*x(1,jj)
- ycenter = ycenter + 0.25d0*x(2,jj)
- enddo
- if ((id .eq. 3) .and. (time_new .le. weldtime)) then
- call dflux(power,time_new,anc,pmax,weldtime)
- else
- power = zero
- end if
- do ii=1,4
- hg_e(ii) = power*ael(ii,i)
- am_e(ii) = cp_e*dens_e*ael(ii,i)
- al_e(ii) = 0.5d0*ael(ii,i)*dens_e*hf(id_m(id)) & *(f(n_e(ii))-fold(n_e(ii)))/dtime
- enddo
- do ii=1,4
- sum = zero
- do jj=1,4
- sum = sum + tk_e*stiff(ii,jj,i)*told(n_e(jj))
- enddo
- cond(n_e(ii)) = cond(n_e(ii)) + sum
- enddo
- do ii=1,4
- am(n_e(ii)) = am(n_e(ii)) + am_e(ii)
- al(n_e(ii)) = al(n_e(ii)) + al_e(ii)
- hg(n_e(ii)) = hg(n_e(ii)) + hg_e(ii)
- enddo
- if (ielem(3,i) .eq. 1) then
- nface = ielem(4,i)
- n1 = nef(1,nface)
- n2 = nef(2,nface)
- x1 = x(1,n1)
- x2 = x(1,n2)
- y1 = x(2,n1)
- y2 = x(2,n2)
- xavg = (x1+x2)*0.5d0
- yavg = (y1+y2)*0.5d0
- t1 = told(n_e(n1))
- t2 = told(n_e(n2))
- tavg = 0.5*(t1+t2)
- flux = zero
- if (id_conf .eq. 0) then
- if ((ttmax(kp(1)) .lt. (tcr1+75.0d0))& .and. (xavg .le. 25.4d0)) then
- call sflux(flux,xavg)
- else
- call fflux(flux,tavg)
- endif
- else
- if (id .eq. 3) then
- if (time_new .gt. weldtime+5.0d0) then
- call fflux(flux,tavg)
- endif
- elseif (tavg .lt. ts(id_m(id))) then
- call fflux(flux,tavg)
- endif
- endif
- ds = sqrt((y2-y1)**2 + (x2-x1)**2)
- hloss = 0.5d0*ds*flux*xavg
- conv(n_e(n1)) = conv(n_e(n1))+hloss
- conv(n_e(n2)) = conv(n_e(n2))+hloss
- elseif (ielem(3,i) .eq. 2) then
- nface = ielem(4,i)
- n1 = nef(1,nface)
- n2 = nef(2,nface)
- x1 = x(1,n1)
- x2 = x(1,n2)
- y1 = x(2,n1)
- y2 = x(2,n2)
- xavg = (x1+x2)*0.5d0
- t1 = told(n_e(n1))
- t2 = told(n_e(n2))
- tavg = 0.5d0*(t1+t2)
- if (id_conf .eq. 2) then ! branch to pipe configuration
- zzz = (x1+x2)*0.5d0
- else
- zzz = (y1+y2)*0.5d0
- endif
- if (tavg .gt. (t0_f+1.0d0)) then
- z_blayer = dmax1(z_blayer,zzz)
- endif
- dist = z_blayer_old-zzz
- if (dist .le. 0.5d0) dist=1.0d8
- call h(dist,tavg,h_c,id_f)
- ds = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
- hloss = 0.5*ds*h_c*xavg*(tavg-t0_f)
- conv(n_e(n1)) = conv(n_e(n1)) + hloss
- conv(n_e(n2)) = conv(n_e(n2)) + hloss
- endif
- 300 continue
- delt = zero
- tmax = zero
- do i=1,nnode
- t(i) = told(i) + dtime*(hg(i)-cond(i)& -conv(i)-al(i))/am(i)
- delt = dmax1(delt,dabs(t(i)-told(i)))
- tmax = max(tmax,t(i))
- enddo
- if (delt .gt. max(deltmx,cnv*tmax)) then
- if (dtime .gt. dtmin) then
- dtime = 0.75d0*dtime
- if (dtime .lt. dtmin) dtime = dtmin
- goto 200
- else
- write(6,*) inc,time,dtime,tmax
- write(6,*) delt,max(deltmx,cnv*tmax)
- istat = 0
- goto 900
- endif
- endif
- do i=1,kpn
- ii = kp(i)
- if (t(ii) .gt. t_kp_max(i)) then
- t_kp_max(i) = t(ii)
- cycle
- endif
- if ((told(ii) .ge. tcr1) & .and. (t(ii) .lt. tcr1)& .and. (ctime(1,i) .lt. 1.0d-6)) then
- fac=(tcr1-told(ii))/(t(ii)-told(ii))
- ctime(1,i)=time+fac*dtime
- endif
- if ((ctime(1,i) .gt. 1.0d-6) & .and. (told(ii) .gt. tcr2)& .and. (t(ii) .le. tcr2)) then
- fac=(tcr2-told(ii))/(t(ii)-told(ii))
- ctime(2,i)=time+fac*dtime
- cctime(i)=ctime(2,i)-ctime(1,i)
- endif
- if ((told(ii) .ge. tcr3+5.d0) & .and. (t(ii) .lt. tcr3+5.d0)) then
- fac=(tcr3+5.d0-told(ii))/(t(ii)-told(ii))
- ctime(3,i)=time+fac*dtime
- endif
- if ((ctime(3,i) .gt. zero)& .and. (told(ii) .gt. tcr3-5.d0)& .and. (t(ii) .le. tcr3-5.d0)) then
- fac=(tcr3-5.d0-told(ii))/(t(ii)-told(ii))
- ctime(4,i)=time+fac*dtime
- crate(i)=10.d0/(ctime(4,i)-ctime(+3,i))
- endif
- if ((iaba .eq. 1)& .and. (i .eq. 1)) then
- write(101,3) time_new,t(ii),(told(ii)-t(ii))/dtime
- endif
- enddo
- 3 format(1x,ES11.4,',',2x,F8.2,2x,ES12.4)
- if ( oldmesher .gt. 0.5d0 ) then
- IMICRO = IMICRO + 1
- IF ( IMICRO .EQ. NMICRO ) THEN
- call MicrostructureTransition(TIME_MICRO,time_new, TMICRO,t& , peak, vr,nnode)
- IMICRO = 0
- DO I = 1, NNODE
- TMICRO(I) = T(I)
- END DO
- TIME_MICRO = TIME_NEW
- END IF
- end if
- IF ( IPRINT .EQ. 0 .AND. TIME .GT. TIME_PRINT) THEN
- IPRINT = 1
- DO I = 1, NNODE
- WRITE(104, 996) I, T(I)-told(i)
- END DO
- END IF
- deltaT = time_new - time
- time=time_new
- z_blayer_old=z_blayer
- do i=1,nnode
- told(i)=t(i)
- if (id_conf .ne. 0) then
- fnew=1.5d0*f(i)-0.5d0*fold(i)
- if (fnew .lt. 0.0d0) fnew=0.0d0
- if (fnew .gt. 1.0d0) fnew=1.0d0
- fold(i)=f(i)
- f(i)=tff(t(i),id_m(id))
- f(i)=(f(i)+fnew)*0.5d0
- endif
- ttmax(i)=max(ttmax(i),t(i)) ! maximum temp at this node
- enddo
- if (inc .eq. incp) then
- inc=0
- write(6,5) time,delt,dtime,tmax,itc, z_blayer_old
- write(12,5) time,delt,dtime,tmax,itc,z_blayer_old
- endif
- 5 format(F8.3,5x,ES10.4,2x,ES10.4,2x,ES10.4,5x,I10, F12.5)
- 995 format(1X, 6e12.7)
- write(103,995) time, t(1), t(55), t(140), t(699)
- 996 FORMAT(1X, I10, ",", E15.5)
- if (id_conf .eq. 0) then
- if ((t_kp_max(1) .lt. (tcr1+75.d0))& .or. (tmax .gt. tcr2-25.)) then
- dtime=min(dtime*1.15,dtmax)
- goto 100
- endif
- else
- if (time .lt. weldtime) goto 100
- if (tmax .gt. tcr2-100.) then
- dtime = min(dtime*1.15,dtmax)
- goto 100
- endif
- endif
- write(6,5) time,delt,dtime,tmax,itc
- write(12,5) time,delt,dtime,tmax,itc
- hdmax1 = 0.0d0
- hdmax2 = 0.0d0
- do i = 1, nnode
- if (nodeflag(i) .eq. 1) then
- if ( hv(i) .gt. hdmax1 ) hdmax1 = hv(i)
- end if
- if (nodeflag(i) .eq. 2) then
- if ( hv(i) .gt. hdmax2 ) hdmax2 = hv(i)
- end if
- end do
- if (id_conf .eq. 0) then
- call post2(iaba,kpn,cctime,crate,t_kp_max,kp)
- else
- if ( oldmesher .lt. 0.5d0 ) then
- call post1(iaba,kpn,cctime,crate,t_kp_max,kp)
- else
- call post3(iaba,kpn,cctime,crate,t_kp_max,kp,hdmax1,hdmax2)
- end if
- endif
- 900 if (iaba .eq. 1) then
- open(102,file='tmax.dat')
- do i=1,nnode
- write(102,25) i, ttmax(i)
- enddo
- close(102)
- open(20,file = 'hardness.txt')
- do i = 1,nnode
- write(20,26) i, coord(1,i), coord(2,i), peak(i), vr(i)& , hv(i)
- end do
- open(201,file = 'Tpeak.out')
- do i = 1,nnode
- write(201,27) i, peak(i)
- end do
- open(202,file = 'Vr.out')
- do i = 1,nnode
- write(202,27) i, vr(i)
- end do
- open(203,file = 'Hv.out')
- do i = 1,nnode
- write(203,27) i, hv(i)
- end do
- open(204,file = 'Tfaren.out')
- do i = 1,nnode
- Tfaren(i)=peak(i)*1.8+32
- write(204,27) i, Tfaren(i)
- end do
- endif
- 25 format (i8,', ', ES14.6)
- 26 FORMAT (1X, I10, 5F15.5)
- 27 format (i8,', ', F15.5)
- istat=1
- CLOSE (20)
- CLOSE (201)
- CLOSE (202)
- CLOSE (203)
- CLOSE (204)
- return
- end
- SUBROUTINE UPDATE_TEMPERATURE_HISTORY(TEMP_HIST,TIMES,T,TIME& ,NNODE)
- IMPLICIT REAL*8 (A-H,O-Z)
- parameter (NN=10000)
- REAL*8 TEMP_HIST(NN,*), T(NN), TIMES(*), TIME
- INTEGER IPOINTER, NNODE
- IPOINTER = 0
- DO I = 1, 8
- IF ( TIMES(I) .LT. 1.0D-12 ) THEN
- IPOINTER = I
- GOTO 100
- END IF
- END DO
- 100 CONTINUE
- IF ( IPOINTER .EQ. 0 ) IPOINTER = 8
- IF ( IPOINTER .LT. 8 ) THEN
- DO I = 1,NNODE
- TEMP_HIST(I,IPOINTER) = T(I)
- TIMES(IPOINTER) = TIME
- END DO
- ELSE
- DO J = 1,7
- DO I = 1,NNODE
- TEMP_HIST(I,J) = TEMP_HIST(I,J+1)
- TIMES(J) = TIMES(J+1)
- END DO
- END DO
- DO I =1, NNODE
- TEMP_HIST(I,8) = T(I)
- TIMES(8) = TIME
- END DO
- END IF
- IF ( IPOINTER .LT. 8 ) THEN
- DO I =1, NNODE
- TEMP_HIST(I,9) = T(I)
- TEMP_HIST(I,10) = T(I)
- END DO
- ELSE
- TSUM1 = 0.0D0
- TSUM2 = 0.0D0
- DO I = 1, 8
- TSUM1 = TSUM1 + TIMES(I)
- TSUM2 = TSUM2 + TIMES(I)*TIMES(I)
- END DO
- DO I =1, NNODE
- ASUM = 0.0D0
- BSUM = 0.0D0
- DO J = 1,8
- ASUM = ASUM + TEMP_HIST(I,J)
- BSUM = BSUM + TEMP_HIST(I,J)*TIMES(J)
- END DO
- COEFB = (BSUM-TSUM1*ASUM/8)/(TSUM2-TSUM1*TSUM1/8)
- COEFA = (ASUM-COEFB*TSUM1)/8.0D0
- TEMP_HIST(I,9) = COEFA + COEFB*TIMES(7)
- TEMP_HIST(I,10) = COEFA + COEFB*TIMES(8)
- END DO
- END IF
- RETURN
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement