Solving a system of ODEs with additional parameters

조회 수: 3 (최근 30일)
Yara Saavedra Ortega
Yara Saavedra Ortega 2020년 5월 10일
댓글: Yara Saavedra Ortega 2020년 5월 16일
I'm trying to solve a system of 6 differential equations which need 12 parameters. I would like to use ode23 to solve them. Following scripts show the methodolody I employed included script and function. Does anyone know where the mistake is?
%Evaluation of the diferential equation system with literature parameters.
%Definition of time domain (in hours)
domain=[0 75];
%Definition of parameter values.
P=[0.355,0.983,4.190,15.6,1.23,0.855,0.0016,2.234,199,0.314,11.501,0.0035];
%Definition of initial conditions.
X0=1.49; %g/L
Sn0=2.28; %g/L
Sc0=20; %g/L
P0=0.26; %g/L
mun0=P(1)*((1-Sn0/P(4))^P(10)); %h^-1
muc0=P(1)*((1-Sc0/P(9))^P(5)); %h^-1
IC=[X0,Sn0,Sc0,P0,mun0,muc0];
%Solving the system.
[t,D]=ode23(@(t,D) ode_sys(t,D,P),domain,IC);
function [dDV_dIV] = ode_sys(t,D,P)
%Solves the set of differential equations corresponding to mass balances
% This function calculates X,Sn,Sc,P,mun,muc that depend on time and an
% established set of parameters.
%Asign places in the array for the parameters
mumax=P(1);
alpha=P(2);
Ksc=P(3);
Snm=P(4);
a1=P(5);
yxpsc=P(6);
mc=P(7);
Ksn=P(8);
Scm=P(9);
a2=P(10);
yxsn=P(11);
mn=P(12);
% Asign places in the array for dependent variables
X=D(1);
Sn=D(2);
Sc=D(3);
P=D(4);
mun=D(5);
muc=D(6);
%Create a vector which contains a function in each place
dDV_dIV=zeros(6,1);
dDV_dIV(1)=(mumax*((Sc/(Ksc+Sc))*(Sn/(Ksn+Sn))*(1-(Sc/Scm)^a1)*(1-(Sn/Snm)^a2)))*X;
dDV_dIV(2)=-(((1/yxsn)*mun)+mn)*X;
dDV_dIV(3)=-((1/yxpsc)*muc+mc)*X;
dDV_dIV(4)=(alpha*mu)*X;
dDV_dIV(5)=mumax*(1-(Sn/Snm)^a2);
dDV_dIV(6)=mumax*(1-(Sc/Scm)^a1);
end
  댓글 수: 2
darova
darova 2020년 5월 10일
What is this?
Yara Saavedra Ortega
Yara Saavedra Ortega 2020년 5월 16일
Thank you! I figured out I had not declared the variable. I am sorry for bothering you with such a simple mistake.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by