Am using Fortran to solve numerical equations using Euler and Runge-Kutta methods and need an expert opinion in the programme I did, can anyone help me plz??
the euler programme
PROGRAM membrane
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
OPEN(unit=5,file='memb.dat',status='unknown')
OPEN(unit=6,file='memb.res',status='unknown')
farad=96485.3383
gascon=8.3145
! convrg=1.0D-5
! PRINT*,' auto 1 other 0'
! read*,iauto
iauto = 1
IF(iauto.EQ.1)THEN
READ(5,*)nep
print*, nep
write(6,*) nep
READ(5,*)temp,umem
print*,temp,umem
write(6,*)temp,umem
DO i = 1,nep
DO j = 1,2
READ(5,*)vpm(i,j),diff(i,j),hidc(i,j),edon(i,j),con(i,j)
PRINT*,i,j,vpm(i,j),diff(i,j),hidc(i,j),edon(i,j),con(i,j)
WRITE(6,*)i,j,vpm(i,j),diff(i,j),hidc(i,j)
WRITE(6,*)i,j,edon(i,j),con(i,j)
END DO
vpm(i,1)=DABS(vpm(i,1))
vpm(i,2)=-DABS(vpm(i,2))
END DO
ELSE
Print*,' Where is the data??'
stop
END IF
node=2000
! thick = membrane thickness in micron
deex = 10.0
deex = deex*1.0D-6
xstep = deex/(DFLOAT(node))
print*,' '
print*,'**************************************************'
print*,' '
print*,' ALL UNITS ARE S.I. '
print*,' '
print*,'**************************************************'
print*,' '
! set initial conditions
pot(1) = 0.0
CALL euler
CALL output
STOP
END
SUBROUTINE EULER
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION conf,vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
DOUBLE PRECISION change,dipsidxn,dipsidxnol
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
dipsidxn = 0.0
DO i=2,node+1
change = 1.0
! set initial conditions
conf(1,1)=con(1,1)
conf(1,2)=con(1,2)
while(change.GT.0.001)DO
c(1,1)=con(1,1)*exp(-vpm(1,1)*farad*edon(1,1)/gascon/temp)
c(1,2)=con(1,2)*exp(-vpm(1,2)*farad*edon(1,2)/gascon/temp)
const1 = (umem/diff(1,1))*(hidc(1,1)*c(i-1,1)-conf(i-1,1))
const3 = (umem/diff(1,2))*(hidc(1,2)*c(i-1,2)-conf(i-1,2))
const2 = (vpm(1,1)*c(i-1,1)*farad/gascon/temp)*dipsidxn
const4 = (vpm(1,2)*c(i-1,2)*farad/gascon/temp)*dipsidxn
c(i,1) = c(i-1,1) + xstep*(const1-const2)
c(i,2) = c(i-1,2) + xstep*(const3-const4)
sum1 = 0.0
sum2 = 0.0
DO k=1,2
DO j=1,nep
const5 = vpm(j,k)*umem/diff(j,k)
const6 = hidc(j,k)*c(i-1,j)-conf(j,k)
sum1 = sum1 + const5*const6
sum2 = sum2+vpm(j,k)*vpm(j,k)*c(i-1,j)
END DO
END DO
sum2 = sum2*farad/gascon/temp
pot(i) = pot(i-1) + xstep*sum1/sum2
dipsidxn = sum1/sum2
change = Dabs((dipsidxn - dipsidxnol)/dipsidxn)
dipsidxnol = dipsidxn
cont5=(vpm(1,1)*c(i-1,1)*farad/gascon/temp)*(sum1/sum2)
cont6=hidc(1,1)*c(i-1,1)
cont7=diff(1,1)/umem
conf(i,1)=(cont6)-((((c(i,1)-c(i-1,1))/xstep)+(cont5))*cont7)
cont8=(vpm(1,2)*c(i-1,2)*farad/gascon/temp)*(sum1/sum2)
cont9=hidc(1,2)*c(i-1,2)
cont10=diff(1,2)/umem
conf(i,2)=(cont9)-((((c(i,2)-c(i-1,2))/xstep)+(cont8))*cont10)
IF(change.lt.0.001)then
print*, i,change
end if
END DO
END DO
RETURN
END
SUBROUTINE output
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION conf,vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
i = 1
write(6,10) i,c(1,1),c(1,2),pot(1),conf(1,1),conf(1,2)
DO i = 2,node+1
iz = i/40
ii = 40*iz
IF(i.eq.ii)THEN
print*, i,c(i,1),c(i,2),pot(i),conf(i,1),conf(i,2)
write(6,10) i,c(i,1),c(i,2),pot(i),conf(i,1),conf(i,2)
END IF
END DO
10 FORMAT(i6,5(5x,e13.5))
RETURN
END
the euler programme
PROGRAM membrane
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
OPEN(unit=5,file='memb.dat',status='unknown')
OPEN(unit=6,file='memb.res',status='unknown')
farad=96485.3383
gascon=8.3145
! convrg=1.0D-5
! PRINT*,' auto 1 other 0'
! read*,iauto
iauto = 1
IF(iauto.EQ.1)THEN
READ(5,*)nep
print*, nep
write(6,*) nep
READ(5,*)temp,umem
print*,temp,umem
write(6,*)temp,umem
DO i = 1,nep
DO j = 1,2
READ(5,*)vpm(i,j),diff(i,j),hidc(i,j),edon(i,j),con(i,j)
PRINT*,i,j,vpm(i,j),diff(i,j),hidc(i,j),edon(i,j),con(i,j)
WRITE(6,*)i,j,vpm(i,j),diff(i,j),hidc(i,j)
WRITE(6,*)i,j,edon(i,j),con(i,j)
END DO
vpm(i,1)=DABS(vpm(i,1))
vpm(i,2)=-DABS(vpm(i,2))
END DO
ELSE
Print*,' Where is the data??'
stop
END IF
node=2000
! thick = membrane thickness in micron
deex = 10.0
deex = deex*1.0D-6
xstep = deex/(DFLOAT(node))
print*,' '
print*,'**************************************************'
print*,' '
print*,' ALL UNITS ARE S.I. '
print*,' '
print*,'**************************************************'
print*,' '
! set initial conditions
pot(1) = 0.0
CALL euler
CALL output
STOP
END
SUBROUTINE EULER
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION conf,vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
DOUBLE PRECISION change,dipsidxn,dipsidxnol
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
dipsidxn = 0.0
DO i=2,node+1
change = 1.0
! set initial conditions
conf(1,1)=con(1,1)
conf(1,2)=con(1,2)
while(change.GT.0.001)DO
c(1,1)=con(1,1)*exp(-vpm(1,1)*farad*edon(1,1)/gascon/temp)
c(1,2)=con(1,2)*exp(-vpm(1,2)*farad*edon(1,2)/gascon/temp)
const1 = (umem/diff(1,1))*(hidc(1,1)*c(i-1,1)-conf(i-1,1))
const3 = (umem/diff(1,2))*(hidc(1,2)*c(i-1,2)-conf(i-1,2))
const2 = (vpm(1,1)*c(i-1,1)*farad/gascon/temp)*dipsidxn
const4 = (vpm(1,2)*c(i-1,2)*farad/gascon/temp)*dipsidxn
c(i,1) = c(i-1,1) + xstep*(const1-const2)
c(i,2) = c(i-1,2) + xstep*(const3-const4)
sum1 = 0.0
sum2 = 0.0
DO k=1,2
DO j=1,nep
const5 = vpm(j,k)*umem/diff(j,k)
const6 = hidc(j,k)*c(i-1,j)-conf(j,k)
sum1 = sum1 + const5*const6
sum2 = sum2+vpm(j,k)*vpm(j,k)*c(i-1,j)
END DO
END DO
sum2 = sum2*farad/gascon/temp
pot(i) = pot(i-1) + xstep*sum1/sum2
dipsidxn = sum1/sum2
change = Dabs((dipsidxn - dipsidxnol)/dipsidxn)
dipsidxnol = dipsidxn
cont5=(vpm(1,1)*c(i-1,1)*farad/gascon/temp)*(sum1/sum2)
cont6=hidc(1,1)*c(i-1,1)
cont7=diff(1,1)/umem
conf(i,1)=(cont6)-((((c(i,1)-c(i-1,1))/xstep)+(cont5))*cont7)
cont8=(vpm(1,2)*c(i-1,2)*farad/gascon/temp)*(sum1/sum2)
cont9=hidc(1,2)*c(i-1,2)
cont10=diff(1,2)/umem
conf(i,2)=(cont9)-((((c(i,2)-c(i-1,2))/xstep)+(cont8))*cont10)
IF(change.lt.0.001)then
print*, i,change
end if
END DO
END DO
RETURN
END
SUBROUTINE output
IMPLICIT REAL (A-H,O-Z)
DOUBLE PRECISION conf,vpm,diff,hidc,temp,umem,con,edon
DOUBLE PRECISION deex,xstep,farad,gascon
COMMON/aleph/vpm(10,2),diff(10,2),hidc(10,2),con(10,2),edon(10,2)
COMMON/a/c(20001,2),pot(20001),conf(20001,2)
COMMON/beth/farad,gascon,deex,umem,nep,xstep,temp,node
i = 1
write(6,10) i,c(1,1),c(1,2),pot(1),conf(1,1),conf(1,2)
DO i = 2,node+1
iz = i/40
ii = 40*iz
IF(i.eq.ii)THEN
print*, i,c(i,1),c(i,2),pot(i),conf(i,1),conf(i,2)
write(6,10) i,c(i,1),c(i,2),pot(i),conf(i,1),conf(i,2)
END IF
END DO
10 FORMAT(i6,5(5x,e13.5))
RETURN
END