首页/文章/ 详情

气动函数计算代码(网页)

1年前浏览4927

这是常用的一些基本气动函数的计算代码,可以代替查气动函数表,把这些代码拷贝粘贴到文本编辑器,另存为html文件,之后用浏览器打开即可。


对于每个气动函数计算,输入已知,点击“计算”,就可以得到结果。


<!DOCTYPE HTML>

<html>

<head>

    <style type="text/css">

        div {

            margin: 20px;

        }

        input {

            margin-left: 5px;

            width: 70px;

        }

        .left {

            position: fixed;

            top: 100px;

            left: 20px;

        }

        .right {

            position: fixed;

            top: 100px;

            left: 700px;

        }


    </style>

</head>

<body>

    

    <h2>气体动力学参数计算1 —— 基本关系式</h2>


    

    <span  class="left">

        <b>Ma -> lambda:</b>

        <input id="c01-gama" type="text" placeholder="Gama"/>

        <input id="c01-ma" type="text" placeholder="Ma"/>

        <input id="c01-lambda" type="text" placeholder="结果"/>

        <input id="c01-btn" type="button" value="计算"><br/><br/>



        <b>lambda -> Ma:</b>

        <input id="c02-gama" type="text" placeholder="Gama"/>

        <input id="c02-lambda" type="text" placeholder="lambda"/>

        <input id="c02-ma" type="text" placeholder="结果"/>

        <input id="c02-btn" type="button" value="计算"><br/><br/>



        <b>(T_s, Ma) -> T_t:</b>

        <input id="c03-gama" type="text" placeholder="Gama"/>

        <input id="c03-ts" type="text" placeholder="Ts"/>

        <input id="c03-ma" type="text" placeholder="Ma"/>

        <input id="c03-tt" type="text" placeholder="结果"/>

        <input id="c03-btn" type="button" value="计算"><br/><br/>


        <b>(T_t, Ma) -> T_s:</b>

        <input id="c04-gama" type="text" placeholder="Gama"/>

        <input id="c04-tt" type="text" placeholder="Tt"/>

        <input id="c04-ma" type="text" placeholder="Ma"/>

        <input id="c04-ts" type="text" placeholder="结果"/>

        <input id="c04-btn" type="button" value="计算"><br/><br/>


        <b>(T_t, T_s) -> Ma:</b>

        <input id="c05-gama" type="text" placeholder="Gama"/>

        <input id="c05-tt" type="text" placeholder="Tt"/>

        <input id="c05-ts" type="text" placeholder="Ts"/>

        <input id="c05-ma" type="text" placeholder="结果"/>

        <input id="c05-btn" type="button" value="计算"><br/><br/>        


        <b>(T_t, T_s) -> lambda:</b>

        <input id="c06-gama" type="text" placeholder="Gama"/>

        <input id="c06-tt" type="text" placeholder="Tt"/>

        <input id="c06-ts" type="text" placeholder="Ts"/>

        <input id="c06-lambda" type="text" placeholder="结果"/>

        <input id="c06-btn" type="button" value="计算"><br/><br/>

        

        <b>(p_s, Ma) -> p_t:</b>

        <input id="c07-gama" type="text" placeholder="Gama"/>

        <input id="c07-ps" type="text" placeholder="Ps"/>

        <input id="c07-ma" type="text" placeholder="Ma"/>

        <input id="c07-pt" type="text" placeholder="结果"/>

        <input id="c07-btn" type="button" value="计算"><br/><br/>


        <b>(p_t, Ma) -> p_s:</b>

        <input id="c08-gama" type="text" placeholder="Gama"/>

        <input id="c08-pt" type="text" placeholder="Pt"/>

        <input id="c08-ma" type="text" placeholder="Ma"/>

        <input id="c08-ps" type="text" placeholder="结果"/>

        <input id="c08-btn" type="button" value="计算"><br/><br/>

    </span>

    

    <span class="right">

        <b>(p_t, p_s) -> Ma:</b>

        <input id="c09-gama" type="text" placeholder="Gama"/>

        <input id="c09-pt" type="text" placeholder="Pt"/>

        <input id="c09-ps" type="text" placeholder="Ps"/>

        <input id="c09-ma" type="text" placeholder="结果"/>

        <input id="c09-btn" type="button" value="计算"><br/><br/>


        <b>(p_t, p_s) -> lambda:</b>

        <input id="c10-gama" type="text" placeholder="Gama"/>

        <input id="c10-pt" type="text" placeholder="Pt"/>

        <input id="c10-ps" type="text" placeholder="Ps"/>

        <input id="c10-lambda" type="text" placeholder="结果"/>

        <input id="c10-btn" type="button" value="计算"><br/><br/>



        <b>T_ratio -> p_ratio:</b>

        <input id="c11-gama" type="text" placeholder="Gama"/>

        <input id="c11-tRatio" type="text" placeholder="Tt/Ts"/>

        <input id="c11-pRatio" type="text" placeholder="结果"/>

        <input id="c11-btn" type="button" value="计算"><br/><br/>


        <b>T_ratio -> rho_ratio:</b>

        <input id="c12-gama" type="text" placeholder="Gama"/>

        <input id="c12-tRatio" type="text" placeholder="Tt/Ts"/>

        <input id="c12-rhoRatio" type="text" placeholder="结果"/>

        <input id="c12-btn" type="button" value="计算"><br/><br/>


        <b>rho_ratio -> T_ratio:</b>

        <input id="c13-gama" type="text" placeholder="Gama"/>

        <input id="c13-rhoRatio" type="text" placeholder="Rhot/Rhos"/>

        <input id="c13-tRatio" type="text" placeholder="结果"/>

        <input id="c13-btn" type="button" value="计算"><br/><br/>

        

        <b>p_ratio -> T_ratio:</b>

        <input id="c14-gama" type="text" placeholder="Gama"/>

        <input id="c14-pRatio" type="text" placeholder="Pt/Ps"/>

        <input id="c14-tRatio" type="text" placeholder="结果"/>

        <input id="c14-btn" type="button" value="计算"><br/><br/>

        

        <b>lambda -> q_lambda:</b>

        <input id="c15-gama" type="text" placeholder="Gama"/>

        <input id="c15-lambda" type="text" placeholder="lambda"/>

        <input id="c15-qLambda" type="text" placeholder="结果"/>

        <input id="c15-btn" type="button" value="计算"><br/><br/>

        

        <b>q_lambda -> lambda:</b>

        <input id="c16-gama" type="text" placeholder="Gama"/>

        <input id="c16-qLambda" type="text" placeholder="q_lambda"/>

        <input id="c16-lambdaA" type="text" placeholder="结果1"/>

        <input id="c16-lambdaB" type="text" placeholder="结果2"/>

        <input id="c16-btn" type="button" value="计算"><br/><br/>

    </span>


<script type="text/javascript">


    window.onload = function() {

document.getElementById("c01-btn").onclick = function() {

let c01_gama = Number(document.getElementById("c01-gama").value);

            let c01_ma = Number(document.getElementById("c01-ma").value);

            let c01_result = ma2Lambda(c01_ma, c01_gama);

document.getElementById("c01-lambda").value = c01_result;

}


        document.getElementById("c02-btn").onclick = function() {

let c02_gama = Number(document.getElementById("c02-gama").value);

            let c02_lambda = Number(document.getElementById("c02-lambda").value);

            let c02_result = lambda2Ma(c02_lambda, c02_gama);

document.getElementById("c02-ma").value = c02_result;

}


        document.getElementById("c03-btn").onclick = function() {

let c03_gama = Number(document.getElementById("c03-gama").value);

            let c03_ts = Number(document.getElementById("c03-ts").value);

            let c03_ma = Number(document.getElementById("c03-ma").value);

            let c03_result = tsMa2Tt(c03_ts, c03_ma, c03_gama);

document.getElementById("c03-tt").value = c03_result;

}


        document.getElementById("c04-btn").onclick = function() {

let c04_gama = Number(document.getElementById("c04-gama").value);

            let c04_tt = Number(document.getElementById("c04-tt").value);

            let c04_ma = Number(document.getElementById("c04-ma").value);

            let c04_result = ttMa2Ts(c04_tt, c04_ma, c04_gama);

document.getElementById("c04-ts").value = c04_result;

}

       

        document.getElementById("c05-btn").onclick = function() {

let c05_gama = Number(document.getElementById("c05-gama").value);

            let c05_tt = Number(document.getElementById("c05-tt").value);

            let c05_ts = Number(document.getElementById("c05-ts").value);

            let c05_result = ttTs2Ma(c05_tt, c05_ts, c05_gama);

document.getElementById("c05-ma").value = c05_result;

}


        document.getElementById("c06-btn").onclick = function() {

let c06_gama = Number(document.getElementById("c06-gama").value);

            let c06_tt = Number(document.getElementById("c06-tt").value);

            let c06_ts = Number(document.getElementById("c06-ts").value);

            let c06_result = ttTs2Lambda(c06_tt, c06_ts, c06_gama);

document.getElementById("c06-lambda").value = c06_result;

}


        document.getElementById("c07-btn").onclick = function() {

let c07_gama = Number(document.getElementById("c07-gama").value);

            let c07_ps = Number(document.getElementById("c07-ps").value);

            let c07_ma = Number(document.getElementById("c07-ma").value);

            let c07_result = psMa2Pt(c07_ps, c07_ma, c07_gama);

document.getElementById("c07-pt").value = c07_result;

}


        document.getElementById("c08-btn").onclick = function() {

let c08_gama = Number(document.getElementById("c08-gama").value);

            let c08_pt = Number(document.getElementById("c08-pt").value);

            let c08_ma = Number(document.getElementById("c08-ma").value);

            let c08_result = ptMa2Ps(c08_pt, c08_ma, c08_gama);

document.getElementById("c08-ps").value = c08_result;

}


        document.getElementById("c09-btn").onclick = function() {

let c09_gama = Number(document.getElementById("c09-gama").value);

            let c09_pt = Number(document.getElementById("c09-pt").value);

            let c09_ps = Number(document.getElementById("c09-ps").value);

            let c09_result = ptPs2Ma(c09_pt, c09_ps, c09_gama);

document.getElementById("c09-ma").value = c09_result;

}


        document.getElementById("c10-btn").onclick = function() {

let c10_gama = Number(document.getElementById("c10-gama").value);

            let c10_pt = Number(document.getElementById("c10-pt").value);

            let c10_ps = Number(document.getElementById("c10-ps").value);

            let c10_result = ptPs2Lambda(c10_pt, c10_ps, c10_gama);

document.getElementById("c10-lambda").value = c10_result;

}


        document.getElementById("c11-btn").onclick = function() {

let c11_gama = Number(document.getElementById("c11-gama").value);

            let c11_tRatio = Number(document.getElementById("c11-tRatio").value);

            let c11_result = tRatio2pRatio(c11_tRatio, c11_gama);

document.getElementById("c11-pRatio").value = c11_result;

}

        

        document.getElementById("c12-btn").onclick = function() {

        let c12_gama = Number(document.getElementById("c12-gama").value);

            let c12_tRatio = Number(document.getElementById("c12-tRatio").value);

            let c12_result = tRatio2rhoRatio(c12_tRatio, c12_gama);

        document.getElementById("c12-rhoRatio").value = c12_result;

        }

        

        document.getElementById("c13-btn").onclick = function() {

        let c13_gama = Number(document.getElementById("c13-gama").value);

            let c13_rhoRatio = Number(document.getElementById("c13-rhoRatio").value);

            let c13_result = rhoRatio2tRatio(c13_rhoRatio, c13_gama);

        document.getElementById("c13-tRatio").value = c13_result;

        }

        

        document.getElementById("c14-btn").onclick = function() {

        let c14_gama = Number(document.getElementById("c14-gama").value);

            let c14_pRatio = Number(document.getElementById("c14-pRatio").value);

            let c14_result = pRatio2tRatio(c14_pRatio, c14_gama);

        document.getElementById("c14-tRatio").value = c14_result;

        }


        document.getElementById("c15-btn").onclick = function() {

        let c15_gama = Number(document.getElementById("c15-gama").value);

            let c15_lambda = Number(document.getElementById("c15-lambda").value);

            let c15_result = lambda2Qlambda(c15_lambda, c15_gama);

        document.getElementById("c15-qLambda").value = c15_result;

        }

        

        document.getElementById("c16-btn").onclick = function() {

        let c16_gama = Number(document.getElementById("c16-gama").value);

            let c16_qLambda = Number(document.getElementById("c16-qLambda").value);

            let c16_result = qLambda2Lambda(c16_qLambda, c16_gama);

        document.getElementById("c16-lambdaA").value = c16_result[0];

            document.getElementById("c16-lambdaB").value = c16_result[1];

        }

}


    // Ma -> lambda

    function ma2Lambda(ma, G=1.4) {

        return Math.sqrt((G+1)/2*ma*ma/(1+(G-1)/2*ma*ma));

    }

    

    // lambda -> Ma

    function lambda2Ma(lambda, G=1.4) {

        return Math.sqrt(2/(G+1)*lambda*lambda/(1-(G-1)/(G+1)*lambda*lambda));

    }


    // T_s, Ma -> T_t

    function tsMa2Tt(ts, ma, G=1.4) {

        return ts*(1+(G-1)/2*ma*ma);

    }


    // T_t, Ma -> T_s

    function ttMa2Ts(tt, ma, G=1.4) {

        return tt/(1+(G-1)/2*ma*ma);

    }


    // T_t, T_s -> Ma

    function ttTs2Ma(tt, ts, G=1.4) {

        return Math.sqrt((tt/ts-1)*(2/(G-1)));

    }


    // T_t, T_s -> lambda

    function ttTs2Lambda(tt, ts, G=1.4) {

        return Math.sqrt((1-ts/tt)*(G+1)/(G-1));

    }


    // p_s, Ma -> p_t

    function psMa2Pt(ps, ma, G=1.4) {

        return ps*(1+(G-1)/2*ma*ma)**(G/(G-1));

    }


    // p_t, Ma -> p_s

    function ptMa2Ps(pt, ma, G=1.4) {

        return pt/(1+(G-1)/2*ma*ma)**(G/(G-1));

    }


    // p_t, p_s -> Ma

    function ptPs2Ma(pt, ps, G=1.4) {

        return Math.sqrt(((pt/ps)**((G-1)/G)-1)*2/(G-1));

    }


    // p_t, p_s -> lambda

    function ptPs2Lambda(pt, ps, G=1.4) {

        return Math.sqrt((1-(ps/pt)**((G-1)/G))*(G+1)/(G-1));

    }


    // T_ratio -> p_ratio

    function tRatio2pRatio(tRatio, G=1.4) {

        return tRatio**(G/(G-1));

    }


    // T_ratio -> rho_ratio

    function tRatio2rhoRatio(tRatio, G=1.4) {

        return tRatio**(1/(G-1));

    }


    // rho_ratio -> T_ratio

    function rhoRatio2tRatio(rhoRatio, G=1.4) {

        return rhoRatio**(G-1);

    }

    

    // p_ratio -> T_ratio

    function pRatio2tRatio(pRatio, G=1.4) {

        return pRatio**((G-1)/G);

    }


    // lambda -> q_lambda

    function lambda2Qlambda(lambda, G=1.4) {

        return ((G+1)/2)**(1/(G-1))*lambda*(1-(G-1)/(G+1)*lambda*lambda)**(1/(G-1));

    }


    // q_lambda -> lambda

    function qLambda2Lambda(qLambda, G=1.4) {

        // bisection method

        

        if (qLambda>1) { return NaN; }


        lambdaA = bisecQ(0, 1);                         // subsonic value

        lambdaB = bisecQ(1, Math.sqrt((G+1)/(G-1)));    // supersonic value

        return [lambdaA, lambdaB];


        function bisecQ(lambda1, lambda2) {

            const N = 200, Err = 1e-8;

            let lambdai, qLambdai;

            let qLambda1 = ((G+1)/2)**(1/(G-1))*lambda1*(1-(G-1)/(G+1)*lambda1*lambda1)**(1/(G-1));

            let qLambda2 = ((G+1)/2)**(1/(G-1))*lambda2*(1-(G-1)/(G+1)*lambda2*lambda2)**(1/(G-1));

            for (let i=0; i<N; i++) {

                lambdai = (lambda1+lambda2)/2;

                qLambdai = ((G+1)/2)**(1/(G-1))*lambdai*(1-(G-1)/(G+1)*lambdai*lambdai)**(1/(G-1));

                if ((qLambda1-qLambda)*(qLambdai-qLambda)>0) {

                    lambda1 = lambdai;

                } else {

                    lambda2 = lambdai;

                }

                if (Math.abs(lambda1-lambda2)<=Err) {

                    break;

                }

            }

            return lambdai;

        }

    }


</script>

</body>

</html>


无人机通用叶轮机械流体基础Fluent
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2023-01-30
最近编辑:1年前
王洪伟
博士 | 教师 教书,也做科研,但主要是学习。
获赞 243粉丝 2160文章 47课程 3
点赞
收藏
未登录
还没有评论
课程
培训
服务
行家
VIP会员 学习计划 福利任务
下载APP
联系我们
帮助与反馈