question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_ten_volt_battery_s_terminal_voltage do 4 kind :numerical 5 describes "A battery of emf %{emf} and internal resistance %{internal} is connected to a resistor. If the current " \ 6 "in the circuit is %{current}, %{terminal}, in volts?" 7 given emf: "10 V" 8 given internal: "3 Ω" 9 given current: "0.5 A" 10 asks terminal: "what is the terminal voltage of the battery when the circuit is closed" 11 end
1 require_relative "../questions/a_ten_volt_battery_s_terminal_voltage" 2 require_relative "../science/current_electricity/ohms_law" 3 4 solve :a_ten_volt_battery_s_terminal_voltage , using: OhmsLaw do 5 objects :battery , :resistor , :circuit 6 7 take emf: circuit . voltage 8 take internal: battery . resistance 9 take current: circuit . current 10 11 deduce_from "connected to a resistor" , circuit . resistance => battery . resistance + resistor . resistance 12 deduce_from "the current in the circuit" , resistor . current => circuit . current 13 14 terminal = resistor . voltage 15 answer terminal :, in: "V" , figures: 2 16 17 conclusion "Part of the emf is spent driving the current through the battery itself; what is left across its " \ 18 "terminals is the voltage across the resistor." 19 end
1 require_relative "../solutions/a_ten_volt_battery_s_terminal_voltage" 2 3 play_with :a_ten_volt_battery_s_terminal_voltage do 4 title "A Ten Volt Battery's Terminal Voltage" 5 end