{
"cells": [
 {
		   "cell_type": "markdown",
	   "metadata": {},
	   "source": [
       "# Chapter 4: Flow Of Fluids"
	   ]
	},
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.10: Temperature_rise.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.10 page number 139\n\n')\n",
"\n",
"//to find the temperature increase\n",
"\n",
"Q=0.001*10^5   //in J/s\n",
"w=0.001*1000   //in kg/s\n",
"density=1000   //in kg/m3\n",
"cp=4.19*10^3   //in J/kg K\n",
"\n",
"delta_T=Q/(w*cp);\n",
"printf('Temperature increase = %f degree celcius',delta_T)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.11: Bernoulli_equation.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.11 page number 142\n\n')\n",
"\n",
"//to find the pressure\n",
"\n",
"u1=0;   //in m/s\n",
"ws=0;\n",
"P1=0.7*10^5    //in Pa\n",
"P3=0\n",
"density=1000   //in kg/m3\n",
"\n",
"u3=((2*(P1-P3))/density)^0.5;\n",
"printf('u3 = %f m/s',u3)\n",
"\n",
"ratio_area=0.5;\n",
"u2=u3/ratio_area;\n",
"printf('\n\nu2 = %f m/s',u2)\n",
"\n",
"//applying bernoulli's equation\n",
"P2=1.7*10^5-((density*u2^2)/2)\n",
"printf('\n\nP2 = %f Pa',P2)\n",
"printf('\nthis flow is physically unreal')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.12: Power_requirements.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.12 page number 143\n\n')\n",
"\n",
"//to find the power requirements\n",
"\n",
"Q=3800/(24*3600)    //in m3/s\n",
"d=0.202    //in m\n",
"\n",
"u=Q/((3.14/4)*d^2);    //in m/s\n",
"delta_P=5.3*10^6    //in Pa\n",
"density=897    //in kg/m3\n",
"F=delta_P/density;    //in J/kg\n",
"ws=9.8*30+F;\n",
"mass_flow_rate= Q*density;\n",
"power=(ws*mass_flow_rate)/0.6;\n",
"\n",
"printf('power required = %f kW',power/1000)\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.13: Hagen_Poiseulle_equation.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.13 page number 146\n\n')\n",
"\n",
"//to find the tube length\n",
"density=1000    //in kg/m3\n",
"viscosity=1*10^-3   //in Pa s\n",
"P=100*1000    //in Pa\n",
"\n",
"vdP=P/density;\n",
"\n",
"Q=2.5*10^-3/(24*3600)\n",
"A=3.14*(0.0005)^2/4;\n",
"u=Q/A;\n",
"printf('u = %f m/s',u)\n",
"\n",
"Re=density*u*0.0005/viscosity;\n",
"printf('\n\nRe = %f',Re)\n",
"\n",
"//F=18.86*L\n",
"L=(-u^2+vdP)/18.86;\n",
"printf('\n\nL = %f m',L)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.14: Pressure_Head_calculatio.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.14 page number 151\n\n')\n",
"\n",
"//to find the discharge pressure\n",
"d=0.025     //in m\n",
"u=3        //in m/s\n",
"density=894   //in kg/m3\n",
"viscosity=6.2*10^4     //in Pa-s\n",
"\n",
"Re=(u*d*density)/viscosity;\n",
"f=0.0045;\n",
"L=50;\n",
"\n",
"delta_P=2*f*density*u^2*(L/d)\n",
"printf('frictional head loss = %f kPa',delta_P/1000)\n",
"\n",
"required_P=25*density*9.8;\n",
"total_head=delta_P+required_P;\n",
"printf('\n\ntotal pressure head = %f bar',total_head/10^5)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15: Level_difference_calculation.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.15 page number 152\n\n')\n",
"\n",
"//to find the level difference\n",
"\n",
"Q=0.8*10^-3;   //in m3/s\n",
"d=0.026    //in m\n",
"A=(3.14*(d^2))/4   //in m2\n",
"\n",
"u=Q/A;    //in m/s\n",
"density=800    //in kg/m3\n",
"viscosity=0.0005   //in Pa-s\n",
"\n",
"Re=(u*density*d)/viscosity;\n",
"f=0.079*(Re)^-0.25;\n",
"L=60\n",
"h_f=2*f*((u^2)/9.8)*(L/d);\n",
"\n",
"printf('level difference = %f m',h_f)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.16: Energy_cost_calculation.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.16 page number 153\n\n')\n",
"\n",
"//to find the engery cost\n",
"delta_z=50;    //in m\n",
"L=290.36    //in m\n",
"d=0.18    //in m\n",
"Q=0.05    //in m3/s\n",
"\n",
"A=(3.14*d^2)/4;    //in m2\n",
"u=Q/A;    //in m/s\n",
"density=1180;   //in kg/m3\n",
"viscosity=0.0012   //in Pa-s\n",
"Re=u*density*d/viscosity;\n",
"\n",
"f=0.004;\n",
"sigma_F=2*f*u^2*L/d;\n",
"ws=((9.8*50)+sigma_F)/0.6;\n",
"mass_flow_rate=Q*density;    //in Kg/s\n",
"power=mass_flow_rate*ws/1000;   //in KW\n",
"energy_cost=power*24*0.8;\n",
"\n",
"printf('Energy cost = Rs %f',energy_cost)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.17: Pressure_loss.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.17 page number 154\n\n')\n",
"\n",
"//to find the pressure loss\n",
"density=998   //in kg/m3\n",
"viscosity=0.0008  //in Pa-s\n",
"d=0.03   //in m\n",
"u=1.2   //in m/s\n",
"\n",
"Re=density*d*u/viscosity;\n",
"\n",
"f=0.0088;\n",
"D=1   //in m\n",
"N=10\n",
"L=3.14*D*N;\n",
"delta_P=(2*f*u^2*L)/d;   //in Pa\n",
"delta_P_coil=delta_P*(1+(3.54*(d/D)));\n",
"\n",
"printf('frictional pressure drop = %f kPa',delta_P_coil)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.18: Pressure_gradient.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.18 page number 154\n\n')\n",
"\n",
"//to find pressure drop per unit length\n",
"\n",
"b=0.050    //in m\n",
"a=0.025    //in m\n",
"d_eq=b-a  //in m\n",
"density=1000  //in kg/m3\n",
"u=3    //in m/s\n",
"viscosity = 0.001\n",
"\n",
"Re=d_eq*u*density/viscosity;\n",
"\n",
"e=40*10^6   //in m\n",
"f=0.0062;\n",
"P_perunit_length=2*f*density*u^2/d_eq;   //in Pa/m\n",
"\n",
"printf('pressure per unit length = %f Pa/m',P_perunit_length)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.19: Flow_rate.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.19 page number 155\n\n')\n",
"\n",
"//to find the flow rate\n",
"d = 0.3   //in m\n",
"u = 17.63   //avg velocity in m/s\n",
"\n",
"q = (3.14/4)*d^2*u;\n",
"printf('volumetric flow rate = %f cubic meter per second',q)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.1: Water_compressibility.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.1 page number 125\n\n')\n",
"\n",
"//to find water compressibility\n",
"delta_p=70;   //in bar\n",
"Et=20680     //in bar\n",
"compressibility = delta_p/Et;\n",
"printf('compressibilty of water = %f',compressibility)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.20: Pipe_dimensions.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.20 page number 156\n\n')\n",
"\n",
"//to find the size of pipe required\n",
"d = 0.15   //in m\n",
"u = (0.0191/0.15^2);   //in m/s\n",
"\n",
"q = (3.14/4)*d^2*u;\n",
"printf('volumetric flow rate = %f cubic meter/s',q)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.21: Pressure_gradient.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.21 page number 160\n\n')\n",
"\n",
"//to find the pressure gradient\n",
"\n",
"Q=0.0003    //in m3/s\n",
"d=0.05    //in m\n",
"A=(3.14*d^2)/4;\n",
"\n",
"u=Q/A;\n",
"\n",
"density=1000;   //in kg/m3\n",
"viscosity=0.001;  //in Pa-s\n",
"e=0.3;\n",
"dp=0.00125;   //particle diameter in m\n",
"\n",
"Re=(dp*u*density)/(viscosity*(1-e));\n",
"fm=(150/Re)+1.75;\n",
"L=0.5   //in m\n",
"delta_Pf=fm*((density*L*u^2)/dp)*((1-e)/e^3);   //in Pa\n",
"\n",
"//applying bernoulli's equation, we get\n",
"delta_P=delta_Pf-(density*9.8*L);\n",
"pressure_gradient=delta_P/(L*1000);   //in kPa/m\n",
"printf('required pressure gradient = %f kPa/m of packed height',pressure_gradient)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.22: Minimum_fluidization_velocity.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.22 page number 163\n\n')\n",
"\n",
"//to find minimum fluidization velocity\n",
"\n",
"d=120*10^-6    //in m\n",
"density=2500   //particle density in kg/m3\n",
"e_min=0.45;\n",
"density_water=1000   //in kg/m3\n",
"viscosity=0.9*10^-3;   //in Pa-s\n",
"umf=(d^2*(density-density_water)*9.8*e_min^3)/(150*viscosity*(1-e_min));\n",
"printf('minimum fludization velocity = %f m/s',umf)\n",
"\n",
"Re_mf=(d*umf*density_water)/(viscosity*(1-e_min));\n",
"\n",
"\n",
"//given that uo/umf=10\n",
"function[f] = F(e)\n",
"    f = e^3+1.657*e-1.675;\n",
"endfunction\n",
"\n",
"//initial guess\n",
"x = 10;\n",
"e = fsolve(x,F);\n",
"\n",
"printf('\n\ne = %f',e)\n",
"length_ratio=(1-e_min)/(1-e);\n",
"printf('\n\nratio of heights = %f',length_ratio)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.23: Pumping_of_fluids.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.23 page number 167\n\n')\n",
"\n",
"//to find the power requirements\n",
"\n",
"P=9807   //in Pa\n",
"density=1000   //in kg/m3\n",
"Q=250/(60*density)\n",
"head=25   //in m\n",
"\n",
"w= head*Q*P;     //in kW\n",
"power_delivered=w/0.65;\n",
"power_taken=power_delivered/0.9;\n",
"\n",
"printf('power_delivered = %f kW',power_delivered/1000)\n",
"printf('\n\npower taken by motor = %f kW',power_taken/1000)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.2: Isothermal_Compressibility.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.2 page number 125\n\n')\n",
"\n",
"disp('this is a theoritical problem,book shall be referred for solution')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.3: Viscosity.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.3 page number 128\n\n')\n",
"\n",
"//to find the viscosity of oil\n",
"\n",
"F=0.5*9.8;   //in N\n",
"A=3.14*0.05*0.15;   //in m2\n",
"shear_stress=F/A;   //in Pa\n",
"printf('shear_stress = %f Pa',shear_stress)\n",
"\n",
"velocity_distribution =0.1/(0.05*10^-3);\n",
"viscosity=shear_stress/velocity_distribution;\n",
"printf('\n\nviscosity = %f Pa-s',viscosity) "
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.4: Streamline_flow.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.4 page number 130\n\n')\n",
"printf('this is a theoritical problem,book shall be referred for solution')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.5: Frictional_losses.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.5 page number 133\n\n')\n",
"\n",
"//to find variation of losses with velocity\n",
"loss_ratio=3.6;     //delta_P2/delta_P1=3.6\n",
"velocity_ratio=2;   //u2/u1=2\n",
"n=log2(loss_ratio);  //delta_P2/delta_P1=(u2/u1)^n\n",
"printf('power constant = %f flow is turbulent',n)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.6: Velocity_profile.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.6 page number 133\n\n')\n",
"printf('this is a theoritical problem,book shall be referred for solution')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.7: Velocity_profile.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.7 page number 134')\n",
"disp('this is a theoritical problem,book shall be referred for solution')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.8: Boundary_layer.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.8 page number 137\n\n')\n",
"\n",
"//to find the boundary layer properties\n",
"\n",
"disp('part 1')\n",
"x=0.05   //in m\n",
"density=1000   //in kg/m3\n",
"viscosity=1*10^-3    //in Pa-s\n",
"u=1   //in m/s\n",
"Re=(density*u*x)/viscosity;\n",
"\n",
"printf('Reynolds Number = %f',Re)\n",
"\n",
"thickness=4.65*x*(Re)^-0.5;\n",
"printf('\nboundary layer thickness = %f m\n',thickness)\n",
"\n",
"disp('part 2')\n",
"Re_x=3.2*10^5;\n",
"x_cr=(Re_x*viscosity)/(density*u);\n",
"printf('transition takes place at x = %f m\n',x_cr) \n",
"\n",
"disp('part 3')\n",
"x=0.5   //in m\n",
"Re=(density*u*x)/viscosity;\n",
"thickness=0.367*x*(Re)^-0.2;\n",
"printf('boundary layer thickness= %f m',thickness)\n",
"\n",
"t_sublayer=71.5*x*(Re)^-0.9;\n",
"printf('\nsub layer thickness= %f m',t_sublayer)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.9: Pipe_flow.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"clc\n",
"clear \n",
"printf('example 4.9 page number 138\n\n')\n",
"\n",
"//to find the flow properties\n",
"d1=0.05   //in m\n",
"A1=(3.14*d1^2)/4;\n",
"density_1=2.1   //in kg/m3\n",
"u1=15     //in m/s\n",
"P1=1.8;   //in bar\n",
"P2=1.3;   //in bar\n",
"\n",
"w=density_1*A1*u1;\n",
"density_2=density_1*(P2/P1);\n",
"printf('density at section 2 = %f kg/cubic meter',density_2)\n",
"\n",
"u2=u1*(density_1/density_2)*(0.05/0.075)^2;\n",
"printf('\n\nvelocity at section 2 = %f m/s',u2)"
   ]
   }
],
"metadata": {
		  "kernelspec": {
		   "display_name": "Scilab",
		   "language": "scilab",
		   "name": "scilab"
		  },
		  "language_info": {
		   "file_extension": ".sce",
		   "help_links": [
			{
			 "text": "MetaKernel Magics",
			 "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
			}
		   ],
		   "mimetype": "text/x-octave",
		   "name": "scilab",
		   "version": "0.7.1"
		  }
		 },
		 "nbformat": 4,
		 "nbformat_minor": 0
}