Sunday, January 24, 2021

Python  Code for designing Doubly-reinforced Beam

# Step-1: Loads

import math
from PIL import Image, ImageDraw, ImageFont
while True:
D = input("Enter overall depth of beam in mm:")#Taking the input of overall depth
try:
val = int(D)#Checking whether its a integer or not
if val > 0:
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(D)#Checking whether its a float or not
if float(D) > 0:#Checking whether it is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
S = input("Enter span of beam in m:")#Taking the input of span
try:
val = int(S)#Checking whether it is a integer or not
if val > 0:#Checking whether it is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(S)#Checking whether it is float or not
if float(S) > 0:#Checking whether positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
B = input("Enter width of beam in mm:")#Asking for the value of width of the beam
try:
val = int(B)#Checking whether the number is integer or not
if val > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(B)#Checking whether the number is float or not
if float(B) > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
LL = input("Enter live load of beam in kN/m:")#Asking for the live load vlaue
try:
val = int(LL)#Checking the given number is integer or not
if val > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(LL)#Checking the given number is float or not
if float(LL) > 0:#Checking whether the given number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
fs = input("Enter the type of steel Fe:")#Asking for the grade of steel
try:
val = int(fs)#Checking whether the given number is integer or not
x = [250,415,500]
if val > 0:
if int(fs) in x:# Checking whether the entered number of steel exist or not
break;
else:
print('This is not a suitable number. Please enter a valid number')
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(fs)#Checking whether the given number is float or not
x = [250, 415, 500]
if float(fs) > 0:#Checking whether the float is positive or not
if int(fs) in x:#Checking whether the entered grade of steel exist or not
break;
else:
print('This is not a suitable number. Please enter a valid number')
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
fck = input("Enter the type of concrete M:")#Asking for grade of concrete
try:
val = int(fck)#Checking for integer
if val > 0:#Checking for positive
break;
else:
print("This is not a suitable number. Please enter a valid number")
break;
except ValueError:
try:
float(fck)#Checking for float
if float(fck) > 0:#Checking whether the float is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
self_weight = (25*float(B)*float(D))/1000000#Calculative self weight of the beam
print('Self weight of beam =',self_weight,'kN/m')
Total_load = float(LL) + self_weight#Calculating total load
print('Total load = ', Total_load,'kN/m')
Factored_load = 1.5*Total_load# Calculating factored load using factor of safety 1.5
print('Factored load =', 1.5*Total_load, 'kN/m')
#Step-2: Calculate design moment and design shear
Design_moment = (Factored_load/8)*(float(S)**2)#Calculating the design moment
print('Design Moment =', Design_moment,'kNm')
Design_shear = (Factored_load*float(S))/2#Calculating the design shear
print('Design Shear force =', Design_shear,'kN')
#Step-3: Calculate limiting MOR for singly reinforced beam section
print('Effective Cover of 50 mm')
#limiting moment of resistance
d = float(D) - 50
print('Effective depth of beam, d=', d)
if float(fs) == 415:
Mu_lim = 0.138*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
elif float(fs) == 250:
Mu_lim = 0.148*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
elif float(fs) == 500:
Mu_lim = 0.133*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
if Mu_lim > Design_moment:#Checking whether double reinforcement required or not
print('No need of doubly reinforced beam.')
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',40)#Entering the font size and type of text design
points = 100,300# entering the coordinate where the string need to be displayed
string = ' Warning!\n No need of doubly reinforced beam.'
draw.text(points, string,'red',font=font1)
image.show()


elif Mu_lim < Design_moment:#Checking whether double reinforcement required or not
print('There is a need of doubly reinforced beam.')
#Step 4: Calculate amount of compression reinforcement required,
DMu = Design_moment - Mu_lim
Xu_lim = {250:0.53, 415:0.48, 500:0.46}
fsc1 = (0.0035*(d*Xu_lim[float(fs)] - 50)*200000)/(d*Xu_lim[float(fs)])#Calculating the compressive force in the compression zone
fsc2 = 0.87*float(fs)
if fsc1 <= fsc2:#Checking for the limiting value
fsc = fsc1
elif fsc1 > fsc2:#Checking for the limiting value
fsc =fsc2
Asc = (DMu/(fsc*(d-50)))*1000000#calculating area of steel required in compression zone
print('Area of steel required in compression:',Asc,'mm2')
while True:
#asking for the bar diameter you want to give in compression zone
dia_pro_c = input("Enter the diameter of the bar you want to provide in compression in mm:")
try:
val = int(dia_pro_c)#Checking for integer
if val > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro_c)#checking for float
if float(dia_pro_c) > 0:#checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar_c = (3.1416/4)*(float(dia_pro_c)**2)#Calculating the area of steel to provide
N_bar_c = 2
while N_bar_c >1:
if N_bar_c*Ast_bar_c > Asc :#Checking whether the provided reinforcement is sufficient or not
M = N_bar_c
print('Required number of bars in compression is ',M)
break
else:
N_bar_c = N_bar_c +1


#Step:5 Calculate amount of tension reinforcement required
Ast2 = (fsc*Asc)/(0.87*float(fs))
Ast1 = (0.362*float(fck)*float(B)*d*Xu_lim[float(fs)])/(0.87*float(fs))
Ast = Ast1 + Ast2#calculating area of steel required in tension zone
print('Area of steel required in tension:',Ast,'mm2')
while True:
# asking for the bar diameter you want to give in tension zone
dia_pro = input("Enter the diameter of the bar you want to provide in tension:")
try:
val = int(dia_pro)#checking for integer
if val > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro)#checking for float
if float(dia_pro) > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar = (3.1416/4)*(float(dia_pro)**2)#calculating area of bar provided in tension
N_bar = 2
while N_bar >1:
if N_bar*Ast_bar > Ast :#comparing provided and required value
N = N_bar
print('Required number of bars in tension',N)
break
else:
N_bar = N_bar +1
#Step 6: Design of shear reinforcement
pt = (100*Ast)/(float(B)*d)#calculating percentage og bar provided
beta = (0.8*float(fck))/(6.89*pt)
beta1 = (math.sqrt(1+(5*beta))-1)/(6*beta)
tc = 0.85*math.sqrt(0.8*float(fck))*beta1#calculating criting shear
print('Critical shear stress as per IS:456-2000:',tc,'N/mm2')
N_shear = (Design_shear*1000)/(float(B)*d)#calculating nominal shear
print('Nominal Shear Stress:',N_shear,'N/mm2')
if N_shear < tc:#comparing to get whether shear reinforcemnet is required or not
print('Shear reinforcement is not required.')
#displaying on the image
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',30)#Entering the font size and type of text design
points = 300,50# entering the coordinate where the string need to be displayed
string = B + 'mm'
draw.text(points, string,'black',font=font1)
string1 = D + 'mm'
point1 = 530,300# entering the coordinate where the string need to be displayed
draw.text(point1,string1,'black',font=font1)
point2 = 300,190# entering the coordinate where the string need to be displayed
string2 = str(M) +' '+ 'of' +' '+ dia_pro_c +'mm'
draw.text(point2,string2,'black',font=font1)
point3 = 300,420# entering the coordinate where the string need to be displayed
string3 = str(N) +' '+ 'of' + ' '+dia_pro + 'mm'
draw.text(point3,string3,'black',font=font1)
string4 = str('No bar required')
point4 = 620,240# entering the coordinate where the string need to be displayed
draw.text(point4,string4,'black',font=font1)
image.show()
elif N_shear > tc:
print('Shear reinforcement is required.')
Shear_req = (N_shear-tc)*float(B)*d
while True:
#asking for the diameter of the bar you want to provide for shear
dia_pro_shr = input("Enter the diameter of the bar you want to provide near the supports in mm:")
try:
val = int(dia_pro_shr)#checking for integer
if val > 0:#checking whther the given number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro_shr)#checking for float
if float(dia_pro_shr) > 0:#checking whether the entered float is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar_shr = (3.1416/4)*(float(dia_pro_shr)**2)#calculating the area of bar to be provided
Sp = (0.87*float(fs)*Ast_bar_shr*float(D))/(Shear_req)
Spac = min(300, 0.75*float(D))
N_shr = 1
while N_shr >0:
if N_shr*Sp > Spac:#comparing whether the provided area is sufficient or not
P = N_shr - 1
print('Number of bars required for shear', N_shr-1)
break
else:
N_shr = N_shr +1



#displaying on the image
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',30)#Entering the font size and type of text design
points = 300,50# entering the coordinate where the string need to be displayed
string = B + 'mm'
draw.text(points, string,'black',font=font1)
string1 = D + 'mm'
point1 = 530,300# entering the coordinate where the string need to be displayed
draw.text(point1,string1,'black',font=font1)
point2 = 300,190# entering the coordinate where the string need to be displayed
string2 = str(M) +' '+ 'of' +' '+ dia_pro_c +'mm'
draw.text(point2,string2,'black',font=font1)
point3 = 300,420# entering the coordinate where the string need to be displayed
string3 = str(N) +' '+ 'of' + ' '+dia_pro + 'mm'
draw.text(point3,string3,'black',font=font1)
string4 = str(P) +' '+ 'of' + ' '+dia_pro_shr + 'mm'
point4 = 620,240# entering the coordinate where the string need to be displayed
draw.text(point4,string4,'black',font=font1)
image.show()

Friday, May 29, 2020



FREE TRANSPORT FOR WOMEN AND WOMEN’S                            SAFETY



INTRODUCTION

We know that today public transport has become an essential service and it provides everyone with access to work , education and other fields of life. Now-a-days news of rape , molestation or misbehave with women are quite often in the media. Everyday, we heard news about crime against women in our country.  In the country like India , women are treated as goddess of the home. We worship many goddess like Laxmi , Sarswati and many more. But inspite of all these , there are some people who misbehave with women and do not give respect to them. Today, women do not feel safe while travelling and while other works. So, its not only the concern of the government to give them security but its also the responsibility of the public .

EXPERIENCE

One day I was travelling by local train in Patna . I found that the compartment was crowded and when I turned my head , I was surprised to see that a girl whose skirt had being lifted up and someone is touching her private parts. She could not swat the hand away nor could she raise an alarm as her voice drowned in the noise of the crowd. All she could do was cringe in shame and hope she made it out of the train of  the train as fast as possible. She was only thirteen years old. The incident was really disgusting and I remembered it for a long time , whenever I tried to forget that incident , it got more sharper. I blame on myself that I had done nothing. I hate crowded spaces and hated travelling by local train in Patna for years afterward.
Many women and girls experience sexual violence  in public spaces, including public transportation, every day, everywhere. A recent national  survey on sexual harassment and assault by Stop Street Harassment indicates that one-in-four women experienced sexual harassment on the regional transit systems. A survey was conducted by Reuter in about 16 major cities , it was found that the highest rates of harassment was faced by the women in Latin America , out of 10 , about 6 of them suffered from physical harassment in public areas.
In India , the recent Safecity Railway Audit report showed it is a problem here, too. The report says that when the interviews asked some questions to women on railway station in Mumbai , many of them refused to tell their incident and told that sexual harassment is part of their life. However ,those who share their incidents , on the basis of that about 54 % had suffered from sexual harassment . They said that touching and groping is quite common . 34% told that they feel unsafe while travelling in public transport.  Nearly all women(94%) said they did not report their experience to the police, and 83% were not aware of their rights under the law.

REASONS WHY GIRLS FEEL INSECURE

The major problem of insecurity felt by girls is that they think they are weaker than boys. That’s why they don’t react on their wrong action against them. Most of the family in India thought that boys are more superior than girls , this generated a mindset of inferiority among girls. So, it’s not only the fault of girl or female who is victimized but its also the fault of the society. Daily , a large number of women and girls suffering  from harassment and rapes, especially in the afternoon and after suffering they even do not reporting to the police because they have lack of faith in the police and also they think that it will lower down her reputation. I don’t think personally that making the transport free for women will create a hope of complete security among the women or girls. It will gives them confirmation that they are really weaker than boys or males. The free transport will definitely create a hope but that is not enough. The past cases also play a major in creating insecurity along girls and their family members.                                                                                                                                                                                                                                                                                      There is a dreadful event which can never be forgotten of Nirbhaya gang-rape and it was happened in the national capital of India on 16 December 2012 in Munirka,  a neighbourhood of South Delhi. She was only just 23 -year old physiotherapy intern. She was going home after watching movie with her male friend by bus at around 8 o’clock at night. Apart from other them, there were 6 other passengers including the driver. All the other 6 raped the girl and beat her friend and thrown him outside the bus roadside. The girl was brutally raped and her private parts were damaged . She was in a critical condition , so she was sent to a hospital in Singapore after 11 days of assault. But she died there after 2 days. When this news spread over the world , people condemned this , not only from India but also all over the world. People came out on the road and started protesting against the state and the central government , thousands of protesters clashed with security forces , since government was not able to provide safety and security to the women in New Delhi . It was not only in Delhi where people were protesting. Protest took place in every big and small cities throughout the country. According to the Indian law, press does not have right to publish a rape victim’s name, so they gave a name Nirbhaya which means ‘fearless’ , and her struggle and death become a remarkable symbol of women’s resistance to rape around the globe.                                                                                         The list of rape does ends here, there is a big list of crimes against women.  Recently, there is a movie released based on the real story of acid attack incident called “Chhapaak”. There is a girl name Laxmi Agarwal is a 28-year old an acid attack survivor who belongs to India. Laxmi , a girl of age 15 suffered from an acid attack when she refused to marry a 32 year old man.

INCIDENTS

There are many examples but I am giving a few ones. A 22-year old girl was sitting in a ladies compartment and travelling from Borivalli to Mulund in a Churchgate bound train . The ladies compartment was just beside the handicap compartment . Both the compartment was separated by railings. A man in the handicap compartment started commenting and abusing her . He not only abused her but also abused the girl sitting beside her. He started trying to reach the girl by putting his hands on the railings. He did not stop there only , he flashed at both the girls and started masturbation in public . When the train stopped at Kandivali station , he got down and tried to get into the ladies compartment but he couldn’t get success because all the other women sitting inside the ladies compartment started yelling at him. When he realized that he will not be able to enter into the compartment , he gave a rape threat and fled away. When the girl called the Railway Helpline number and explained all the incidents to the authority on the helpline , the authority instead of providing some help, he laughed at her and disconnect the call. After this , the girl posted the incidents in the social media , when this news got viral , then only police started their investigation.
In the second incident, a 14 year girl child was targeted. It was a Sunday morning , after compeletion of her tuition, she took a train from CSTM to reach her home in Kalyan. When she entered the ladies compartment , she found that the compartment was empty and hence taking advantage of this situation , a man entered into the compartment just before when the train was about to leave the station.
When the man entered the compartment , the girl told him that it is a ladies compartment and you should leave but the man didn’t listen anything and started moving towards her silently. She tried to pull the chain and stop the train but when she realized that she failed to pull the chain, she jumped out of the train because she scared of being raped or molested by that man. The girl got fractures in her legs and severe head injuries when people found her on the track. After that , she was hospitalized.
There are many incidents like harassment and assault of women in buses, auto rickshaws, cabs, etc are taking place daily . And in spite of the “security measures” taken by the government, there is no significant decline in the number of cases registered by women against assault or harassment in public places. Only reservation of seats in buses and making ladies compartments in local trains or installation of CCTV cameras is not enough. There is a need of vigilance on part of the Police Department and related authorities. In the both of the above cases that I had discussed , the victims may be suffered less if the police and the related authorities will be vigilant and active to handle these anti-social elements.

ROLE OF FREE TRANSPORT IN REDUCING CRIMES AGAINST WOMENS

We know that women would be less likely to participate in the labour force when perceived threat of crime against women is high and the deterrent effect is likely to be stronger in traditional societies. In 2006, a household survey conducted in Delhi which identified that lack of safety is the major cause of non-participation of women in workforce. So, for more involvement of women in workforce , it is necessary to provide them a safe public transport and give them freedom of movement and a safe environment for movement.
Free transport is a step to provide women a safe and priceless movement so that they can also participate in the workforce. Free transport also help those women those who are poor and can’t afford private transport. Free transport are also having guard to secure their safety while travelling.

GOVERNMENT INITIATIVE FOR WOMEN SAFETY IN TRANSPORT

· The government should ensure that no one use black films on public transport vehicles, as ordered by the court.
· Its necessary to verify identities of drivers and other persons working in public transport vehicles so that for any un-convenience , they can be asked .
· The police/security should be present on roads to handle any assault or misbehave with women.
· The information about the drivers and the other personnel should be displayed in the bus along with the CCTV camera and GPS system so that if the bus get deviated from its route , it can be traced.
· The government should provide regular patrolling of buses and other public transports .

 THE ROLE OF DRIVERS AND CONDUCTORS FOR WOMEN SAFETY

· The  conductor should make sure that no man is sitting on the reserved seats for women .
· The conductor should make sure that no men is standing near the researved seats.
· The conductors should not incline while collecting fare from reserved seats.
·The drivers and the conductors have the responsibility to intervene and stop any kind of misbehaviour done with the women passengers.
· The drivers and conductors should not hesitate to call the police or any related authorities if it necessary.

HOW CAN WE PREPARE GIRLS FROM CHILDHOOD TO HANDLE SUCH INCIDENTS

If we don’t want to hear such type of news, its necessary to prepare and trained  the girls from childhood only. The girls should be trained about the self-defence . Women should to trained how to tackle such type of problem. A strict rule be made to punish those crazy people who harass and assault women. There is a not to treat both boys and girls equal so that it does not create a sense inferiority and weakness among the girls.

Saturday, April 25, 2020

ENVIRONMENT AND BIOLOGY: THE VISION OF SUSTAINABLE FUTURE


The environment is all that envelopes the earth, the things around us. What we see, feel, breathe, eat constitutes the environment. The trees, the air, the food, the rivers, the roads, the greenery, the desserts, the deforested patches of ground, all of them come within what we call environment.  It is considered that earth is the only planet in the universe having required environment for the existence. Without environment we can’t guess our life. So, the study of biology is become the most important part of our life because it helps us to save endangered species, preserve ecosystem , cure diseases and save our planet. The environment supports our lives and the lives of the other species. And it is a complete cycle that enables living possible on the earth. The natural phenomena surround the survival of species, there’s a need for understanding the environment we are all relying on. The food chain, the process of photosynthesis, etc are the key processes behind the survival of plants and similarly, plants are the reasons behind our survival. As human beings are considered as the most intelligent creature made by the nature on the earth, they have lots of eagerness to know things in the universe which leads them towards the technological advancement. Then these remarkable growth of technological  progress and advancement  has also the  negative impact on the ecological state of our planet. It is  the human species that is reliable, responsible for causing the major pollution, contamination, and harm to the environment. The exploitative ways of using the resources have caused a depletion in the availability of the resources-the absolute example of the same is existing and going to be the major water crisis. 
The smoke from factories, vehicles, automobiles, etc become the major reason behind air pollution. Similarly, ailments like noise pollution, water pollution, global warming, ozone depletion, water spills, etc have become very crucial now. Day by day many natural resources and fossils, fuels , wood products, animals and plants are getting reduced. Then it’s our responsibility to  reduce the use of these resources and save for the future generation.
Sustainability creates and maintains the conditions under which humans and nature can exist in productive harmony, that permit fulfilling the social, economic and other requirements of present and future generations. Environmental sustainability involves making decisions and taking action that are in the interests of protecting the natural world, with particular emphasis on preserving the capability of the environment to support human life. Sustainable development is the need of the present time not only for the survival of mankind but also for its future protection. Unlike the other great revolutions in human history the Green Revolution and the Industrial Revolution the ‘sustainable revolution’ will have to take place rapidly, consciously and on many different levels and in many different spheres, simulta­neously. According to  the U.S.Environmental Protection Agency, any energy we conserve will conserve these non-renewable natural resources, which include oil, coal and natural gas. It is the responsibility of each and every individual living on the earth worldwide. Everyone should come forth and join the campaign for the environment safety.   Because  environment also affects us physically ,mentally and even spiritually. As we know that there are various cycles which happen regularly between environment and living things to maintain the nature’s balance. However, by any means if such cycles gets disturbed which ultimately affects the human lives. As we know that our environment helps to grow, develop and flourish on the earth for thousands of years. As day is passing some natural  resources are getting less available in the environment then it becomes the matter of serious debate .We can improve these resources by growing  awareness that doing so can bring economic and employment benefits as well as environment improvement. The Indian Government has also stated its Sustainable Development program that provide opportunities for change.
As a civil engineer, we can help plan dams and levees to regulate water flow through the area. We even coordinate the placement and the design of landfills and quarries to minimize environmental impact on surrounding homes and businesses. Transportation civil engineers help us all move around our communities and our country. Recycling helps the environment because it saves space in landfill sites, and it can reduce pollution substantially, along with innumerable other benefits. We also know that recycling saves energy and raw materials.
In such busy, crowded and advanced life we must take care of such types of small bad habits on daily basis. It is true that only a small effort by the end of everyone can bring a major positive change towards our declining environment. We should not use the use the natural resources in wrong ways for just our selfishness and fulfil our destructive wishes. We should grow and develop science and technologies for the betterment of our lives but always be sure that it would not ruin our environment in future in anyways. We should be sure that new technologies would never disturb the ecological balance.






Tuesday, April 14, 2020

MATLAB code to determine the type of flow for different cross section



  • Firstly, the  code is asking  the user to give whether the cross-section of the channel is rectangular, triangular or trapezoidal. You need to give the instruction as defined in the code, and asking for the requirements inputs.
%asking for section information
section = input('Enter Tr for trapezoidal T for triangle and R for rectangle:','s');
discharge = input('Enter the discharge of water:');
n= input('Enter the value of coefficient of mannings:');
if section=='Tr'
    %following are the required data for computation of the flow for
    %trapezoidal section
    m=input('Enter the slope of trapezoidal section:');
    b=input("Enter the bed width of the trapezoidal section:");
    s=input('Enter the slope of the bed:');
    y=input('Enter the depth of flow:');
    tr(m,s,b,y,discharge,n)
elseif section=="T"
    %following are the required data for computation of the flow for
    %triangular section
    m=input("Enter the slope of the triangular section:");
    s=input("Enter the slope of the bed: ");
    flow_depth=input('Enter the depth of flow:');
    t(m,s,flow_depth,discharge,n)
elseif section=="R"
    %following are the required data for computation of the flow for the
    %rectangular section
    b=input('Enter the breadth of the channel:');
    y=input('Enter the depth of the flow:');
    s=input('Enter the slope of the bed:');
    %distance_at_x=input('Enter the distance at which you want the depth of flow')
    %rkm(n,discharge,b,y,s)
    r(b,s,y,discharge,n)
end
  • The calculation of normal depth , critical depth for rectangular channel.
  • Then calling the function spcase and np for comparison.
                                                                 
%calculation for rectangular section
function rectangle = r(b,s,y,discharge,n)
    area=b*y;
    wetted_perimeter = b+2*y;
    hydraulic_radius = area/wetted_perimeter;
    discharge_permeter = discharge/b;
    critical_depth = ((discharge_permeter)^2/9.81)^(1/3)
    if s <0
        spcase(s,critical_depth,y)
    elseif s==0
        spcase(s,critical_depth,y)
    elseif s>0   
        p = round((discharge*n/(b*sqrt(s)))^3,9);
        np(p,b,s,y,critical_depth)
    end
        %Vineet Kumar
        %IIT Jammu
        %Civil Department
    function normal_depth = np(p,b,s,y,critical_depth)
         normal_depth = roots([b*b 0 0 -4*p -4*b*p -p*b*b]);
         integer_normal_depth = normal_depth(imag(normal_depth)==0)
         z=length(integer_normal_depth)
         for i=1:z
             if integer_normal_depth(i) > 0
                 real_normal_depth = integer_normal_depth(i)
             end
         end 
        cm(real_normal_depth,y,critical_depth)
    end
end

  • The calculation of normal depth , critical depth for trapezoidal channel.
  • Then calling the function spcase and np for comparison.
%calculation for trapezoidal section
function trapezoidal = tr(m,s,b,y,discharge,n)
    area = b*y+m*y*y;
    wetted_perimeter = b+2*y*sqrt(m*m+1);
    hydraulic_radius = area/wetted_perimeter;
    velocity_of_flow = discharge/area;
    %here e is assigned as slope divided by breadth to make the equation of
    %equation for critical depth simpler
    e = m/b;
    % here h is nothing but the velocity head
    h = (velocity_of_flow)^2/(2*9.81);
    %calculating critical depth
    real_critical_depth = roots([e 1-4*h*e -2*h]);
    %real_critical_depth = depth(img(depth)==0)
    %eliminating the imaginary roots and the negative roots because depth
    %can't be negative or imaginary
    z = length(real_critical_depth);
    for i = 1:z
        if real_critical_depth(i) > 0
            critical_depth = real_critical_depth(i)
        end
    end
    np(discharge,n,s,b,m,critical_depth)
    function nr_depth = np(discharge,n,s,b,m,critical_depth)
        p = (discharge*n/sqrt(s))^3;
        c=sqrt(m*m+1);
        %finding the roots for the normal depth
        normal_depth = roots([m^5 5*b*m^4 10*(b^2)*(m^3) 10*(b^3)*(m^2) 5*m*b^4 b^5 0 0 -4*p*c^2 -4*c*b*p -p*b^2]);
        integer_roots = normal_depth(imag(normal_depth)==0);
        z = length(integer_roots);
        for i = 1:z
            if integer_roots(i)>0
                real_normal_depth = integer_roots(i)
            end
        end
        cm(real_normal_depth,y,critical_depth)
    end
end

  • The calculation of normal depth , critical depth for triangular channel.
  • Then calling the function spcase and np for comparison.
%calculation for triangular section
function triangular = t(m,s,flow_depth,discharge,n)
    y=flow_depth;
    area = m*y*y;
    wetted_perimeter = 2*y*sqrt(m*m+1);
    hydraulic_radius = area/wetted_perimeter;
    critical_depth = ((2*discharge^2)/(9.81*m^2))^(1/5)
    p =(discharge*n/sqrt(s))^3;
    %calculating normal depth
    real_normal_depth = (4*p*(m*m+1)/m^5)^(1/8)
    if s > 0
        cm(real_normal_depth,y,critical_depth)    
    elseif s < 0
        spcase(s,critical_depth,y)
    elseif s==0
        spcase(s,critical_depth,y)
    end
end

  • Comparison function is defined for comparing actual depth, normal depth and critical depth.
  • With the help of comparison, it will determine whether the flow is M1 ,M2, M3, S1,S2,S3,C1,C3,H2,H3,A2 and A3.
%comparing the flow depth, normal depth and the critical depth to determine
%the type of flow
function comparison = cm(real_normal_depth,y,critical_depth)
    if real_normal_depth > critical_depth
        disp('The flow is mild')
        if real_normal_depth > y > critical_depth
            disp('M2')
        elseif real_normal_depth < y
            disp('M1')
        elseif y < critical_depth
            disp('M3')
        end
    elseif critical_depth > real_normal_depth
        disp('The flow is steep')
        if y > critical_depth
            disp('S1')
        elseif critical_depth > y > real_normal_depth
            disp('S2')
        elseif real_normal_depth > y
            disp('S3')
        end
    elseif real_normal_depth == critical_depth
        disp('The flow is critical')
        if y > critical_depth
            disp('C1')
        elseif y < critical_depth
            disp('C3')
        end
    end
end
function h_and_adv = spcase(s,critical_depth,y)
    if s==0
        disp('The flow is horizontal')
        if y > critical_depth
            disp('H2')
        elseif y < critical_depth
            disp('H3')
        end
    elseif s < 0
        disp('The flow is adverse')
        if y > critical_depth
            disp('A2')
        elseif y < critical_depth
            disp('A3')
        end
    end
end