首页/文章/ 详情

pybamm电池模型说明、案例

1年前浏览1773
以下为pybamm电池模型简单介绍和案例。

模拟实例

1.car_current_simulation
代码如下:

#

# Simulate user-defined current profile

#

import pybamm

import numpy as np


def car_current(t):

    """

    Piecewise constant current as a function of time in seconds. This is adapted

    from the file getCarCurrent.m, which is part of the LIONSIMBA toolbox [1]_.


    References

    ----------

    .. [1] M Torchio, L Magni, R Bushan Gopaluni, RD Braatz, and D. Raimondoa.

           LIONSIMBA: A Matlab framework based on a finite volume model suitable

           for Li-ion battery design, simulation, and control. Journal of The

           Electrochemical Society, 163(7):1192-1205, 2016.

    """


    current = (

        1 * (t >= 0) * (t <= 50)

        - 0.5 * (t > 50) * (t <= 60)

        + 0.5 * (t > 60) * (t <= 210)

        + 1 * (t > 210) * (t <= 410)

        + 2 * (t > 410) * (t <= 415)

        + 1.25 * (t > 415) * (t <= 615)

        - 0.5 * (t > 615)

    )


    return current


# load model

pybamm.set_logging_level("INFO")

model = pybamm.lithium_ion.DFN()


# create geometry

geometry = model.default_geometry


# load parameter values and process model and geometry

param = model.default_parameter_values

param["Current function [A]"] = car_current

param.process_model(model)

param.process_geometry(geometry)


# set mesh

mesh = pybamm.Mesh(geometry, model.default_submesh_types, model.default_var_pts)


# discretise model

disc = pybamm.Discretisation(mesh, model.default_spatial_methods)

disc.process_model(model)


# simulate car current for 30 minutes

t_eval = np.linspace(0, 1800, 600)

solution = pybamm.CasadiSolver(mode="fast").solve(model, t_eval)


# plot

plot = pybamm.QuickPlot(solution)

plot.dynamic_plot()


运行结果图:

2.US06_simulation
代码如下:
#
# Simulate drive cycle loaded from csv file
#
import pybamm
import numpy as np

# load model
pybamm.set_logging_level("INFO")
model = pybamm.lithium_ion.DFN()

# create geometry
geometry = model.default_geometry

# load parameter values and process model and geometry
param = model.default_parameter_values
param["Current function [A]"] = "[current data]US06"
param.process_model(model)
param.process_geometry(geometry)

# set mesh
var = pybamm.standard_spatial_vars
var_pts = {var.x_n: 20, var.x_s: 20, var.x_p: 20, var.r_n: 10, var.r_p: 10}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)

# discretise model
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)

# simulate US06 drive cycle
t_eval = np.linspace(0, 600, 600)

# need to increase max solver steps if solving DAEs along with an erratic drive cycle
solver = pybamm.CasadiSolver(mode="fast")
solver.max_steps = 10000

solution = solver.solve(model, t_eval)

# plot
plot = pybamm.QuickPlot(solution)
plot.dynamic_plot()

运行结果如下:

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