question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_wire_held_up_by_a_field do 4 kind :numerical 5 describes "A straight wire of mass %{mass} and length %{length} carries a current of %{current}. It is suspended " \ 6 "in mid-air by a uniform horizontal magnetic field. Taking g as %{gravity}, %{field}, in teslas?" 7 given mass: "200 g" 8 given length: "1.5 m" 9 given current: "2 A" 10 given gravity: "9.8 m/s2" 11 asks field: "what is the magnitude of the magnetic field" 12 end
1 require_relative "../questions/a_wire_held_up_by_a_field" 2 require_relative "../science/moving_charges_and_magnetism/magnetic_force" 3 4 solve :a_wire_held_up_by_a_field , using: MagneticForce do 5 objects :wire 6 7 take mass: wire . mass 8 take length: wire . length_in_the_field 9 take current: wire . current 10 take gravity: g 11 12 deduce_from "suspended in mid-air" , wire . force_on_a_wire => wire . mass * g 13 14 field = B 15 answer field :, in: "T" , figures: 2 16 17 conclusion "The field's push on the current holds up the wire's weight, so the field is the weight over " \ 18 "the current times the length." 19 end
1 require_relative "../solutions/a_wire_held_up_by_a_field" 2 3 play_with :a_wire_held_up_by_a_field do 4 title "A Wire Held Up by a Field" 5 end