首页/文章/ 详情

pybamm电池模型基础语法(Python编程)

1年前浏览1929
前一篇文章介绍了Python编程软件以及电池模拟代码库的安装过程,点击标题   pybamm锂离子电池模拟环境搭建步骤和过程  可以查看。本文主要分享自己从零基础开始学习pybamm代码语言的笔记和经验。

1. Doyle-Fuller-Newman (DFN) model电化学模型简单调用

import pybamm  #在python中引入电池电化学模拟代码库

model = pybamm.lithium_ion.DFN() 

#调用Doyle-Fuller-Newman (DFN) 锂离子电池模型

sim = pybamm.Simulation(model)  # 仿真

sim.solve([0, 3600]) #求解

sim.plot() #绘制主要的参数曲线


以上简单语句是调用Doyle-Fuller-Newman (DFN) 锂离子电池模型,所有参数全部采用模型默认值,以1C电流放电过程的模拟,并且绘制主要的参数曲线。



2. 模型变量以及参数值的查找

# 1. Doyle-Fuller-Newman (DFN) model电化学模型简单调用

import pybamm #在python中导入电池电化学模拟代码库

model = pybamm.lithium_ion.DFN() #调用Doyle-Fuller-Newman (DFN) 锂离子电池模型

 
# 模型变量列表查看
model.variable_names() #模型变量列表
model.variables.search("electrolyte") #查找模型中包含指定单词electrolyte的变量 

#参数值可用search查找
parameter_values.search("electrolyte")#查看模型中包含指定单词electrolyte的参数值

前面采用模型默认参数运行了放电模拟,第二部分代码介绍模型中变量的查找,以及参数值查看,以上代码运行结果如下:

模型变量查找结果:

Electrolyte concentration

Electrolyte concentration [Molar]

Electrolyte concentration [mol.m-3]

Electrolyte current density

Electrolyte current density [A.m-2]

Electrolyte flux

Electrolyte flux [mol.m-2.s-1]

Electrolyte potential

Electrolyte potential [V]

Electrolyte tortuosity

Gradient of electrolyte potential

Gradient of negative electrolyte potential

Gradient of positive electrolyte potential

Gradient of separator electrolyte potential

Negative electrolyte concentration

Negative electrolyte concentration [Molar]

Negative electrolyte concentration [mol.m-3]

Negative electrolyte potential

Negative electrolyte potential [V]

Negative electrolyte tortuosity

Positive electrolyte concentration

Positive electrolyte concentration [Molar]

Positive electrolyte concentration [mol.m-3]

Positive electrolyte potential

Positive electrolyte potential [V]

Positive electrolyte tortuosity

Separator electrolyte concentration

Separator electrolyte concentration [Molar]

Separator electrolyte concentration [mol.m-3]

Separator electrolyte potential

Separator electrolyte potential [V]

Sum of electrolyte reaction source terms

Sum of negative electrode electrolyte reaction source terms

Sum of positive electrode electrolyte reaction source terms

Sum of x-averaged negative electrode electrolyte reaction source terms

Sum of x-averaged positive electrode electrolyte reaction source terms

X-averaged battery electrolyte ohmic losses [V]

X-averaged electrolyte concentration

X-averaged electrolyte concentration [Molar]

X-averaged electrolyte concentration [mol.m-3]

X-averaged electrolyte overpotential

X-averaged electrolyte overpotential [V]

X-averaged electrolyte potential

X-averaged electrolyte potential [V]

X-averaged negative electrolyte concentration

X-averaged negative electrolyte concentration [mol.m-3]

X-averaged negative electrolyte potential

X-averaged negative electrolyte potential [V]

X-averaged negative electrolyte tortuosity

X-averaged positive electrolyte concentration

X-averaged positive electrolyte concentration [mol.m-3]

X-averaged positive electrolyte potential

X-averaged positive electrolyte potential [V]

X-averaged positive electrolyte tortuosity

X-averaged separator electrolyte concentration

X-averaged separator electrolyte concentration [mol.m-3]

X-averaged separator electrolyte potential

X-averaged separator electrolyte potential [V]


参数值查看结果:
EC initial concentration in electrolyte [mol.m-3]       4541.0
Electrolyte conductivity [S.m-1]    <function electrolyte_conductivity_Capiglia1999>
Electrolyte diffusivity [m2.s-1]    <function electrolyte_diffusivity_Capiglia1999>
Initial concentration in electrolyte [mol.m-3]  1000.0
Negative electrode Bruggeman coefficient (electrolyte)  1.5
Positive electrode Bruggeman coefficient (electrolyte)  1.5
Separator Bruggeman coefficient (electrolyte)   1.5
Typical electrolyte concentration [mol.m-3]     1000.0


3. 可以对模型默认参数进行简单修改

# 1. Doyle-Fuller-Newman (DFN) model电化学模型简单调用
import pybamm #在python中导入电池电化学模拟代码库
model = pybamm.lithium_ion.DFN() #调用Doyle-Fuller-Newman (DFN) 锂离子电池模型
 
#查看默认参数值
parameter_values = model.default_parameter_values
parameter_values.search("Current function [A]") #用search查看默认参数值
 
#可以对默认参数进行简单修改:
parameter_values["Current function [A]"] = 3  #修改参数值
parameter_values.search("Current function [A]") #查看修改后参数值  

 

以上代码运行结果如下:

Current function [A]    0.680616     默认参数值,放电电流
Current function [A]    3            修改后参数值
 
来源:锂想生活
化学python
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2023-09-18
最近编辑:1年前
堃博士
博士 签名征集中
获赞 94粉丝 118文章 365课程 0
点赞
收藏
未登录
还没有评论
课程
培训
服务
行家
VIP会员 学习 福利任务 兑换礼品
下载APP
联系我们
帮助与反馈