Can you help solving this differential equation using ode15i, please?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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.
답변 (1개)
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!