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
Example 1-20240709_090551__R01_c2_over_Diff-Coeff_Data Export.csv
I have datasets for transport properties that depend on concentration of electrolyte as well as Temperature. But I am unable to do interpolation and use it for pybamm use. I have edited one of the existing parameter sets to modify the functions. However, I get error and understand that c_e and T are symbolic so these require a functional form. How should I approach this problem? FYI, the regularr grid interpolator does a great job to fit the data if I just do it in a separate python notebook.
def fit_and_create_interpolator(csv_file_path):
"""
Fit the data from CSV and create an interpolator.
Parameters:
- csv_file_path: str, path to the CSV file containing data.
Returns:
- interp_func: RegularGridInterpolator function for diffusivity.
"""
# Load the data
data = pd.read_csv(csv_file_path)
# Extract concentration column and convert to mol/m^3
c2 = data['c2'].values * 1000
# Extract temperature values from column names and convert to Kelvin
temp_columns = [col for col in data.columns if 'Diff Coeff' in col]
temperatures_celsius = [float(col.split('.')[0]) for col in temp_columns]
temperatures_kelvin = [temp + 273.15 for temp in temperatures_celsius]
# Extract diffusion coefficient columns for each temperature
diff_coeffs = [data[col].values for col in temp_columns]
# Prepare data for RegularGridInterpolator
diff_coeff_matrix = np.array(diff_coeffs).T
# Create RegularGridInterpolator
interp_func = RegularGridInterpolator((c2, temperatures_kelvin), diff_coeff_matrix, method='linear', bounds_error=False, fill_value=None)
return interp_func
def electrolyte_diffusivity_AEM(c_e, T, interp_func, c2_bounds, temp_bounds):
"""
Diffusivity of LiPF6 in EC:EMC (3:7) as a function of ion concentration and temperature.
Parameters
----------
c_e: :class:`pybamm.Symbol`
Dimensional electrolyte concentration in mol/m^3
T: :class:`pybamm.Symbol`
Dimensional temperature in Kelvin
interp_func: RegularGridInterpolator
Interpolator function for diffusivity
c2_bounds: tuple
Bounds for concentration
temp_bounds: tuple
Bounds for temperature
Returns
-------
:class:`pybamm.Symbol`
Solid diffusivity
"""
def diffusivity_function(c_e, T):
# Clamp values to the bounds
c_e_clamped = np.clip(c_e, c2_bounds[0], c2_bounds[1])
T_clamped = np.clip(T, temp_bounds[0], temp_bounds[1])
# Interpolator requires inputs in 2D array form
return interp_func((c_e_clamped, T_clamped))[0]
return pybamm.Function(diffusivity_function, c_e, T)
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.
-
Example 1-20240709_090551__R01_c2_over_Diff-Coeff_Data Export.csv
I have datasets for transport properties that depend on concentration of electrolyte as well as Temperature. But I am unable to do interpolation and use it for pybamm use. I have edited one of the existing parameter sets to modify the functions. However, I get error and understand that c_e and T are symbolic so these require a functional form. How should I approach this problem? FYI, the regularr grid interpolator does a great job to fit the data if I just do it in a separate python notebook.
def fit_and_create_interpolator(csv_file_path):
"""
Fit the data from CSV and create an interpolator.
def electrolyte_diffusivity_AEM(c_e, T, interp_func, c2_bounds, temp_bounds):
"""
Diffusivity of LiPF6 in EC:EMC (3:7) as a function of ion concentration and temperature.
Beta Was this translation helpful? Give feedback.
All reactions