# # David Goodwin and Chris Schneider # Math 152 # sections 201,202 # Fluid Force # This maplet allows the user to practice computing the hydrostatic force on a parabolic plate submerged in water using integrals. To use this maplet the user presses the new problem button whose called function will randomly generate a problem in the form a*x^(1/2), as well as the water level and maximum value of the domain which is then used to determine the height of the plate. The hint button calls another window that has information on how to work the problems. The new prolem is displayed in a word problem format that is displayed in the text box below the two previous mentioned buttons. Below the text box and to the right, there is a plotter and a button labeled display. The display button calls a function that plots the function, its upperbound and the water level in the plot box. The series of text boxes on the right hand side of the screen are there to accept the users answers. The top box expects an varying width of the parabolic plate, the next box expects the width # multiplied by dy, below that the text box expects the varying height of the water above each width, the box below that on eexpects the pressure which is rho*g*the height. The next box down expects the user to set up the integral to be evaluated and the last box expects the evaluated answer. Each of these text boxes are accompanied by a check button and a show button. The check button checks the users answer against the right answer and show gives the right answer in the comment box. The text box at the bottom is there to tell the user if he or she got the right answer and also displays the right answer when the user clicks the show button for any given question, i feel that the correct answer should be shown here because it allows the user to check their answer against the right answer and see what they did wrong. At the bottom of the screen there is a quit button that allows the user to exit the maplet. # Note: the function that checks the users dA, checks against the right answer which is just the x*dy. If the user just forgets the dy then the comment box prompts them to check for that mistake. The answer accepted by the computed integral text box is checked against and expects the most simplified version of the answer, not a decimal value. This was done so that the user could use the maplet without the need of a calculator. # restart: with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): with(RandomTools): StartEngine(); randomize(): rand0:=rand(1..2): rand1:=rand(1..5): rand2:=rand(8..10): rand3:=rand(1..5): new_prob:=proc() global rand0, rand1, rand2, rand3, w, h, rhog,mini,waterlevel,xright,top, plate; local a,probtype,plate2,waterlevel2,top2; a:=rand1(); waterlevel:=rand2(); xright:=rand3(); probtype:=rand0(); plate:=[a*x^2,a*abs(x)][probtype]; top:=eval(plate, x=xright); mini:=min(waterlevel,top); w:=[2*(y/a)^(1/2),2*y/a][probtype]; h:=waterlevel-y; rhog:=980; plate2:=convert(plate,string); waterlevel2:=convert(waterlevel,string); top2:=convert(top,string); Set('problem'=cat("Compute the fluid force on a plate above the function y = ",plate2," below y = ",top2," submerged in a bucket of water with the water level at y = ",waterlevel2,".")); Set('myplot'=plot(0, x=-5..5, 0..10)); Set('wide'="", 'wide'(background)=white); Set('area'="", 'area'(background)=white); Set('depth'="", 'depth'(background)=white); Set('pressure'="", 'pressure'(background)=white); Set('integral'="", 'integral'(background)=white); Set('value'="", 'value'(background)=white); Set('comments'="", 'comments'(background)=white); end proc: plot_it:=proc() global plate, top, waterlevel, xright; Set('myplot'=plot([plate,top,waterlevel],x=-xright..xright, view=[-xright-1..xright+1,0..max(top,waterlevel)], color=[green,green,blue], scaling=constrained, tickmarks=[3,2])); end proc: check_w:=proc() global w; local user_w; user_w:=Get(wide::algebraic); if simplify(normal(user_w - w)) = 0 then Set('comments'="correct keep going", 'wide'(background)=green, 'comments'(background)=green); else Set('comments'="try again",'wide'(background)=red,'comments'(background)=red); end if; end proc: show_w:=proc() global w; Set('wide'=w,'wide'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: check_dA:=proc() global w; local da, user_da, notda; da:=w*dy; notda:=w; user_da:=Get(area::algebraic); if simplify(normal(user_da - da)) = 0 then Set('comments'="correct keep going", 'area'(background)=green,'comments'(background)=green); elif user_da - notda = 0 then Set('comments'="Remember the dy.", 'area'(background)=yellow,'comments'(background)=yellow); else Set('comments'="try again", 'area'(background)=red,'comments'(background)=red); end if; end proc: show_dA:=proc() global w; local da; da:=w*dy; Set('area'=da, 'area'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: check_depth:=proc() global h; local user_depth; user_depth:=Get(depth::algebraic); if simplify(normal(user_depth - h)) = 0 then Set('comments'="correct keep going", 'depth'(background)=green, 'comments'(background)=green); else Set('comments'="try again", 'depth'(background)=red, 'comments'(background)=red); end if; end proc: show_depth:=proc() global h; Set('depth'=h, 'depth'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: check_pressure:=proc() global h,rhog; local user_pressure,pres; pres:=rhog*h; user_pressure:=Get(pressure::anything); if simplify(normal(user_pressure - pres)) = 0 then Set('comments'="correct keep going", 'pressure'(background)=green, 'comments'(background)=green); else Set('comments'="try again", 'pressure'(background)=red, 'comments'(background)=red); end if; end proc: show_pressure:=proc() global h,rhog; local pres; pres:=rhog*h; Set('pressure'=pres, 'pressure'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: check_int:=proc() global h,w,rhog,mini; local user_int,integral1; integral1:=Int(rhog*h*w,y=0..mini); user_int:=Get(integral::algebraic); if simplify(normal(user_int - integral1)) = 0 then Set('comments'="correct keep going", 'integral'(background)=green, 'comments'(background)=green); else Set('comments'="try again", 'integral'(background)=red, 'comments'(background)=red); end if; end proc: show_int:=proc() global h,w,rho,mini; local integral1; integral1:=Int(rhog*h*w,y=0..mini); Set('integral'=integral1, 'integral'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: check_val:=proc() global h,w,rhog,mini; local user_val,val1; val1:=int(rhog*h*w,y=0..mini); user_val:=Get(value::algebraic); if simplify(normal(user_val - val1)) = 0 then Set('comments'="correct keep going", 'comments'(background)=green, 'value'(background)=green); else Set('comments'="try again", 'comments'(background)=red, 'value'(background)=red); end if; end proc: show_val:=proc() global h,w,rho,mini; local val1; val1:=int(rhog*h*w,y=0..mini); Set('value'=val1, 'value'(background)=yellow); Set('comments'="", 'comments'(background)=white); end proc: Fluid_Force:= Maplet(onstartup = RunWindow(MAIN), Font[helv10]("helvetica",10), Window[MAIN]('title'="Fluid Force", [ [ Button("New Problem", Evaluate('function' = "new_prob")), Button("Hint", onclick=A1), Button("Quit", Shutdown()) ], [ TextBox['problem']('width'=70, height=2) ], [ "Enter each of the following for the slice at height y of thickness dy." ], BoxRow( BoxColumn( [ Button("Display",Evaluate('function'="plot_it")) ], [ Plotter['myplot']('width'=200, 'height'=200) ] ), BoxColumn( [ "w =",TextField['wide']('width'=30), Button("check", Evaluate('function' = "check_w")), Button("show", Evaluate('function' = "show_w")), Button("hint", onclick=W) ], [ "dA =",TextField['area']('width'=30), Button("check", Evaluate('function' = "check_dA")), Button("show", Evaluate('function' = "show_dA")), Button("hint", onclick=dA) ], [ "h =",TextField['depth']('width'=30), Button("check", Evaluate('function' = "check_depth")), Button("show", Evaluate('function' = "show_depth")), Button("hint", onclick=H) ], [ "P =",TextField['pressure']('width'=30), Button("check", Evaluate('function' = "check_pressure")), Button("show", Evaluate('function' = "show_pressure")), Button("hint", onclick=P) ], "Set up the integral for the force:", [ "F =",TextField['integral']('width'=30), Button("check", Evaluate('function' = "check_int")), Button("show", Evaluate('function' = "show_int")), Button("hint", onclick=Int) ], "Evaluate the integral for the force:", [ "F =",TextField['value']('width'=30), Button("check", Evaluate('function' = "check_val")), Button("show", Evaluate('function' = "show_val")), Button("hint", onclick=Value) ] ) ), [ TextField['comments']('width'=70, 'editable'='false') ], BoxRow('background'="#DDFFFF", 'inset'=0, 'spacing'=0, Label("Programmers: Goodwin / Schneider", 'font'=helv10), HorizontalGlue(), Label("Copyright 2006, D.B. Meade and P.B. Yasskin", 'font'=helv10), HorizontalGlue(), Label("v. 1.2a May 2006", 'font'=helv10) ) ] ), Window[Hint]('title'="Hints", [ halign=none, [ "F =", MathMLViewer('value' = MathML[Export](Int('P','A') = Int('rho'*'g'*'h'*'w','y'='a'..'b')), 'width'=250,'height'=75), HorizontalGlue(), Button("Close", CloseWindow(Hint)) ], [ TextBox("The force is the pressure times the area.\nThe hydrostatic pressure varies with the depth of the water.\nSo, the hydrostatic force must be computed using an integral.\n\nThe limits of integration run from the lowest point to the highest point of the plate submerged under the water.\n\nThe density of water is rho = 1 gm/cm^3.\nThe acceleration of gravity is g = 980 cm/sec^2", width=65, height=9) ] ] ), Action[A1](RunWindow(Hint)), Window[HintW]('title'="Hint", [ [ "w is the width of the slice of the plate at height y.\nw = 2 * x where x is expressed as a function of y." ], [ Button("Close", CloseWindow(HintW)) ] ] ), Action[W](RunWindow(HintW)), Window[HintdA]('title'="Hint", [ [ "dA is the area of the slice of the plate at height y with thickness dy,\ndA = w * dy" ], [ Button("Close", CloseWindow(HintdA)) ] ] ), Action[dA](RunWindow(HintdA)), Window[HintH]('title'="Hint", [ [ "h is the depth of water above of the slice of plate at height y.\nh = Top of the water - y" ], [ Button("Close", CloseWindow(HintH)) ] ] ), Action[H](RunWindow(HintH)), Window[HintP]('title'="Hint", [ [ "P is the pressure of the water on the slice at height y.\nP=rho*g*h, where rho = 1 gm/cm^3 and g = 980 cm/sec^2." ], [ Button("Close", CloseWindow(HintP)) ] ] ), Action[P](RunWindow(HintP)), Window[HintInt]('title'="Hint", [ [ "Format: F = Int( P * w, y = min..max).\nYou only need to integrate over the part of the plate which is under the water." ], [ Button("Close", CloseWindow(HintInt)) ] ] ), Action[Int](RunWindow(HintInt)), Window[HintValue]('title'="Hint", [ [ "Expand the integrand." ], [ Button("Close", CloseWindow(HintValue)) ] ] ), Action[Value](RunWindow(HintValue)) ): Maplets[Display](Fluid_Force);