question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :four_hollow_columns do 4 kind :numerical 5 describes "Four identical hollow cylindrical columns of mild steel support a big structure of mass %{mass}. The " \ 6 "inner and outer radii of each column are %{inner} and %{outer} respectively. Assuming the load " \ 7 "distribution to be uniform, and taking Young's modulus of steel as %{modulus} and g as %{gravity}, " \ 8 "%{strain}?" 9 given mass: "50000 kg" 10 given inner: "30 cm" 11 given outer: "60 cm" 12 given modulus: "2.0e11 N/m2" 13 given gravity: "9.8 m/s2" 14 asks strain: "what is the compressional strain of each column" 15 end
1 require_relative "../questions/four_hollow_columns" 2 require_relative "../science/mechanical_properties_of_solids/youngs_modulus" 3 4 solve :four_hollow_columns , using: YoungsModulus do 5 objects :structure , :column , :inner_hole , :outer_rim 6 7 take mass: structure . mass 8 take inner: inner_hole . thickness 9 take outer: outer_rim . thickness 10 take modulus: column . youngs_modulus 11 take gravity: g 12 13 deduce_from "hollow cylindrical columns" , column . cross_section => outer_rim . cross_section - inner_hole . cross_section 14 deduce_from "Four identical" , column . load => structure . mass * g / 4 15 16 strain = column . strain 17 answer strain :, figures: 3 18 19 conclusion "Each column carries a quarter of the weight over the ring of steel between its two radii; " \ 20 "steel is so stiff that it shortens by less than a millionth of its length." 21 end
1 require_relative "../solutions/four_hollow_columns" 2 3 play_with :four_hollow_columns do 4 title "Four Hollow Columns" 5 end