question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :bringing_in_a_charge do 4 kind :numerical 5 describes "A charge of %{source} is located %{distance} from a point P. %{work} in bringing a charge of %{brought} " \ 6 "from infinity to the point P, in joules?" 7 given source: "4e-7 C" 8 given distance: "9 cm" 9 given brought: "2e-9 C" 10 asks work: "What is the work done" 11 end
1 require_relative "../questions/bringing_in_a_charge" 2 require_relative "../science/electrostatic_potential_and_capacitance/electrostatic_potential" 3 4 solve :bringing_in_a_charge , using: ElectrostaticPotential do 5 objects :source , :brought 6 7 take source: source . charge 8 take distance: brought . distance ( from: source ) 9 take brought: brought . charge 10 11 work = brought . work_to_bring_in ( by: source ) 12 answer work :, in: "J" , figures: 2 13 14 conclusion "The potential at P is the work per unit charge to bring a charge there from far away, by any " \ 15 "path; the charge brought in times that potential is the work." 16 end
1 require_relative "../solutions/bringing_in_a_charge" 2 3 play_with :bringing_in_a_charge do 4 title "Bringing In a Charge" 5 end