I am attempting to solve the Poisson-Boltzmannn equation, which describes the distribution of potential and concentration in relation to a charged surface in a liquid, for a cylinder. The equation this presents is a 2nd order nonlinear ODE that cannot be represented as an IVP, but instead must be solved as a BVP. The initial ODE from this relationship is:
I know in order to use bvp4c in Matlab I have to break this into a system of first order ODEs, so I have set y1=y' to generate the following system:
with the boundary cnoditions:
(1) y1 @ x(1,end) = 0
(2) y @ x(1,1) = y_d
There are additional equations that define the system, which include:
mu_x = eta_x.*(8-9*eta_x+3*eta_x.^2)./((1-eta_x).^3)
eta_x = vion*(c_cation+c_anion)
c_cation = c_bulk*exp(-z*y+mu_bulk-mu_x)
c_anion = c_bulk*exp(z*y+mu_bulk-mu_x)
c_x = c_cation+c_anion
q_x = z*c_cation-z*c_anion
c_tot = sum(c_x*pi*(x(1,n+1).^2-x(1,n).^2))
q_tot = sum(q_x*pi*(x(1,n+1).^2-x(1,n).^2))
y_d = Vcell/2/Vt-q_tot*dion*F/2/ereo/Vt
In these equations, variables directly related to distance from the charged surface, x, are row vectors with identical length to the vector, x. These variables include: y1, y2, c_cation, c_anion, c_x, q_x, mu_x, and eta_x.
Some values are constant and they are included in the code I have already generated which will be posted below.
I have generated a code that will predict reasonable values for y if given reasonable mu_x and y_d values (see the original system of ODEs), but the issues I am having are:
(1) How do I include the additional equations in the existing model,and
(2) These equations must be solved iteratively and both depend on and affect the solution of the system of ODEs. How do I perform this iterative calculation?
Here is the code I have generated:
function dydx = mybvp(x,y)
global F z c_bulk ereo Vt mu_bulk mu_x
dydx = [ y(2,:).*10^-12; 2*z*F*c_bulk/ereo/Vt*exp(mu_bulk-mu_x(1,:))*sinh(y_d)];
function in = mybvpin (x)
solinit = bvpinit(linspace(0,155*10^-12,100),@mybvpin);
sol = bvp4c(@mybvp,@mybvpbc,solinit);
Thanks in advance for your assistance!