Draw a diagram using TikZ to represent a parallel connection of two blocks

tikz-pgftikz-styles

I am learning TikZ to draw diagrams for LaTeX documents.. One challenge for me is to draw a block diagram using TikZ for a parallel connection of two blocks. Kindly help me with a suitable TikZ code to draw this diagram. Thank you!

enter image description here

Best Answer

This diagram made using TikZ. A good practice is to define your own styles with tikzset and normally creating some level of flexibility with n args and defining a default style.

This is how I created the styles: addCross, mySimpleArrow and myBlock. These commands were written so that I can place them as the optional argument of a scope block, that is \begin{scope}[opt args]. Please, notice you can edit the arrow style at your will. If you want colors, just use a syntax like mySimpleArrow={blue}{red} instead of mySimpleArrow at the scope block.

The first blocks of scopes define the main nodes of the diagram, i.e., circles and squares. The last scope if responsible for drawing the connections between nodes.

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{addCross/.style n args={6}{
    minimum size={#5 mm},
    path picture={
      \draw[#6]
      (path picture bounding box.south east) -- (path picture bounding box.north west)
      (path picture bounding box.south west) -- (path picture bounding box.north east);
      \node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {#1};
      \node at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$)  {#2};
      \node at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {#3};
      \node at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$)  {#4};
    }
  },
  addCross/.default={}{}{}{}{10}{}
}
\tikzset{mySimpleArrow/.style n args={2}{
    >={latex[#1]},
    every path/.style={draw=#2}
  },
  mySimpleArrow/.default={black}{black}
}
\tikzset{myBlock/.style ={
    every node/.style={rectangle,draw, text=black,
      minimum width=1.5cm, minimum height=1.5cm,}
  }
}

\begin{document}
\begin{tikzpicture}[ultra thick, font={\Large}]
\node[draw,circle,addCross={\small$+$}{}{\small$+$}{}{10}{}] (S) at (2,0) {};

\begin{scope}[myBlock]
  \node (G1) at (0,1) {$G_1(s)$};
  \node (G2) at (0,-1) {$G_2(s)$};
\end{scope}

\begin{scope}[mySimpleArrow]
  \path[->] (G1) -| (S) node[above, midway]{$Y_1(s)$};
  \path[->] (G2) -| (S) node[below, midway]{$Y_2(s)$};
  \path[->] (-3,0) node[above]{$U(s)$} -- ++(1,0) coordinate(U) |- (G1) node[above, midway]{$U_1(s)$};
  \path[->] (U) |- (G2) node[below, midway]{$U_2(s)$};
  \path[->] (S) -- ++(2,0) node[above]{$Y(s)$};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

P.S. I'd say your image comes from a Ogata's book. I recognize the arrow style despite not reproducing it exactly at this example.