Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the below code, the print statement said invalid syntax and I have attached a screenshot can you help me fix it please? CODE:- def

For the below code, the print statement said "invalid syntax" and I have attached a screenshot can you help me fix it please? image text in transcribed CODE:-  def van_Der_Waals_fn(V): """The van Der Waals equation, written in cubic form in the molar volume""" global p, T, a, b, R val = p*V**3 - (p*b + R*T)*V**2 + a*V - a*b return val def d_dV_van_Der_Waals_fn(V): """Derivative of the van-Der_Waals Equation With respect to V""" global p, T, a, b, R return (a + p*(3*V**2 - 2*b*V) - 2*R*T*V) def criticalTemprature(): """Will return the critical temprature callcuated as (8*a)/(27*R*b)""" global p, T, a, b, R return (8*a)/(27*R*b) def criticalPressure(): """Will return the critical pressure callcuated as a/27b^2""" global p, T, a, b, R return a/(27*b**2) def NewtonRaphson(initial, test_fn, d_dx_test_fn, depth, eps=1.0e-06, depth_limit = 150): """Newton-Raphson method to find roots of a polynomial equation. This implementation includes a convergence test (comparison to the parameter eps) as well as a non-convergence check (check to see if the recursion depth has reached a limit). What is returned from this func tion is the current version of the root as well as the current recursion depth. If the recursion depth equals the recursion depth check, then the recursion terminates and returns the current version of the root. Note that if this is the case, then the returned root should be treated with suspicion, since NR is a quadratically convervent method and thus the inability of NR to find a root indicates (for this problem) an ill-formed implementation, or, that the user has chosen p and T outside the vapor-liquid equilibrium portion of the phase diagram. OR... THE USER HAS IMPLEMENTED THE VAN DER WAALS EQUATION AND/OR ITS DERIVATIVE INCORRECTLY!!""" if (depth == depth_limit): #print "Here " + str(depth) + " initial is " + str(initial) return [initial, depth] if(abs(test_fn/d_dx_test_fn)   initial initial- test_fn/d_dx_test_fn #print "Here " + str(depth) + " initial is " + str(initial) 2862, in run_code exec(code obj, self.user_global_ns, self.user_ns) test _fn van_Der Waals fn(initial) d_dx_test_fnd_dV_van_Der Waals_fn(initial) depthE 1 return NewtonRaphson(initial, test fn, d_dx_test_fn, depth, eps, depth_limit) File "" line 1, in  runfile'/Users/jerusalenwogayehu untitled28. py", wdir-'/Users/ jerusalemwogayehu) def printReport(guessi, guess2): global substance, p, T, a, b, R print "Critical Temperature (K) for s: fnn"s(substance, criticalTenprature)) "Critical Pressure (atm) for %s: 4f "4( substance, "Given Temperature (K): "4(T) "Given Pressure (atm): fn"(p) File "/Users/jerusalemwogayehu/ anaconda3/lib/python3.6/site-packages/ spyder/utils/site/sitecustomize.py, line 710, in runfile criticalPres sure()) vall NewtonRaphson guess1, van_Der_Waals_fn(guess1), d_dV_van_Der_Waals fn guess1), ) execfile filenane, namespace) #print (vall) val2 NewtonRaphson guess2, van_Der_Waals_fn(guess2), d_dV_van_Der_Waals fn guess2), ) File "/Users/jerusalemwogayehu/ anaconda3/lib/python3.6/site-packages/ spyder/utils/site/sitecustomize.py,Line 101, in execfile #print (val2) print "85 lquid phase molar volume at the given p and T: Af Iterations to convergence: %d "%(substance, val1[0], vall [1])- "85 liquid phase molar volume at the given p and T: ?f Iterations to convergence : "$( substance, val2[0], val2(11) print "n # Example in" exec compile(f.read, filename, exec'), namespace) substance"OXYGEN R-0.082057 #gas constant: Liter atm/mol K a-1.364 #van der Waals parameter : liters*2 atm / mol*2 b-0.0319 #van der Waals parameter: liter / mol File "/Users/jerusalemwogayehu/ untitled20.py", line 64 (K) for print "Critical Temperature %f "s( substance, 85: P-10.8 #Problem specified pressure (atm) T-125.0 #Problem specified temperature (K) criticalTemprature()) SyntaxError: invalid syntax In [11]: In [11]: printReport (e,1.2) ! #Van der Waals problem for nitrious oxide substance"METHANE" R-0.082057 #gas constant: Liter atm/mol K a-2.273 #van der Iaals parameter: liters*2 atm / mol*2 b-8.0431 #van der Waals parameter: liter / mol sp-10.8 #Problem specified pressure (atm)

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions