TransWikia.com

nodal analysis example

TeX - LaTeX Asked by GIsaa on May 5, 2021

I am having some difficulty with circuitikz.
If you happen to have some spare time, please kindly help me on the following problem !!!

I would like to draw the following diagram:

enter image description here

so far i was able only to get this:

documentclass[a4paper]{article}

usepackage[siunitx, RPvoltages]{circuitikz}

begin{document} 

begin{circuitikz}[scale=1.2]
    draw 
    (0,0) -- (2,0) to [twoport,t={$K^{th} branch  element$}] (4,0) -- (6,0)
    (3,-1) node[ground ] {}  ;
    
   
    draw (0,0) node[label={[font=footnotesize]above:$i$}] {} ;
    draw (6,0) node[label={[font=footnotesize]above:$j$}] {} ;

    draw (6,0) to[open, v=$v_k$] (0,0) ;
    
    draw (0,0) to[open, v=$V_i$] (3,-1) ;
    
    draw (6,0) to[open, v^=$V_j$] (3,-1) ;
   
end{circuitikz}

end{document}

enter image description here

2 Answers

Maybe this answer will suffice

enter image description here

documentclass[a4paper]{article}
usepackage[siunitx, RPvoltages]{circuitikz}
usetikzlibrary{positioning, arrows.meta}
begin{document}

begin{circuitikz}[scale=1.2]
    draw                   [short, *-, green!50!black, ultra thick]                
                                        (0,0)   coordinate(left)  
                to          [
                twoport,
                t={$K^{th}$ branch element},
                bipoles/twoport/width = 2.5, name=port, fill=blue!30
                            ]
                                        (10,0) 
                to          [short,-*]              
                                        (10,0)  coordinate(right) ; 
   coordinate  [above=of port]         (ab);
   coordinate  [below=of port]         (cd);
   draw        [
                ->, thick, red!50!black,
                shorten >=0.5cm,
                shorten <=0.5cm, 
                >=stealth, 
                out=45, 
                in=180,
                looseness=1
                ]
                                        (left) 
                to                      (ab) node[fill=blue!20, circle, ]{$v_k$}; 
   draw        [
                ->, thick, red!50!black,
                shorten >=0.5cm,
                shorten <=0.5cm, 
                >=stealth, 
                out=0, 
                in=135,
                looseness=1
                ]
                                        (ab) to (right);
   draw        [
                ->, thick, red!50!black,
                shorten >=0.5cm,
                shorten <=0.5cm, 
                >=stealth, 
                out=-45, 
                in=180,
                looseness=1
                ]
                                        (left) 
                to                      node[pos=0.5, fill=blue!20, circle]{$v_k$} (cd) ;
draw       [
                ->, thick, red!50!black,
                shorten >=0.5cm,
                shorten <=0.5cm, 
                >=stealth, 
                out=0, 
                in=225,
                looseness=1
                ]
                                        (cd) 
                to                      node[pos=0.5, fill=blue!20, circle]{$v_k$}          (right) ;                       
draw                                   (cd) node[circ]{}node[eground]{} ; 

node       [above=4pt of left, fill=red!20, circle]{$+$} 
        node[below=4pt of left,fill=red!20, circle]{$+$} 
        node[left=4pt of left, draw, circle,fill=blue!20]{$i$};
node       [above=4pt of right,fill=red!20, circle]{$-$} 
        node[below=4pt of right,fill=red!20, circle]{$+$} 
        node[right=4pt of right, draw, circle,fill=blue!20]{$j$};
node       [ below right=4pt and 0.5cm of cd,fill=red!20, circle]{$-$} 
        node[below left=4pt and 1.2cm of cd,fill=red!20, circle]{$-$} 
        node[below left=4pt and 0.5cm of cd, draw, circle,fill=blue!20]{$o$};
end{circuitikz}

end{document}

Correct answer by js bibra on May 5, 2021

This is one possible solution (although really, this is a bit of a stretch for circuitikz).

  1. use the correct syntax for the block label, and put the voltage in the block (so that the distances are corrected; it needs a little push, it's so big...)
  2. don't draw the leads yourself, let circuitikz do its work
  3. use the circ nodes for the dots.

enter image description here

documentclass[a4paper]{article}
usepackage[siunitx, RPvoltages]{circuitikz}
begin{document}

begin{circuitikz}[scale=1.2]
    draw
    (0,0) to[twoport,t={$K^{th}$ branch element}, 
    bipoles/twoport/width=2.5, v^>=$v_k$, voltage shift=2]
    (6,0) (3,-1) node[circ]{}  node[ground ] {}  ;

    draw (0,0) node[circ, label={[font=footnotesize]above:$i$}] {} ;
    draw (6,0) node[circ, label={[font=footnotesize]above:$j$}] {} ;

    draw (0,0) to[open, v=$V_i$] (3,-1) ;
    draw (6,0) to[open, v^=$V_j$] (3,-1) ;
end{circuitikz}

end{document}

If you want also + and - signs on the voltages, or have a better-shaped arrow, have a look at "advances voltages", the second example here: https://texdoc.org/serve/circuitikz/0#b7; like for example

enter image description here

documentclass[a4paper]{article}
usepackage[siunitx, RPvoltages]{circuitikz}
defeurVPM#1#2#3{% node, label,
    draw [thin, blue, shorten >=7pt, shorten <=7pt]
        (#1-Vfrom) edge[bend #3, looseness=0.7, -Stealth]
        node[pos=0.5,anchor=ctikzgetanchor{#1}{Vlab}]{#2} (#1-Vto);
    draw [thick, blue] (#1-Vfrom) ++(-3pt,0) -- ++(6pt,0)
        (#1-Vto) ++(-3pt,0) -- ++(6pt,0) ++(-3pt,-3pt) -- ++(0,6pt);
;}

begin{document}

begin{circuitikz}[scale=1.2]
    draw
    (0,0) to[twoport,t={$K^{th}$ branch element},
    bipoles/twoport/width=2.5, v^>, name=vk, voltage shift=2]
    (6,0) (3,-1) node[circ]{}  node[ground ] {}  ;   eurVPM{vk}{$V_k$}{left}

    draw (0,0) node[circ, label={[font=footnotesize]above:$i$}] {} ;
    draw (6,0) node[circ, label={[font=footnotesize]above:$j$}] {} ;

    draw (0,0) to[open, v, name=vi] (3,-1) ; eurVPM{vi}{$V_i$}{left}
    draw (6,0) to[open, v^, name=vj] (3,-1) ;  eurVPM{vj}{$V_j$}{right}
end{circuitikz}

end{document}

Answered by Rmano on May 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP