/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Problem 44 Compute velocity and acceleratio... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Compute velocity and acceleration. In a laboratory experiment waves are generated through the impact of a model slide into a wave tank. (The intention of the experiment is to model a future tsunami event in a fjord, generated by loose rocks that fall into the fjord.) At a certain location, the elevation of the surface, denoted by \(\eta\), is measured at discrete points in time using an ultra-sound wave gauge. The result is a time series of vertical positions of the water surface elevations in meter: \(\eta\left(t_{0}\right), \eta\left(t_{1}\right), \eta\left(t_{2}\right), \ldots, \eta\left(t_{n}\right)\). There are 300 observations per second, meaning that the time difference between to neighboring measurement values \(\eta\left(t_{i}\right)\) and \(\eta\left(t_{i+1}\right)\) is \(h=1 / 300\) second. Write a Python program that accomplishes the following tasks: 1\. Read \(h\) from the command line. 2\. Read the \(\eta\) values in the file src/random/gauge. dat into an array eta. 3\. Plot eta versus the time values. 4\. Compute the velocity \(v\) of the surface by the formula $$ v_{i} \approx \frac{\eta_{i+1}-\eta_{i-1}}{2 h}, \quad i=1, \ldots, n-1 $$ Plot \(v\) versus time values in a separate plot. 5\. Compute the acceleration \(a\) of the surface by the formula $$ a_{i} \approx \frac{\eta_{i+1}-2 \eta_{i}+\eta_{i-1}}{h^{2}}, \quad i=1, \ldots, n-1 $$ Plot \(a\) versus the time values in a separate plot.

Short Answer

Expert verified
Plot the elevation, velocity, and acceleration against time using the provided formulas.

Step by step solution

01

Read Inputs

First, read the time difference per sample, \(h\), from the command line. Since there are 300 observations per second, you'll typically have \(h = \frac{1}{300}\). Then, load the wave elevation data from the file `src/random/gauge.dat` into an array called `eta`. Use `numpy` for numerical operations and `matplotlib` for plotting.
02

Plot Elevation Data

Create an array `time` which represents the time values corresponding to each \(\eta\). This is accomplished by multiplying the index of each \(\eta\) by \(h\). Use `matplotlib` to plot the elevation `eta` against `time`. The plot will provide a visual representation of the water surface elevation over time.
03

Compute Velocity

Define an array `v` to hold the velocity values. For each \(i\) from 1 to \(n-1\), compute the velocity using the formula: \[v_{i} \approx \frac{\eta_{i+1} - \eta_{i-1}}{2h}\] This formula captures the rate of change of \(\eta\) per unit time, approximating the derivative. Exclude the boundary points \(t_0\) and \(t_n\) since they require data outside the available range. Plot `v` versus `time`.
04

Compute Acceleration

Define an array `a` to hold the acceleration values. For each \(i\) from 1 to \(n-1\), compute the acceleration using the formula: \[a_{i} \approx \frac{\eta_{i+1} - 2\eta_{i} + \eta_{i-1}}{h^2}\] This formula computes the second derivative of \(\eta\), representing the rate of change of velocity per unit time. Like before, exclude \(t_0\) and \(t_n\) due to boundary limitations. Plot `a` versus `time`.

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 91Ó°ÊÓ!

Key Concepts

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

Python Programming
Understanding Python programming is crucial for tackling the given exercise efficiently. Python is a high-level programming language known for its readability and simplicity, making it ideal for scientific computations. The task involves reading data and performing numerical differentiation to compute wave velocities and accelerations.

Firstly, you need to read the time step, \( h \), from the command line. This will dictate how you handle successive data points for computation. Then, using Python libraries like `numpy` and `matplotlib`, you can import the data from a file and store it in an array named `eta`.

Once you have the data, the next step is to visualize it, which Python excels at with libraries like `matplotlib`. With simple commands, you can plot the elevation against time, which helps in visually analyzing the data before performing further computations.

Python’s rich ecosystem of libraries makes it a powerful tool for scientific computing tasks like this, enabling clear and efficient code to handle complex numerical calculations.
Wave Analysis
Wave analysis in this context involves understanding wave motion through data collected by ultra-sound wave gauges. The primary focus here is on measuring the displacement of the water surface over time.

In the exercise, you are given elevation data points \( \eta(t_0), \eta(t_1), \ldots, \eta(t_n) \), which represent the height of wave surfaces at different time intervals. These measurements form a time series that helps in analyzing how waves propagate through the medium—in this case, a wave tank.

The task is to compute two main parameters of wave motion—velocity and acceleration. Velocity gives an idea of how fast the wave surface is changing its elevation, while acceleration indicates how the velocity of the surface changes over time. This analysis aids in understanding the dynamic behavior of waves, useful for modeling natural phenomena like tsunamis.
Scientific Computing
Scientific computing provides the framework for applying computational techniques to solve scientific problems, such as the numerical differentiation present in this exercise.

The main computation tasks involve estimating the derivatives of the wave height data. Numerical differentiation allows you to calculate the velocity and acceleration without needing an explicit mathematical function, which is common when dealing with discrete data samples.

For velocity, the formula used is:
\[ v_{i} \approx \frac{\eta_{i+1} - \eta_{i-1}}{2h} \]
This approximates the rate of change of elevation data to derive the velocity of the wave particles.

Acceleration is computed using the second derivative approximation:
\[ a_{i} \approx \frac{\eta_{i+1} - 2\eta_{i} + \eta_{i-1}}{h^2} \]
This captures how the velocity of the particles is changing, which gives insights into the force acting on them. By leveraging scientific computing tools, these calculations become more precise and efficient.
Data Visualization
Data visualization is an important step that aids in interpreting the computational results of any scientific experiment. In this exercise, you visualize both the original elevation data and the computed velocity and acceleration.

Using `matplotlib`, visualizing the dataset begins with plotting the wave elevation \( \eta \) against time, which gives an overall impression of the wave profile over time. It shows peaks and valleys, helping observe natural wave behavior directly.

After calculating velocity, a separate plot demonstrates how quickly the water surface is rising or falling over time. This is crucial for understanding the immediate responses to disturbances.

Similarly, plotting acceleration lays out the rate at which the wave speed itself changes. The plots provide visual insights that numbers alone cannot. This two-dimensional representation helps in identifying trends, cycles, and anomalies in the wave behaviors effectively, making data easy to comprehend and analyze.

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

Throw dice and compute a small probability. Compute the probability of getting 6 eyes on all dice when rolling 7 dice. Since you need a large number of experiments in this case (see the first paragraph of Chapter 8.3), you can save quite some simulation time by using a vectorized implementation. Name of program file: roll_7dice.py.

Independent vs. dependent random numbers. Generate a sequence of \(N\) independent random variables with values 0 or 1 and print out this sequence without space between the numbers (i.e., as 001011010110111010\() .\) The next task is to generate random zeros and ones that are dependent. If the last generated number was 0 , the probability of generating a new 0 is \(p\) and a new 1 is \(1-p\). Conversely, if the last generated was 1, the probability of generating a new 1 is \(p\) and a new 0 is \(1-p\). Since the new value depends on the last one, we say the variables are dependent. Implement this algorithm in a function returning an array of \(N\) zeros and ones. Print out this array in the condense format as described above. Choose \(N=80\) and try the probabilities \(p=0.5, p=0.8\) and \(p=0.9\). Can you by visual inspection of the output characterize the differences between sequences of independent and dependent random variables? Name of program file: dependent_random_variables.py.

Probabilities of rolling dice. 1\. You throw a die. What is the probability of getting a \(6 ?\) 2\. You throw a die four times in a row. What is the probability of getting 6 all the times? 3\. Suppose you have thrown the die three times with 6 coming up all times. What is the probability of getting a 6 in the fourth throw? 4\. Suppose you have thrown the die 100 times and experienced a 6 in every throw. What do you think about the probability of getting a 6 in the next throw? First try to solve the questions from a theoretical or common sense point of view. Thereafter, make functions for simulating cases 1,2 , and 3 . Name of program file: rolling_dice.py.

Flip a coin \(N\) times. Make a program that simulates flipping a coin \(N\) times. Print out "tail" or "head" for each flip and let the program count the number of heads. (Hint: Use \(\mathrm{r}=\) random random () and define head as \(\mathrm{r} \Leftrightarrow 0.5\) or draw an integer among \(\\{1,2\\}\) with \(r=\) random . randint \((1,2)\) and define head when \(r\) is 1.) Name of program file: flip_coin.py.

Muke u cluss fur \(2 D\) nutuluwr wulk. The purpose of this exercise is to reimplement the ualk2D. py program from Chapter \(8.7 .1\) with the aid of classes. Make a class Particle with the coordinates \((x, y)\) and the time step number of a particle as attributes. A method move moves the particle in one of the four directions and updates the \((x, y)\) coordinates. Another class, Particles, holds a list of Particle objects and a plotstep parameter (as in walk2D.py). A method move moves all the particles one step, a method plot can make a plot of all particles, while a method moves performes a loop over time steps and calls move and plot in each step. Equip the Particle and Particles classes with print functionality such that one can print out all particles in a nice way by saying print \(\mathrm{P}\) (for a Particles instance \(\mathrm{p}\) ) or print self (inside a method). Hint: In _str_-, apply the pformat function from the pprint module to the list of particles, and make sure that__repr__ just reuse __str__ in both classes. To verify the implementation, print the first three positions of four particles in the walk2D. py program and compare with the corresponding results produced by the class-based implementation (the seed of the random number generator must of course be fixed identically in the two programs). You can just perform p.move() and print p three times in a verify function to do this verification task. Organize the complete code as a module such that the classes Particle and Particles can be reused in other programs. The test block should call a run(N) method to run the walk for \(N\) steps, where \(N\) is given on the command line. Compare the efficiency of the class version against the vectorized version in ualk2Dv.py, using the techniques of Appendix G.6.1. Name of program file: walk2Dc.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.