有关Cantera安装在python语言环境下的历程
1、安装Anaconda ;
2、打开Anaconda Prompt,输入 conda create -n test -c cantera cantera ipython matplotlib ,出现提时,输入 y (如果你不是第一次下载,只需要找到Anaconda下对应的Anaconda Prompt即可);
3、检查是否安上cantera,输入 activate test 按回车,输入 conda list ,查看是否有cantera(这一步本人以为可以省略);
4、打开Anaconda,把Applications on 换成test ,点击Spayder的install(是为了下载此种情况下的spyder,如果已经有了,即为launch状态,直接打开即可);
5、试运行代码(为他们公司所提供的代码);
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
gas = ct.Solution('gri30.yaml')
initial_state = 1200, 5 * ct.one_atm, 'CH4:0.35, O2:1.0, N2:3.76'
# Run a simulation with the full mechanism
gas.TPX = initial_state
r = ct.IdealGasConstPressureReactor(gas)
sim = ct.ReactorNet([r])
tt = []
TT = []
t = 0.0
# Rmax is the maximum relative reaction rate at any timestep
Rmax = np.zeros(gas.n_reactions)
while t < 0.02:
t = sim.step()
tt.append(1000 * t)
TT.append(r.T)
rnet = abs(gas.net_rates_of_progress)
rnet /= max(rnet)
Rmax = np.maximum(Rmax, rnet)
plt.plot(tt, TT, label='K=53, R=325', color='k', lw=3, zorder=100)
# Get the reaction objects, and sort them so the most active reactions are first
R = sorted(zip(Rmax, gas.reactions()), key=lambda x: -x[0])
# Test reduced mechanisms with different numbers of reactions
C = plt.cm.winter(np.linspace(0, 1, 5))
for i, N in enumerate([40, 50, 60, 70, 80]):
# Get the N most active reactions
reactions = [r[1] for r in R[:N]]
# find the species involved in these reactions. At a minimum, include all
# species in the reactant mixture
species_names = {'N2', 'CH4', 'O2'}
for reaction in reactions:
species_names.update(reaction.reactants)
species_names.update(reaction.products)
# Get the species objects
species = [gas.species(name) for name in species_names]
# create the new reduced mechanism
gas2 = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
species=species, reactions=reactions)
# Re-run the ignition problem with the reduced mechanism
gas2.TPX = initial_state
r = ct.IdealGasConstPressureReactor(gas2)
sim = ct.ReactorNet([r])
t = 0.0
tt = []
TT = []
while t < 0.02:
t = sim.step()
tt.append(1000 * t)
TT.append(r.T)
plt.plot(tt, TT, lw=2, color=C[i],
label='K={0}, R={1}'.format(gas2.n_species, N))
plt.xlabel('Time (ms)')
plt.ylabel('Temperature (K)')
plt.legend(loc='upper left')
plt.title('Reduced mechanism ignition delay times\n'
'K: number of species; R: number of reactions')
plt.xlim(0, 20)
plt.tight_layout()
plt.show()
(本文在形成阶段参考了1、如何安装开源化学反应动力学分析软件Cantera,网址https://jingyan.baidu.com/article/a3761b2be079961576f9aad9.html
2、beidou111 的 安装cantera并且运行一个官方示例,网址安装cantera并且运行一个官方示例_beidou111的博客-CSDN博客_cantera安装
特别致谢。
3、代码是官网的,网址mechanism_reduction.py | Cantera
4、如果操作时仍有失败的情况,欢迎留言。)
有关Cantera安装在python语言环境下的历程相关推荐
- python开发工具及环境配置_python_在windows下安装配置python开发环境及Ulipad开发工具...
最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...
- Windows重装系统+虚拟机virtuabox安装+ubuntu系统安装+linux环境下安装fsl 一条龙(步步亲测有效)
Windows重装系统+虚拟机virtuabox安装+ubuntu系统安装+linux环境下安装fsl 一条龙 零:综述 一.windows10系统的安装 1.准备工作 2.制作启动盘 3.修改启动设 ...
- Python语言环境错误:不支持的语言环境设置
本文翻译自:Python locale error: unsupported locale setting Why do I get the following error when doing th ...
- JAVA调用 keras,在TensorFlow(Python, Java)环境下使用Keras模型
Keras 是一个用 Python 编写的高级神经网络 API,它能够以 TensorFlow, CNTK, 或者 Theano 作为后端运行.Keras 的开发重点是支持快速的实验.有时候我们在使用 ...
- ATX+Python+uiautomator2环境下进行手机UI自动化测试
ATX+Python+uiautomator2环境下进行手机UI自动化测试 环境搭建 手机环境初始化 在网页端的UI查看器中查看控件及属性 以下是一些自己测试的脚本 环境搭建 开始配置uiautoma ...
- linux 安装防病毒软件,04Linux环境下Norton防病毒软件安装和使用.doc
04Linux环境下Norton防病毒软件安装和使用 Linux环境下 Norton防病毒软件安装和使用 项目编号:项目名称:编 写 人:詹硕编写日期:2012-08-13审 核 人:审核日期:批 准 ...
- mt2503[Input Method]允许多种语言输入法在不同语言环境下都能自由切换
[DESCRIPTION] 在不同语言环境下多种语言输入法如何能自由切换(按#键).如手机有英语.俄语两种语言,如何实现不管是英语还是俄语环境下,编辑界面都能 够出现英语的输入法(ABC和abc)和俄 ...
- python安装docx库_linux 环境下的python 安装 docx 的过程
由于linux 系统环境下的python是系统管理员安装好的,所安装的库也是固定的. 如果环境中没有自己要用的库,则需要自己安装.并且只能自己新建一个虚拟环境,让python 运行在新建的虚拟环境中. ...
- python爬虫scrapy步骤mac系统_Mac中Python 3环境下安装scrapy的方法教程
前言 最近抽空想学习一下python的爬虫框架scrapy,在mac下安装的时候遇到了问题,逐一解决了问题,分享一下,话不多说了,来一起看看详细的介绍吧. 步骤如下: # 在Mac上Python3环境 ...
最新文章
- jQuery.delegate() 函数详解
- 安装eclipse的maven插件
- HLSL Texture Object Sample 的一些笔记
- ubuntu搭建Tomcat7.0
- [No000035]操作系统Operating System之OS Interface操作系统接口
- OpenCV——素描
- 预防和检测如日中天?事件响应表示不服
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(2)-easyui构建前端页面框架[附源码]
- fastjson SerializerFeature
- 高通WLAN芯片点灯方法-QCA9563操控9880GPIO进行点灯
- 2022上海Java工资收入概览
- 磁共振影像分析之: 基于FSL的VBM分析(2)
- (5.3)NISP1级——【电子邮件安全】
- 基于TI DLP技术的工业级DLP3010光机
- 0x00000....蓝屏
- linux更换进程执行码,第八节 进程的切换和系统的一般执行过程—— 20135203齐岳...
- GPON技术学习(一)--------GPON系统整体概况
- Excel VBA - 操作文件
- jenkins恢复assign roles
- 工业以太网交换机在地铁中运用