PFGplotstable 中的数值精度问题

PFGplotstable 中的数值精度问题

我正在创建一个表,它可以自动生成可压缩流的各种感兴趣的数量的输出。

第一列包含马赫数,用于计算其他列中的数量:

\documentclass{book}
\usepackage[utf8]{inputenc} 
\usepackage{amsmath} % Used by equations
\usepackage{amssymb}
\usepackage{pgfplotstable}
\usepackage{pgfplots}
\usepackage{longtable}

\pgfplotsset{compat=1.17}

\begin{document}

\pgfkeys{/pgf/number format/.cd,fixed,precision=15}
\def\gma{1.40}

\pgfplotstableset{
    create on use/Mach/.style={
        create col/expr={0.01*\pgfplotstablerow+0.91}
    },
    create on use/P_over_P0/.style={
        create col/expr={((1+((\gma-1)/2)*\thisrow{Mach}^2)^(-\gma/(\gma-1)))}
    },
    create on use/m_dot_sqrt_cpT0_over_Ap0/.style={
        create col/expr={\gma/sqrt(\gma-1)*\thisrow{Mach}*(1 + (\gma-1)/2*\thisrow{Mach}^2)^(-(\gma+1)/(2*(\gma-1)))}
    },
    create on use/m_dot_sqrt_cpT0_over_Ap/.style={
        create col/expr={\thisrow{m_dot_sqrt_cpT0_over_Ap0}/\thisrow{P_over_P0}}
    },
    create on use/impulse_function/.style={
        create col/expr={1/\thisrow{m_dot_sqrt_cpT0_over_Ap}*(1+\gma*\thisrow{Mach}^2)}
    },
}

\pgfplotstablenew[
    columns={Mach, P_over_P0, m_dot_sqrt_cpT0_over_Ap0, m_dot_sqrt_cpT0_over_Ap, impulse_function},
    ]{10}{\loadedtable}

% Custom command for empty row
\newcommand{\emptyrow}{& & & &\\}

\pgfplotstabletypeset[
    begin table=\begin{longtable},
    end table=\end{longtable},
    columns/Mach/.style={column name=M, column type={|l}, fixed zerofill, precision=3},
    columns/P_over_P0/.style={column name=$\frac{P}{P_0}$, column type=l, fixed zerofill, precision=4},
    columns/m_dot_sqrt_cpT0_over_Ap0/.style={column name=$\frac{\dot{m}\sqrt{c_p T_0}}{A p_0}$, column type=l, fixed zerofill, precision=4},
    columns/m_dot_sqrt_cpT0_over_Ap/.style={column name=$\frac{\dot{m}\sqrt{c_p T_0}}{A p}$, column type=l, fixed zerofill, precision=4},
    columns/impulse_function/.style={column name=$\frac{F}{\dot{m}\sqrt{c_p T_0}}$, column type=l|, fixed zerofill, precision=4},
    every head row/.style={output empty row, before row={
    \multicolumn{5}{c}{Gas Flow Tables ($\gamma=1.400$): Subsonic Flow} \\
    \hline 
    \fontsize{11}{13}\selectfont 
    M & $\frac{P}{P_0}$ & $\frac{\dot{m}\sqrt{c_p T_0}}{A p_0}$ & $\frac{\dot{m}\sqrt{c_p T_0}}{A p}$ &$\frac{F}{\dot{m}\sqrt{c_p T_0}}$ \\[\arraystretch \tabcolsep] \hline\endhead\hline\endfoot\hline\endlastfoot}},
    every nth row={5}{before row={\emptyrow}},
]{\loadedtable}

\end{document}

这将生成下表:

流量表

但是,数字稍微有点错误。例如,最底下的一行,中间值应该返回“1.2810”,而不是 1.2813。我尝试将顶行的精度提高到 4 以上,但没有任何区别。

它采用 longtable 格式,因为实际上有 100 行,而不是这里显示的 10 行。

相关内容