You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to generate the EIS using the following code, the EIS profile is shifting to the right side when we increase the charge C rate from 0.3 to 1C or 3C (refer to the figure below). How we can explain this behavior in DFN model? Please feel free to comment on it.
Initial conditions and parameter update
import pybamm
import matplotlib.pyplot as plt
import pbeis
import numpy as np
import matplotlib.pyplot as plt
import time as timer
from scipy.fft import fft
exp = pybamm.Experiment(
["Hold at 4.2 V until C/100",
"Rest for 4 hours",
"Discharge at 0.1C until 2.5 V", # initial capacity check
"Charge at 0.3C until 4.2 V",
"Hold at 4.2 V until C/100",]
[("Discharge at 1C until 2.5 V", # ageing cycles
"Charge at 0.3C until 4.2 V",
"Hold at 4.2 V until C/100",)] * cycle_number
)
start_time = timer.time()
sim = pybamm.Simulation(model, parameter_values=updated_parameters,experiment=exp,solver=pybamm.CasadiSolver(mode='safe without grid'),var_pts=var_pts)
solution = sim.solve()
Set initial conditions of aged_model from the solution and EIS Running
#frequency range
frequencies = np.logspace(-4, 2, 30)
#amplitude of the current for EIS
I = 1 * 1e-3
number_of_periods = 20
samples_per_period = 20
#Current function
def current_function(t):
#return I * pybamm.sin(2 * np.pi * F * t)
return I * pybamm.sin(2 * np.pi * pybamm.InputParameter("Frequency [Hz]") * t)
updated_parameters["Current function [A]"] = current_function
sim_aged = pybamm.Simulation(aged_model, parameter_values=updated_parameters,solver=pybamm.CasadiSolver(mode='safe without grid'),var_pts=var_pts)
impedances_time = []
for frequency in frequencies:
# Solve
period = 1 / frequency
dt = period / samples_per_period
t_eval = np.array(range(0, 1 + samples_per_period * number_of_periods)) * dt
sol = sim_aged.solve(t_eval, inputs={"Frequency [Hz]": frequency},initial_soc=0.9)
# Extract final two periods of the solution
time = sol["Time [s]"].entries[-3 * samples_per_period - 1 :]
current = sol["Current [A]"].entries[-3 * samples_per_period - 1 :]
voltage = sol["Terminal voltage [V]"].entries[-3 * samples_per_period - 1 :]
# FFT
current_fft = fft(current)
voltage_fft = fft(voltage)
# Get index of first harmonic
idx = np.argmax(np.abs(current_fft))
impedance = -voltage_fft[idx] / current_fft[idx]
impedances_time.append(impedance)`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello @brosaplanella @tinosulzer and Everyone,
I am trying to generate the EIS using the following code, the EIS profile is shifting to the right side when we increase the charge C rate from 0.3 to 1C or 3C (refer to the figure below). How we can explain this behavior in DFN model? Please feel free to comment on it.
Initial conditions and parameter update
import pybamm
import matplotlib.pyplot as plt
import pbeis
import numpy as np
import matplotlib.pyplot as plt
import time as timer
from scipy.fft import fft
parameter_values = pybamm.ParameterValues("Chen2020")
pp = pybamm.ParameterValues("OKane2022")
model = pybamm.lithium_ion.DFN(
{
"thermal": "lumped", #lumped thermal submodel
"surface form": "differential", #Adding capacitance to the model
#"SEI": "solvent-diffusion limited",
#"SEI porosity change": "true",
#"lithium plating": "partially reversible",
#"lithium plating porosity change": "true", # alias for "SEI porosity change"
#"particle mechanics":"swelling only",
#"SEI on cracks": "true",
#"loss of active material": "stress-driven",
)
var_pts = {
"x_n": 5, # negative electrode
"x_s": 5, # separator
"x_p": 5, # positive electrode
"r_n": 30, # negative particle
"r_p": 30, # positive particle
}
def get_chen2020_parameters():
parameter_values = pybamm.ParameterValues("Chen2020")
parameters = parameter_values
return parameters
def get_okane2022_degradation_parameters():
degradation_parameters = {
'Dead lithium decay constant [s-1]': 1e-06,
'Dead lithium decay rate [s-1]':pp["Dead lithium decay rate [s-1]"],
'Initial plated lithium concentration [mol.m-3]': 0.0,
'Lithium metal partial molar volume [m3.mol-1]': 1.3e-05,
'Lithium plating kinetic rate constant [m.s-1]': 1e-09,
'Lithium plating transfer coefficient': 0.65,
'Negative electrode LAM constant exponential term': 2.0,
'Negative electrode LAM constant proportional term [s-1]': 2.7778e-07,
"Negative electrode Paris' law constant b": 1.12,
"Negative electrode Paris' law constant m": 2.2,
"Negative electrode Poisson's ratio": 0.3,
"Negative electrode Young's modulus [Pa]": 15000000000.0,
'Negative electrode cracking rate':pp["Negative electrode cracking rate"],
'Negative electrode critical stress [Pa]': 60000000.0,
'Negative electrode initial crack length [m]': 2e-08,
'Negative electrode initial crack width [m]': 1.5e-08,
'Negative electrode number of cracks per unit area [m-2]': 3180000000000000.0,
'Negative electrode partial molar volume [m3.mol-1]': 3.1e-06,
'Negative electrode reference concentration for free of deformation [mol.m-3]': 0.0,
'Negative electrode volume change':pp["Negative electrode volume change"],
'Positive electrode LAM constant exponential term': 2.0,
'Positive electrode LAM constant proportional term [s-1]': 2.7778e-07,
'Positive electrode OCP entropic change [V.K-1]': 0.0,
"Positive electrode Paris' law constant b": 1.12,
"Positive electrode Paris' law constant m": 2.2,
"Positive electrode Poisson's ratio": 0.2,
"Positive electrode Young's modulus [Pa]": 375000000000.0,
'Positive electrode active material volume fraction': 0.665,
'Positive electrode cracking rate':pp["Positive electrode cracking rate"],
'Positive electrode critical stress [Pa]': 375000000.0,
'Positive electrode initial crack length [m]': 2e-08,
'Positive electrode initial crack width [m]': 1.5e-08,
'Positive electrode number of cracks per unit area [m-2]': 3180000000000000.0,
'Positive electrode partial molar volume [m3.mol-1]': 1.25e-05,
'Positive electrode reference concentration for free of deformation [mol.m-3]': 0.0,
'Positive electrode volume change':pp["Positive electrode volume change"],
'Typical plated lithium concentration [mol.m-3]': 1000.0,
'Exchange-current density for stripping [A.m-2]':pp["Exchange-current density for stripping [A.m-2]"],
'Exchange-current density for plating [A.m-2]':pp["Exchange-current density for plating [A.m-2]"],
return degradation_parameters
def update_parameters():
# Load Chen2020 parameters
chen2020_params = get_chen2020_parameters()
updated_parameters = update_parameters()
Set up experiment
cycle_number = 10
exp = pybamm.Experiment(
["Hold at 4.2 V until C/100",
"Rest for 4 hours",
"Discharge at 0.1C until 2.5 V", # initial capacity check
"Charge at 0.3C until 4.2 V",
"Hold at 4.2 V until C/100",]
"Charge at 0.3C until 4.2 V",
"Hold at 4.2 V until C/100",)] * cycle_number
)
start_time = timer.time()
sim = pybamm.Simulation(model, parameter_values=updated_parameters,experiment=exp,solver=pybamm.CasadiSolver(mode='safe without grid'),var_pts=var_pts)
solution = sim.solve()
Set initial conditions of aged_model from the solution and EIS Running
aged_model = model.set_initial_conditions_from(solution)
#frequency range
frequencies = np.logspace(-4, 2, 30)
#amplitude of the current for EIS
I = 1 * 1e-3
number_of_periods = 20
samples_per_period = 20
#Current function
def current_function(t):
#return I * pybamm.sin(2 * np.pi * F * t)
return I * pybamm.sin(2 * np.pi * pybamm.InputParameter("Frequency [Hz]") * t)
updated_parameters["Current function [A]"] = current_function
sim_aged = pybamm.Simulation(aged_model, parameter_values=updated_parameters,solver=pybamm.CasadiSolver(mode='safe without grid'),var_pts=var_pts)
impedances_time = []
for frequency in frequencies:
# Solve
period = 1 / frequency
dt = period / samples_per_period
t_eval = np.array(range(0, 1 + samples_per_period * number_of_periods)) * dt
sol = sim_aged.solve(t_eval, inputs={"Frequency [Hz]": frequency},initial_soc=0.9)
# Extract final two periods of the solution
time = sol["Time [s]"].entries[-3 * samples_per_period - 1 :]
current = sol["Current [A]"].entries[-3 * samples_per_period - 1 :]
voltage = sol["Terminal voltage [V]"].entries[-3 * samples_per_period - 1 :]
# FFT
current_fft = fft(current)
voltage_fft = fft(voltage)
# Get index of first harmonic
idx = np.argmax(np.abs(current_fft))
impedance = -voltage_fft[idx] / current_fft[idx]
impedances_time.append(impedance)`
Beta Was this translation helpful? Give feedback.
All reactions