question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_brass_rod_joined_to_a_steel_rod do 4 kind :numerical 5 describes "A brass rod of length %{length} and diameter 3.0 mm is joined to a steel rod of the same length and " \ 6 "diameter. The ends of the rod are free to expand (Co-efficient of linear expansion of brass = " \ 7 "%{brass_expansion}, steel = %{steel_expansion}). %{change} at %{hot}, if the original lengths are at " \ 8 "%{cool}, in cm?" 9 given length: "50 cm" 10 given brass_expansion: "2.0e-5 K-1" 11 given steel_expansion: "1.2e-5 K-1" 12 given hot: "250 °C" 13 given cool: "40.0 °C" 14 asks change: "What is the change in length of the combined rod" 15 end
1 require_relative "../questions/a_brass_rod_joined_to_a_steel_rod" 2 require_relative "../science/thermal_properties_of_matter/thermal_expansion" 3 4 solve :a_brass_rod_joined_to_a_steel_rod , using: ThermalExpansion do 5 objects :brass , :steel , :combined 6 7 take length: brass . length_at_first 8 take brass_expansion: brass . coefficient_of_linear_expansion 9 take steel_expansion: steel . coefficient_of_linear_expansion 10 take hot: brass . temperature_after 11 take cool: brass . temperature_at_first 12 13 deduce_from "of the same length" , steel . length_at_first => brass . length_at_first 14 deduce_from "if the original lengths are at" , steel . temperature_at_first => brass . temperature_at_first , 15 steel . temperature_after => brass . temperature_after 16 deduce_from "joined to" , combined . change_in_length => brass . change_in_length + steel . change_in_length 17 18 change = combined . change_in_length 19 answer change :, in: "cm" , figures: 2 20 21 conclusion "With both ends free, each rod grows as it would alone, and the combined rod grows by the " \ 22 "sum of the two." 23 end
1 require_relative "../solutions/a_brass_rod_joined_to_a_steel_rod" 2 3 play_with :a_brass_rod_joined_to_a_steel_rod do 4 title "A Brass Rod Joined to a Steel Rod" 5 end