Modeling DAE system with discontinous solution (jump condition domain)

3 views (last 30 days)
Hello,
I am trying build steady-state 1D electrodialysis model in matlab, cromprizing three sub domains, namely the analyte channel, the catholyte channel and an ion exchange membrane inbetween. I have provided the key eqations, while there are still some other minor algebraic equations.
DAE system:
(dc/dt=0)
Boundary condition: Neuman boundary conditions (also shown in the sketch)
Internal boundary condition (jump condition)
(membran solution interface continuity condition)
The masstransport is modeled using the nerst plank equation for each species and the electricfield is calculated through ohms law. Additionally I use the electron neutrality condition to close the mass balance. The individuall sub domains are connetced through an internal flux continuity boundary condition.
So far i have a rough understanding of the various ode solvers but from what i understand, the ode solvers only work when the whole problem is fully defined. In my case however, I have these sub domains connected via flux continuity boundary conditions, which is why i can not solve the sub domains individually. I have to solve them all at once. Additionally the boundary continuity boundary condition at the membrane interface introduces a jump (discontinuity) to the conentration and the potential profile. (qualitatively sketched below)
I am now looking for an appropirate way to model this system. The tricky part is the continuity condition at the membrane interface.
I hope to solve this problem with bvp5c where one can define multiple boundary condition inside the domain as described in this documentation:
But I am not entirlly sure how to implement the countinuity condition.
I have figured that it is possible to have jumps in the solution but since the continuity boundary condition which i am aiming to use is more complex that what has been done in the documentation, I am not quite sure on how to implent it. I would need the derivertives at the interface, instad of simply relating the absolute values at the interface to each other. (as it is done here)
function res = bc(YL,YR) % boundary conditions
res = [YL(1,1) % v(0) = 0
YR(1,1) - YL(1,2) - 1 % Here, I introduced a jump with a constant value at x=1
YR(2,1) - YL(2,2) % Continuity of C(x) at x=1
YR(2,end) - 1]; % C(lambda) = 1
end
Does anyone have an Idea, how i can use this solver for my problem. Any alternative approaches and clues are also very welcome.
Thank you^^
Bonus:
Ideally I want to build a hirachical model where all these three domains are modeled as individual systems (ode systems) and conntect them through a continiuty condtion for the concentraiton and the donnanpotential for the electric field. Also for the purpose of reusing the individuall models for later simulations. I know that this is common practice in gPROMS but i couldnt find similar approaches to modeling using matlab. Is there a similar modeling framework in matlab? I have only seen people using the various ode solvers for modeling in matlab for fully defined ODE systems.
  5 Comments
Torsten
Torsten on 26 Feb 2023
I don't understand the background of your equations which I think would be necessary to help.
What variables are known, what are unknown ?
How are ϕ and φ related ?
Is c related to the C_i ?
Berat Cagan Türkmen
Berat Cagan Türkmen on 26 Feb 2023
Hey thank for feedback,
you are right my intial question was strongly missleading because i screenshoted them form different recources. i rewrote the equations with some additional expainations. I hope that helps.
to still briefly answer your questions:
  1. ϕ and φ are the same
  2. c and C_i are the same

Sign in to comment.

Answers (1)

Berat Cagan Türkmen
Berat Cagan Türkmen on 26 Feb 2023
Edited: Berat Cagan Türkmen on 26 Feb 2023
I will try to explain the phyiscal backgroung of the equations used. Aigan, i want model the masstransport of ions in a chemical cell.
I start with the general continuity equation and since i am only interested in in the steady state solution i set
Flux of of ions are describe with the so called nernst plank equation.
Here, the frist term descirbes the ion flux due to diffusion (conenctraion gradient is the driving force) and the second term is the flux due to the potential gradient (electric field is the driving force)
by combing the flux with the continuity equation we get the first equation.
these are the balance equation for the ionic species in our system. when whe have N diffierence species we need N-1 of these balance equations for each region. Remember we had three different regions anaolyte, catholyte and membrane.
The last species is calculated via the electroneutrality condition, which basically assumes that at each point in our system the potential must cancel out.
to solve the system we still need an equation to describe the potential field (electric field) inside the system. We do this using the relationship between the current density and flux of ions. (we basicly say that that the flowing current i our system is basicly the flow of the electroylte...i hope this is intuitive)
here we can insert the ion flux given by the nerst plank equation and isolate , wich gives is the following equation
(i made a small adjustment to this equation by removing the third term in the numerator)
This should be the whole set of equaitons where every variable is known exept for the species concentreation and the potential ϕ, which i want to solve for.
As for the boundary conditions:
I have neuman boundary condition. L is basicly the maximal lenghth of the system. i compute form 0 to L. is known.
As sketched above i have two membrane/solution interfaces where the concentration jumps. At these interfaces i want to implement the continuity condition. is the ion flux intering the interface form the solution side and is the ion flux leaving form the membrane site (and vice verca)
Aigan i am inserting the ion flux from the nerst plank equation which yield the final equation.
I need to someone incorporate this equation as an internal boundary condition, which i am currently failing at.
  20 Comments
Berat Cagan Türkmen
Berat Cagan Türkmen on 5 Mar 2023
d^2c_2/dx^2 = -z1/z2 * d^2c_1/dx^2
by the relation
z1*c_1 + z2*c_2 = 0
And then you solve the equation for d^2c_1/dx^2, substitute y(1) = c_1, y(2) = dc_1/dx as usual. What's the problem ?
this works for 2 species, you are right. but i have more then 2 species i cant do that.
i is the index of the equation being solved (namely for c_i), j is the summation index over all c_j coming from substituting the expression for dphi/dx.
okey, i believe i understand what you mean but in the end i still have all the dc_1^2/dx^2,dc_2^2/dx^2,dc_3^2/dx^2,dc_4^2/dx^2 etc. which prevent me from solving the eqation for each individual dc_i^2/dx^2. the only difference is that the i is for N-1 species and and j is for all the N species
At the moment, we do not discuss about the internal boundaries, but about how to set up the system to be solved (which solution variables are to be used; should there be an extra equation for phi or should phi be completely substituted by the c_i). I think if you find the way of solving the "usual" equations in the literature (without extra difficulties) would already be of great help.
okey, I will look for information on that regard.
The problem i see however, is that the bvp5c model forces me to form first order odes. but if i could code a finite difference method based solver, shouldnt i be able to manually discritize me second order and the dphi/dx equation?
Torsten
Torsten on 5 Mar 2023
Edited: Torsten on 6 Mar 2023
d^2c_2/dx^2 = -z1/z2 * d^2c_1/dx^2
by the relation
z1*c_1 + z2*c_2 = 0
And then you solve the equation for d^2c_1/dx^2, substitute y(1) = c_1, y(2) = dc_1/dx as usual. What's the problem ?
this works for 2 species, you are right. but i have more then 2 species i cant do that.
Write down the system for N species. If you arrange the equations with regard to d^2c_i/dx^2 (i=1,...,N-1) and substitute d^2c_N/dx^2 as you substituted d^2c_2/dx^2 above, you get a linear system of equations of the form
a11*d^2c_1/dx^2 + a12*d^2c_2/dx^2 + ... + a1,N-1*d^2c_(N-1)/dx^2 = b_1
a21*d^2c_1/dx^2 + a22*d^2c_2/dx^2 + ... + a2,N-1*d^2c_(N-1)/dx^2 = b_2
...
aN-1,1*d^2c_1/dx^2 + aN-1,2*d^2c_2/dx^2 + ... + aN-1,N-1*d^2c_(N-1)/dx^2 = b_N-1
Here, a_ij and bi depend on c_i and dc_i/dx.
This system can be solved for the d^2c_i/dx^2 using backslash, as I already told you in a previous response.
The problem i see however, is that the bvp5c model forces me to form first order odes. but if i could code a finite difference method based solver, shouldnt i be able to manually discritize me second order and the dphi/dx equation?
Where do you see a problem in writing second-order derivatives as two first-order derivatives ?
In my experience, self-written numerical code (e.g. to solve a multipoint boundary value problem) should only come into play if the available solvers are not applicable. I don't see that this is the case here.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!