Challenge

FINAL INDEPENDENT PROJECT

AIM:Simulation of water reservoir system using MATLAB
OBJECTIBVE:The objective of water Reservoir simulation is to calculate all the imporatant variables which affect the pperformance of the water reservoir system.The simulation follow these conditions.
CONDITION:
while simulating this system the following conditions should be made;
1.simulation is done for 60 consecutive months.
2.water received through direct rain fall is assumed to be not more than 30% of the capacity of the reservoir.
3.water received through river inflow is assumed to be not more than 130% of the capacity of the reservoir.
4.seepage losses is not more than 5%
5.evaporation losses is not more than 8%.
6.The water demand is not more than the capacity of the reservoir.
2.Print the variables (VI<VPM<GV<SL<EL<TL<VNET<DEMAND<SHORTAGE<SPILL<MONTHS)in the command window.
3.plot the graph between
1.NET VOLUME AND DEMAND
2.SHORTAGE AND SPILL
3.TOTAL LOSS AND GROSS VOLUME over the months.
TERMS USED:
1.M=MONTHS
2.C=CAPACITY
3.RF=RAINFALL
4.RI=RIVER INFLOW
5.VI=VOLUME INFLOW
6.VPM=VOLUME OF PREVIOUS MONTH
7.GV=GROSS VOLUME
8.SL=SEEPAGE LOSS
9.EL=EVAPORATIVE LOSS
10.TL=TOTAL LOSS
11.V_NET=NET VOLUME
12.DEMAND
13.SHORTAGE
14.SPILL
CODE EXPLANATION:
1.Firstly we start with clear all ,close all and clc commands were used to clear the workspace,close all the current open windows ,and clean the command window, respectively.
2.The initial value of VPM was assumed to zero [vpm(1)=0].
3.The total month of simulation run is stored in variabe 'M' and afterbthat input,the syntax is written to take the input of capacity of the reservoir.
4.Print the header of the data.
5.Now,a syntax is written to ignore the warning.
6.Now from here ,our loop starts.The loop will run from 2 to M+1.where 'M' is months
7.after that,the value of 'i' is stored in the variable 'Months(i)'.
8.Now three random numbers are generated.These random numbers will be generated between 0 and 1 for every iteration run.These random numbers will be different in each iteration.
9.water received through direct rain fall is assumed to be not more than 30% of the capacity of the reservoir.water received through river inflow is assumed to be not more than 130% of the capacity of the reservoir.seepage losses is not more than 5%.Evaporation losses is not more than 8%.The water demand is not more than the capacity of the reservoir.
RAINFALL=RANDOM NO.*CAPACITY OF THE RESERVOIR*0.3
RAININFLOW=RANDOM NO.*CAPACITY OF THE RESERVOIR*1.3
10.After that,VOLUME INFLOW=RAINFALL+RIVER INFLOW.
11.Next we calculte the gross volume by the equation
GROSS VOLUME=VOLUME INFLOW+VOLUME OF WATER IN THE PREVIOUS MONTH.
12.Next we calculate the SEEPAGE LOSS=GROSS VOLUME*0.05.
13.And EVAPORATIVE LOSS=GROSS VOLUME*0.08
14.By adding the seepage loss and evaporative loss we can get the total loss
TOTAL LOSS=SEEPAGE LOSS +EVAPORATIVE LOSS.
15.Finally we find the NET VOLUME.
NET VOLUME=GROSS VOLUME-TOTAL LOSS.
16.In the same way we will find the Demand
DEMAND =RANDOM NO*CAPACITY OF THE RESERVOIR.
If DEMAND>NET VOLUME
THEN SHORTAGE =DEMAND -NET VOLUME
VPM=0
SPILL=0
17.If the demand is lower than the net volume then we have to calculate the difference between them.
DIFFERENCE=NET VOLUME-DEMAND
18.If th difference is lower than the capacity,which means we have extra water.That extra water needs to be spill because we cant store them.Now we will folloe]w these statements.
if Difference >capacity of Reservoir
then
SPILL=DIFFERENCE-CAPACITY OF RESERVOIR
VPM=CAPACITY OF RESERVOIR
SHORTAGE=0
else
VPM=DIFFERENCE
SPILL=0
SHORTAGE=0
19.At the point ,our loop and all conditions were ended.After that will we print all the variables in the output.
20.Now we will plot graphs of variations.
21.After plotting the graphs,I provided the labeling,title and legends for all three plots.
22.Now the program is ended.
PROGRAM CODE:
clear all
close all
clc
VPM(1)=0;
M=60;
C=input('Enter the capacity of reservior(in million cubic feet): ');
Header1=('n Months Volume Inflow Gross Volume Seepage Loss Evap loss Total loss Net Volume Demand Shortage Spill n');
Header2=(' prev.Month n');
% TO PRINT THE HEADER IN OUTPUT
fprintf(Header1)
fprintf(Header2)
warning('off')
% Loop and conditions
for i=2:M+1
Months(i)=i-1;
r1=rand;
r2=rand;
r3=rand;
RF(i)=r1*C*0.3; %condition for rainfall
RI(i)=r2*C*1.3; %condition for river inflow
VI(i)=RF(i)+RI(i); %condition for volume inflow
GV(i)=VI(i)+VPM(i-1); %condition for gross volume of water
SL(i)=GV(i)*0.05;
EL(i)=GV(i)*0.08;
TL(i)=SL(i)*EL(i);
V_Net(i)=GV(i)-TL(i);
Demand(i)=r3*C;
if Demand(i)>V_Net(i)
Shortage(i)=Demand(i)-V_Net(i);
VPM(i)=0;
Spill(i)=0;
else
Difference(i)=V_Net(i)-Demand(i);
if Difference(i)>C
Spill(i)=Difference(i)-C;
VPM(i)=C;
Shortage(i)=0;
end
end
%End of the condition
% to print allthe data in output
fprintf('%d',Months(i))
fprintf(' %08.2f',VI(i))
fprintf(' %08.2f',VPM(i))
fprintf(' %08.2f',GV(i))
fprintf(' %08.2f',SL(i))
fprintf(' %08.2f',EL(i))
fprintf(' %08.2f',TL(i))
fprintf(' %08.2f',V_Net(i))
fprintf(' %08.2f',Demand(i))
fprintf(' %08.2f',Shortage(i))
fprintf(' %08.2f',Spill(i))
% plotting figures
figure(1)
plot(Months,Demand,'color','k','marker','o')
plot(Months,V_Net,'color','b','marker','s')
hold on
pause(0.01)
xlabel('Months')
ylabel('Water Quality(mcft)')
title('Variation in Demand and Net Volume of Reservoir')
legend('Net Volume','Demand')
grid on
figure(2)
plot(Months,Spill,'color','b','marker','o')
plot(Months,Shortage,'color','r','marker','s')
hold on
pause(0.01)
xlabel('Months')
ylabel('Water Quality(mcft)')
title('Variation in Demand and Net Volume of Reservoir')
legend('Shortage','Spill')
grid on
figure(3)
plot(Months,TL,'color','g','marker','o')
plot(Months,GV,'color','m','marker','s')
hold on
pause(0.01)
xlabel('Months')
ylabel('Water Quality(mcft)')
title('Variation in Demand and Net Volume of Reservoir')
legend('Gross Volume','Total Loss')
grid on
end
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.