Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following code from fortran 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 do i=0,n1 call fcn(h,x0,xn) x0=xn t=t+h

Write the following code from fortran 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 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

Fortran code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

Explain how SIHRM is linked to different global business strategies

Answered: 1 week ago