{"id":1152847,"date":"2025-01-13T17:30:57","date_gmt":"2025-01-13T09:30:57","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1152847.html"},"modified":"2025-01-13T17:30:59","modified_gmt":"2025-01-13T09:30:59","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8python%e5%ae%89%e8%a3%85cantera","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1152847.html","title":{"rendered":"\u5982\u4f55\u5229\u7528python\u5b89\u88c5cantera"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25182727\/3554a84b-f1f9-415a-9661-90108ce2b8f3.webp\" alt=\"\u5982\u4f55\u5229\u7528python\u5b89\u88c5cantera\" \/><\/p>\n<p><p> <strong>\u5229\u7528Python\u5b89\u88c5Cantera\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u3001Anaconda\u3001\u6216\u8005\u6e90\u7801\u5b89\u88c5\u7b49\u65b9\u5f0f\u3002\u63a8\u8350\u4f7f\u7528pip\u3001Anaconda\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u65b9\u6cd5\u76f8\u5bf9\u7b80\u5355\u4e14\u4e0d\u6613\u51fa\u9519\u3002<\/strong> \u6211\u4eec\u63a8\u8350\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff0c\u56e0\u4e3apip\u662fPython\u7684\u6807\u51c6\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u64cd\u4f5c\u7b80\u5355\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528pip\u3001Anaconda\u3001\u4ee5\u53ca\u6e90\u7801\u5b89\u88c5Cantera\uff0c\u5e76\u89e3\u91ca\u5982\u4f55\u89e3\u51b3\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528pip\u5b89\u88c5Cantera<\/h3>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5pip<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86pip\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u7cfb\u7edf\u4e0a\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u4e0b\u8f7d <code>get-pip.py<\/code> \u6587\u4ef6\uff0c\u7f51\u5740\u662f <a href=\"https:\/\/bootstrap.pypa.io\/get-pip.py%E3%80%82\">https:\/\/bootstrap.pypa.io\/get-pip.py\u3002<\/a><\/li>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-shell\">python get-pip.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e0a\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-shell\">curl https:\/\/bootstrap.pypa.io\/get-pip.py -o get-pip.py<\/p>\n<p>python get-pip.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p><h4>2\u3001\u5b89\u88c5Cantera<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5pip\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Cantera\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip install cantera<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5Cantera\u53ca\u5176\u4f9d\u8d56\u5305\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0cCantera\u5c06\u88ab\u5b89\u88c5\u5728\u4f60\u7684Python\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0pip\u5b89\u88c5\u65b9\u5f0f\u7684\u4f18\u52bf\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528pip\u5b89\u88c5Cantera\u7684\u4f18\u52bf\u5728\u4e8e\u5176\u7b80\u4fbf\u6027\u548c\u666e\u904d\u6027\u3002pip\u4f5c\u4e3aPython\u7684\u6807\u51c6\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570Python\u5f00\u53d1\u73af\u5883\uff0c\u5e76\u4e14\u80fd\u591f\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u51cf\u5c11\u624b\u52a8\u914d\u7f6e\u7684\u9ebb\u70e6\u3002\u901a\u8fc7pip\u5b89\u88c5\uff0c\u7528\u6237\u53ea\u9700\u4e00\u6761\u547d\u4ee4\u5c31\u80fd\u5b8c\u6210\u5b89\u88c5\uff0c\u5927\u5927\u7b80\u5316\u4e86\u5b89\u88c5\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u4e86\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Anaconda\u5b89\u88c5Cantera<\/h3>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5Anaconda<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86Anaconda\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8bbf\u95eeAnaconda\u5b98\u7f51\uff1a<a href=\"https:\/\/www.anaconda.com\/products\/distribution\">https:\/\/www.anaconda.com\/products\/distribution<\/a><\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8e\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Anaconda\u5b89\u88c5\u5305\uff0c\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<p><h4>2\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u4e0e\u5176\u4ed6\u9879\u76ee\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u5efa\u8bae\u4e3aCantera\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\u3002\u6253\u5f00Anaconda Prompt\uff08\u6216\u7ec8\u7aef\uff09\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">conda create -n cantera_env python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>cantera_env<\/code>\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u5b89\u88c5Python 3.8\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u521b\u5efa\u865a\u62df\u73af\u5883\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">conda activate cantera_env<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4\u3001\u5b89\u88c5Cantera<\/h4>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Cantera\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">conda install -c cantera cantera<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u5c06\u4eceCantera\u7684Anaconda\u9891\u9053\u4e0b\u8f7d\u5e76\u5b89\u88c5Cantera\u53ca\u5176\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u6e90\u7801\u5b89\u88c5Cantera<\/h3>\n<\/p>\n<p><h4>1\u3001\u514b\u9686Cantera\u6e90\u7801<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Git\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4eceGit\u5b98\u7f51\uff08<a href=\"https:\/\/git-scm.com\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E3%80%82%E7%84%B6%E5%90%8E%EF%BC%8C%E6%89%93%E5%BC%80%E5%91%BD%E4%BB%A4%E8%A1%8C%EF%BC%88%E6%88%96%E7%BB%88%E7%AB%AF%EF%BC%89%EF%BC%8C%E8%BF%90%E8%A1%8C%E4%BB%A5%E4%B8%8B%E5%91%BD%E4%BB%A4%E5%85%8B%E9%9A%86Cantera%E6%BA%90%E7%A0%81%EF%BC%9A\">https:\/\/git-scm.com\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u7136\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\uff08\u6216\u7ec8\u7aef\uff09\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u514b\u9686Cantera\u6e90\u7801\uff1a<\/a><\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">git clone https:\/\/github.com\/Cantera\/cantera.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u5c06Cantera\u7684\u6e90\u7801\u514b\u9686\u5230\u4f60\u7684\u672c\u5730\u673a\u5668\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5b89\u88c5\u4f9d\u8d56\u5305<\/h4>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Cantera\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u5305\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip install numpy scipy matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u5305\u662fCantera\u8fd0\u884c\u6240\u5fc5\u9700\u7684\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u7f16\u8bd1\u548c\u5b89\u88c5Cantera<\/h4>\n<\/p>\n<p><p>\u8fdb\u5165Cantera\u6e90\u7801\u76ee\u5f55\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u548c\u5b89\u88c5Cantera\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">cd cantera<\/p>\n<p>python setup.py build<\/p>\n<p>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u5c06\u7f16\u8bd1Cantera\u7684\u6e90\u7801\u5e76\u5c06\u5176\u5b89\u88c5\u5230\u4f60\u7684Python\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u9a8c\u8bc1Cantera\u5b89\u88c5\u662f\u5426\u6210\u529f<\/h3>\n<\/p>\n<p><p>\u65e0\u8bba\u4f60\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\u5b89\u88c5Cantera\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u884c\uff08\u6216\u7ec8\u7aef\uff09\uff0c\u8fd0\u884cPython\u89e3\u91ca\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728Python\u89e3\u91ca\u5668\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cantera as ct<\/p>\n<p>print(ct.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5982\u679cCantera\u5b89\u88c5\u6210\u529f\uff0c\u4f60\u5c06\u770b\u5230\u8f93\u51fa\u7684Cantera\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/h3>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u6743\u9650\u95ee\u9898<\/h4>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884c\u547d\u4ee4\u3002\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u53f3\u952e\u70b9\u51fb\u547d\u4ee4\u884c\u7a0b\u5e8f\uff0c\u9009\u62e9\u201c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u201d\u3002\u5728macOS\u6216Linux\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u524d\u52a0\u4e0a<code>sudo<\/code>\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo pip install cantera<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f9d\u8d56\u5305\u51b2\u7a81<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u4f9d\u8d56\u5305\u51b2\u7a81\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9694\u79bb\u3002\u4f7f\u7528Anaconda\u521b\u5efa\u865a\u62df\u73af\u5883\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u7f51\u7edc\u95ee\u9898<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u7f51\u7edc\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362\u955c\u50cf\u6e90\u3002\u4f8b\u5982\uff0c\u5728\u4e2d\u56fd\u5927\u9646\u5730\u533a\uff0c\u53ef\u4ee5\u4f7f\u7528\u56fd\u5185\u7684\u955c\u50cf\u6e90\uff0c\u5982\u6e05\u534e\u5927\u5b66\u7684\u955c\u50cf\u6e90\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip install -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple cantera<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001Cantera\u7684\u57fa\u672c\u4f7f\u7528<\/h3>\n<\/p>\n<p><h4>1\u3001\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5Cantera\u540e\uff0c\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u5b83\u8fdb\u884c\u70ed\u529b\u5b66\u548c\u5316\u5b66\u52a8\u529b\u5b66\u8ba1\u7b97\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u6c14\u76f8\u5bf9\u8c61\u5e76\u8ba1\u7b97\u5176\u70ed\u529b\u5b66\u6027\u8d28\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cantera as ct<\/p>\n<h2><strong>\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61\uff0c\u6307\u5b9a\u6c14\u4f53\u79cd\u7c7b<\/strong><\/h2>\n<p>gas = ct.Solution(&#39;gri30.yaml&#39;)<\/p>\n<h2><strong>\u8bbe\u7f6e\u6c14\u4f53\u72b6\u6001<\/strong><\/h2>\n<p>gas.TPX = 300.0, ct.one_atm, &#39;CH4:1, O2:2, N2:7.52&#39;<\/p>\n<h2><strong>\u6253\u5370\u6c14\u4f53\u7684\u6e29\u5ea6\u3001\u538b\u529b\u548c\u5bc6\u5ea6<\/strong><\/h2>\n<p>print(f&#39;Temperature: {gas.T} K&#39;)<\/p>\n<p>print(f&#39;Pressure: {gas.P} Pa&#39;)<\/p>\n<p>print(f&#39;Density: {gas.density} kg\/m^3&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5316\u5b66\u53cd\u5e94\u6a21\u62df<\/h4>\n<\/p>\n<p><p>Cantera\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6a21\u62df\u5316\u5b66\u53cd\u5e94\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u6a21\u62df\u7532\u70f7\u71c3\u70e7\u53cd\u5e94\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cantera as ct<\/p>\n<h2><strong>\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61<\/strong><\/h2>\n<p>gas = ct.Solution(&#39;gri30.yaml&#39;)<\/p>\n<h2><strong>\u8bbe\u7f6e\u521d\u59cb\u72b6\u6001<\/strong><\/h2>\n<p>gas.TPX = 300.0, ct.one_atm, &#39;CH4:1, O2:2, N2:7.52&#39;<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u6052\u5bb9\u53cd\u5e94\u5668<\/strong><\/h2>\n<p>reactor = ct.IdealGasReactor(gas)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u53cd\u5e94\u5668\u7f51\u7edc<\/strong><\/h2>\n<p>sim = ct.ReactorNet([reactor])<\/p>\n<h2><strong>\u6a21\u62df\u53cd\u5e94\u8fc7\u7a0b<\/strong><\/h2>\n<p>time = 0.0<\/p>\n<p>for n in range(100):<\/p>\n<p>    time += 1.0e-5<\/p>\n<p>    sim.advance(time)<\/p>\n<p>    print(f&#39;Time: {time:.2e} s, Temperature: {reactor.T:.2f} K, CH4: {reactor.thermo[&#39;CH4&#39;]:.2e}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001Cantera\u7684\u9ad8\u7ea7\u4f7f\u7528<\/h3>\n<\/p>\n<p><h4>1\u3001\u70ed\u529b\u5b66\u5e73\u8861\u8ba1\u7b97<\/h4>\n<\/p>\n<p><p>Cantera\u53ef\u4ee5\u7528\u4e8e\u8ba1\u7b97\u5316\u5b66\u53cd\u5e94\u7684\u70ed\u529b\u5b66\u5e73\u8861\u72b6\u6001\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u8ba1\u7b97\u7532\u70f7\u71c3\u70e7\u53cd\u5e94\u7684\u5e73\u8861\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cantera as ct<\/p>\n<h2><strong>\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61<\/strong><\/h2>\n<p>gas = ct.Solution(&#39;gri30.yaml&#39;)<\/p>\n<h2><strong>\u8bbe\u7f6e\u521d\u59cb\u72b6\u6001<\/strong><\/h2>\n<p>gas.TPX = 300.0, ct.one_atm, &#39;CH4:1, O2:2, N2:7.52&#39;<\/p>\n<h2><strong>\u8ba1\u7b97\u5e73\u8861\u72b6\u6001<\/strong><\/h2>\n<p>gas.equilibrate(&#39;TP&#39;)<\/p>\n<h2><strong>\u6253\u5370\u5e73\u8861\u72b6\u6001\u4e0b\u7684\u6c14\u4f53\u6210\u5206<\/strong><\/h2>\n<p>print(f&#39;Temperature: {gas.T} K&#39;)<\/p>\n<p>print(f&#39;Pressure: {gas.P} Pa&#39;)<\/p>\n<p>print(&#39;Mole fractions:&#39;)<\/p>\n<p>for species in gas.species_names:<\/p>\n<p>    print(f&#39;{species}: {gas[species].X[0]:.2e}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u55b7\u7ba1\u6d41\u52a8\u6a21\u62df<\/h4>\n<\/p>\n<p><p>Cantera\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6a21\u62df\u55b7\u7ba1\u5185\u7684\u6d41\u52a8\u8fc7\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u6a21\u62df\u4e00\u4e2a\u7b80\u5355\u7684\u55b7\u7ba1\u6d41\u52a8\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cantera as ct<\/p>\n<h2><strong>\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61<\/strong><\/h2>\n<p>gas = ct.Solution(&#39;gri30.yaml&#39;)<\/p>\n<h2><strong>\u8bbe\u7f6e\u521d\u59cb\u72b6\u6001<\/strong><\/h2>\n<p>gas.TPX = 300.0, ct.one_atm, &#39;CH4:1, O2:2, N2:7.52&#39;<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u55b7\u7ba1\u5bf9\u8c61<\/strong><\/h2>\n<p>nozzle = ct.IdealGasFlow(gas)<\/p>\n<h2><strong>\u8bbe\u7f6e\u55b7\u7ba1\u7684\u5165\u53e3\u548c\u51fa\u53e3\u6761\u4ef6<\/strong><\/h2>\n<p>nozzle.inlet.TP = 300.0, ct.one_atm<\/p>\n<p>nozzle.outlet.P = 0.5 * ct.one_atm<\/p>\n<h2><strong>\u8ba1\u7b97\u55b7\u7ba1\u5185\u7684\u6d41\u52a8\u72b6\u6001<\/strong><\/h2>\n<p>nozzle.solve()<\/p>\n<h2><strong>\u6253\u5370\u55b7\u7ba1\u51fa\u53e3\u7684\u72b6\u6001<\/strong><\/h2>\n<p>print(f&#39;Temperature: {nozzle.outlet.T} K&#39;)<\/p>\n<p>print(f&#39;Pressure: {nozzle.outlet.P} Pa&#39;)<\/p>\n<p>print(f&#39;Mach number: {nozzle.outlet.mach_number}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5229\u7528Python\u5b89\u88c5Cantera\uff0c\u5305\u62ec\u4f7f\u7528pip\u3001Anaconda\u3001\u4ee5\u53ca\u6e90\u7801\u5b89\u88c5\u4e09\u79cd\u65b9\u6cd5\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u4ecb\u7ecd\u4e86\u5982\u4f55\u9a8c\u8bc1Cantera\u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5\u3002\u6700\u540e\uff0c\u6211\u4eec\u5c55\u793a\u4e86Cantera\u7684\u4e00\u4e9b\u57fa\u672c\u548c\u9ad8\u7ea7\u4f7f\u7528\u793a\u4f8b\uff0c\u5305\u62ec\u521b\u5efa\u6c14\u76f8\u5bf9\u8c61\u3001\u6a21\u62df\u5316\u5b66\u53cd\u5e94\u3001\u70ed\u529b\u5b66\u5e73\u8861\u8ba1\u7b97\u4ee5\u53ca\u55b7\u7ba1\u6d41\u52a8\u6a21\u62df\u3002<\/p>\n<\/p>\n<p><p><strong>\u5229\u7528Python\u5b89\u88c5Cantera\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u548c\u73af\u5883\u9009\u62e9\u9002\u5408\u7684\u65b9\u6cd5\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u53ea\u8981\u6309\u7167\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff0c\u90fd\u80fd\u591f\u987a\u5229\u5b89\u88c5Cantera\u5e76\u5f00\u59cb\u4f7f\u7528\u5b83\u8fdb\u884c\u70ed\u529b\u5b66\u548c\u5316\u5b66\u52a8\u529b\u5b66\u8ba1\u7b97\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u8be6\u7ec6\u7684\u4ecb\u7ecd\u548c\u793a\u4f8b\uff0c\u5e0c\u671b\u80fd\u591f\u5e2e\u52a9\u4f60\u987a\u5229\u5b89\u88c5\u548c\u4f7f\u7528Cantera\u3002\u5982\u679c\u5728\u5b89\u88c5\u548c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003Cantera\u7684\u5b98\u65b9\u6587\u6863\uff08<a href=\"https:\/\/cantera.org\/documentation.html%EF%BC%89%E8%8E%B7%E5%8F%96%E6%9B%B4%E5%A4%9A%E4%BF%A1%E6%81%AF%E5%92%8C%E5%B8%AE%E5%8A%A9%E3%80%82\">https:\/\/cantera.org\/documentation.html\uff09\u83b7\u53d6\u66f4\u591a\u4fe1\u606f\u548c\u5e2e\u52a9\u3002<\/a><\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u7684\u7cfb\u7edf\u662f\u5426\u652f\u6301Cantera\u7684\u5b89\u88c5\uff1f<\/strong><br \/>\u5728\u5b89\u88c5Cantera\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u6ee1\u8db3\u57fa\u672c\u8981\u6c42\u3002\u9996\u5148\uff0c\u786e\u8ba4\u4f60\u7684Python\u7248\u672c\u4e3a3.6\u6216\u66f4\u9ad8\u7248\u672c\u3002\u5176\u6b21\uff0c\u68c0\u67e5\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u662f\u5426\u4e3aWindows\u3001macOS\u6216Linux\uff0c\u5e76\u786e\u4fdd\u5df2\u5b89\u88c5\u5408\u9002\u7684C++\u7f16\u8bd1\u5668\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u68c0\u67e5Python\u7248\u672c\u3002<\/p>\n<p><strong>Cantera\u7684\u5b89\u88c5\u8fc7\u7a0b\u9700\u8981\u591a\u957f\u65f6\u95f4\uff1f<\/strong><br \/>\u5b89\u88c5Cantera\u7684\u65f6\u95f4\u53d6\u51b3\u4e8e\u591a\u4e2a\u56e0\u7d20\uff0c\u5305\u62ec\u4f60\u7684\u7f51\u7edc\u901f\u5ea6\u3001\u8ba1\u7b97\u673a\u6027\u80fd\u4ee5\u53ca\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9700\u8981\u4e0b\u8f7d\u7684\u4f9d\u8d56\u9879\u3002\u4e00\u822c\u800c\u8a00\uff0c\u4f7f\u7528pip\u5b89\u88c5\u7684\u8fc7\u7a0b\u901a\u5e38\u53ea\u9700\u51e0\u5206\u949f\uff0c\u4f46\u5982\u679c\u4f60\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u6784\u5efa\uff0c\u53ef\u80fd\u9700\u8981\u66f4\u957f\u65f6\u95f4\uff0c\u5c24\u5176\u662f\u5728\u7f16\u8bd1\u548c\u914d\u7f6e\u9636\u6bb5\u3002<\/p>\n<p><strong>\u6211\u5728\u5b89\u88c5Cantera\u65f6\u9047\u5230\u9519\u8bef\uff0c\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u5982\u679c\u5728\u5b89\u88c5Cantera\u65f6\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u51e0\u4e2a\u89e3\u51b3\u65b9\u6848\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86\u6240\u6709\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\uff0c\u5305\u62ecNumPy\u548cSciPy\u7b49\u3002\u5176\u6b21\uff0c\u53ef\u4ee5\u67e5\u9605Cantera\u7684\u5b98\u65b9\u6587\u6863\u548cGitHub\u9875\u9762\uff0c\u5bfb\u627e\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848\u3002\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u8003\u8651\u5728\u76f8\u5173\u793e\u533a\u6216\u8bba\u575b\u4e0a\u5bfb\u6c42\u5e2e\u52a9\uff0c\u63d0\u4f9b\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u5c06\u6709\u52a9\u4e8e\u4ed6\u4eba\u66f4\u597d\u5730\u7406\u89e3\u4f60\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5229\u7528Python\u5b89\u88c5Cantera\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u3001Anaconda\u3001\u6216\u8005\u6e90\u7801\u5b89\u88c5\u7b49\u65b9\u5f0f\u3002\u63a8\u8350\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":1152852,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152847"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1152847"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152847\/revisions"}],"predecessor-version":[{"id":1152854,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152847\/revisions\/1152854"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1152852"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1152847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1152847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1152847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}