联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-04-18 11:22

MAST90045 - Assignment 1, 2020

The level of a dam

In this assignment we will model the changing level (or height) of water in a dam (Figure 1).

The minimum level is 0 and the maximum is hmax. The level increases when rain falls in the

catchment area and decreases as a result of evaporation and use. We will ignore any loss due

to leaks or seepage.

Height and volume

Volume Let A(h) be the cross-sectional area of the dam at height h.

h Area A(h)

Figure 1: An idealized dam.

The volume of water contained by the dam when it is filled to level h is

V (h) = Z h

0

A(u) du.

Write a function volume(h, hmax, ftn) that returns V (h) for h ∈ [0, hmax], where hmax is

hmax and ftn is a function of a single variable which is assumed to return A(h). For h < 0 or

h > hmax your function should return NA.

Give consideration to the accuracy of any numerical algorithms you use. Discuss your

choices.

Height If the current level of the dam is h and the volume of the dam changes by an amount

v, then the level of the dam becomes u = H(h, v) where u satisfies

V (u) = V (h) + v.

Note that if the right-hand side of this equation is > Vmax = V (hmax) or < 0, then this equation

has no solution. In this case we take u = hmax or u = 0, respectively.

Using a root-finding algorithm, write a function height(h, hmax, v, ftn) that returns

H(h, v), where hmax is hmax and ftn is a function of a single variable that is assumed to return

A(h). For h < 0 or h > hmax your function should return NA.

What is a suitable tolerance for the root-finding algorithm? Discuss your choice.

Figure 2: A schematic dam.

Test case Suppose that the dam is bowl-shaped with profile given by the equation y = πx2

.

That is, the dam has the shape obtained by rotating the curve y = πx2 about the y-axis

(Figure 2).

In this case it is easily seen that, for h ∈ [0, hmax] and v ∈ [−h

2/2, Vmax − h2/2],

A(h) = h;V (h) = h2/2; andH(h, v) = ph2 + 2v.

To test that your function height(h, hmax, v, ftn) works, define

A <- function(h) return(h)

then calculate height(h, hmax = 4, v, ftn = A) for the following values of h and v:

h −1 0.5 0.5 3.5 3.5 3.5 5

v 1 1 −1 1 2 −1 1

Check that your numerical results agree with the formula given above.

Tracking height over time

Suppose that h(t) is the level of the dam at the start of day t, and that v(t) is the volume

of rain falling into the catchment during day t, for t = 1, . . . , n. Also let α be the volume of

water taken from the dam for use per day, and let βA(h(t)) be the volume of water lost due to

evaporation during day t. Then the level of water in the dam at the start of day t + 1 is given

by

h(t + 1) = H(h(t), v(t) − α − βA(h(t))).

Further suppose that hmax = 3, α = 2, β = 0.1, and A(h) has the form

A(h) = (100h2 for 0 ≤ h ≤ 2;

400(h − 1) for 2 ≤ h ≤ 3.

The file catchment_b.txt gives v(t) for n = 100 consecutive days. Write a program that

reads this file then, for a given value of h(1), calculates h(2), . . . , h(n + 1). Plot your output for

the case h(1) = 1, as in the figure below.

2

0 20 40 60 80 100

0.0 0.5 1.0 1.5 2.0 2.5 3.0

Daily water level in a dam

day

level

Figure 3: Simulated time trace of water level for dam, h(1) = 1.

3


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp