Question: Pls, Covert the following Fortran code to Python : implicit real*8(a-h,o-z) external fcn,funzX1 common/par/pot,t h=1.d0 n=24 n1=int(n/h) x0=60.d0 t=0.d0 pot=0.d0 open(20,file='result.txt') write(20,*)t,x0 do i=0,n1 call

Pls, Covert the following Fortran code to Python :

implicit real*8(a-h,o-z) external fcn,funzX1 common/par/pot,t h=1.d0 n=24 n1=int(n/h) x0=60.d0 t=0.d0 pot=0.d0 open(20,file='result.txt') write(20,*)t,x0 do i=0,n1 call fcn(h,x0,xn) x0=xn t=t+h write(20,*)t,x0 end do end

subroutine fcn(h,x0,xn) implicit real*8(a-h,o-z) common/par/pot,t if (x0<59.d0) then pot=4320000.d0 xk1=funzX1(x0) xk2=funzX1(x0+0.5d0*xk1*h) xk3=funzX1(x0+0.5d0*xk2*h) xk4=funzX1(x0+xk3*h) xn=x0+(h/6.d0)*(xk1+2.d0*xk2+2.d0*xk3+xk4) go to 1 end if if (x0>61.d0) then pot=0.d0 xk1=funzX1(x0) xk2=funzX1(x0+0.5d0*xk1*h) xk3=funzX1(x0+0.5d0*xk2*h) xk4=funzX1(x0+xk3*h) xn=x0+(h/6.d0)*(xk1+2.d0*xk2+2.d0*xk3+xk4) go to 1 end if xk1=funzX1(x0) xk2=funzX1(x0+0.5d0*xk1*h) xk3=funzX1(x0+0.5d0*xk2*h) xk4=funzX1(x0+xk3*h) xn=x0+(h/6.d0)*(xk1+2.d0*xk2+2.d0*xk3+xk4) 1 return end

double precision function funzX1(x) implicit real*8(a-h,o-z) common/par/pot,t cp=4186.d0 ro=1.d0 U=12558.d0 S=1.2d0 tin=17.d0 ta=20.d0 V=80.d0 if (t.GE.0.d0 .AND. t.LT.7.d0) then Q=0.d0 end if if (t.GT.7.d0 .AND. t.LT.9.d0) then Q=70.d0 end if if (t.GT.9.d0 .AND. t.LT.14.d0) then Q=40.d0 end if if (t.GT.14.d0 .AND. t.LT.15.d0) then Q=30.d0 end if if (t.GT.15.d0 .AND. t.LT.19.d0) then Q=10.d0 end if if (t.GT.19.d0 .AND. t.LT.20.d0) then Q=50.d0 end if if (t.GT.20.d0 .AND. t.LT.24.d0) then Q=10.d0 end if funzX1=(Q/V)*(tin-x)-(U*S*(x-ta))/(V*ro*cp)+pot/(V*ro*cp) return end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!