我想绘制驻波下计算粒子路径的图表,路径方程为 sin(kx)sinh[k(z+h)]=C,其中 C 为常数。我试过这个方法,但失败了。
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw [-latex] (0,0)--(16,0) node[pos=1, above left] {\(x\)};
\draw [-latex] (0,0)--(0,8) node [pos=1, above right] {\(z\)};
\draw (6,6)--(6,0.25) node[pos=0.5, currarrow, sloped] {};
\draw plot [smooth] coordinates {(6,0.25) (5.75,0.05) (5.5,0)};
\draw plot [smooth] coordinates {(6,0.25) (6.25,0.05) (6.5,0)};
\draw (12,6)--(12,0.25) node[pos=0.5, currarrow, sloped, rotate=180] {};
\draw plot [smooth] coordinates {(12,0.25) (11.75,0.05) (11.5,0)};
\draw plot [smooth] coordinates {(12,0.25) (12.25,0.05) (12.5,0)};
\draw (3,0) node [below] {\(N\)};
\draw (9,0) node [below] {\(N\)};
\draw (0,0) node [below] {\(A,\ x=0\)};
\draw (6,0) node [below] {\(A,\ x=\pi /k\)};
\draw (12,0) node [below] {\(A,\ x=2\pi /k\)};
% (x,6) -- (3,y) -- (x,6)
\draw [0.11:3.031] plot (\x, {-ln(5/sin(\x r))+sqrt(5/sin(\x r)+1)});
\end{tikzpicture}
\end{figure}
答案1
正确的语法是\draw plot[domain=0.11:3.031] (\x, {-ln(5/sin(\x r))+sqrt(5/sin(\x r)+1)});
- 但我建议对所有图表使用 PGFPlots。我不知道常数应该是什么,我只是随意放了一些。
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{decorations.markings}
\tikzset{
arr/.style={decoration={markings, mark=at position 0.5 with {\arrow{>}}},postaction={decorate}},
}
\begin{document}
\begin{tikzpicture}[
trig format=rad,
declare function={
asinh(\x)=ln(\x+sqrt(\x^2+1));
particle(\x,\C)=4*asinh(abs(\C/sin(\x)));
}
]
\begin{axis}[
width=10cm, height=4cm,
xmin=0, xmax=2.5*pi,
ymin=0, ymax=6,
xtick={0, pi, 2*pi},
xticklabels={$0$,$\pi$,$2\pi$},
ytick=\empty,
domain=0:2.5*pi, samples=100, smooth,
]
\addplot[]{particle(\x,0.2)};
\addplot[]{particle(\x,0.3)};
\addplot[]{particle(\x,0.4)};
\addplot[]{particle(\x,0.5)};
\addplot[]{particle(\x,0.6)};
\addplot[]{particle(\x,0.7)};
\addplot[]{particle(\x,0.8)};
\addplot[]{particle(\x,0.9)};
\addplot[]{particle(\x,1.0)};
\addplot[]{particle(\x,1.1)};
\addplot[]{particle(\x,1.2)};
\pgfplotsinvokeforeach{pi,2*pi}{
\draw (#1,6) -- (#1,0.25);
\draw plot [smooth] coordinates {(#1,0.25) (#1-0.25,0.05) (#1-0.5,0)};
\draw plot [smooth] coordinates {(#1,0.25) (#1+0.25,0.05) (#1+0.5,0)};
}
\end{axis}
\end{tikzpicture}
\end{document}
编辑:带箭头
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{decorations.markings, arrows.meta}
\tikzset{
arr/.style={decoration={markings,
mark=at position 0.35 with {\arrow{Stealth[scale=0.6]}},
mark=at position 0.50 with {\arrow{Stealth[scale=0.6]}},
mark=at position 0.65 with {\arrow{Stealth[scale=0.6]}},
},postaction={decorate}},
}
\begin{document}
\begin{tikzpicture}[
declare function={
asinh(\x)=ln(\x+sqrt(\x^2+1));
particle(\x,\C)=4*asinh(abs(\C/sin(\x)));
}
]
\begin{axis}[
trig format plots=rad,
width=10cm, height=4cm,
xmin=0, xmax=2.5*pi,
ymin=0, ymax=5,
xtick={0, pi, 2*pi},
xticklabels={$0$,$\pi$,$2\pi$},
ytick=\empty,
xtick align=outside, xtick pos=bottom,
samples=50,
]
\pgfplotsset{domain=pi-0.1:0.1}
\addplot[arr]{particle(\x,0.2)};
\addplot[arr]{particle(\x,0.3)};
\addplot[arr]{particle(\x,0.4)};
\addplot[arr]{particle(\x,0.5)};
\addplot[arr]{particle(\x,0.6)};
\addplot[arr]{particle(\x,0.7)};
\addplot[arr]{particle(\x,0.8)};
\addplot[arr]{particle(\x,0.9)};
\addplot[arr]{particle(\x,1.0)};
\addplot[arr]{particle(\x,1.1)};
\addplot[arr]{particle(\x,1.2)};
\pgfplotsset{domain=pi+0.1:2*pi-0.1}
\addplot[arr]{particle(\x,0.2)};
\addplot[arr]{particle(\x,0.3)};
\addplot[arr]{particle(\x,0.4)};
\addplot[arr]{particle(\x,0.5)};
\addplot[arr]{particle(\x,0.6)};
\addplot[arr]{particle(\x,0.7)};
\addplot[arr]{particle(\x,0.8)};
\addplot[arr]{particle(\x,0.9)};
\addplot[arr]{particle(\x,1.0)};
\addplot[arr]{particle(\x,1.1)};
\addplot[arr]{particle(\x,1.2)};
\pgfplotsset{domain=3*pi-0.1:2*pi+0.1}
\addplot[arr]{particle(\x,0.2)};
\addplot[arr]{particle(\x,0.3)};
\addplot[arr]{particle(\x,0.4)};
\addplot[arr]{particle(\x,0.5)};
\addplot[arr]{particle(\x,0.6)};
\addplot[arr]{particle(\x,0.7)};
\addplot[arr]{particle(\x,0.8)};
\addplot[arr]{particle(\x,0.9)};
\addplot[arr]{particle(\x,1.0)};
\addplot[arr]{particle(\x,1.1)};
\addplot[arr]{particle(\x,1.2)};
\draw (pi,5) edge[-{Stealth[scale=0.6]}] (pi,3.5) -- (pi,0.8) to[out=-90, in=0] (pi-0.2,0);
\draw (pi,0.8) to[out=-90, in=180] (pi+0.2,0);
\draw (2*pi,5) edge[-{Stealth[reversed, scale=0.6]}] (2*pi,3.5) -- (2*pi,0.8) to[out=-90, in=0] (2*pi-0.2,0);
\draw (2*pi,0.8) to[out=-90, in=180] (2*pi+0.2,0);
\end{axis}
\end{tikzpicture}
\end{document}
答案2
我有一个不太漂亮的解决方案:
...但代码更紧凑:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\draw[gray!20, thin, step=0.5] (-.1,-.1) grid (9,2.0);
\draw[ very thin,->] (-.1,0) -- (9.5,0) node[right] {$x$};
\draw (0,.1)--(0,-.1) node[below] () {$0$} (pi,.1)--(pi,-.1) node[below] () {$\pi$} (2*pi,.1)--(2*pi,-.1) node[below] () {$2\pi$};
\draw[very thin,->] (0,-.1) -- (0,2.2) node[above] {$z$};
\clip (-.1,-.1) rectangle (9.5,1.9);
\foreach \k in {.5,1,...,5}{%
\draw[latex-latex,cyan] plot[domain=0.3:2.8,smooth] (\x,{1/(\k*abs(sin(\x r)))});
\draw[latex-latex,cyan] plot[domain=3.4:6,smooth] (\x,{1/(\k*abs(sin(\x r)))});
\draw[latex-latex,cyan] plot[domain=6.5:8,smooth] (\x,{1/(\k*abs(sin(\x r)))});
}
\draw[-latex,cyan] (pi,0)--(pi,1.9);
\draw[-latex,cyan] (2*pi,0)--(2*pi,1.9);
\end{tikzpicture}
\end{document}