Code runs and gets stuck running without producing results ode45

>> hw7p2a(v, f)
Unrecognized function or variable 'v'.
this is the only error produced, and only after i get the program to stop trying to run. Until then it just keeps running without producing any result
function dFdv = hw7p2a (v,f)
x=f(1); %variable one
y=f(2); %variable two
%explicit equations
ka=2; %dm^6/mol^2
kc=0.5; %dm^6/mol^2
alpha =.4; %dm^-3
eps= -1/2;
Ca0=2; %mol/dm^3
v0=5; %dm^3/s
Fa0=Ca0*v0;
%auxillary equations
Ca=Ca0*(1-x)/(1+eps*x)*y;
Cb=Ca0*y;
Cc=Ca0*(1/2*x)/(1-eps*x)*y;
ra=-ka*(Ca^2*Cb-(Cc/kc));
dxdv=-ra/Fa0; %PFR mole balance
dydv=-alpha/(2*y)*(1+eps*x); %ergun's eqn
dFdv=[dxdv;dydv];
end
[v,f]=ode45('hw7p2a',[0 100],[0 1]);
figure,plot(v,x(:,1));
ylabel('X'), xlabel('V (dm^3');

Answers (2)

What is wrong

1 Comment

Good catch! i changed my naming convention from prior codes and dint update. However, it is still not running to completion

Sign in to comment.

The equations start to oscillate badly near time 3.47542, therefore requiring that it takes small steps to try to meet integration tolerances.
You need to switch to a stiff solver.

Asked:

on 9 Mar 2020

Answered:

on 9 Mar 2020

Community Treasure Hunt

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

Start Hunting!