Effacer les filtres
Effacer les filtres

ODE45 running infinitely without solving

2 vues (au cours des 30 derniers jours)
Ajmal R S
Ajmal R S le 4 Mai 2020
Commenté : Ajmal R S le 5 Mai 2020
I tried to code an ode45 function to find the concentration wrt to thickness of membrane but the ode45 function is taking too long without actually solving the code
ts = 100e-06; %in m
ta = 100e-09; %in m
z0 = ta + ts ; %z = ta+ts
zend = ta + ts + del_d ; %z = ta+ts+delta_d
[zdsol,cdsol]=ode45(@(z,c) decp(z,c), [z0,zend],c0);
And this is the function
function dc = decp(z,c)
x1_dsd = -6.92e-12;
x2_dsd = -9.95e-11;
x3_dsd = 1.51e-9;
dsd_d= x1_dsd*c^2 + x2_dsd*c + x3_dsd;
dc = ((0.02+6*c)/dsd_d);
end
With Js and Jw being constants
Please help !

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Mai 2020
Modifié(e) : Walter Roberson le 5 Mai 2020
try ode23s. if your system is stiff then ode45 can take a long long time.
Also I worry that your c0 is associated with time 0; it needs to be associated with time z0 instead.
Your denominator dsd_c has zeros near time 1e-11 which could be a problem
  5 commentaires
Walter Roberson
Walter Roberson le 5 Mai 2020
we need the rest of your code to test with
Ajmal R S
Ajmal R S le 5 Mai 2020
Here is the full code.
clc;
clear all;
A = 0.5;
B = 0.4;
S = 200e-06;
Jw= 6;
Js= 0.02;
c0 = 1;
v = 20; %cross flow velocity feed and draw in cm/s
x1_rho = 0.04;
x2_rho = 1;
rho_d = x1_rho*c0 + x2_rho; %in cgs
x1_mu = 0.02;
x2_mu = 0.06;
x3_mu = 0.89;
mu_d = x1_mu*c0^2 + x2_mu*c0 + x3_mu; %in cgs
L = 8.55; %channel length in cm
dh = 0.42; %hydrauic diameter in cm made it 0.2 to meet conditions in ref.
Re = (rho_d*1000*v*10^-2*dh*10^-2)/(mu_d*10^-3);
x1_dsd = 6.92e-12;
x2_dsd = -9.95e-11;
x3_dsd = 1.51e-9;
dsd_d= x1_dsd*c0^2 + x2_dsd*c0 + x3_dsd; %given in section 3.2 in m2/s
Sc = (mu_d*10^-3)/(rho_d*1000*dsd_d);
Sh = 1.85*(Re*Sc*(dh/L))^0.33;
k_d = (Sh*dsd_d)/(dh*10^-2); %in m/s
del_d = dsd_d/k_d; %in m
ts = 100e-06; %in m
ta = 100e-09; %in m
zend = ta + ts ; %z = ta+ts
z0 = ta + ts + del_d ; %z = ta+ts+delta_d
[zdsol,cdsol]=ode23s(@(z,c) decp(z,c), [z0,zend],c0);
And the function
function dc = decp(z,c)
x1_dsd = 6.92e-12;
x2_dsd = -9.95e-11;
x3_dsd = 1.51e-9;
dsd_d= x1_dsd*c^2 + x2_dsd*c + x3_dsd;
dc = ((0.02+6*c)/dsd_d);
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by