The Depth Gauge Problem Liquids are often stored in elliptical storage tanks as shown below. To measure the volume of liquid in the tank, a depth gauge (measuring stick) can be used. It is inserted into an opening at the top and the level of liquid on the gauge can be used to determine the amount of liquid in the tank.
The tank has width w, height h and length len (all in meters). In the example output shown below, we take w=8, h=4 and len=7. Your programs should work for any values of w, h and len, not just these specific values.
The assignment is divided into two parts.
Part 1:
In the first part of the assignment we look at inserting a measuring stick that is already calibrated in units of 10 centimeters. This measuring gauge can be inserted into an opening at the top of the tank and used to measure the depth of the liquid in the tank.
Your task will be to write a C program to produce a table of values showing the volume of liquid in the tank for each of the points on the gauge.
The output of your program (for the example above) should look like:
Depth 10 cm : Volume 1.188814 cubic meters
Depth 20 cm : Volume 3.336448 cubic meters
Depth 30 cm : Volume 5.992683 cubic meters
. . .
Depth 380 cm : Volume 172.547399 cubic meters
Depth 390 cm : Volume 174.657114 cubic meters
Depth 400 cm : Volume 175.743037 cubic meters
Methodology for Part 1:
If the tank has width W and height H (in centimeters), the focal radii of the cross section are A = W/2 and B = H/2. Then the equation of the ellipse is:
X2/A2 + Y2/B2 = 1
To find the volume at given depth you should compute the cross-sectional area of the tank for each given depth using a numerical integration algorithm such as the trapezoidal method. You must use a general integration function and apply it to this particular function. Do not write an integration function that is specific to this problem. Do not use an analytic solution to integrate the function. Then multiply this by the length of the tank.
Hint: It is probably easier to imagine the tank on its side so that the depth gauge is inserted horizontally. If you do this you must express the equation as a function of y and integrate that function.
Part 2:
The second part of the assignment is a variation on this. In this case the stick is not calibrated. We would like to calibrate it. Rather than calibrate it by equidistant markings, we calibrate it to show at what level the tank contains a certain volume of the liquid.
You are to write a C program that determines where the gauge should be marked (to the nearest millimeter) corresponding to volumes of 5, 10, 15, … cubic meters (up to the total volume of the tank).
The output of your program (for the example above) should look like:
Volume 5: Depth 26.54 cm
Volume 10: Depth 42.48 cm
Volume 15: Depth 56.08 cm
. . .
Volume 165: Depth 355.12 cm
Volume 170: Depth 370.52 cm
Volume 175: Depth 392.03 cm
Methodology for Part 2:
If we view the volume as a function of the position y, this problem reduces to the problem of finding a root of the equation V(y) = depth, for the various depths. While the function V(y) is not given by a simple formula, it can be determined for any y by using the numerical integration as defined in part 1. Write a program to determine the roots of this equation for each depth by using a root finding algorithm such as the bisection method. Again, you must use a general root finding function and apply it to this particular function. Do not use an analytic solution to solve this problem. Each function evaluation will have to be done using an integration algorithm such as the trapezoidal method.
Answer:
Program code screen shot:
Sample Output:
Program code to copy:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
// define the global variable
double width;
double height;
double length;
// declare a function function() to compute the
// cross section area of the tank
double function(double x);
// declare the function num_Integration_trapezoidal()
// to compute the intergration value by using trapezoidal
method
double num_Integration_trapezoidal(double A, double B, int n);
// define the main function
int main()
{
// define a variable to keep maintining the
calibrated
// units of the stick
int calibratedUnit = 0;
// define a variable to hold the upper bound of
the
// integration value
int upperBound = 100;
// declare the required variables
double stickHeight, area_of_tank, volume_of_tank;
printf("To compute the volume at the given depth
at"
" certain cross sectional
area\n\n");
// prompt the user for the width, height and length of
the
// tank in meters
printf("Enter the data measurements in meters\n");
// prompt and read the width of the tank
printf("Enter tank width(m): ");
scanf("%lf", &width);
// prompt and read the height of the tank
printf("Enter tank height(m): ");
scanf("%lf", &height);
// prompt and read the length of the tank
printf("Enter tank length(m): ");
scanf("%lf", &length);
// at every calibratedUnit, find the area and
volume and display the
// volume cubic meters
for (calibratedUnit = 10; calibratedUnit <= height
* 100; calibratedUnit += 10)
{
// find the stick height
stickHeight = calibratedUnit /
100.0;
// call the
num_Integration_trapezoidal() function
// to find the area
area_of_tank =
num_Integration_trapezoidal(height/2.0-stickHeight,height/2.0,
upperBound);
// compute the volume of the
tank
volume_of_tank = area_of_tank *
length;
// display the depth and volume
of the tank
printf("Depth %d cm: Volume %.6lf
cubic metres\n",
calibratedUnit,
volume_of_tank);
}
getchar(); // to halt the program
getchar(); // to halt the program
return 0;
}
// declare a function function() that accepts a double
value
// and returns a double.
// This function is to compute the cross-section area of the
tank.
double function(double x)
{
double A = height / 2.0;
double B = width / 2.0;
double y = (B / A) * sqrt(A * A - x * x);
return y;
}
// define a function num_Integration_trapezoidal() that
accepts
// two double values and an integer value and returns a double
value.
// This function is to find the intergrated value of the
cross-section area
// by using trapezoidal method
double num_Integration_trapezoidal(double A, double B, int n)
{
// declare the required variables
double xVal, dx, totalSum = 0.0;
double result = 0;
int i = 0;
// find the interval value of the integration
dx = (B - A) / n;
// find the initial sum value
totalSum = (function(A) + function(B))/2;
// add the value A with interval
xVal = A + dx;
// loop through each value of the interval till it
reaches the
// upper bound
for (i = 1; i < n; i++)
{
// find the sum of the
cross-section area
totalSum += function(xVal);
// increment the interval
value
xVal += dx;
}
// find the total area
result = 2 * totalSum * dx;
// return the result
return result;
}
The Depth Gauge Problem Liquids are often stored in elliptical storage tanks as shown below. To...
Maybe it’s easier to imagine the tank on its side so that the depth gauge is inserted horizontally if you do this you must express the equation as a function of y and integrate that function. Please use the ellipse formula, and compute the volume of liquid by trapezoidal integral and function you altered for the ellipse formula. MUST contain following function: Void trapezoidal_integral (double depth, int n, double width, double height, double length, double *integral_result) Sample output: Enter the...
Write a C program that outputs values of the volume of an elliptically shaped tank in a table. (a) The values of the depth increment by 10 cm each time. Using the equation of an ellipse, find the volume at the specified depths by computing the cross-sectional area using numerical integration. The equation used must be a general one that would work for any function and not just this problem. Do you not use analytical methods. (b)write a program that...
this is from measurement and instruction. looking for solution to understand better . 3.43. in a particular measurement system, quantity x is caicuiated by subtracting a measurement of a quantity : from a measurement of a quantity y, that is, xy- if the possible measurement errors in y and: are tay and b, respectively, show that the value of x can be expressed as-y(ay -bz). (a) What is inconvenient about this expression for x, and what is the basis for...
Coding for Python - The pattern detection problem – part 3: def pattern_search_max(data_series, pattern, threshold) Please do not use 'print' or 'input' statements. Context of the assignment is: In this assignment, your goal is to write a Python program to determine whether a given pattern appears in a data series, and if so, where it is located in the data series. Please see attachments below: We need to consider the following cases: Case 1 - It is possible that the...
Time Notes Evaluate de Info This problem contains three parts. In Part A. you are asked to determine the parameters of the pront function - the contribution margin and the feed costs. You should not move on to Parts and Cuntil you get Part A correct, or until you use up all of your tries. The correct prent function parameters will be given to you after you have completed Part A - you should use these parameters in Parts B...
PLEASE HURRY. Below is the prompt for this problem. Use the code for bag1.cxx, bag1.h and my code for bag.cpp. Also I have provided errors from linux for bag.cpp. Please use that code and fix my errors please. Thank you The goal of assignment 3 is to reinforce implementation of container class concepts in C++. Specifically, the assignment is to do problem 3.5 on page 149 of the text. You need to implement the set operations union, intersection, and relative...
summatize the following info and break them into differeng key points. write them in yojr own words apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...