\section{Expert tutorial: methane liquefaction by the Linde process} \label{sec:tutorial-methane-linde} This tutorial constructs a PH worksheet and a complete correction for an advanced methane-liquefaction exercise based on the Linde cycle. Its scope is the coupled thermodynamic process: chemistry, preliminary pure-substance questions, and methane-release modelling are outside the exercise. LuaCoolProp regenerates every isoline and resolves every state against the external CoolProp shared library. Consequently, the generated worksheet remains useful with a different chart size, another reviewed CoolProp release, or deliberately changed operating data. \begin{LCPWarning}[An advanced coupled-flow problem] This is not a single closed refrigeration cycle. It contains a fresh feed, a recirculated vapour stream, two streams exchanging heat in one regenerator, a phase separator, and a product stream. Several state enthalpies cannot be calculated until the separator mass balance and the regenerator energy balance have been closed. Drawing compressors first would silently assume a value of $h_1$ that the problem has not yet established. \end{LCPWarning} \subsection{Read the process as a directed network} The fresh methane flow rate is \( \dot m=\qty{1.0}{\kilogram\per\second} \) at state 0, with $p_0=\qty{1}{\bar}$ and $T_0=\qty{7}{\celsius}$. The principal high-pressure stream passes through three ideal compressors and three isobaric coolers: \[ 1\xrightarrow{C_1}2\xrightarrow{E_1}3 \xrightarrow{C_2}4\xrightarrow{E_2}5 \xrightarrow{C_3}6\xrightarrow{E_3}7. \] The intermediate pressures and the two prescribed cooler outlet enthalpies are \[ p_2=p_3=\qty{5}{\bar},\qquad p_4=p_5=\qty{25}{\bar},\qquad h_3=\qty{866}{\kilo\joule\per\kilogram},\qquad h_5=\qty{840}{\kilo\joule\per\kilogram}. \] State 7 is fixed by $p_7=\qty{100}{\bar}$ and $T_7=\qty{-63}{\celsius}$. The hot side of the regenerator cools this stream isobarically to $T_{7'}=\qty{-82}{\celsius}$. The valve then produces state 8 at \qty{1}{\bar} with $h_8=h_{7'}$. The separator replaces state 8 by two saturated outlet streams at \qty{1}{\bar}: saturated vapour 9 is recycled, while saturated liquid 10 is the product. The recycled vapour is heated from 9 to $1'$ by the cold side of the regenerator and mixed with fresh state 0 to form state 1. This gives the dependency order used in the implementation: \[ \begin{split} &(0,7,7',9,10)\longrightarrow 8\longrightarrow x_8 \longrightarrow (\dot m_1,\dot m_{1'}) \\ &\quad\longrightarrow h_{1'}\longrightarrow h_1 \longrightarrow (2,4,6) \longrightarrow (\dot Q_{E1},\dot Q_{E2},\dot Q_{E3},\dot W_{C1}). \end{split} \] \subsection{Use a shared worksheet and progressive solution} The generated teaching pair consists of three files: \begin{center} \begin{tabularx}{\textwidth}{@{}>{\raggedright\arraybackslash\ttfamily}p{.43\textwidth}X@{}} \toprule File & Responsibility \\ \midrule tutorial/methane-linde-worksheet.tex & One-page blank PH worksheet.\\ tutorial/methane-linde-solution.tex & Six-page progressive correction.\\ tutorial/source/methane-linde-diagrams.tex & Shared isolines, state solver, balances, process paths, annotations, and log output.\\ \bottomrule \end{tabularx} \end{center} The two drivers change only one Boolean. This prevents a later modification of the pressure or enthalpy domain from desynchronizing the student and teacher documents. \begin{LCPExample}{Thin worksheet and solution drivers} % Student worksheet \newif\ifMethaneLindeSolution \MethaneLindeSolutionfalse % Progressive model solution \newif\ifMethaneLindeSolution \MethaneLindeSolutiontrue \end{LCPExample} \subsection{Step 1: regenerate the blank methane PH chart} The worksheet covers approximately $-100\leq h\leq\qty{1200}{\kilo\joule\per\kilogram}$ and $\qty{0.2}{\bar}\leq p\leq\qty{200}{\bar}$. A logarithmic pressure axis is essential: the one-bar separator and the hundred-bar regenerator must be readable on the same sheet. \begin{LCPExample}{Axis used by the regenerated worksheet} \begin{axis}[ lcp fluid=Methane, width=24cm,height=15.8cm, xmin=-100,xmax=1200, ymin=.2,ymax=200,ymode=log, xlabel={Specific enthalpy $h$ (\si{\kilo\joule\per\kilogram})}, ylabel={Pressure $p$ (bar)}, grid=both, auto node placement, auto node algorithm=repair, auto node candidates=19, auto node bbox mode=oriented] % Four independently calculated families follow. \end{axis} \end{LCPExample} Four families provide the property information needed for the exercise: \begin{enumerate} \item qualities $x=0,0.1,\ldots,1$ define the two-phase region; \item isotherms from \qty{103}{\kelvin} to \qty{373}{\kelvin} locate the directly specified temperatures and support interpolation; \item isentropes from \qty{1}{\kilo\joule\per\kilogram\per\kelvin} to \qty{6.5}{\kilo\joule\per\kilogram\per\kelvin} construct the ideal compressor outlets; and \item isochores from \qty{0.005}{\cubic\metre\per\kilogram} to \qty{5}{\cubic\metre\per\kilogram} provide a useful secondary property grid. \end{enumerate} \begin{LCPExample}{Quality and temperature families} \LCPAddPHQuality[ fluid=Methane, pressure min=20000,pressure max=20000000, quality values={0,0.1,0.2,0.3,0.4,0.5, 0.6,0.7,0.8,0.9,1}, quality symbol=x,labels=true] \LCPAddPHIsotherms[ fluid=Methane, pressure min=20000,pressure max=20000000, temperature unit=K, temperature values={103,113,123,133,143,153, 163,173,183,193,203,213,223,233,243,253, 263,273,283,293,303,313,323,333,343,353, 363,373}, temperature symbol=T, isotherm label every=2,labels=true] \end{LCPExample} \begin{LCPExample}{Entropy and specific-volume families} \LCPAddPHIsentropes[ fluid=Methane, pressure min=20000,pressure max=20000000, entropy unit=kjkgk, entropy values={1,1.5,2,2.5,3,3.5,4,4.5, 5,5.5,6,6.5}, entropy symbol=s, isentrope label every=2,labels=true] \LCPAddPHIsochores[ fluid=Methane, pressure min=20000,pressure max=20000000, specific volume unit=m3kg, specific volume values={0.005,0.01,0.02,0.05, 0.1,0.2,0.5,1,2,5}, specific volume symbol=v, isochore label every=2,labels=true] \end{LCPExample} Alternate members of the isotherm, isentrope, and isochore families are labelled, but every requested curve remains in the plot. The distinction matters: label density is a typographic choice, whereas curve density determines graphical interpolation accuracy. Label placement is handled exclusively by \pkg{pgfplots-autonode}. \IfFileExists{tutorial/methane-linde-worksheet.pdf}{% \begin{center} \includegraphics[width=\textwidth] {tutorial/methane-linde-worksheet.pdf} \end{center} }{\begin{LCPWarning}[Methane worksheet not built] Run \texttt{scripts/build-examples.sh} before compiling the manual. \end{LCPWarning}} \subsection{Step 2: calculate the primitive states} The first calculations use only data explicitly supplied by the exercise. Short invisible paths export complete endpoint states without introducing hand-written chart coordinates. \begin{LCPExample}{Feed and one-bar saturation endpoints} \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=1bar, from={temperature=7C},to={quality=1}, style={draw=none}, export coordinates=MethaneLindeFeedVapour] \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=1bar, from={quality=0},to={quality=1}, style={draw=none}, export coordinates=MethaneLindeSaturation] \end{LCPExample} This resolves states 0, 9, and 10. The high-pressure side supplies states 7 and $7'$: \begin{LCPExample}{High-pressure regenerator endpoints} \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=100bar, from={temperature=-63C}, to={temperature=-82C}, style={draw=none}, export coordinates=MethaneLindeHighRegenerator] \end{LCPExample} The first page of the progressive correction shows only the one-, five-, twenty-five-, and hundred-bar construction levels and the directly specified states 0, 7, and 10. \IfFileExists{tutorial/methane-linde-solution.pdf}{% \begin{center} \includegraphics[page=1,width=\textwidth] {tutorial/methane-linde-solution.pdf} \end{center} }{\begin{LCPWarning}[Methane solution not built] Run \texttt{scripts/build-examples.sh} before compiling the manual. \end{LCPWarning}} \subsection{Step 3: throttle and separate the two-phase outlet} The insulated valve has no moving part. The steady-flow first law therefore gives \[ h_8=h_{7'}. \] The complete state 8, including its quality, is obtained from pressure and enthalpy: \begin{LCPExample}{Joule--Thomson throttle from 100 bar to 1 bar} \LCPAddPHProcess[ fluid=Methane,type=isenthalp, from={pressure=100bar,temperature=-82C}, to={pressure=1bar}, export coordinates=MethaneLindeThrottle, log coordinates=true] \edef\MethaneLindeQualityEight{\fpeval{ \MethaneLindeThrottleToQuality}} \end{LCPExample} CoolProp returns \[ h_8=h_{7'}=\qty{314.835}{\kilo\joule\per\kilogram}, \qquad x_8=0.617062. \] The separator is isobaric. It does not follow a reversible thermodynamic path between 8, 9, and 10; it routes the two phase fractions into two outlet streams. The two horizontal arrows are therefore a flow-topology representation, not equilibrium trajectories undergone by individual fluid particles. \begin{LCPExample}{Represent both separator outlet streams} \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=1bar, from={enthalpy=\MethaneLindeThrottleToEnthalpySI Jkg}, to={quality=1},name=ml-eight-nine] \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=1bar, from={enthalpy=\MethaneLindeThrottleToEnthalpySI Jkg}, to={quality=0},name=ml-eight-ten] \end{LCPExample} \IfFileExists{tutorial/methane-linde-solution.pdf}{% \begin{center} \includegraphics[page=2,width=\textwidth] {tutorial/methane-linde-solution.pdf} \end{center} }{} \subsection{Step 4: close the separator mass balance} Let $\dot m_1$ be the flow rate through the high-pressure train and state 8, and let $\dot m_{1'}$ be the recycled saturated-vapour flow rate. By the definition of vapour quality, \[ \dot m_{1'}=x_8\dot m_1. \] At steady state, the saturated-liquid product flow equals the fresh feed flow: \[ \dot m=(1-x_8)\dot m_1. \] Hence \[ \dot m_1=\frac{\dot m}{1-x_8}, \qquad \dot m_{1'}=\frac{x_8\dot m}{1-x_8}. \] \begin{LCPExample}{Mass-flow rates calculated from the exported quality} \edef\MethaneLindeMassFlowOne{\fpeval{ 1/(1-\MethaneLindeQualityEight)}} \edef\MethaneLindeMassFlowOneBis{\fpeval{ \MethaneLindeQualityEight *\MethaneLindeMassFlowOne}} \end{LCPExample} For the current library, the automatically generated values are \[ \dot m_1=\qty{2.61139}{\kilogram\per\second}, \qquad \dot m_{1'}=\qty{1.61139}{\kilogram\per\second}. \] Both equalities $\dot m_1=\dot m+\dot m_{1'}$ and $\dot m_{1'}=x_8\dot m_1$ should be checked before proceeding. \subsection{Step 5: close the two-stream regenerator balance} The regenerator is globally insulated and has no moving part. The two streams have different flow rates, so equating their specific-enthalpy changes would be wrong. Its steady-flow balance is \[ \dot m_1(h_{7'}-h_7) +\dot m_{1'}(h_{1'}-h_9)=0. \] Solving for the only unknown gives \[ h_{1'}=h_9 -\frac{\dot m_1}{\dot m_{1'}}(h_{7'}-h_7). \] \begin{LCPExample}{Cold-stream outlet enthalpy from the regenerator balance} \edef\MethaneLindeEnthalpyOneBisSI{\fpeval{ \MethaneLindeSaturationToEnthalpySI -(\MethaneLindeMassFlowOne /\MethaneLindeMassFlowOneBis) *(\MethaneLindeHighRegeneratorToEnthalpySI -\MethaneLindeHighRegeneratorFromEnthalpySI)}} \end{LCPExample} The live result is $h_{1'}=\qty{677.122}{\kilo\joule\per\kilogram}$. It lies to the right of state 9, as required for the cold stream that receives heat, while $7'$ lies to the left of state 7 because the high-pressure stream is cooled. \subsection{Step 6: close the mixer balance and reveal state 1} The adiabatic one-bar mixer has no moving part. Mass and enthalpy-flow conservation give \[ \dot m_1=\dot m+\dot m_{1'}, \qquad \dot m_1h_1=\dot m h_0+\dot m_{1'}h_{1'}. \] Therefore \[ h_1=\frac{\dot m h_0+\dot m_{1'}h_{1'}}{\dot m_1}. \] \begin{LCPExample}{Mixer outlet enthalpy} \edef\MethaneLindeEnthalpyOneSI{\fpeval{ (\MethaneLindeFeedVapourFromEnthalpySI +\MethaneLindeMassFlowOneBis *\MethaneLindeEnthalpyOneBisSI) /\MethaneLindeMassFlowOne}} \end{LCPExample} LuaCoolProp obtains $h_1=\qty{751.038}{\kilo\joule\per\kilogram}$ and, by querying the complete state at \qty{1}{\bar}, $T_1=\qty{-48.371}{\celsius}$. This is why state 1 must not be placed at the fresh-feed temperature. The recycle stream changes the compressor inlet substantially. \subsection{Step 7: construct the first compression and cooler} Only now is state 1 fully known. Compressor $C_1$ is adiabatic and reversible, so $s_2=s_1$ and $p_2=\qty{5}{\bar}$. \begin{LCPExample}{First compressor and first isobaric cooler} \LCPAddPHProcess[ fluid=Methane,type=isentrope, from={pressure=1bar, enthalpy=\MethaneLindeEnthalpyOneSI Jkg}, to={pressure=5bar}, export coordinates=MethaneLindeCOne, log coordinates=true] \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=5bar, from={entropy=\MethaneLindeCOneToEntropySI JkgK}, to={enthalpy=866kJkg}, export coordinates=MethaneLindeEOne] \end{LCPExample} The exact process export gives $h_2=\qty{979.046}{\kilo\joule\per\kilogram}$ and $T_2=\qty{56.861}{\celsius}$. State 3 is not inferred from a temperature curve: its enthalpy is explicit in the statement. \IfFileExists{tutorial/methane-linde-solution.pdf}{% \begin{center} \includegraphics[page=3,width=\textwidth] {tutorial/methane-linde-solution.pdf} \end{center} }{} \subsection{Step 8: repeat the invariant pattern for stages 2 and 3} The second stage repeats ``isentropic compression, then isobaric cooling'' at the next pressure level: \begin{LCPExample}{Second compression stage} \LCPAddPHProcess[ fluid=Methane,type=isentrope, from={pressure=5bar,enthalpy=866kJkg}, to={pressure=25bar}, export coordinates=MethaneLindeCTwo, log coordinates=true] \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=25bar, from={entropy=\MethaneLindeCTwoToEntropySI JkgK}, to={enthalpy=840kJkg}, export coordinates=MethaneLindeETwo] \end{LCPExample} This yields $h_4=\qty{1145.817}{\kilo\joule\per\kilogram}$ and $T_4=\qty{129.797}{\celsius}$. The third stage ends at the given state 7: \begin{LCPExample}{Third compression stage} \LCPAddPHProcess[ fluid=Methane,type=isentrope, from={pressure=25bar,enthalpy=840kJkg}, to={pressure=100bar}, export coordinates=MethaneLindeCThree, log coordinates=true] \LCPAddPHProcess[ fluid=Methane,type=isobar,pressure=100bar, from={entropy=\MethaneLindeCThreeToEntropySI JkgK}, to={temperature=-63C}, export coordinates=MethaneLindeEThree] \end{LCPExample} The third compressor outlet is $h_6=\qty{1066.089}{\kilo\joule\per\kilogram}$ at $T_6=\qty{115.236}{\celsius}$. \IfFileExists{tutorial/methane-linde-solution.pdf}{% \begin{center} \includegraphics[page=5,width=\textwidth] {tutorial/methane-linde-solution.pdf} \end{center} }{} \subsection{Step 9: calculate powers with a declared sign convention} Heat and useful work are counted positive when received by the methane. With negligible kinetic- and potential-energy changes, the steady-flow first law is \[ \dot Q+\dot W_u=\dot m(h_{\mathrm{out}}-h_{\mathrm{in}}). \] The coolers have no moving part, hence \[ \begin{aligned} \dot Q_{E1}&=\dot m_1(h_3-h_2),\\ \dot Q_{E2}&=\dot m_1(h_5-h_4),\\ \dot Q_{E3}&=\dot m_1(h_7-h_6). \end{aligned} \] All three must be negative. Their automated values are \[ \dot Q_{E1}=\qty{-295.2}{\kilo\watt},\qquad \dot Q_{E2}=\qty{-798.6}{\kilo\watt},\qquad \dot Q_{E3}=\qty{-1693.4}{\kilo\watt}. \] For the first ideal compressor, \[ \dot W_{C1}=\dot m_1(h_2-h_1) =\qty{595.4}{\kilo\watt}. \] The three idealized compressor paths imply \( \dot W_{C1}+\dot W_{C2}+\dot W_{C3} =\qty{1916.5}{\kilo\watt}. \) The exercise independently specifies a total motor power of \qty{1.8}{\mega\watt}; it is that prescribed value, rather than the sum of graphically inferred ideal stage powers, that belongs in the requested cooling effectiveness: \[ e_T=-\frac{\dot Q_{E1}+\dot Q_{E2}+\dot Q_{E3}} {\dot W_{\mathrm{motor}}} =1.5485. \] \begin{LCPExample}{Power and effectiveness calculations in LaTeX} \edef\MethaneLindeThermalPowerOneKW{\fpeval{ \MethaneLindeMassFlowOne *(866000-\MethaneLindeCOneToEnthalpySI)/1000}} \edef\MethaneLindeCompressorOnePowerKW{\fpeval{ \MethaneLindeMassFlowOne *(\MethaneLindeCOneToEnthalpySI -\MethaneLindeEnthalpyOneSI)/1000}} \edef\MethaneLindeCoolingEffectiveness{\fpeval{ -(\MethaneLindeThermalPowerOneKW +\MethaneLindeThermalPowerTwoKW +\MethaneLindeThermalPowerThreeKW)/1800}} \end{LCPExample} \subsection{Step 10: read the complete process without inventing a cycle} The final page overlays the entire network on the dense regenerated chart. The colour semantics are intentionally structural: \begin{itemize} \item red paths are the three isentropic compressions; \item blue paths are the three isobaric coolers; \item purple paths are the two sides of the regenerator and the throttle; \item teal paths represent mixing and phase separation. \end{itemize} The graphic is not a single polygon. At state 8 one incoming stream becomes states 9 and 10; at state 1, states 0 and $1'$ merge. Drawing an artificial arrow from 10 to 0 would incorrectly suggest that the liquid product is reheated and recycled. State 10 leaves the process, while state 0 is new feed. \IfFileExists{tutorial/methane-linde-solution.pdf}{% \begin{center} \includegraphics[page=6,width=\textwidth] {tutorial/methane-linde-solution.pdf} \end{center} }{} The calculated state table is: \begin{center} \small \begin{tabular}{@{}c r r r r@{}} \toprule State & $p/\mathrm{bar}$ & $T/{}^\circ\mathrm C$ & $h/\mathrm{kJ\,kg^{-1}}$ & $x$ \\ \midrule 0 & 1 & 7.000 & 870.145 & --- \\ 1 & 1 & $-48.371$ & 751.038 & --- \\ $1'$ & 1 & $-83.412$ & 677.122 & --- \\ 2 & 5 & 56.861 & 979.046 & --- \\ 3 & 5 & 7.105 & 866.000 & --- \\ 4 & 25 & 129.797 & 1145.817 & --- \\ 5 & 25 & 5.609 & 840.000 & --- \\ 6 & 100 & 115.236 & 1066.089 & --- \\ 7 & 100 & $-63.000$ & 417.612 & --- \\ $7'$ & 100 & $-82.000$ & 314.835 & --- \\ 8 & 1 & $-161.642$ & 314.835 & 0.61706 \\ 9 & 1 & $-161.642$ & 510.562 & 1 \\ 10 & 1 & $-161.642$ & $-0.557$ & 0 \\ \bottomrule \end{tabular} \end{center} Values shown as ``---'' are single-phase states, for which vapour quality is not defined. \subsection{Graphical estimates versus live calculations} The approximate column uses values read from a printed chart, with an uncertainty of approximately \(\pm\qty{20}{\kilo\joule\per\kilogram}\). The current calculation evaluates the exact state model exposed by the installed CoolProp library. The two sets must not be mixed silently. \begin{center} \small \begin{tabular}{@{}l r r@{}} \toprule Quantity & Approximate chart reading & Current live calculation \\ \midrule $h_0/\mathrm{kJ\,kg^{-1}}$ & 860 & 870.145 \\ $h_7/\mathrm{kJ\,kg^{-1}}$ & 410 & 417.612 \\ $h_{7'}=h_8\,/\mathrm{kJ\,kg^{-1}}$ & 300 & 314.835 \\ $h_9/\mathrm{kJ\,kg^{-1}}$ & 440 & 510.562 \\ $x_8$ & 0.60 & 0.61706 \\ $\dot m_1/\mathrm{kg\,s^{-1}}$ & 2.5 & 2.61139 \\ $h_{1'}/\mathrm{kJ\,kg^{-1}}$ & 620 & 677.122 \\ $h_1/\mathrm{kJ\,kg^{-1}}$ & 720 & 751.038 \\ $h_2/\mathrm{kJ\,kg^{-1}}$ & 960 & 979.046 \\ $h_4/\mathrm{kJ\,kg^{-1}}$ & 1110 & 1145.817 \\ $h_6/\mathrm{kJ\,kg^{-1}}$ & 1040 & 1066.089 \\ $e_T$ & 1.4 & 1.5485 \\ \bottomrule \end{tabular} \end{center} This difference is pedagogically useful. A graphical answer should be reported with graphical precision and compared with the computed state. An automated answer should report its fluid model, CoolProp version, exact inputs, and sign convention. The solution log provides the live values needed for that audit. \subsection{Numerical API and reproducible build} Every calculated process uses \key{export coordinates}. Among the reusable results are the endpoint enthalpy, temperature, entropy, quality, pressure, specific volume, and plotted coordinates. The implementation deliberately feeds those full-precision SI macros into later processes; rounded numbers are used only for display. For example, these two definitions are fundamentally different: \begin{LCPExample}{Keep calculation data separate from presentation} % Full-precision value used as a later state input: from={entropy=\MethaneLindeCOneToEntropySI JkgK} % Rounded presentation of the same calculation: \qty[round-mode=places,round-precision=1] {979.045669801632}{\kilo\joule\per\kilogram} \end{LCPExample} Build the worksheet, progressive solution, all examples, and the complete manual through the repository workflow: \begin{LCPExample}{Rebuild the complete documentation set} export LUACOOLPROP_LIB=/path/to/libCoolProp.dylib ./scripts/build-examples.sh \end{LCPExample} The generated PDFs are installed beside their drivers. Console transcripts are retained under \path{tutorial/logs}; the methane solution log records $x_8$, both recirculation flow rates, $h_{1'}$, $h_1$, the three cooling powers, the first compressor power, the ideal three-compressor total, and $e_T$. When adapting the example, preserve the solution order: \begin{enumerate} \item resolve directly specified and saturated states; \item apply the isenthalpic valve constraint; \item calculate quality and close the separator mass balance; \item close the two-stream regenerator energy balance; \item close the mixer mass and energy balances; \item construct each isentropic compressor and isobaric cooler; \item calculate powers from unrounded exported enthalpies; and \item audit signs, flow conservation, and the difference between specified motor power and idealized diagram readings. \end{enumerate} That order turns an apparently circular network into a deterministic, reproducible calculation. .