#!/usr/bin/env python # coding: utf-8 # # Homework 13 # In[2]: import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # ## Problem 1 # # Plot pressure $P$ (kPa) versus molar volume $V$ (m$^3$/kmol) for an ideal gas at 300 K. $R_g$ = 8314.46 J/kmol$\cdot$K. # * Let $V$ vary from 0.05 to 1 m$^3$/kmol. # # $$ P = \frac{R_gT}{V}.$$ # # * Include axis labels that include the units. Make the x axis vary from 0 to 1 (m$^3$/kmol) and the y axis vary from 0 to 60000 (kPa). # * Practice using different line styles. # In[ ]: # ## Problem 2 # This repeats Problem 7 from HW 11 # # * The Haaland equation relates the friction factor $f$ in turbulent pipe flow to the Reynolds number $Re$. # $$\frac{1}{\sqrt{f}} = -1.8\log_{10}\left[\left(\frac{\epsilon/D}{3.7}\right)^{1.11}+ \frac{6.9}{Re}\right].$$ # # * Write a function to compute $f(Re, \epsilon/D)$. # * Create an array of 100 $Re$ points that is uniformly spaced on a log scale, for $1000\le Re\le 1\times 10^8$ # * On a single plot, compare f versus Re for $\epsilon/D=$0.01, 0.001, 0.0001, 0.0. # * Reproduce the plot shown below. (Line colors don't need to match perfectly.) # # # In[ ]: # ## Problem 3 # # * Use numpy to write the $Re$ data of Problem 2 and the four $f$ curves for each $\epsilon/D$ values to a text file called "haaland.txt". # * Include a header that is descriptive of the columns. # * Use the following format code: "%12.5e". # * Load the data in the file into Excel using Excel's file loading features. Upload your Excel file in addition to your Python notebook. # In[ ]: # ## Problem 4 # # * Use numpy to load the data in file "haaland.txt" into an array. # In[ ]: # In[ ]: