Download presentation

Presentation is loading. Please wait.

1
**Chp3 Tutorial: Prob 3.14 Solution**

Engineering 25 Chp3 Tutorial: Prob 3.14 Solution Bruce Mayer, PE Licensed Electrical & Mechanical Engineer

2
P3.14 Water Reservoir Vol Using estimates of rainfall, evaporation, and water consumption, the town engineer developed the following model of the water volume in the reservoir as a function of time where V is the water volume in liters, t is time in days, and r is the town's consumption rate in liters per day. Write TWO user-defined functions. The first function should define the function V(t) for use with the fzero function. The second function should use fzero to compute how long it will take for the water volume to decrease to x percent of its initial value of 109 L. The inputs to the second function should be x and r. Test your functions for the case where x = 50 percent and r = 107 L/day.

3
A NearBy Reservoir

4
A NearBy Reservoir This 315-acre anglers oasis sits in the heart of Suburban Castro Valley but, you'd never know it from your surroundings once inside the park. Miles of parkland and trails make Chabot a haven for outdoor enthusiasts. Hikers can enjoy scenic walks on the 280-acre Fairmont Ridge. Park trails are designed for shared useage. Lake Chabot is well known among the running community. The park hosts Half Marathons, 5K's and the Kids Fun Run. In fact, Trail Runner magazine chose this setting as one of America's Most Scenic Races.

5
**Water Reservoir Vol Problem 3-14 appears to have an inconsistency**

The fzero built-in function operates on any SINGLE VARIABLE function as described in Tab of the text book. In this case want to input a V(t), function, NOT a V(t,x,r) function to determine the %-decrease time. The problem, however, says that TWO parameters, x & r, must also be sent to the V(t) function before using fzero

6
Use GLOBALS for x&r We can “work around” the fzero single-varialbe requirement for V(t) by declaring x & r as GLOBAL Variables as described on pg 124 of the Text Declaring x & r as globals in BOTH the calling function and the V(t) function gives the single-Var function, V(t), access to r & x withOUT listing them in the V-function argument

7
**Physical Analysis The Reservoir Volume vs t Function**

Now need to find the time, td, for the volume to decrease TO x-percent of the initial Volume for a given water consumption rate, r i.e, Find td such that

8
**Physical Analysis Now need to define a function for which zeros exist**

In this case define a DIFFERENCE Function Want to ZERO Vguess - Vcalc Now ΔV will be ZERO when t = td so that V(td) = Vfinal Thus the function to be zeroed is the DIFFERENCE between Vfinal (the Goal) and V(t) (the Guess) Want: Vgoal − Vguess = 0

9
**Guess&Check Demo Make a Time Guess, tGuess Calc VGuess = V(tGuess)**

Calc % Full for the Guess Calc Difference Guess AGAIN

10
**Guess&Check Demo First Trial Run (Cmd Window) >> r = 1e7 r =**

>> >> VtoverVi (1e9 + 1e8*(1 - exp(-t/100)) - r*t)/1e9 VtoverVi = @(t)(1e9+1e8*(1-exp(-t/100))-r*t)/1e9 >> Goal = 0.55 Goal = 0.5500 >> Guess31 = VtoverVi(31) Guess31 = 0.7167 >> del31 = Goal - Guess31 del31 =

11
**Guess & Check Ans >> P3_14_ReservoirVolume_1302 r = 10000000**

VtoverVi = @(t)(1e9+1e8*(1-exp(-t/100))-r*t)/1e9 Goal = 0.5500 Guess31 = 0.7167 del31 = Guess62 = 0.4262 del62 = 0.1238 Guess47 = 0.5675 del47 = Guess48 = 0.5581 del48 = Guess49 = 0.5487 del49 = 0.0013

12
**Guess&Check .m-file % Bruce Mayer, PE % ENGR25 * 12Feb13**

% Problem 3_14 % P3_14_ReservoirVolume_1302.m r = 1e7 % consumption rate % Create ANON fcn to return % of Initial Vol VtoverVi (1e9 + 1e8*(1 - exp(-t/100)) - r*t)/1e9 Goal = 0.55 % to 55% of initial Volume Guess31 = VtoverVi(31) del31 = Goal - Guess31 Guess62 = VtoverVi(62) del62 = Goal - Guess62 Guess47 = VtoverVi(47) del47 = Goal - Guess47 Guess48 = VtoverVi(48) del48 = Goal - Guess48 Guess49 = VtoverVi(49) del49 = Goal - Guess49

13
MATLAB GamePlan Write the single variable (var = t) function deltaV(t) for use in fzero This function receives parameters r & x as GLOBAL variables rd & xd Write the calling function, time_to_decrease(x,r), that calls into action fzero with deltaV as its argument This calling function sends rd & xd to deltaV by way of the GLOBAL declaration

14
Structure Chart Note How GLOBALS ByPass the Normal Communication Path

15
Fcn deltaV.m

16
**time_to_decrease(x,r).m**

Only 4 active commands

17
The Calling Program

18
**Example Call User Inputs**

x = 50 & r = 1e7 Takes 54.2 days to drop to 50% initial for use rate of 1e7 Liters per Day Percent of Initial Storage, x = 50 Consumption Rate in L/day, r = 1e7 for x = 50 for r = The time to Decrease in Days =

19
**Cmd Window Session For x = 50%, and r = 1e7 liters per day**

>> td50_1e7 = time_to_decrease(50,1e7) Rd = Xd = 50 t_dec = td50_1e7 = Thus for a 1e7 liter/day consumption rate, a 50% decrease in volume takes about 54 days

20
**Cmd Window Session For x = 27%, and r = 4e6 liters/day**

>> td27_4e6 = time_to_decrease(27,4e6) Rd = Xd = 27 t_dec = td27_4e6 = Thus for a 4e6 liter/day consumption rate, a decrease to 27% of the initial volume takes about 204 days

21
**DeltaV Plot Anonymous fcn For x = 27%, and r = 4e6 liters/day**

dV = Goal – Guess Goal = 1e9*(27/100) Guess = (1e9 + 1e8*(1-exp(-tg/100)) - 4e6*tg); >> dV27_4e6 (1e9*(1-73/100 )) - (1e9 + 1e8*(1-exp(-tg/100)) - 4e6*tg); % Vfinal - Vguess >> tplot = linspace(-350,350,700); >> VolDiff = dV27_4e6(tplot); >> plot(tplot, VolDiff, 'LineWidth', 3), grid, xlabel('t (days)'), ylabel('DeltaV (L)'), title('P3-14: Need to ZERO‘)

22
DeltaV Plot Note that fzero can Return ERRONEOUS (negative) Results if Start-Pt is Off

23
**Erroneous result For x = 65%, and r = 1e6 liters/day**

>> td65_1e6 = time_to_decrease(65,1e6) Rd = Xd = 65 t_dec = td65_1e6 = For THIS SET of Parameters fzero found a NEGTIVE (erroneous Root)

24
**Erroneous DeltaV Plot fzero found the negative root**

When in Doubt PLOT it fzero found the negative root The can be fixed by changing the starting point to 200

25
**Erroneous result For x = 65%, and r = 1e6 liters/day**

Change This Line in the time_to_decrease code t_dec = fzero('deltaV', 200) The new (Mathimatically Correct) result >> td65_1e6 = time_to_decrease(65,1e6) Rd = Xd = 65 t_dec = td65_1e6 =

26
Erroneous Comment Even though Days is correct by the Equation, it is NOT physically reasonable Since Weather is CYCICAL on a 365 day basis, anything over a Year violates nature and is thus NOT Applicable Some Advice Always do a Reality Check on the Results returned by ANY computer program When in Doubt PLOT

Similar presentations

OK

MTH16_Lec-14_sec_10-1_Infinite_Series.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &

MTH16_Lec-14_sec_10-1_Infinite_Series.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on resistance temperature detectors Ppt on our changing earth Ppt on conservation of plants and animals Ppt on sound navigation and ranging system of equations Spinal cord anatomy and physiology ppt on cells Ppt on case study of leadership Weekends by appt only Ppt on motivational quotes Download ppt on oxidation and reduction Ppt on amending the constitution