Updates to ctml_writer.py associated with BinarySolutionTabulatedThermo class.
-Removes option to read tabulated thermo from an external csv file (this is now handled from within cti or xml). -Renames `rateCoeff` keyword to the more appropriate `rate_coeff_type`, and fixing keyword order so that this new keyword is listed last. -Removes `else` statement from `if isinstance(self._standardState, standardState) -Removes unused `_pure` attribute from `IdealSolidSolution` and `BinarySolutionTabulatedThermo` -Changes default on `tabulated_species` keyword to `None`. -Removing superfluous `standardState:_build` from ctml_writer.py - Removes unnecessary conc_dim() definition in `table` class. - Removes unnecessary units defintion for mole fractions in `table` class. - Improves grammar in error message for case when thermo table is not provided for `tabulated_species`.
This commit is contained in:
parent
11271d90b2
commit
8169c26271
3 changed files with 25 additions and 64 deletions
|
|
@ -191,7 +191,7 @@ ideal_interface(
|
|||
species = "(dummy)", # dummy entry for global kinetics
|
||||
site_density = (1.0e-2, 'mol/cm2')) # dummy entry for global kinetics
|
||||
|
||||
edge_reaction("Li[anode] <=> Li+[elyt] + V[anode] + electron", [4, 0.0, (0, 'kJ/mol')], rateCoeff = "exchangecurrentdensity", beta = 0.5,id="anode_reaction")
|
||||
edge_reaction("Li[anode] <=> Li+[elyt] + V[anode] + electron", [4, 0.0, (0, 'kJ/mol')], rate_coeff_type = "exchangecurrentdensity", beta = 0.5,id="anode_reaction")
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
|
@ -205,7 +205,7 @@ ideal_interface(
|
|||
species = "(dummy)", # dummy entry for global kinetics
|
||||
site_density = (1.0e-2, 'mol/cm2')) # dummy entry for global kinetics
|
||||
|
||||
edge_reaction("Li+[elyt] + V[cathode] + electron <=> Li[cathode]", [100, 0.0, (0, 'kJ/mol')], rateCoeff = "exchangecurrentdensity", beta = 0.5,id="cathode_reaction")
|
||||
edge_reaction("Li+[elyt] + V[cathode] + electron <=> Li[cathode]", [100, 0.0, (0, 'kJ/mol')], rate_coeff_type = "exchangecurrentdensity", beta = 0.5,id="cathode_reaction")
|
||||
|
||||
# Dummy species
|
||||
species(
|
||||
|
|
|
|||
|
|
@ -650,10 +650,6 @@ class species(object):
|
|||
ss['model'] = id
|
||||
if isinstance(self._standardState, standardState):
|
||||
self._standardState.build(ss)
|
||||
else:
|
||||
nt = len(self._thermo)
|
||||
for n in range(nt):
|
||||
self._thermo[n].build(t)
|
||||
|
||||
class thermo(object):
|
||||
"""Base class for species standard-state thermodynamic properties."""
|
||||
|
|
@ -815,8 +811,7 @@ class NASA9(thermo):
|
|||
|
||||
class standardState(object):
|
||||
"""Base class for species standard-state properties."""
|
||||
def _build(self, p):
|
||||
return p.addChild("standardState")
|
||||
|
||||
|
||||
class constantIncompressible(standardState):
|
||||
"""Constant molar volume."""
|
||||
|
|
@ -1299,10 +1294,12 @@ class reaction(object):
|
|||
self._kf = [self._kf]
|
||||
elif self._type == 'surface':
|
||||
self._kf = [self._kf]
|
||||
if self._rate_coeff_type:
|
||||
kfnode['type'] = self._rate_coeff_type
|
||||
elif self._type == 'edge':
|
||||
self._kf = [self._kf]
|
||||
if self._rateCoeff:
|
||||
kfnode['type'] = self._rateCoeff
|
||||
if self._rate_coeff_type:
|
||||
kfnode['type'] = self._rate_coeff_type
|
||||
elif self._type == 'threeBody':
|
||||
self._kf = [self._kf]
|
||||
self.mdim += 1
|
||||
|
|
@ -1621,8 +1618,14 @@ class surface_reaction(reaction):
|
|||
A heterogeneous chemical reaction with pressure-independent rate
|
||||
coefficient and mass-action kinetics.
|
||||
"""
|
||||
def __init__(self, equation='', kf=None, id='', order='', beta = 0.0,
|
||||
options=[]):
|
||||
def __init__(self,
|
||||
equation='',
|
||||
kf=None,
|
||||
id='',
|
||||
order='',
|
||||
beta = 0.0,
|
||||
options=[],
|
||||
rate_coeff_type = ''):
|
||||
"""
|
||||
:param equation:
|
||||
A string specifying the chemical equation.
|
||||
|
|
@ -1649,10 +1652,14 @@ class surface_reaction(reaction):
|
|||
potential difference between two phases is applied to the
|
||||
activiation energy of the fwd reaction. The remainder is applied to
|
||||
the reverse reaction.
|
||||
:param rate_coeff_type:
|
||||
Form of the rate coefficient given. If none given, assumed that the
|
||||
rate coefficient is the standard kf.
|
||||
"""
|
||||
reaction.__init__(self, equation, kf, id, order, options)
|
||||
self._type = 'surface'
|
||||
self._beta = beta
|
||||
self._rate_coeff_type = rate_coeff_type
|
||||
|
||||
|
||||
class edge_reaction(reaction):
|
||||
|
|
@ -1662,13 +1669,13 @@ class edge_reaction(reaction):
|
|||
kf = None,
|
||||
id = '',
|
||||
order = '',
|
||||
rateCoeff = '',
|
||||
beta = 0.0,
|
||||
options = []):
|
||||
options = [],
|
||||
rate_coeff_type = ''):
|
||||
reaction.__init__(self, equation, kf, id, order, options)
|
||||
self._type = 'edge'
|
||||
self._beta = beta
|
||||
self._rateCoeff = rateCoeff
|
||||
self._rate_coeff_type = rate_coeff_type
|
||||
|
||||
|
||||
#--------------
|
||||
|
|
@ -2178,7 +2185,6 @@ class IdealSolidSolution(phase):
|
|||
|
||||
phase.__init__(self, name, 3, elements, species, note, 'None',
|
||||
initial_state, options)
|
||||
self._pure = 0
|
||||
self._stdconc = standard_concentration
|
||||
if self._stdconc is None:
|
||||
raise CTI_Error('In phase ' + name + ': standard_concentration must be specified.')
|
||||
|
|
@ -2209,12 +2215,11 @@ class BinarySolutionTabulatedThermo(phase):
|
|||
transport = 'None',
|
||||
initial_state = None,
|
||||
standard_concentration = None,
|
||||
tabulated_species = '',
|
||||
tabulated_species = None,
|
||||
tabulated_thermo = None,
|
||||
options = []):
|
||||
phase.__init__(self, name, 3, elements, species, note, 'None',
|
||||
initial_state, options)
|
||||
self._pure = 0
|
||||
self._tabSpecies = tabulated_species
|
||||
self._tabThermo = tabulated_thermo
|
||||
self._stdconc = standard_concentration
|
||||
|
|
@ -2229,8 +2234,6 @@ class BinarySolutionTabulatedThermo(phase):
|
|||
raise CTI_Error('In phase ' + name
|
||||
+ ': Thermo data must be provided for the tabulated_species.')
|
||||
|
||||
def conc_dim(self):
|
||||
return (1,-3)
|
||||
def build(self, p):
|
||||
ph = phase.build(self, p)
|
||||
e = ph.child("thermo")
|
||||
|
|
@ -2267,7 +2270,6 @@ class table(thermo):
|
|||
def build(self,t):
|
||||
x = ', '.join('{0:12.5e}'.format(val) for val in self.x[0])
|
||||
u1 = t.addChild("moleFraction", x)
|
||||
u1['units'] = self.x[1]
|
||||
u1['size'] = str(len(self.x[0]))
|
||||
h = ', '.join('{0:12.5e}'.format(val) for val in self.h[0])
|
||||
u2 = t.addChild("enthalpy", h)
|
||||
|
|
@ -2278,47 +2280,6 @@ class table(thermo):
|
|||
u3['units'] = self.s[1]
|
||||
u3['size'] = str(len(self.s[0]))
|
||||
|
||||
class csvfile(thermo):
|
||||
"""User provided CSV file for BinarySolutionTabulatedThermo"""
|
||||
def __init__(self,filename):
|
||||
fh = open(filename)
|
||||
x = []
|
||||
linenumber = 0
|
||||
for line in fh.readlines():
|
||||
linenumber += 1
|
||||
line = line.strip()
|
||||
if not line.startswith("*"):
|
||||
value = re.split(r';|,\s|\s+|\t',line)
|
||||
if len(value) != 3:
|
||||
raise CTI_Error('In file: ' + filename + ', bad line format at line:' + str(value))
|
||||
else:
|
||||
y = [float(val) for val in value]
|
||||
x.append(y)
|
||||
fh.close()
|
||||
dat = []
|
||||
for i in range(3):
|
||||
dat.append([row[i] for row in x])
|
||||
self.length = len(dat[0])
|
||||
self.dat = dat
|
||||
|
||||
def build(self,t):
|
||||
energy_units = _uenergy + '/' + 'mol'
|
||||
dat_str = ['','','']
|
||||
nr = 0
|
||||
for rows in self.dat:
|
||||
dat_str[nr] += ', '.join('{0:12.5e}'.format(val) for val in rows)
|
||||
dat_str[nr] += '\n'
|
||||
nr += 1
|
||||
u1 = t.addChild("moleFraction", dat_str[0])
|
||||
u1['units'] = str(1)
|
||||
u1['size'] = str(self.length)
|
||||
u2 = t.addChild("enthalpy", dat_str[1])
|
||||
u2['units'] = energy_units
|
||||
u2['size'] = str(self.length)
|
||||
u3 = t.addChild("entropy", dat_str[2])
|
||||
u3['units'] = energy_units + '/K'
|
||||
u3['size'] = str(self.length)
|
||||
|
||||
class lattice(phase):
|
||||
def __init__(self,
|
||||
name = '',
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ function E_cell = lithium_ion_battery(X_Li_ca, X_Li_an, T, P, I_app, R_elyt)
|
|||
% Reference:
|
||||
% M. Mayur, S. DeCaluwe, B. L. Kee, W. G. Bessler, "Modeling
|
||||
% thermodynamics and kinetics of intercalation phases for lithium-ion
|
||||
% batteries in Cantera", Computer Physics Communications
|
||||
% batteries in Cantera", under review at Electrochimica Acta.
|
||||
|
||||
|
||||
% Parameteres
|
||||
% Parameters
|
||||
inputCTI = 'lithium_ion_battery.cti'; % cantera input file name
|
||||
F = 96485; % Faraday's constant [C/mol]
|
||||
S_ca = 1.1167; % [m^2] Cathode total active material surface area
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue