Skip to content

Commit

Permalink
Merge branch 'development' into feature/mod_battery_cycle_only
Browse files Browse the repository at this point in the history
  • Loading branch information
d-cogswell committed May 24, 2023
2 parents 085c908 + 8b4c351 commit 24f3815
Show file tree
Hide file tree
Showing 22 changed files with 328 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mpet-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:

steps:
- name: Set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64

- name: Checkout MPET
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1
path: mpet
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/mpet-regression-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,27 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7","3.8","3.9","3.10"]
python-version: ["3.8","3.9","3.10","3.11"]
defaults:
run:
shell: bash -l {0}
steps:

- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
path: mpet
- uses: actions/checkout@v2
with:
fetch-depth: 1
path: base-mpet
ref: ${{ github.base_ref }}

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
activate-environment: mpet-env

- name: Install daetools via conda
- name: Install daetools via mamba
run: |
conda activate mpet-env
conda install -c conda-forge daetools python=${{ matrix.python-version }} pip
mamba install daetools
- name: Install additional dependencies using mpet's setup.py
run: |
Expand All @@ -57,7 +49,6 @@ jobs:
- name: run tests for modified branch and get coverage
run: |
conda activate mpet-env
cd mpet/bin/workdir
coverage run --source=../../mpet/ run_tests.py --test_dir ./tests --output_dir ../../bin/workdir/modified > /dev/null
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.9] - 2023-01-27
### Added
- Regression tests for Python 3.10 and 3.11.
- Additional badges added to README.

### Fixed
- Code clean up and maintenance updates.


## [0.1.8] - 2022-02-14
### Added
- Online documentation with updated installation instructions: [https://mpet.readthedocs.io/en/latest/](https://mpet.readthedocs.io/en/latest/)
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Development: [![Coverage Status](https://coveralls.io/repos/github/TRI-AMDD/mpet/badge.svg?branch=development)](https://coveralls.io/github/TRI-AMDD/mpet?branch=development)
Master: [![Coverage Status](https://coveralls.io/repos/github/TRI-AMDD/mpet/badge.svg?branch=master)](https://coveralls.io/github/TRI-AMDD/mpet?branch=master)
[![Build](https://img.shields.io/github/actions/workflow/status/TRI-AMDD/mpet/mpet-regression-test.yml?branch=development)](https://github.com/TRI-AMDD/mpet/actions/workflows/mpet-regression-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/TRI-AMDD/mpet/badge.svg?branch=development)](https://coveralls.io/github/TRI-AMDD/mpet?branch=development)
[![readthedocs](https://readthedocs.org/projects/mpet/badge/?version=latest)](https://mpet.readthedocs.io)
[![release](https://img.shields.io/github/v/release/TRI-AMDD/mpet)](https://github.com/TRI-AMDD/mpet/releases)

# MPET -- Multiphase Porous Electrode Theory

This software is designed to run simulations of batteries with porous electrodes using porous electrode theory, which is a volume-averaged, multiscale approach to capture the coupled behavior of electrolyte and active material within electrodes. As a result, with physical parameter inputs and run protocols (specified current or voltage profiles), it makes predictions about the internal dynamics within a battery (electrolyte concentration and potential, solid phase concentrations, reaction rates, etc.) and also macroscopic, easily measurable electrochemical quantities such as total current and voltage. In this way, it is similar to the [`dualfoil`](http://www.cchem.berkeley.edu/jsngrp/fortran.html) code released by Newman and coworkers from Berkeley. This software has much of the functionality contained in `dualfoil` (it is currently missing, e.g., temperature dependence). However, beyond the standard porous electrode theory simulations, this software can also simulate electrodes in which the active materials phase separate using non-equilibrium thermodynamics within a phase field modeling framework. Such behavior is common in widely used electrode materials, including graphite and LiFePO4.
Expand Down
23 changes: 23 additions & 0 deletions configs/params_NMC532_Colclasure20.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Cathode parameters from A. Colclasure et al., J. Electrochim. Acta 337, 135854 (2020).
# See params_electrodes.cfg for parameter explanations.

[Particles]
type = diffn
discretization = 9.e-8
shape = sphere
thickness = 10e-6

[Material]
muRfunc = NMC532_Colclasure20
noise = false
noise_prefac = 1e-6
numnoise = 200
rho_s = 2.9869e28
D = 1
Dfunc = NMC532_Colclasure20

[Reactions]
rxnType = BV_Colclasure20
k0 = 10
alpha = 0.5
Rfilm = 0e-0
23 changes: 23 additions & 0 deletions configs/params_graphite_Colclasure20.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Cathode parameters from A. Colclasure et al., J. Electrochim. Acta 337, 135854 (2020).
# See params_electrodes.cfg for parameter explanations.

[Particles]
type = diffn
discretization = 2.e-7
shape = sphere
thickness = 20e-9

[Material]
muRfunc = LiC6_Colclasure_1506T
noise = false
noise_prefac = 1e-6
numnoise = 200
rho_s = 1.6862e28
D = 3.0e-14
Dfunc = constant

[Reactions]
rxnType = BV_mod01
k0 = 11
alpha = 0.5
Rfilm = 0.e-0
114 changes: 114 additions & 0 deletions configs/params_system_Colclasure20.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#Parameters for the low loading cell (1.5 mAh/cm^2) from A. Colclasure et al., J. Electrochim. Acta 337, 135854 (2020).
# See params_system.cfg for parameter explanations.

[Sim Params]
# Constant voltage or current or segments of one of them
# Options: CV, CC, CCsegments, CVsegments
profileType = CC
# Battery (dis)charge c-rate (only used for CC), number of capacities / hr
# (positive for discharge, negative for charge)
Crate=-2
#Optional nominal 1C current density for the cell, A/m^2
1C_current_density = 13.475
# Voltage cutoffs, V
Vmax = 4.1
Vmin = 0
# Continuation directory.
# Options: false, absolute directory path
prevDir = false
# Final time (only used for CV), [s]
tend = 1.2e4
# Number disc. in time
tsteps = 200
# Numerical Tolerances
relTol = 1e-6
absTol = 1e-6
# Temperature, K
T = 303.15
# Random seed. Set to true to give a random seed in the simulation
randomSeed = false
# Value of the random seed, must be an integer
seed = 0
# Series resistance, [Ohm m^2]
Rser = 0.
# Cathode, anode, and separator numer disc. in x direction (volumes in electrodes)
Nvol_c = 20
Nvol_s = 10
Nvol_a = 20
# Number of particles per volume for cathode and anode
Npart_c = 1
Npart_a = 1

[Electrodes]
cathode = params_NMC532_Colclasure20.cfg
anode = params_graphite_Colclasure20.cfg
# Rate constant of the Li foil electrode, A/m^2
# Used only if Nvol_a = 0
k0_foil = 1e0
# Film resistance on the Li foil, Ohm m^2
Rfilm_foil = 0e-0

[Particles]
# electrode particle size distribution info, m
mean_c = 1.8e-6
stddev_c = 0e-9
mean_a = 4.0e-6
stddev_a = 0e-9
# Initial electrode filling fractions
cs0_c = 0.91
cs0_a = 0.05

[Conductivity]
# Simulate bulk cathode conductivity (Ohm's Law)?
simBulkCond_c = false
simBulkCond_a = false
# Dimensional conductivity (used if simBulkCond = true), S/m
sigma_s_c = 1e-1
sigma_s_a = 1e-1
# Simulate particle connectivity losses (Ohm's Law)?
# Options: true, false
simPartCond_c = false
simPartCond_a = false
# Conductance between particles, S = 1/Ohm
G_mean_c = 1e-14
G_stddev_c = 0
G_mean_a = 1e-14
G_stddev_a = 0

[Geometry]
# Thicknesses, m
L_c = 42e-6
L_a = 47e-6
L_s = 20e-6
# Volume loading percents of active material (volume fraction of solid
# that is active material)
P_L_c = 0.7803
P_L_a = 0.9026
# Porosities (liquid volume fraction in each region)
poros_c = 0.33
poros_a = 0.37
poros_s = 0.39
# Bruggeman exponent (tortuosity = porosity^bruggExp)
BruggExp_c = -1.0
BruggExp_a = -1.2
BruggExp_s = -1.3

[Electrolyte]
# Initial electrolyte conc., mol/m^3
c0 = 1200
# Cation/anion charge number (e.g. 2, -1 for CaCl_2)
zp = 1
zm = -1
# Cation/anion dissociation number (e.g. 1, 2 for CaCl_2)
nup = 1
num = 1
# Electrolyte model,
# Options: dilute, SM
elyteModelType = SM
# Stefan-Maxwell property set, see props_elyte.py file
SMset = Colclasure20
# Reference electrode (defining the electrolyte potential) information:
# number of electrons transfered in the reaction, 1 for Li/Li+
n = 1
# Stoichiometric coefficient of cation, -1 for Li/Li+
sp = -1
File renamed without changes.
11 changes: 11 additions & 0 deletions dockerfiles/Dockerfile-daetools-2.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10-bullseye

#Install necessary packages for daetools
RUN apt-get update && \
apt-get install --yes libgl1-mesa-glx libgfortran5

#Download and install daetools
RUN wget https://sourceforge.net/projects/daetools/files/daetools/2.0.0/daetools-2.0.0-gnu_linux-x86_64.zip && \
unzip daetools-2.0.0-gnu_linux-x86_64.zip && \
pip install ./daetools-2.0.0-gnu_linux-x86_64 && \
rm -r ./daetools*
6 changes: 0 additions & 6 deletions dockerfiles/Dockerfile-mpet-deps

This file was deleted.

8 changes: 2 additions & 6 deletions mpet/config/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ def _init_from_cfg(self, paramfile):
if self.D_s['Nvol_a'] > 0:
trodes.append('a')
self['trodes'] = trodes
# to check for separator, directly access underlying dict of system config;
# self['Nvol']['s'] would not work because that requires have_separator to
# be defined already
self['have_separator'] = self.D_s['Nvol_s'] > 0

# load electrode parameter file(s)
self.paramfiles = {}
Expand Down Expand Up @@ -506,7 +502,7 @@ def _scale_electrode_parameters(self):
self[trode, param] = value / kT

# scalings on separator
if self['have_separator']:
if self['Nvol']['s']:
self['L']['s'] /= self['L_ref']

def _scale_macroscopic_parameters(self, Vref):
Expand Down Expand Up @@ -761,7 +757,7 @@ def _distr_part(self):
# For homogeneous particles (only one 'volume' per particle)
elif solidType in ['homog', 'homog_sdn', 'homog2', 'homog2_sdn']:
# Each particle is only one volume
psd_num = np.ones(raw.shape, dtype=np.int)
psd_num = np.ones(raw.shape, dtype=int)
# The lengths are given by the original length distr.
psd_len = raw
else:
Expand Down
2 changes: 1 addition & 1 deletion mpet/config/parameterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __getitem__(self, item):
d = {}
# some parameters are also defined for the separator
trodes = self['trodes'][:] # make a copy here to avoid adding values to the original
if item in PARAMS_SEPARATOR and self['have_separator']:
if item in PARAMS_SEPARATOR:
trodes.append('s')
for trode in trodes:
# get the value for this electrode/separator and store it
Expand Down
4 changes: 4 additions & 0 deletions mpet/electrode/diffusion/NMC532_Colclasure20.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def NMC532_Colclasure20(y):
cm2_s = 20000.*10**(-2319.*y**10 + 6642.*y**9 - 5269.*y**8 - 3319.*y**7 + 10038.*y**6
- 9806.*y**5 + 5817.*y**4 - 2286.*y**3 + 575.3*y**2 - 83.16*y-9.292)
return cm2_s/1e4
29 changes: 29 additions & 0 deletions mpet/electrode/materials/LiC6_Colclasure_1506T.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np


def LiC6_Colclasure_1506T(self, y, ybar, muR_ref, ISfuncs=None):
"""Taken from Colclasure 2020, but only for lithiating. The range of\
confidence is 0.01 to 0.97 for voltages of ~0.6V and \
0.0435V. Don’t calculate U2 for intercalation fractions below 0.8, \
it will cause numeric issues just use U1."""
x = y
U1 = \
- 1.059423355572770E-02*np.tanh((x - 1.453708425609560E-02) / 9.089868397988610E-05) \
+ 2.443615203087110E-02*np.tanh((x - 5.464261369950400E-01) / 6.270508166379020E-01) \
- 1.637520788053810E-02*np.tanh((x - 5.639025014475490E-01) / 7.053886409518520E-02) \
- 6.542365622896410E-02*np.tanh((x - 5.960370524233590E-01) / 1.409966536648620E+00) \
- 4.173226059293490E-02*np.tanh((x - 1.787670587868640E-01) / 7.693844911793470E-02) \
- 4.792178163846890E-01*np.tanh((x + 3.845707852011820E-03) / 4.112633446959460E-02) \
+ 6.594735004847470E-01 \
- 4.364293924074990E-02*np.tanh((x - 9.449231893318330E-02) / -2.046776012570780E-02) \
- 8.241166396760410E-02*np.tanh((x - 7.746685789572230E-02) / 3.593817905677970E-02)
U2 = \
-1.731504647676420E+02*np.power(x, 8.0) + 8.252008712749000E+01*np.power(x, 7.0) \
+ 1.233160814852810E+02*np.power(x, 6.0) + 5.913206621637760E+01*np.power(x, 5.0) \
+ 3.322960033709470E+01*np.power(x, 4.0) + 3.437968012320620E+00*np.power(x, 3.0) \
- 6.906367679257650E+01*np.power(x, 2.0) - \
1.228217254296760E+01*x - 5.037944982759270E+01
U = U1 + (U2 - U1) / (1.0 + np.exp(-1.0e2*(x - 1.02956203215198)))
muR = self.get_muR_from_OCV(U, muR_ref)
actR = None
return muR, actR
18 changes: 18 additions & 0 deletions mpet/electrode/materials/NMC532_Colclasure20.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np


def NMC532_Colclasure20(self, y, ybar, muR_ref, ISfuncs=None):
x = y
OCV = (5.314735633000300E+00 +
-3.640117692001490E+03*x**14.0 + 1.317657544484270E+04*x**13.0
- 1.455742062291360E+04*x**12.0 - 1.571094264365090E+03*x**11.0
+ 1.265630978512400E+04*x**10.0 - 2.057808873526350E+03*x**9.0
- 1.074374333186190E+04*x**8.0 + 8.698112755348720E+03*x**7.0
- 8.297904604107030E+02*x**6.0 - 2.073765547574810E+03*x**5.0
+ 1.190223421193310E+03*x**4.0 - 2.724851668445780E+02*x**3.0
+ 2.723409218042130E+01*x**2.0 - 4.158276603609060E+00*x +
-5.573191762723310E-04*np.exp(6.560240842659690E+00*x**4.148209275061330E+01)
)
muR = self.get_muR_from_OCV(OCV, muR_ref)
actR = None
return muR, actR
11 changes: 11 additions & 0 deletions mpet/electrode/reactions/BV_Colclasure20.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import numpy as np


def BV_Colclasure20(eta, c_sld, c_lyte, k0, E_A, T, act_R=None,
act_lyte=None, lmbda=None, alpha=None):
"""Implemented for the Finegan 2020/Colclasure 2020 model comparison
for the NMC electrode"""
ecd = k0 * (165*c_sld**5 - 752.4*c_sld**4 + 1241*c_sld**3
- 941.7*c_sld**2 + 325*c_sld - 35.85) * (c_lyte/1.2)**0.5
Rate = ecd * (np.exp(-alpha*eta/T) - np.exp((1-alpha)*eta/T))
return Rate
Loading

0 comments on commit 24f3815

Please sign in to comment.