FINAL INDEPENDENT PROJECT
Topic:
Simulation of Water Reservoir.
Aim:
The aim of this topic is to simulate a Water Reservoir using Matlab.
Objective:
The objective of this topic is to calculate the important variables which affect the Water Reservoir performance.
Graphs to be plot:
* Net Volume and Demand.
* Variation in Shortage and Spill.
* Variation in Gross Volume and Total Loss.
Conclusion (or) Motive of the selected Topic:
The conclusion of this topic is to have a overlook on the future of the Water Reservoir.
Terms used and their abbreviations:
* EL: Evaporation Loss.
* GV: Gross Volume.
* TL: Total Loss.
* VPM: Volume of Last Month.
* SL: Seepage Loss.
* V_Net: Net Volume.
* M: Months.
* C: Capacity.
* RF: Rain Fall.
* RI: River Inflow.
* VI: Volume Inflow.
Starting the coding through Matlab:
% program to simulate a Water Resevoir
clear all
close all
clc
VPM(1)=0
M-60
C=input('Enter the capacity of reservoir(in Million Cubic Feet):')
% Making a Header for the output data
Header1=('n Months Volume Inflow Volume of Gross Volume Seepage Loss Evap. Loss Total Loss Net Volume Demand Shortage Spill n')
Header2=('prev.Month')
% To print 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
RI(i)=r2*C*1.3
VI(i)=RF(i)+RI(i)
GV(i)=VI(i)+VPM(i-1)
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
else
VPM(i)=Difference(i)
Spill(i)=0
Shortage(i)=0
end
end
%End of the conditions
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 n',Spill(i))
%plotting the figures
figure(1)
plot(Months,Demand,'color','k','marker','o')
plot(Months,V_Net,'color','b','marker','s')
hold on
xlabel('Months')
ylabel('Water Quantity')
title('Variation in Denamn and Net volume of Reservoir')
legend('Net Volume','Demand')
figure(2)
plot(Months,Spill,'color','b','marker','o')
plot(Months,Shortage,'color','r','marker','s')
hold on
xlabel('Months')
ylabel('water Quantity')
title('Variation in shortage and spill of reservoir')
legend('shortage','spill')
figure(3)
plot(Months,TL,'color','g','marker','o')
plot(Months,GV,'color','m','marker','s')
hold on
xlabel('Months')
ylabel('Water Quantity')
title('variation in gross volume and total loss of reservoir')
legend('Gross Volume','Total Loss)
end
% Program to simulate a Water Reservoir ends here.
Errors faced during programming:
Error 1: I wrote 'Headwr2' in line 13 instead of writing 'Header' and i corrected it.
Error 2: I just fogot to include 'r3=rand' in the program, this occured an error in the line 28. Then i went through the program and added it.
Error 3: Instead of putting '-' i programmed '_' and this was changed after the error displayed in the command window.
Error 4: In line 60 i programmed 'polt' for 'plot', this was then changed when the error appeared in the command window.
Explanation:
Step 1: First step is to clear is to include 'clear all,'close all' and 'clc' in the beginning of the program.
Step 2: Giving the Header output data.
Step 3: Printing the Header in the output.
Step 4: Giving proper inputs for Loop and the Conditions are given.
Step 5: Giving the inputs for plotting the figures.
Step 6: The inputs for plotting the figure1, figure2 and figure3 respectively are given seperately.
Step 7: For all the Plotting inputs the xlabel and the ylabel are given seperately.
Step 8: The title is given for each figure while giving the plotting inputs.
Step 9: When the plotting inputs are given for each figure seperately the legend is also given seperately for each figure.
Step 10: During programming we have used 'for' in the beginning and for every 'for' used an 'end' should be given in the programming to complete the program in a well manner.