I wonder if a time section dependent isotherm is possible in CADET? I wanted to simulate a situation where either the isotherm parameters change or the isotherm model changes during one single simulation (experiment).
Time section dependent isotherm
After looking at the CADET document, I found the inlet unit and transport parameters can be section dependent, but not adsorption models. This is not supported now.
Run simulations sequentially, use the last state of a previous simulation to initialize the next
This should be possible. Relevant fields to check are: write_solution_last_unit (or write_solution_last). This will write the state vectors at the last time point to last_state_y in the output group and time derivatives to last_state_ydot. Appending last_state_ydot to last_state_y gives the final vector that can be passed to the next simulation through the init_state in the input group.
Using external functions
A successful example is posted below. This can change isotherm parameters but not the model itself.
This plots q and c_p as well as c as a function of particle radius r at an axial position at a fixed time. Note thatc is a constant at an axial position and is not dependent on r. To facilitate comparison I plotted it as a straight horizontal line here.
The initial state of simulation 2 (at the same axial position):
The magnitude is already different. Upon a closer look at the outputted last_state_y vector in simulation 1:
It already contains these large values that are not seen in the simulation 1 which I think caused the problem.
Is there any conversion between the output last_state_y and the input init_state to properly set up the simulations?
In your particular example (breaking up the simulation in parts with same isotherm), I suggest to disable consistent initialization for the second part:
model.root.input.solver.consistent_init_mode = 0 # or 3
My theory is that consistent initialization somehow fails and produces those unreasonable values.
Another way to accomplish your goal (change isotherm parameters during simulation) are external functions. Here, the isotherm parameters are taken as
where T = T(t) is some profile provided to the simulator. So each isotherm parameter is a third-degree polynomial of a given profile. You could set the constant coefficients of the isotherm parameters to your first configuration and the linear coefficients to
second configuration - first configuration.
For the first part of the simulation, we need to set T = 0 and for the second, we change to T=1. Here are the docs for specifying a profile, where you’d set VELOCITY to inf: A profile is usually moved along the column over time. In your case, we want the profile to instantly apply to all spatial positions (solely depend on time).
We have some posts in the forum about external functions.
Disabling the consistent initialization unfortunately did not work. IDAS would fail at t=0, which is kind of strange since the last_state_y and last_state_ydot from simulation 1 should already be consistent? I think the problem may have something to do with the last_state_y vector from simulation 1, it already contained some unreal values which I was not able to find at any t, r and z.
Using external functions seems to be working. My test case is simple: GRM, Multi-component Langmuir
t \in (0, 4000): q_{max}=21, \; k_a=100 t \in (4000, 8000): q_{max}=23, \; k_a=110.
The warning would still appear: Warning: setExternalFunctions::113] Index 0 exceeds number of passed external functions (0), external dependence is ignored\r\n, but it should be fine. The following plot would appear:
The sharp decrease at t=4000 made sense because q_{max} and k_a increased, the column continued to absorb the feed so the outlet concentration decreased.
This is actually something @j.breuer and I were discussing recently. I need to follow this exact approach to solve a dilemma described in the earlier post (Protein at inlet not showing up at outlet - #10 by Flynn). We were not able to figure out a solution (Jan mentioned there might be a problem with consistent initialization). I still have those hdf5 files lying around, so we could look into actually solving the problem again. To be honest, it was a highly atypical application of CADET and using a workaround with running simulations sequentially is totally fine. The ultimate outlet solution already requires three separate simulations, before we implement the workaround.
I have another application on the docket that also requires using section-dependent isotherm parameters, so I am interested in the outcome of your investigation @Flynn.