My program is not using some of my initial conditions

I have been trying to run my program and its running, but the problem is some of my initial conditions do not start from there. for example I used 19.6916 but it started from zero(0) instead until the 2206th second before it started integrating same with some others. I changed the initial conditions but it keeps using the previous one. Please what could be wrong

4 Comments

Try to re-write your question as if you're describing the problem to someone you just met on the street wearing a Matlab t-shirt. The following clauses are meaningless to us without further details:
  • some of my initial conditions do not start from there
  • I used 19.6916 but it started from zero(0) instead until the 2206th second before it started integrating same with some others
Okay sorry still trying to get a hold of this. I am trying to simulate a model of a semi-explicit Differential algebraic equations system with five differntial equations and 18 algebraic equation using ODE15s. I supplied my initial conditions for the variables but when I run the program i get a wrong result because the integration does not start from the initial conditions I provided(it seems like the program decides its initial conditions). Which is strange because its supposed to start from there. Eg
function y = gas_lift_ftn(t,x)
%Define other parameters%
mga = x(1);
mgt = x(2);
mot = x(3);
Pa = x(4);
rho_a= x(5);
Pwh = x(6);
Pw = x(7);
rho_w = x(8);
Pbh = x(9);
wiv = x(10);
wpc = x(11);
wpg = x(12);
wpo = x(13);
wro = x(14);
wrg = x(15);
Lw = 1217;
Lbh = 132;
La = 230.87;
D = 0.508;
Aw = 0.203;
Abh = 0.203;
Aa = 0.126;
Va = 29.012;
rho_o = 923.9;
Civ = 15*10^-5; Cpc = 1.655*10^-3; Cr = 2.623*10^-4;
Pr = 2.5497295*10^7; Ps = 3.704669*10^6;
Ta = 293; Tw = 293; Mw = 0.0289; R = 8.314;
g = 9.8;wgl = 3.9; GOR= 0.1;
y(1,1) = wgl - wiv;
y(2,1) = wiv - wpg + wrg;
y(3,1) = wro - wpo;
y(4,1) = -Pa+((((Ta*R)/(Va*Mw))+((g*La)/(La*Aa)))*mga) ;
y(5,1) = -rho_a +((Mw*Pa)/(Ta*R));
y(6,1) = -Pwh + ((((Tw*R)/Mw)*(mgt/((Lw*Aw)+(Lbh*Abh)-(mot/rho_o))))-(0.5*(mgt + mot)/((Lw*Aw)*g*Lw)));
y(7,1) = -rho_w +((mgt+ mot -(rho_o*Lbh*Abh))/(Lw*Aw));
y(8,1) = -Pw + Pwh +(((g/(Lw*Aw))*(mot + mgt -(rho_o*Lbh*Abh))*Lw))+((128*0.003*Lw*wpc)*((mot*Pwh*Mw)+(rho_o*R*Tw*mgt))/(3.14*D^4*Pwh*Mw*rho_o*(mgt+mot)));
y(9,1) = -Pbh + Pw + (rho_w*g*Lbh)+ ((128*0.003*wro*132)/(3.14*0.508^4*923.9));
y(10,1) = -wiv +(Civ*sqrt(max (0,(rho_a*(Pa-Pw)))));
y(11,1) = -wpc +(Cpc*sqrt(max(0,(rho_w*(Pwh - Ps)))));
y(12,1) = -wpg + ((mgt/(mgt+mot))*wpc);
y(13,1) = -wpo + ((mot/(mgt+mot))*wpc);
y(14,1) = -wro + (Cr*sqrt(rho_o* max(0,(Pr-Pbh))));
y(15,1) = -wrg + (GOR*wro);
Main script;
clear all
clc
%gaslift systems network
tspan = 0:36000;
% The script for gas lift network model defining initial conditions and
% boundaries
x0 =[4350.1; 10951; 86038; 12978262.55; 153.97023; 5107660.998; 8598289.779; 292.38; 8976895.366; 3.89; 33.52; 3.78; 31.3; 32.4; 3.24];
M = diag([ones(1,3) zeros(1,12)]);
options = odeset('Mass',M, 'RelTol',1e-3,'AbsTol',1e-5);
% call
[t,x] = ode15s(@gas_lift_ftn,tspan,x0,options);
figure (1);
% title
title ('Gas-lift Network')
when I run the program, the vales of x at x(12) does not start at the initial condition provided 31.3, rather it starts from 29.74, x(14) starts from 0 rather than the initial condition 32.4 that I provided which is strange because it is supposed to use my initial guess as a starting point. Please what is the reason
The algebraic variables are initialized such that you start from a vector of consistent initial values. The fact that ode15s changes the values you provided means that your x0 vector didn't satisfy the algebraic equations.
x0(12) is not 31.3: it is 3.78
The value that is 31.3 is x0(13)
When I test, on the first call to gas_lift_ftn, the x values are exactly the same as the x0 values you set.
Note that your function is called with t=0 a total of 17 times as part of gradient estimation. Perhaps you happened to be looking at it on a call other than the first one.

Sign in to comment.

Answers (0)

Categories

Asked:

on 16 Apr 2019

Commented:

on 17 Apr 2019

Community Treasure Hunt

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

Start Hunting!