Synchronous generator 2

.PS
include(pstricks.m4)

cct_init

scale=1.0

dy=0.5
dx=0.5

toff = 0.05

define(`termrad_',`sourcerad_/4')
define(`terminal',`circle rad termrad_')

define(`viscous_friction',`\
                  [#Damping
                  command "`\pscustom[fillstyle=solid,fillcolor=lightgray,linecolor=white]{'"
                  # Dummy quote to fool syntax highlighter"
                  line color "white" from ($1 + ($2,-$2)) up dy/8 right dx/8 then right dx/8 down dy/8 \
                  then down dy/4 left dy/4 then left dx/8 up dy/8 then up dy/8 right dx/8
                  command "`}%'"
                  line from ($1 + ($2,-$2)) up dy/8 right dx/8 then down dy/4 left dx/4

                  command "`\pscustom[fillstyle=solid,fillcolor=lightgray,linecolor=white]{'" 
                  line color "white" from ($1 - ($2,-$2)) up dy/8 right dx/8 then left dx/8 up dy/8 \
                  then down dy/4 left dy/4 then right dx/8 down dy/8 then up dy/8 right dx/8
                  command "`}%'"
                  line from ($1 - ($2,-$2)) up dy/8 right dx/8 then down dy/4 left dx/4
                  ]')
                  
define(`inertia',`[#Inertia
                   C1: circle rad sourcerad_;
                   C2: arcd(C1.c+($1,$1),sourcerad_,135,-45) cw;
                   line from C1.nw to C2.nw;
                   line from C1.se to C2.se;
                   dot(at C1.c)
                  ]')

# See Circuit Macros manual version 11.1.3, Section 13 "Writing macros", Example 4, Figure 82
# Arg 2 is quoted so m4h expands after source() sets it, not a stale m4h from e.g. larrow
define(`phsource',`source($1,`
    m4smp_ang = rp_ang; rp_ang = 0
    savem4dir
    define(`m4_dir_',right)define(`m4a_',1)define(`m4b_',0)define(`m4c_',0)define(`m4d_',1)
    sinusoid(m4h/2,twopi_/(m4h),
    ifelse(`$2',,,`($2)/360*twopi_+')pi_/2,-m4h/2,m4h/2) with .Origin at Here
    restorem4dir
    rp_ang = m4smp_ang',
    $3,$4,$5)')
 
O: (0,0)

A2: terminal with .c at O
line left 2*dx from A2.w
line up dy/2
Ea: phsource(up_ dy, 0); llabel(_-,\mathbf{E}_{af},_+)
line up dy/2
La: inductor(right_ to 1/2 between Here and (A2.w.x,Here.y),,3,,dimen_/5); llabel(,X_s,)
Ra: resistor(right_ to (A2.w.x,Here.y)); llabel(,R_a,)
A1: terminal

switch(right_ 2*dx from A1.e,,DK); larrow(\mathbf{I}_a = 0)
Va: phsource(down_ to (Here.x,A2.y), 0); llabel(_+,\mathbf{V}_a,_-)
line to A2.e

Lf: inductor(right_ dx from (Ea.c-(2*dx,0)),,3,,dimen_/5)
line down from Lf.start to (Lf.start.x,A2.n.y)
F1: terminal
F2: terminal with .c at (Lf.end.x,F1.y)
arrowline(up_ from F2.n to Lf.end); rlabel(,I_{f|_{DC}},)

Jm: inertia(dx/8) with .C1 at Lf.c-(1.5*dx,1.5*dy)
S1: line thick 1.25 from Jm.C2.ne to Lf.c
S2: line thick 1.25 from Jm.C1 down 1.5*dx left 1.5*dx
arcd(Here,sourcerad_+dx/8,-30,105) ccw <-
"$T_m$" at last arc .start ljust

Dm: viscous_friction((.4 between S2.start and S2.end),dx/32) with .c at .4 between S2.start and S2.end


arcd((.4 between S2.start and S2.end),sourcerad_+dx/8,-15,120) ccw ->
"$T_b{=}B\omega_m$" at last arc .end rjust
#"$B$" at last arc .start ljust

arcd(Jm.C2.c,sourcerad_+dx/8,-15,105) ccw ->
"$T_{j}{=}J\dfrac{d\omega_m}{dt}$" at last arc .end rjust
#"$J$" at last arc .start ljust

arcd((.75 between S2.start and S2.end),sourcerad_+dx/8,-30,105) ccw <-
"$\omega_m$" at last arc .start ljust

arcd((.15 between S1.start and S1.end),sourcerad_+dx/8,-30,105) ccw ->
"$T_e$" at last arc .end rjust


.PE