\input regression-test.tex \documentclass{article} \usepackage{tikzphysics} \newdimen\actual \newdimen\error \newcommand{\assertcoord}[5]{% \pgfextractx{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#3\relax \ifdim\error<0pt\error=-\error\fi \ifdim\error<.04pt\TYPE{PASS: #5 x}\else\TYPE{FAIL: #5 x got \the\actual}\fi \pgfextracty{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#4\relax \ifdim\error<0pt\error=-\error\fi \ifdim\error<.04pt\TYPE{PASS: #5 y}\else\TYPE{FAIL: #5 y got \the\actual}\fi} \newdimen\expectedx \newdimen\expectedy \newcommand{\sameanchor}[4]{% \pgfextractx{\expectedx}{\pgfpointanchor{#1}{#3}}% \pgfextracty{\expectedy}{\pgfpointanchor{#1}{#3}}% \assertcoord{#1}{#2}{\expectedx}{\expectedy}{#4}} \begin{document}\START\setbox0=\hbox{\begin{tikzpicture} \node[thermal reservoir] (N0) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N0}{bottom-\p}} \TYPE{PASS: thermal reservoir bottom anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N0}{right-\p}} \TYPE{PASS: thermal reservoir right anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N0}{top-\p}} \TYPE{PASS: thermal reservoir top anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N0}{left-\p}} \TYPE{PASS: thermal reservoir left anchors} \node[gas chamber] (N1) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N1}{bottom-\p}} \TYPE{PASS: gas chamber bottom anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N1}{right-\p}} \TYPE{PASS: gas chamber right anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N1}{top-\p}} \TYPE{PASS: gas chamber top anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N1}{left-\p}} \TYPE{PASS: gas chamber left anchors} \node[thermal wall] (N2) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N2}{bottom-\p}} \TYPE{PASS: thermal wall bottom anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N2}{right-\p}} \TYPE{PASS: thermal wall right anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N2}{top-\p}} \TYPE{PASS: thermal wall top anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N2}{left-\p}} \TYPE{PASS: thermal wall left anchors} \node[heat engine] (N3) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N3}{rim-\p}} \TYPE{PASS: heat engine rim anchors} \node[refrigerator] (N4) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N4}{bottom-\p}} \TYPE{PASS: refrigerator bottom anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N4}{right-\p}} \TYPE{PASS: refrigerator right anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N4}{top-\p}} \TYPE{PASS: refrigerator top anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N4}{left-\p}} \TYPE{PASS: refrigerator left anchors} \node[isothermal process] (N5) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N5}{process-\p}} \TYPE{PASS: isothermal process process anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N5}{volume-axis-\p}} \TYPE{PASS: isothermal process volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N5}{pressure-axis-\p}} \TYPE{PASS: isothermal process pressure-axis anchors} \node[isobaric process] (N6) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N6}{process-\p}} \TYPE{PASS: isobaric process process anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N6}{volume-axis-\p}} \TYPE{PASS: isobaric process volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N6}{pressure-axis-\p}} \TYPE{PASS: isobaric process pressure-axis anchors} \node[isochoric process] (N7) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N7}{process-\p}} \TYPE{PASS: isochoric process process anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N7}{volume-axis-\p}} \TYPE{PASS: isochoric process volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N7}{pressure-axis-\p}} \TYPE{PASS: isochoric process pressure-axis anchors} \node[adiabatic process] (N8) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N8}{process-\p}} \TYPE{PASS: adiabatic process process anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N8}{volume-axis-\p}} \TYPE{PASS: adiabatic process volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N8}{pressure-axis-\p}} \TYPE{PASS: adiabatic process pressure-axis anchors} \node[polytropic process] (N9) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N9}{process-\p}} \TYPE{PASS: polytropic process process anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N9}{volume-axis-\p}} \TYPE{PASS: polytropic process volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N9}{pressure-axis-\p}} \TYPE{PASS: polytropic process pressure-axis anchors} \node[rectangular cycle] (N10) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N10}{AB-\p}} \TYPE{PASS: rectangular cycle AB anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N10}{BC-\p}} \TYPE{PASS: rectangular cycle BC anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N10}{CD-\p}} \TYPE{PASS: rectangular cycle CD anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N10}{DA-\p}} \TYPE{PASS: rectangular cycle DA anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N10}{volume-axis-\p}} \TYPE{PASS: rectangular cycle volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N10}{pressure-axis-\p}} \TYPE{PASS: rectangular cycle pressure-axis anchors} \node[carnot cycle] (N11) {}; \foreach \p in {0,...,100}{\pgfpointanchor{N11}{hot-\p}} \TYPE{PASS: carnot cycle hot anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N11}{expansion-\p}} \TYPE{PASS: carnot cycle expansion anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N11}{cold-\p}} \TYPE{PASS: carnot cycle cold anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N11}{compression-\p}} \TYPE{PASS: carnot cycle compression anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N11}{volume-axis-\p}} \TYPE{PASS: carnot cycle volume-axis anchors} \foreach \p in {0,...,100}{\pgfpointanchor{N11}{pressure-axis-\p}} \TYPE{PASS: carnot cycle pressure-axis anchors} \assertcoord{N0}{heat-top}{0cm}{0.4cm}{N0 heat-top} \assertcoord{N1}{heat-left}{-1.2cm}{0cm}{N1 heat-left} \assertcoord{N3}{heat-in}{0cm}{0.6cm}{N3 heat-in} \assertcoord{N4}{heat-in}{0cm}{-0.6cm}{N4 heat-in} \assertcoord{N5}{process-50}{0cm}{-0.375cm}{N5 process-50} \assertcoord{N6}{process-50}{0cm}{0.75cm}{N6 process-50} \assertcoord{N7}{process-50}{-1cm}{0.1875cm}{N7 process-50} \assertcoord{N8}{process-50}{0cm}{-0.6474094313379011cm}{N8 process-50} \assertcoord{N9}{process-50}{0cm}{-0.5206306162918602cm}{N9 process-50} \assertcoord{N10}{state-A}{-1cm}{-0.75cm}{N10 state-A} \assertcoord{N11}{state-A}{-1cm}{0.75cm}{N11 state-A} \assertcoord{N11}{state-B}{-0.5cm}{0.0cm}{N11 state-B} \assertcoord{N11}{state-C}{1.0792014356780038cm}{-0.9519682991676598cm}{N11 state-C} \assertcoord{N11}{state-D}{0.05280095711866917cm}{-0.6779524487514899cm}{N11 state-D} \sameanchor{N11}{hot-0}{state-A}{Carnot hot 0} \sameanchor{N11}{hot-100}{state-B}{Carnot hot 100} \sameanchor{N11}{expansion-0}{state-B}{Carnot expansion 0} \sameanchor{N11}{expansion-100}{state-C}{Carnot expansion 100} \sameanchor{N11}{cold-0}{state-C}{Carnot cold 0} \sameanchor{N11}{cold-100}{state-D}{Carnot cold 100} \sameanchor{N11}{compression-0}{state-D}{Carnot compression 0} \sameanchor{N11}{compression-100}{state-A}{Carnot compression 100} \node[isothermal process,pv start volume=3,pv start pressure=1,pv end volume=1] (Reverse) {}; \assertcoord{Reverse}{end}{-1cm}{0.75cm}{Reverse end} \node[isothermal process,rotate=90,scale=2] (Rot) at (5,5) {}; \assertcoord{Rot}{start}{3.5cm}{3cm}{Rot start} \node[isothermal process,pv width=8cm,pv start pressure=2] (Later) {}; \assertcoord{N5}{process-50}{0cm}{-0.375cm}{N5 process-50} \pic (E) {heat engine diagram};\pic (R) at (8,0) {refrigerator diagram}; \assertcoord{E-hot}{center}{0cm}{2cm}{E-hot center} \assertcoord{E-work}{center}{2.1cm}{0cm}{E-work center} \assertcoord{R-cold}{center}{8cm}{-2cm}{R-cold center} \assertcoord{N3}{north east}{0.424264069cm}{0.424264069cm}{N3 north east} \pgfextractx{\actual}{\pgfpointshapeborder{N3}{\pgfpoint{3cm}{3cm}}} \error=\actual\advance\error by-.424264069cm \ifdim\error<0pt\error=-\error\fi \ifdim\error<.04pt\TYPE{PASS: circular engine automatic border x}\else\TYPE{FAIL: circular engine automatic border x}\fi \pgfextracty{\actual}{\pgfpointshapeborder{N3}{\pgfpoint{3cm}{3cm}}} \error=\actual\advance\error by-.424264069cm \ifdim\error<0pt\error=-\error\fi \ifdim\error<.04pt\TYPE{PASS: circular engine automatic border y}\else\TYPE{FAIL: circular engine automatic border y}\fi \node[pv diagram] (Frame) {}; \node[isothermal process,pv show axes=false] (Hidden) {}; \foreach \p in {0,...,100}{\pgfpointanchor{Frame}{volume-axis-\p}\pgfpointanchor{Frame}{pressure-axis-\p}} \TYPE{PASS: shared PV frame all axis percentages} \assertcoord{Frame}{origin}{-2.000000000cm}{-1.500000000cm}{Frame origin} \assertcoord{Frame}{pressure-end}{-2.000000000cm}{1.500000000cm}{Frame pressure-end} \assertcoord{Frame}{volume-end}{2.000000000cm}{-1.500000000cm}{Frame volume-end} \assertcoord{Hidden}{start-pressure}{-2.000000000cm}{0.750000000cm}{Hidden start-pressure} \assertcoord{Hidden}{end-pressure}{-2.000000000cm}{-0.750000000cm}{Hidden end-pressure} \assertcoord{Hidden}{process-50}{0.000000000cm}{-0.375000000cm}{Hidden process-50} \assertcoord{N5}{process-17}{-0.660000000cm}{0.179104478cm}{N5 process-17} \assertcoord{N5}{process-37}{-0.260000000cm}{-0.206896552cm}{N5 process-37} \assertcoord{N5}{process-83}{0.660000000cm}{-0.654135338cm}{N5 process-83} \assertcoord{N6}{process-17}{-0.660000000cm}{0.750000000cm}{N6 process-17} \assertcoord{N6}{process-37}{-0.260000000cm}{0.750000000cm}{N6 process-37} \assertcoord{N6}{process-83}{0.660000000cm}{0.750000000cm}{N6 process-83} \assertcoord{N8}{process-17}{-0.660000000cm}{-0.006394857cm}{N8 process-17} \assertcoord{N8}{process-37}{-0.260000000cm}{-0.463871617cm}{N8 process-37} \assertcoord{N8}{process-83}{0.660000000cm}{-0.928062955cm}{N8 process-83} \assertcoord{N9}{process-17}{-0.660000000cm}{0.083641084cm}{N9 process-17} \assertcoord{N9}{process-37}{-0.260000000cm}{-0.342493549cm}{N9 process-37} \assertcoord{N9}{process-83}{0.660000000cm}{-0.804456087cm}{N9 process-83} \assertcoord{N7}{process-17}{-1.000000000cm}{0.558750000cm}{N7 process-17} \assertcoord{N7}{process-37}{-1.000000000cm}{0.333750000cm}{N7 process-37} \assertcoord{N7}{process-83}{-1.000000000cm}{-0.183750000cm}{N7 process-83} \node[carnot cycle,carnot temperature ratio=.8,carnot expansion ratio=1.8,pv show axes=false] (Other) {}; \assertcoord{Other}{state-A}{-1.000000000cm}{0.750000000cm}{Other state-A} \assertcoord{Other}{state-A-volume}{-1.000000000cm}{-1.500000000cm}{Other state-A-volume} \assertcoord{Other}{state-A-pressure}{-2.000000000cm}{0.750000000cm}{Other state-A-pressure} \assertcoord{Other}{state-B}{-0.200000000cm}{-0.250000000cm}{Other state-B} \assertcoord{Other}{state-B-volume}{-0.200000000cm}{-1.500000000cm}{Other state-B-volume} \assertcoord{Other}{state-B-pressure}{-2.000000000cm}{-0.250000000cm}{Other state-B-pressure} \assertcoord{Other}{state-C}{1.144470593cm}{-0.927566598cm}{Other state-C} \assertcoord{Other}{state-C-volume}{1.144470593cm}{-1.500000000cm}{Other state-C-volume} \assertcoord{Other}{state-C-pressure}{-2.000000000cm}{-0.927566598cm}{Other state-C-pressure} \assertcoord{Other}{state-D}{-0.253071893cm}{-0.469619876cm}{Other state-D} \assertcoord{Other}{state-D-volume}{-0.253071893cm}{-1.500000000cm}{Other state-D-volume} \assertcoord{Other}{state-D-pressure}{-2.000000000cm}{-0.469619876cm}{Other state-D-pressure} \assertcoord{Other}{hot-0}{-1.000000000cm}{0.750000000cm}{Other hot-0} \assertcoord{Other}{hot-37}{-0.704000000cm}{0.236111111cm}{Other hot-37} \assertcoord{Other}{hot-100}{-0.200000000cm}{-0.250000000cm}{Other hot-100} \assertcoord{Other}{expansion-0}{-0.200000000cm}{-0.250000000cm}{Other expansion-0} \assertcoord{Other}{expansion-37}{0.297454120cm}{-0.611728079cm}{Other expansion-37} \assertcoord{Other}{expansion-100}{1.144470593cm}{-0.927566598cm}{Other expansion-100} \assertcoord{Other}{cold-0}{1.144470593cm}{-0.927566598cm}{Other cold-0} \assertcoord{Other}{cold-37}{0.627379874cm}{-0.814906832cm}{Other cold-37} \assertcoord{Other}{cold-100}{-0.253071893cm}{-0.469619876cm}{Other cold-100} \assertcoord{Other}{compression-0}{-0.253071893cm}{-0.469619876cm}{Other compression-0} \assertcoord{Other}{compression-37}{-0.529435292cm}{-0.188691962cm}{Other compression-37} \assertcoord{Other}{compression-100}{-1.000000000cm}{0.750000000cm}{Other compression-100} \assertcoord{N10}{state-A-volume}{-1.000000000cm}{-1.500000000cm}{N10 state-A-volume} \assertcoord{N10}{state-A-pressure}{-2.000000000cm}{-0.750000000cm}{N10 state-A-pressure} \assertcoord{N10}{state-B-volume}{-1.000000000cm}{-1.500000000cm}{N10 state-B-volume} \assertcoord{N10}{state-B-pressure}{-2.000000000cm}{0.750000000cm}{N10 state-B-pressure} \assertcoord{N10}{state-C-volume}{1.000000000cm}{-1.500000000cm}{N10 state-C-volume} \assertcoord{N10}{state-C-pressure}{-2.000000000cm}{0.750000000cm}{N10 state-C-pressure} \assertcoord{N10}{state-D-volume}{1.000000000cm}{-1.500000000cm}{N10 state-D-volume} \assertcoord{N10}{state-D-pressure}{-2.000000000cm}{-0.750000000cm}{N10 state-D-pressure} \pic[rotate=90,scale=2,transform shape] (Custom) at (10,10) {heat pump diagram={thermo diagram separation=3cm,thermo diagram work length=2cm,thermal device size=2cm,reservoir height=1cm}}; \assertcoord{Custom-hot}{center}{4.000000000cm}{10.000000000cm}{Custom-hot center} \assertcoord{Custom-device}{hot}{8.000000000cm}{10.000000000cm}{Custom-device hot} \assertcoord{Custom-work}{center}{10.000000000cm}{16.000000000cm}{Custom-work center} \node[heat engine,draw=blue,fill=yellow] (Colored) {}; \node[isothermal process,pv start volume=3,pv start pressure=1,pv end volume=1,pv show axes=false] (Compress) {}; \assertcoord{Compress}{process-37}{0.260000000cm}{-0.504424779cm}{Compress process-37} \foreach \p in {0,...,100}{\pgfpointanchor{E-heat-hot-\p}{center}} \TYPE{PASS: E heat-hot all flow coordinates} \assertcoord{E-heat-hot-0}{center}{0.000000000cm}{1.600000000cm}{E heat-hot 0} \assertcoord{E-heat-hot-37}{center}{0.000000000cm}{1.230000000cm}{E heat-hot 37} \assertcoord{E-heat-hot-100}{center}{0.000000000cm}{0.600000000cm}{E heat-hot 100} \foreach \p in {0,...,100}{\pgfpointanchor{E-heat-cold-\p}{center}} \TYPE{PASS: E heat-cold all flow coordinates} \assertcoord{E-heat-cold-0}{center}{0.000000000cm}{-0.600000000cm}{E heat-cold 0} \assertcoord{E-heat-cold-37}{center}{0.000000000cm}{-0.970000000cm}{E heat-cold 37} \assertcoord{E-heat-cold-100}{center}{0.000000000cm}{-1.600000000cm}{E heat-cold 100} \foreach \p in {0,...,100}{\pgfpointanchor{E-work-\p}{center}} \TYPE{PASS: E work all flow coordinates} \assertcoord{E-work-0}{center}{0.600000000cm}{0.000000000cm}{E work 0} \assertcoord{E-work-37}{center}{1.155000000cm}{0.000000000cm}{E work 37} \assertcoord{E-work-100}{center}{2.100000000cm}{0.000000000cm}{E work 100} \foreach \p in {0,...,100}{\pgfpointanchor{R-heat-hot-\p}{center}} \TYPE{PASS: R heat-hot all flow coordinates} \assertcoord{R-heat-hot-0}{center}{8.000000000cm}{0.600000000cm}{R heat-hot 0} \assertcoord{R-heat-hot-37}{center}{8.000000000cm}{0.970000000cm}{R heat-hot 37} \assertcoord{R-heat-hot-100}{center}{8.000000000cm}{1.600000000cm}{R heat-hot 100} \foreach \p in {0,...,100}{\pgfpointanchor{R-heat-cold-\p}{center}} \TYPE{PASS: R heat-cold all flow coordinates} \assertcoord{R-heat-cold-0}{center}{8.000000000cm}{-1.600000000cm}{R heat-cold 0} \assertcoord{R-heat-cold-37}{center}{8.000000000cm}{-1.230000000cm}{R heat-cold 37} \assertcoord{R-heat-cold-100}{center}{8.000000000cm}{-0.600000000cm}{R heat-cold 100} \foreach \p in {0,...,100}{\pgfpointanchor{R-work-\p}{center}} \TYPE{PASS: R work all flow coordinates} \assertcoord{R-work-0}{center}{10.100000000cm}{0.000000000cm}{R work 0} \assertcoord{R-work-37}{center}{9.545000000cm}{0.000000000cm}{R work 37} \assertcoord{R-work-100}{center}{8.600000000cm}{0.000000000cm}{R work 100} \assertcoord{Custom-work-50}{center}{10cm}{14cm}{transformed heat pump work midpoint} \physicshelp{heat pump diagram}\physicshelp{insulated wall}\physicshelp{pv diagram} \end{tikzpicture}}\END\end{document}