question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_mass_on_a_spring_on_a_table do 4 kind :numerical 5 describes "A spring having with a spring constant %{constant} is mounted on a horizontal table. A mass of %{mass} " \ 6 "is attached to the free end of the spring. The mass is then pulled sideways to a distance of " \ 7 "%{distance} and released. %{frequency}, in hertz?" 8 given constant: "1200 N/m" 9 given mass: "3 kg" 10 given distance: "2.0 cm" 11 asks frequency: "Determine the frequency of oscillations" 12 end
1 require_relative "../questions/a_mass_on_a_spring_on_a_table" 2 require_relative "../science/oscillations/spring_oscillator" 3 4 solve :a_mass_on_a_spring_on_a_table , using: SpringOscillator do 5 objects :block 6 7 take constant: block . spring_constant 8 take mass: block . mass 9 take distance: block . amplitude 10 11 frequency = block . frequency 12 answer frequency :, in: "Hz" , figures: 2 13 14 conclusion "The spring's stiffness against the mass sets the angular frequency, and how far the mass is pulled " \ 15 "out makes no difference to how often it swings." 16 end
1 require_relative "../solutions/a_mass_on_a_spring_on_a_table" 2 3 play_with :a_mass_on_a_spring_on_a_table do 4 title "A Mass on a Spring on a Table" 5 end