Nodal and mesh analysis 1

.PS
include(pstricks.m4)

scale=25.4  # scale factor for the diagram

cct_init

dy=20 # vertical spacing between elements
dx=30 # horizontal spacing between elements

O: (0,0)  # origin point for the circuit diagram

move to O

Iy: source(up_ dy,I);llabel(,i_y,)
{ # Push current location to the "stack"
  N1:dot(at Here)
  line up dy
  R1: resistor(right_ 2*dx);llabel(,R_1,)
  line down to (Here.x,Iy.end.y)
  dot(at Here)
} # Return to the previous location on the "stack"
R2: resistor(right_ dx);llabel(,R_2,)
{ # Push current location to the "stack"
  N2: dot(at Here)
  Vx: source(down_ to (Here.x,O.y),V,,R);rlabel(,v_x,)
  dot(at Here)
  ground(at Here)
} # Return to the previous location on the "stack"
R3: resistor(right_ dx); llabel(,R_3,)
N3: dot(at Here)
R4: resistor(down_ to (Here.x,O.y));llabel(,R_4,)
line left to O

# Draw mesh current
I1: arcd(1/2 between Iy.end and Vx.end,dy/4,-135,-45) cw ->
I2: arcd(1/2 between Vx.start and R4.end,dy/4,-135,-45) cw ->
I3: arcd(1/2 between Iy.end and R1.end,dy/4,-135,-45) cw ->

# Label mesh current
"$i_1$" at I1.c
"$i_2$" at I2.c
"$i_3$" at I3.c

# Label nodal voltages
"$v_1$" at N1.n rjust above
"$v_2$" at N2.n above
"$v_3$" at N3.n ljust above


.PE