question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :an_electron_circling_in_a_field do 4 kind :numerical 5 describes "An electron (mass %{mass}, charge %{charge}) is moving with a speed of %{speed} in a magnetic field of " \ 6 "%{field} perpendicular to it. %{radius}, in cm?" 7 given mass: "9e-31 kg" 8 given charge: "1.6e-19 C" 9 given speed: "3e7 m/s" 10 given field: "6e-4 T" 11 asks radius: "What is the radius of its path" 12 end
1 require_relative "../questions/an_electron_circling_in_a_field" 2 require_relative "../science/moving_charges_and_magnetism/magnetic_force" 3 4 solve :an_electron_circling_in_a_field , using: MagneticForce do 5 objects :electron 6 7 take mass: electron . mass 8 take charge: electron . charge 9 take speed: electron . speed 10 take field: B 11 12 radius = electron . radius_of_the_path 13 answer radius :, in: "cm" , figures: 2 14 15 conclusion "The magnetic force is always across the motion, so it bends the path into a circle without " \ 16 "changing the speed; heavier or faster charges circle wider." 17 end
1 require_relative "../solutions/an_electron_circling_in_a_field" 2 3 play_with :an_electron_circling_in_a_field do 4 title "An Electron Circling in a Field" 5 end