Dear CADET users,
I face an issue when I tried to do Yamamoto approach on CADET-process. It showed index error that “tuple index out of range”. Could I please ask what might cause this problem and how I could fix it? Here is my script: (very similar to the tutorial)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
from CADETProcess.tools.yamamoto import GradientExperiment
def read_data(file_name):
# read raw data, assumes there are no column headers
data = pd.read_csv(file_name,header=None)
# split the two traces and drop NaN
# must be split first because one dataframe is longer than the other
salt_data = data[[0,1]].dropna()
protein_data = data[[2,3]].dropna()
# Convert each column to numpy arrays
time1 = np.array(salt_data[0])
c_salt = np.array(salt_data[1])
time2 = np.array(protein_data[2])
c_protein = np.array(protein_data[3])
# create interpolation function to interpolate shorter
# array (salt) to same x-locations as the longer array (protein)
interp_func = interp1d(time1,c_salt)
c_salt_interp = interp_func(time2)
return time2,c_salt_interp,c_protein
def create_experiment(file_name, gradient_volume):
"""CSV should have format of [time, salt, time, protein]."""
time,c_salt,c_protein = read_data(file_name)
return GradientExperiment(time, c_salt, c_protein, gradient_volume)
experiment_1 = create_experiment('./YamamotoExperiments/Single/40MV.csv', 34.4e-6)
experiment_2 = create_experiment('./YamamotoExperiments/Single/50MV.csv', 43e-6)
experiment_3 = create_experiment('./YamamotoExperiments/Single/60MV.csv', 51.6e-6)
experiments = [experiment_1, experiment_2, experiment_3]
from CADETProcess.tools.yamamoto import plot_experiments
plot_experiments(experiments)
from CADETProcess.processModel import ComponentSystem
component_system = ComponentSystem(['Salt', 'A'])
from CADETProcess.processModel import StericMassAction
binding_model = StericMassAction(component_system)
binding_model.adsorption_rate = [1, 1]
binding_model.desorption_rate = [1, 1]
binding_model.capacity = 4.7 * 175
from CADETProcess.processModel import LumpedRateModelWithoutPores
membrane = LumpedRateModelWithoutPores(component_system, 'membrane')
membrane.length = 0.12/100 #m
membrane.diameter = 3/100 #m
membrane.total_porosity = 0.8
membrane.binding_model = binding_model
membrane.axial_dispersion = 0.0013
from CADETProcess.tools.yamamoto import fit_parameters
yamamoto_results = fit_parameters(experiments, membrane)
print(yamamoto_results.characteristic_charge)
print(yamamoto_results.k_eq)
yamamoto_results.plot()
40MV.csv (87.6 KB)
50MV.csv (114.4 KB)
60MV.csv (131.5 KB)
I also attach the data sheet in case you want to test. Thank you so much for your time and generous help!
Kind regards,
Annie