フィルターのクリア

Can you help solving this differential equation using ode15i, please?

3 ビュー (過去 30 日間)
Tadele
Tadele 2022 年 12 月 30 日
コメント済み: Tadele 2023 年 1 月 3 日
function dydz = MS_AA_imp(z, x, dx_dz ,x_p, V, Z,h)
TempK = 25 + 273.15; % Temp in Kelvin
Faraday = 96485.336; % Faraday constant [C/mol]
R_id = 8.314; % R constant [J/(K mol)]
VM_1 = 1.8e-5; % AA molar volume of lysine [m3/mol] ---converted to m3--which was 18 cm3/mol
VM_2 = 1.57e-5; % Na molar volume [m3/mol] * Calculated from rS
VM_3 = 4.47e-6; % Cl molar volume [m3/mol] * calcualted form rS
VM_4 = 1.8e-5; % Water molar volume [m3/mol]
D_14_inf = 6.67e-10; % D14 value under diluted conditions and IEP [m^2/s]---substituted for D14_inf amino acid which I found on literature and used for the
%calculation of Diffusivity at different concentration(imperical relation fourn using experimental value) D= 10^(-9) (0.665-0.393x_i)
D_24 = 1.33E-9; % D24 value under diluted conditions [m^2/s]
D_34 = 2.03E-9; % D34 value under diluted conditions [m^2/s]
x_1 = x(1);
x_2 = x(2);
x_3 = x(3);
x_4 = x(4);
x_5 = x(5); %psi.
h=7; %hydration number at specific pH and ionic strength
%Vol_exclusion = (1 + 4*x_1 + 4*x_1^2 - 4*x_1^3 + x_1^4)/((1-x_1)^3);
hydration= x_1./((x_1).*(1-x_1.*h).*(R_id*TempK)); % new hydration formula
%CT = x_1 / VM_1 + x_2 / VM_2 + x_3 / VM_3 + x_4 / VM_4;
CT = x_1 / VM_1 + x_2 / VM_2 + x_3 / VM_3 + x_4 / VM_4;
%D_14 = D_14_inf * ( 0.21 + 0.79* exp(-4.7*x_1))/ hydration;
D_14 =10e-9 .*(0.665-0.393.*x_1)./(1+x_1.* (h./(1-x_1.* h))); % new D_14 formula
IStr = 0.5* (Z(2).^2 .* x_2/(VM_2 *1000) + Z(3).^2 .* x_3/(VM_3 *1000));
D_23 = ((D_24 + D_34)./2 .* IStr .^(0.55) ./ (abs((Z(2)) * (Z(3))).^(2.3)));
D_23V = D_23 * VM_3 *CT;
D_32V = D_23 * VM_2 *CT;
J_1 = x_p(1) * V; %think about changing to total molar flux instead of using volumetric flux V (x_tot*v=N_tot--but x_tot=1 thus N_tot=v)
J_2 = x_p(2) * V;%know that the volumetric flux here the same as the total molar flux since the concentration
J_3 = x_p(3) * V;
J_4 = x_p(4) * V;
dpsidz = x_5;
%eq1 = Vol_exclusion * dphi_dz(1) + x_1 * Z(1) * Faraday / (R_id .* TempK)* dphi_dz(5) - (J_4 * x_1 - J_1* x_4)/(D_14 * VM_4 * CT);
eq1 = hydration * dx_dz(1) + x_1 * Z(1) * Faraday / (R_id .* TempK)* dx_dz(5) - (J_4 * x_1 - J_1* x_4)/(D_14 * CT);
%eq1 = hydration* diff(x_1) + x_1 * Z_AA * Faraday * diff(psi)/ ( R * TempK) == N_4 * x_1/ D_14;
eq2 = dx_dz(2) + x_2 * Z(2) * Faraday * dx_dz(5) / ( R_id * TempK) - (J_3 * x_2 - J_2 * x_3)/ D_23 - (J_4 * x_2 - J_2 * x_4)/ (D_24 *CT);
eq3 = dx_dz(3) + x_3 * Z(3) * Faraday * dx_dz(5) / ( R_id * TempK) - (J_2 * x_3 - J_3 * x_2)/ D_23 - (J_4 * x_3 - J_3 * x_4)/ (D_34* CT); %D_32V replaced with D_
eq4 = x_1 + x_2 + x_3 + x_4 - 1; % contiuty
%eq5 = Z(1) * x_1/ VM_1 + Z(2)* x_2/ VM_2 + Z(3) * x_3/VM_3;
eq5 = Z(1) * x_1 + Z(2)* x_2 + Z(3) * x_3; % changed from the above line removing VM
dydz = [eq1; eq2; eq3; eq4; eq5];
end
  13 件のコメント
Torsten
Torsten 2023 年 1 月 2 日
What's the matter with x(5) ? --->>this is anther differential equation with different variable. But I wanted to calculate it as a fitting paramets that will be calculated automatically when othe variables(x1-x4) are solved.
How ?
In the testcode above:
y0 are your initial conditions.
tspan is Z span.
Adapt the call to decic to your problem now.
Tadele
Tadele 2023 年 1 月 3 日
about x(5), I removed it form the first script I posted to make it easier for someone who helps solving the equations, hoping that I will add that after I get help solving the equations without varieble x(5). But it becomes difficult now to solve it for me.
I also tried the test code you have sent me by adding the intial conditions and tsapan to adapt them to the decic. It is still showing me error. Does it work for you (if you have tried it)? Otherwise is there any other way that you recommend me to solve it?
If you have time can you also suggest me how to use the output of one function as an input for the other function so that I can run an algorithm that converges a guess value and calculated value? If it is easier with codes, I can post it here.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 12 月 30 日
編集済み: Jan 2022 年 12 月 30 日
dx_dz = ???
x_p = ???
V = ???
Z = ???
h = ???
tspan = [0, 10]; % ???
x0 = rand(1, 5); % ???
[Z, Y] = ode15s(@(z, x) MS_AA_imp(z, x, dx_dz, x_p, V, Z, h), tspan, x0);
Although the names of the variables do not matter, "dx_dz", "dydz" and "z", "x" is confusing.
  2 件のコメント
Torsten
Torsten 2022 年 12 月 30 日
dx_dz are input to "MS_AA_imp" from ODE15I and are the time-derivatives of the variables solved for.
Since the ODE system does not seem to be explicit in dx_dz, it will at least be necessary to use ODE15S together with the mass matrix option.
Jan
Jan 2022 年 12 月 30 日
@Torsten: I know. I've mentioned the names of the variables due to:
function dydz = MS_AA_imp(z, x, ...
% ^ ^
This is not an error, but maybe confusing, especially if "dx_dz" is occurring also, even if it has a different meaning.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeChemistry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by