question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_submarine_window do 4 kind :numerical 5 describes "At a depth of %{depth} in an ocean, a submarine has a window of area %{area}, and its interior is " \ 6 "maintained at sea-level atmospheric pressure. The density of sea water is %{density}; take g as " \ 7 "%{gravity} and atmospheric pressure as %{atmosphere}. %{force}, in newtons?" 8 given depth: "1000 m" 9 given area: "0.04 m2" 10 given density: "1.03e3 kg/m3" 11 given gravity: "10 m/s2" 12 given atmosphere: "1.01e5 Pa" 13 asks force: "What is the force acting on the window" 14 end
1 require_relative "../questions/a_submarine_window" 2 require_relative "../science/mechanical_properties_of_fluids/pressure_at_depth" 3 4 solve :a_submarine_window , using: PressureAtDepth do 5 objects :submarine , :window 6 7 take depth: submarine . depth 8 take area: window . area 9 take density: rho 10 take gravity: g 11 take atmosphere: P_a 12 13 deduce_from "maintained at sea-level atmospheric pressure" , window . pressure => submarine . gauge_pressure 14 15 force = window . thrust 16 answer force :, in: "N" , figures: 3 17 18 conclusion "The air inside pushes back with the atmosphere's share, so what is left pressing on the " \ 19 "window is the gauge pressure of the water over its area." 20 end
1 require_relative "../solutions/a_submarine_window" 2 3 play_with :a_submarine_window do 4 title "A Submarine Window" 5 end