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');

답변 (2개)

darova
darova 2020년 3월 9일

0 개 추천

What is wrong

댓글 수: 1

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

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2020년 3월 9일

0 개 추천

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.

카테고리

질문:

2020년 3월 9일

답변:

2020년 3월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by