Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Plot the viscosity of water. The viscosity of water, \(\mu\), varies with the temperature \(T\) (in Kelvin) according to $$ \mu(T)=A \cdot 10^{B /(T-C)} $$ where \(A=2.414 \cdot 10^{-5} \mathrm{~Pa} \mathrm{~s}, B=247.8 \mathrm{~K}\), and \(C=140 \mathrm{~K}\). Plot \(\mu(T)\) for \(T\) between 0 and 100 degrees Celsius. Label the \(x\) axis with 'temperature (C)' and the \(y\) axis with 'viscosity (Pa s)'. Note that \(T\) in the formula for \(\mu\) must be in Kelvin. Name of program file: water_viscosity.py.

Short Answer

Expert verified
Plot of water viscosity against temperature is implemented using Python, showing how viscosity decreases as temperature rises.

Step by step solution

01

Understanding the Formula

The given formula for the viscosity of water, \( \mu(T) = A \cdot 10^{B/(T-C)} \), requires constants \( A = 2.414 \times 10^{-5} \, \mathrm{Pa\, s}, B = 247.8 \, \mathrm{K} \), and \( C = 140 \, \mathrm{K} \). Temperature \( T \) is in Kelvin.
02

Temperature Conversion

Given the range is 0 to 100 degrees Celsius, convert this to Kelvin by adding 273.15 to each Celsius value. Thus, the range in Kelvin is from \( 273.15 \, \mathrm{K} \) to \( 373.15 \, \mathrm{K} \).
03

Implementing the Formula in Code

Create a Python file named `water_viscosity.py`. Use a Python library like Matplotlib for plotting, and NumPy for calculations. Define the required constants and write a function to compute \( \mu(T) \) over the temperature range.
04

Creating the Plot

Use Matplotlib to plot the graph of viscosity against temperature. Set the x-axis (temperature) range from 0 to 100 degrees Celsius and label it. The y-axis should represent viscosity in Pascal-seconds (Pa s), labeled accordingly.
05

Verifying and Saving the Plot

Ensure the plot is correct by verifying the expected behavior of the plot (viscosity decreases with increased temperature). Save the plot as an image file if needed using Matplotlib's `savefig` function.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

Viscosity of Water Calculation
To calculate the viscosity of water, we use the formula: \[ \mu(T) = A \cdot 10^{B/(T-C)} \] Here, the constants are given as follows: - \( A = 2.414 \times 10^{-5} \) Pa s, - \( B = 247.8 \) K, - \( C = 140 \) K. In this formula, \( T \) represents the temperature in Kelvin. The goal is to calculate \( \mu \), the viscosity, as temperature changes between the given limits. Viscosity tends to decrease as temperature increases. This is due to the molecular interactions becoming less significant at higher temperatures. This behavior is important in many scientific and engineering applications. Understanding and calculating viscosity is essential for studying fluid dynamics and designing systems involving fluid flow. Using the given formula, we need to compute \( \mu(T) \) for the specific range of temperatures defined for this problem.
Temperature Conversion in Python
When dealing with scientific calculations, it is important to use consistent units. This often means converting temperatures from Celsius to Kelvin. In our exercise, we are working with temperatures from 0 to 100 degrees Celsius. To convert these to Kelvin, we use the simple formula: \[ T_{\text{Kelvin}} = T_{\text{Celsius}} + 273.15 \] This conversion is straightforward in Python. To achieve this in code, you can use NumPy to easily handle arrays of temperatures. Define an array for Celsius temperatures and convert each element to Kelvin by adding 273.15. Here's a small snippet demonstrating how you can accomplish this: ```python import numpy as np celsius_temps = np.arange(0, 101) kelvin_temps = celsius_temps + 273.15 ``` With the temperatures converted to Kelvin, you can now proceed with calculating the viscosity.
Matplotlib Plotting
Once you have the viscosity values calculated over your range of temperatures, visualizing this data is made straightforward with Matplotlib. Matplotlib is a powerful Python library that helps you create a wide array of static, interactive, and animated plots. For the given problem, you are required to plot the viscosity \(\mu(T)\) against temperature in Celsius. First, ensure you've installed Matplotlib using pip if you haven't already: ```bash pip install matplotlib ``` In your Python script, you can begin by importing Matplotlib and plotting your data: ```python import matplotlib.pyplot as plt plt.plot(celsius_temps, viscosity_values, label='Viscosity vs Temperature') plt.xlabel('Temperature (C)') plt.ylabel('Viscosity (Pa s)') plt.title('Viscosity of Water as a Function of Temperature') plt.legend() plt.grid(True) plt.show() ``` This code sets up a line plot and labels your axes and title properly. It's a good idea to include a grid and a legend for better readability of your plot. If needed, you can save your plot as an image using Matplotlib's `savefig` method.
NumPy for Scientific Calculations
In scientific computing tasks, managing large sets of data efficiently is crucial. NumPy is a highly-regarded library in Python that is built for handling large arrays and matrices, along with a variety of mathematical functions. When calculating something as detailed as the viscosity of water over a temperature range, NumPy simplifies operations like this. NumPy offers many advantages:
  • It supports element-wise calculations, making operations on large datasets effortless.
  • Its array objects are optimized for performance, ensuring your programs run efficiently.
  • It provides a comprehensive collection of mathematical functions, perfect for scientific applications.
In our case, we use NumPy to handle an array of temperature values in Kelvin. We then utilize these values in the viscosity formula. Here's an example illustrating how this might look in Python: ```python viscosity_values = A * 10 ** (B / (kelvin_temps - C)) ``` This calculated array, `viscosity_values`, can easily be plotted using Matplotlib. NumPy's power and ease of use make it irreplaceable for performing scientific calculations like these.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Plot a w-like function. Define mathematically a function that looks like the 'w' character. Plot this function. Name of program file: plot_w.py.

Plot a formula. Make a plot of the function \(y(t)=v_{0} t-0.5 g t^{2}\) for \(v_{0}=10, g=9.81\) and \(t \in\left[0,2 v_{0} / g\right] .\) The label on the \(x\) axis should be 'time (s)' and the label on the \(y\) axis should be 'height \((\mathrm{m}) '\). Name of program file: plot_ball1.py.

Experience overflow in a function. When an object (ball, car, airplane) moves through the air, there is a very, very thin layer of air close to the object's surface where the air velocity varies dramatically \(^{18}\), from the same value as the velocity of the object at the object's surface to zero a few centimeters away. The change in velocity is quite abrupt and can be modeled by the functiion $$ v(x)=\frac{1-e^{x / \mu}}{1-e^{1 / \mu}} $$ where \(x=1\) is the object's surface, and \(x=0\) is some distance away where one cannot notice any wind velocity \(v\) because of the passing object \((v=0)\). The vind velocity coincides with the velocity of the object at \(x=1\), here set to \(v=1\). The parameter \(\mu\) is very small and related to the viscosity of air. With a small value of \(\mu\), it becomes difficult to calculate \(v(x)\) on a computer. Make a function \(v(x, m u=1 E-6\), exp=math.exp) for calculating the formula for \(v(x)\) using exp as a possibly user-given exponentional function. Let the v function return the nominator and denominator in the formula as well as the fraction (result). Call the v function for various \(\mathrm{x}\) values between 0 and 1 in a for loop, let mu be \(1 \mathrm{E}-3\), and have an inner for loop over two different exp functions: math. exp and numpy. exp. The output will demonstrate how the denominator is subject to overflow and how difficult it is to calculate this function on a computer. Also plot \(v(x)\) for \(\mu=1,0.01,0.001\) on \([0,1]\) using 10,000 points to see what the function looks like. Name of program file: boundary_layer_func1.py.

Simulate by hand a vectorized expression. Suppose \(\mathrm{x}\) and \(\mathrm{t}\) are two arrays of the same length, entering a vectorized expression, $$ y=\cos (\sin (x))+\exp (1 / t) $$ If \(\mathrm{x}\) holds two elements, 0 and 2, and \(\mathrm{t}\) holds the elements 1 and 1.5, calculate by hand (using a calculator) the y array. Thereafter, write a program that mimics the series of computations you did by hand (typically a sequence of operations of the kind we listed on page 182 - use explicit loops, but at the end you can use Numerical Python functionality to check the results). Name of program file: simulate_vector_computing.py.

Plot the velocity profile for pipeflow. A fluid that flows through a (very long) pipe has zero velocity on the pipe wall and a maximum velocity along the centerline of the pipe. The velocity \(v\) varies through the pipe cross section according to the following formula: $$ v(r)=\left(\frac{\beta}{2 \mu_{0}}\right)^{1 / n} \frac{n}{n+1}\left(R^{1+1 / n}-r^{1+1 / n}\right) $$ where \(R\) is the radius of the pipe, \(\beta\) is the pressure gradient (the force that drives the flow through the pipe), \(\mu_{0}\) is a viscosity coefficient (small for air, larger for water and even larger for toothpaste), \(n\) is a real number reflecting the viscous properties of the fluid ( \(n=1\) for water and air, \(n<1\) for many modern plastic materials), and \(r\) is a radial coordinate that measures the distance from the centerline \((r=0\) is the centerline, \(r=R\) is the pipe wall). Make a function that evaluates \(v(r) .\) Plot \(v(r)\) as a function of \(r \in[0, R]\), with \(R=1, \beta=0.02, \mu=0.02\), and \(n=0.1 .\) Thereafter, make an animation of how the \(v(r)\) curves varies as \(n\) goes from 1 and down to \(0.01\). Because the maximum value of \(v(r)\) decreases rapidly as \(n\) decreases, each curve can be normalized by its \(v(0)\) value such that the maximum value is always unity. Name of program file: plot_velocity_pipeflow.py.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free