Berikut merupakan Perhitungan Fortran Dengan mengguakan Logika Utama metode Newton Raphson untuk iterasinya,, Dan subrutinenya menggunakan metode Simpsons rule. Kasus yang diberikan adalah untuk menghitung konversi dari reaksi yang dijalankan di reactor batch yang bekerja adiabatic dengan berorder2 AB ra= - dCadt=kCa2 dengan k=A e-ErT
c Septiadhi Wirawan c Tugas Prokom 2 C 07/250925/TK/32472
integer ITER,itermax real*8 dx,tolx,x0,x1,tr,fnol,fp,fm common/simpsonrule/tr logical yadhi
Write(*,*)'silahkan input nilai x0(trial)' read (*,*)x0 write(*,*)'silahkan input nilai tr' read(*,*) tr Write(*,*)'
Septiadhi Wirawan'
Write(*,*)'
07/250925/TK/32472'
Write(*,*)'========================================== ============' Write(*,*)'
Tugas 2 Prokom'
Write(*,*)'
Mencari Konversi reaksi A ke B menggunakan '
Write(*,*)'
Metode Newton Rhapson Featuring Simpson Rule
'
Write(*,*)'========================================== ============' Write(*,*)' Iterasi
X
Fobjective'
Write(*,*)'========================================== ============'
dx=0.01 Itermax = 99 Iter = 0 Tolx = 0.0001
c Main Program Metode Newton-Rhapson yadhi=.false. while (.not.yadhi)do iter=iter+1 call hitungF (x0,Fnol) call hitungF (x0+dx,fp) calL hitungF (x0-dx,Fm) Faks= (fp-fm)/2/dx x1= x0-Fnol/Faks
if (abs(x1-x0).gt.tolx)then
x0=x1 else xnew=x1 yadhi=.true. iter=itermax+1 end if write(*,*)iter,x1,fnol,fp endwhile
if (x1.GT.1)then write (*,*)'' write(*,*)'Nilai tebakan xcoba tidak memenuhi fungsi' else write(*,*)'' write(*,*)'Konversi setelah t=10 menit adalah','"',xnew,'"' endif end
c Subroutine 1 Metode Simpson Rule subroutine hitungF (xf,F) real*8 xo,Ainteg,tr,zn,zo,znew,xnew,dx,xf,f common/simpsonrule/tr
N=40 xo=0
dx = (xf-xo)/(N) call hitungz(xo,zo) call hitungz(xf,zn) sum=0 do 90 i=1,N-1 xnew=xo+(i)*dx call hitungz(xnew,znew) if((-1)**i.LT.0)THEN z= 4*znew else z= 2*znew end if sum=sum+z 90 continue Sum = Sum+zo+zn Ainteg=sum*dx/3 F=tr-ainteg end
c Subroutine 2 subroutine hitungZ (xf,z) real*8 Cao,Ar,Er,rho,entalpi,cp,tnol,xf,z,k
Ar = 10**6 Er = 5500
Cp = 1 Rho = 1000 Cao = 2 entalpi = (-8000) Tnol = 363
T=Tnol-Cao*Xf*entalpi/rho/Cp k=Ar*exp(-er/t) z=1/k/cao/(1-xf)**2 end