question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :copper_and_steel_end_to_end do 4 kind :numerical 5 describes "A copper wire of length %{copper_length} and a steel wire of length %{steel_length}, both of diameter " \ 6 "%{diameter}, are connected end to end. When stretched by a load, the net elongation is found to be " \ 7 "%{elongation}. %{load}, in newtons?" 8 given copper_length: "2.2 m" 9 given steel_length: "1.6 m" 10 given diameter: "3.0 mm" 11 given elongation: "0.70 mm" 12 asks load: "What is the load applied" 13 end
1 require_relative "../questions/copper_and_steel_end_to_end" 2 require_relative "../science/mechanical_properties_of_solids/youngs_modulus" 3 4 solve :copper_and_steel_end_to_end , using: YoungsModulus do 5 objects :copper , :steel , :both 6 7 take copper_length: copper . original_length 8 take steel_length: steel . original_length 9 take diameter: copper . diameter 10 take elongation: both . extension 11 12 deduce_from "both of diameter" , steel . diameter => copper . diameter 13 deduce_from "connected end to end" , steel . load => copper . load 14 deduce_from "the net elongation" , both . extension => copper . extension + steel . extension 15 assume copper . youngs_modulus => "1.1e11 Pa" , steel . youngs_modulus => "2.0e11 Pa" 16 17 load = copper . load 18 answer load :, in: "N" , figures: 2 19 20 conclusion "One load pulls both wires; the stiffer steel stretches less, and the two stretches together make " \ 21 "the elongation that is measured." 22 end
1 require_relative "../solutions/copper_and_steel_end_to_end" 2 3 play_with :copper_and_steel_end_to_end do 4 title "Copper and Steel End to End" 5 end