我怎样才能绘制节流阀?

我怎样才能绘制节流阀?

我正在尝试复制这个节流阀图以用于我的分子热力学笔记。

节流阀

但是,我对 tikz 还比较陌生,而且我正在努力复制连接到活塞的小“圆柱体”(我标记了我正在谈论的内容)。

在此处输入图片描述

我尝试改变圆柱体的宽度,但无法按预期减小它。我该如何修复?

这是我目前的代码:

    \documentclass[tikz]{standalone}
    \usepackage{amsthm}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{xcolor}
    \usepackage{graphicx}
    \usepackage{tikz}
    \usepackage{tkz-euclide}
    \usepackage{pdfpages}
    \usepackage{xlop}
    \usepackage{float}
    
    \begin{document}
        \begin{tikzpicture}
            % Left "cylinder"
            \node[draw, left color = gray!90, right color = gray!80, middle color = gray!40, shape = rectangle, minimum width = 0.01 cm, minimum height = 2 cm, anchor = center, rotate = 90] at (-2.600, 0.000) {};
            % Right "cylinder"
            \node[draw, left color = gray!90, right color = gray!80, middle color = gray!40, shape = rectangle, minimum width = 0.01 cm, minimum height = 2 cm, anchor = center, rotate = 90] at (3.100, 0.000) {};
            % Room for the piston
            \node[draw, shape = rectangle, minimum width = 8.5 cm, minimum height = 2 cm, anchor = center] at (0.000,0.000) {};
            % Left piston
            \node[draw, left color = gray!90, right color = gray!80, middle color = gray!40, shape = rectangle, minimum width = 2 cm, minimum height = 0.4 cm, anchor = center, rotate = 90] at (-1.500, 0.000) {};
            % Right piston
            \node[draw, left color = gray!90, right color = gray!80, middle color = gray!40, shape = rectangle, minimum width = 2 cm, minimum height = 0.4 cm, anchor = center, rotate = 90] at (2.000, 0.000) {};
            % Initial volume
            \node[draw, fill = gray!25, shape = rectangle, minimum width = 2 cm, minimum height = 0.6 cm, anchor = center, rotate = 90] at (-0.850, 0.000) {};
            % Choke valve area
            \node[draw, fill = orange!70, shape = rectangle, minimum width = 2 cm, minimum height = 0.2 cm, anchor = center, rotate = 90] at (-0.300, 0.000) {};
            %  Final volume
            \node[draw, fill = gray!25, shape = rectangle, minimum width = 2 cm, minimum height = 1.4 cm, anchor = center, rotate = 90] at (0.750, 0.000) {};
            % nodes
            \draw[-]  ( 1.425,  1.200) -- ( 1.425,  1.500);
            \draw[-]  ( 0.050,  1.200) -- ( 0.050,  1.500);
            \draw[-]  ( 0.050,  1.350) -- ( 1.425,  1.350) node[midway, fill = white]{$V_{f}$};
            \draw[-]  (-1.150,  1.200) -- (-1.150,  1.500);
            \draw[-]  (-0.550,  1.200) -- (-0.550,  1.500);
            \draw[-]  (-1.150,  1.350) -- (-0.550,  1.350) node[midway, fill = white]{$V_{0}$};
            \draw[->] (-0.300, -1.500) -- (-0.300, -1.100);
            \node at  (-0.850,  0.000) {$P_{0}$};
            \node at  ( 0.700,  0.000) {$P_{f}$};
            \node at  (-0.300, -1.700) {\small{válvula de estrangulamiento}};
        \end{tikzpicture}
\end{document}

通过显示的代码,我得到了下图:

在此处输入图片描述

我很感激任何帮助或建议来改善这个形象。谢谢!

答案1

首先,2[inner sep] 是节点占用的绝对最小空间,因此在使用 [最小高度] 和 [最小宽度](无文本)时设置 [inner sep=0pt]。

其次,阴影似乎是在旋转之后应用的。

\documentclass[tikz]{standalone}
%\usepackage{amsthm}% not used
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
\usepackage{xcolor}
%\usepackage{graphicx}% redunctant
%\usepackage{tikz}% redundant
%\usepackage{tkz-euclide}
%\usepackage{pdfpages}
%\usepackage{xlop}
%\usepackage{float}
    
    \usetikzlibrary{shadings}
    
    \begin{document}
        \begin{tikzpicture}
            % Left "cylinder"
            \node[draw, top color = gray!90, bottom color = gray!80, middle color = gray!40, shape = rectangle, minimum height = 0.1 cm, minimum width = 2 cm, inner sep=0pt, anchor = center] at (-2.600, 0.000) {};
            % Right "cylinder"
            \node[draw, top color = gray!90, bottom color = gray!80, middle color = gray!40, shape = rectangle, minimum height = 0.1 cm, minimum width = 2 cm, inner sep=0pt, anchor = center] at (3.100, 0.000) {};
            % Room for the piston
            \node[draw, shape = rectangle, minimum width = 8.5 cm, minimum height = 2 cm, anchor = center] at (0.000,0.000) {};
            % Left piston
            \node[draw, top color = gray!90, bottom color = gray!80, middle color = gray!40, shape = rectangle, minimum height = 2 cm, minimum width = 0.4 cm, inner sep=0pt, anchor = center] at (-1.500, 0.000) {};
            % Right piston
            \node[draw, top color = gray!90, bottom color = gray!80, middle color = gray!40, shape = rectangle, minimum height = 2 cm, minimum width = 0.4 cm, inner sep=0pt, anchor = center] at (2.000, 0.000) {};
            % Initial volume
            \node[draw, fill = gray!25, shape = rectangle, minimum width = 2 cm, minimum height = 0.6 cm, anchor = center, rotate = 90] at (-0.850, 0.000) {};
            % Choke valve area
            \node[draw, fill = orange!70, shape = rectangle, minimum width = 2 cm, minimum height = 0.2 cm, anchor = center, rotate = 90] at (-0.300, 0.000) {};
            %  Final volume
            \node[draw, fill = gray!25, shape = rectangle, minimum width = 2 cm, minimum height = 1.4 cm, anchor = center, rotate = 90] at (0.750, 0.000) {};
            % nodes
            \draw[-]  ( 1.425,  1.200) -- ( 1.425,  1.500);
            \draw[-]  ( 0.050,  1.200) -- ( 0.050,  1.500);
            \draw[-]  ( 0.050,  1.350) -- ( 1.425,  1.350) node[midway, fill = white]{$V_{f}$};
            \draw[-]  (-1.150,  1.200) -- (-1.150,  1.500);
            \draw[-]  (-0.550,  1.200) -- (-0.550,  1.500);
            \draw[-]  (-1.150,  1.350) -- (-0.550,  1.350) node[midway, fill = white]{$V_{0}$};
            \draw[->] (-0.300, -1.500) -- (-0.300, -1.100);
            \node at  (-0.850,  0.000) {$P_{0}$};
            \node at  ( 0.700,  0.000) {$P_{f}$};
            \node at  (-0.300, -1.700) {\small{válvula de estrangulamiento}};
        \end{tikzpicture}
\end{document}

演示

相关内容