DC circuits
In the circuit shown in the figure, the node voltage $V_B$ (with node 0 taken as ground) is $7.5\,$V. Find $V_s$.Hint: Convert $I_s$-$R_4$ to Thevenin form, and use nodal analysis.
In [1]:
from IPython.display import Image
Image(filename =r'dc_circuit_1_fig_1.png', width=320)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat dc_circuit_1_orig.in
We now replace the string \$Vs with the value of our choice by running the python script given below. It takes an existing circuit file dc_circuit_1_orig.in and produces a new circuit file dc_circuit_1.in, after replacing \$Vs with the value of our choice.
In [3]:
import gseim_calc as calc
s_Vs = '4' # to be changed by user
l = [
('$Vs', s_Vs),
]
calc.replace_strings_1("dc_circuit_1_orig.in", "dc_circuit_1.in", l)
print('dc_circuit_1.in is ready for execution')
dc_circuit_1.in is ready for execution
Execute the following cell to run GSEIM on dc_circuit_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("dc_circuit_1.in")
os.system('run_gseim dc_circuit_1.in')
Circuit: filename = dc_circuit_1.in GSEIM: Program completed.
Out[4]:
0
The circuit file (dc_circuit_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on dc_circuit_1.in) creates the data file dc_circuit_1.dat in the same directory. We can now use the python code below to compute and display the quantities of interest.
In [5]:
calc.print_dc(infile='dc_circuit_1.in', i_slv=0, i_out=0,
var_name="VA", s_format="%7.2f", s1="VA:", s2="V")
calc.print_dc(infile='dc_circuit_1.in', i_slv=0, i_out=0,
var_name="VB", s_format="%7.2f", s1="VB:", s2="V")
calc.print_dc(infile='dc_circuit_1.in', i_slv=0, i_out=0,
var_name="VC", s_format="%7.2f", s1="VC:", s2="V")
VA: 4.00 V VB: 4.50 V VC: 7.25 V
This notebook was contributed by Prof. M. B. Patil, IIT Bombay. He may be contacted at mbpatil@ee.iitb.ac.in.
In [ ]: