I am trying to plot a graph for the Van-der-Waals equation $P=\frac{RT}{V-b}-\frac{a}{V^2} with fixed constants R, T, a, b but definitely there's smth I'm doing wrong. This is my MWE:
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}[
declare function={
R = 8.31;
T=273;
a=24.76;
b=0.02661;
P(R,T,x, a, b) = (R*T)/(x - b) -(a/x^2);
P0 = P(8.314, 50, 22.4, 24.76, 0.02661);
}
]
\begin{axis}[
ytick={0,P0},
yticklabels={$0$,$P_0$}
]
\addplot[dashed, thick, domain=0:100]{P(8.314, 50, 22.4, 24.76, 0.02661)};
\addplot[thick]{P(R,T,x, a, b)};
\end{axis}
\end{tikzpicture}
\end{document}
and this is approximately what I want to obtain:

I'd be very grateful if someone helped me to figure out my issue

Pshould be defined asP(\R,\T,\x,\a,\b) = (\R*\T)/(\x-\b) - (\a/\x^2);But sinceRis a constant I would define it asP(\x,\T,\a,\b) = (R*\T)/(\x-\b) - (\a/\x^2);. Doing that allows you to call it as\addplot {P(x,T,a,b)};. Then the remaining part is to find a suitabledomainfor the volume (here variablex). Good luck. Please share your result when you are successful. – Stefan Pinnow Nov 24 '21 at 10:36