Change demand temperature as the model runs:
tmax = 200; a=0.1; b=10; dt = .1; InitGraph(); ScaleWindow(0,-1,tmax,100); DrawAxes(); Label('Water heater- proportional plus integral',1,25); tnk = 0; Colour(Black); t = 0; i=0; LineStart(t,tnk); StepModel();
//executed in StepModel() integral+= .0005*(demand-tout)*dt; if(integral>1){integral=1;} if(integral<0){integral=0;} u= (demand-tout)/200+integral; if(u>1){u=1;} if(u<0){u=0;} tnk=tnk+(-a*tnk+b*u)*dt; tout=pipe[i]; pipe[i]=tnk; i=i+1; if(i>99){i=0;} t = t + dt; Colour(Red); Spot(t, demand); Colour(Blue); Spot(t, 100*u); Colour(Black); Spot(t, tout); if (t