summaryrefslogtreecommitdiff
path: root/Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb')
-rw-r--r--Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb1365
1 files changed, 1365 insertions, 0 deletions
diff --git a/Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb b/Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb
new file mode 100644
index 0000000..49e1cef
--- /dev/null
+++ b/Basic_Engineering_Thermodynamics_by_R_Joel/5-Gases_and_single_phase_systems.ipynb
@@ -0,0 +1,1365 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 5: Gases and single phase systems"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.10: temperature.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.10');\n",
+"\n",
+"// aim : To determine\n",
+"// the new temperature of the gas\n",
+"\n",
+"// Given values\n",
+"V1 = .015;// original volume,[m^3]\n",
+"T1 = 273+285;// original temperature,[K]\n",
+"V2 = .09;// final volume,[m^3]\n",
+"\n",
+"// solution \n",
+"// Given gas is following the law,P*V^1.35=constant\n",
+"// so process is polytropic with\n",
+"n = 1.35; // polytropic index\n",
+"\n",
+"// hence\n",
+"T2 = T1*(V1/V2)^(n-1);// final temperature, [K]\n",
+"\n",
+"t2 = T2-273;// [C]\n",
+"\n",
+"mprintf('\n The new temperature of the gas is = %f C \n',t2);\n",
+"\n",
+"// there is minor error in book's answer\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.11: volume_pressure_and_temperature.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.11');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a) original and final volume of the gas\n",
+"// (b) final pressure of the gas\n",
+"// (c) final temperature of the gas\n",
+"\n",
+"// Given values\n",
+"m = .675;// mass of the gas,[kg]\n",
+"P1 = 1.4;// original pressure,[MN/m^2]\n",
+"T1 = 273+280;// original temperature,[K]\n",
+"R = .287;//gas constant,[kJ/kg K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// using characteristic equation, P1*V1=m*R*T1\n",
+"V1 = m*R*T1*10^-3/P1;// [m^3]\n",
+"// also Given \n",
+"V2 = 4*V1;// [m^3]\n",
+"mprintf('\n (a) The original volume of the gas is = %f m^3\n',V1);\n",
+"mprintf('\n and The final volume of the gas is = %f m^3\n',V2);\n",
+"\n",
+"// (b)\n",
+"// Given that gas is following the law P*V^1.3=constant\n",
+"// hence process is polytropic with \n",
+"n = 1.3; // polytropic index\n",
+"P2 = P1*(V1/V2)^n;// formula for polytropic process,[MN/m^2]\n",
+"mprintf('\n (b) The final pressure of the gas is = %f kN/m^2\n',P2*10^3);\n",
+"\n",
+"// (c)\n",
+"// since mass is constant so,using P*V/T=constant\n",
+"// hence\n",
+"T2 = P2*V2*T1/(P1*V1);// [K]\n",
+"t2 = T2-273;// [C]\n",
+"mprintf('\n (c) The final temperature of the gas is = %f C\n',t2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.12: change_of_internal_energy_work_done_and_heat_transfer.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.12');\n",
+"\n",
+"// aim : T0 determine \n",
+"// (a) change in internal nergy of the air\n",
+"// (b) work done\n",
+"// (c) heat transfer\n",
+"\n",
+"// Given values\n",
+"m = .25;// mass, [kg]\n",
+"P1 = 140;// initial pressure, [kN/m^2]\n",
+"V1 = .15;// initial volume, [m^3]\n",
+"P2 = 1400;// final volume, [m^3]\n",
+"cp = 1.005;// [kJ/kg K]\n",
+"cv = .718;// [kJ/kg K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// assuming ideal gas\n",
+"R = cp-cv;// [kJ/kg K]\n",
+"// also, P1*V1=m*R*T1,hence\n",
+"T1 = P1*V1/(m*R);// [K]\n",
+"\n",
+"// given that process is polytropic with \n",
+"n = 1.25; // polytropic index\n",
+"T2 = T1*(P2/P1)^((n-1)/n);// [K]\n",
+"\n",
+"// Hence, change in internal energy is,\n",
+"del_U = m*cv*(T2-T1);// [kJ]\n",
+"mprintf('\n (a) The change in internal energy of the air is del_U = %f kJ',del_U);\n",
+"if(del_U>0)\n",
+" disp('since del_U>0, so it is gain of internal energy to the air')\n",
+"else\n",
+" disp('since del_U<0, so it is gain of internal energy to the surrounding')\n",
+"end\n",
+"\n",
+"// (b)\n",
+"W = m*R*(T1-T2)/(n-1);// formula of work done for polytropic process,[kJ]\n",
+"mprintf('\n (b) The work done is W = %f kJ',W);\n",
+"if(W>0)\n",
+" disp('since W>0, so the work is done by the air')\n",
+"else\n",
+" disp('since W<0, so the work is done on the air')\n",
+"end\n",
+"\n",
+"// (c)\n",
+"Q = del_U+W;// using 1st law of thermodynamics,[kJ]\n",
+"mprintf('\n (c) The heat transfer is Q = %f kJ',Q);\n",
+"if(Q>0)\n",
+" disp('since Q>0, so the heat is received by the air')\n",
+"else\n",
+" disp('since Q<0, so the heat is rejected by the air')\n",
+"end\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.13: volume_work_done_and_change_of_internal_energy.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.13');\n",
+"\n",
+"// aim : To determine the\n",
+"// final volume, work done and the change in internal energy\n",
+"\n",
+"// Given values\n",
+"P1 = 700;// initial pressure,[kN/m^2]\n",
+"V1 = .015;// initial volume, [m^3]\n",
+"P2 = 140;// final pressure, [kN/m^2]\n",
+"cp = 1.046;// [kJ/kg K]\n",
+"cv = .752; // [kJ/kg K]\n",
+"\n",
+"// solution\n",
+"\n",
+"Gamma = cp/cv;\n",
+"// for adiabatic expansion, P*V^gamma=constant, so\n",
+"V2 = V1*(P1/P2)^(1/Gamma);// final volume, [m^3]\n",
+"mprintf('\n The final volume of the gas is V2 = %f m^3\n',V2);\n",
+"\n",
+"// work done\n",
+"W = (P1*V1-P2*V2)/(Gamma-1);// [kJ]\n",
+"mprintf('\n The work done by the gas is = %f kJ\n',W);\n",
+"\n",
+"// for adiabatic process\n",
+"del_U = -W;// [kJ]\n",
+"mprintf('\n The change of internal energy is = %f kJ',del_U);\n",
+"if(del_U>0)\n",
+" disp('since del_U>0, so the the gain in internal energy of the gas ')\n",
+"else\n",
+" disp('since del_U<0, so this is a loss of internal energy from the gas')\n",
+"end\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.14: heat_transfer_change_of_internal_energy_and_mass.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.14');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a)heat transfer\n",
+"// (b)change of internal energy\n",
+"// (c)mass of gas\n",
+"\n",
+"// Given values\n",
+"V1 = .4;// initial volume, [m^3]\n",
+"P1 = 100;// initial pressure, [kN/m^2]\n",
+"T1 = 273+20;// temperature, [K]\n",
+"P2 = 450;// final pressure,[kN/m^2]\n",
+"cp = 1.0;// [kJ/kg K]\n",
+"Gamma = 1.4; // heat capacity ratio\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// for the isothermal compression,P*V=constant,so\n",
+"V2 = V1*P1/P2;// [m^3]\n",
+"W = P1*V1*log(P1/P2);// formula of workdone for isothermal process,[kJ]\n",
+"\n",
+"// for isothermal process, del_U=0;so\n",
+"Q = W;\n",
+"mprintf('\n (a) The heat transferred during compression is Q = %f kJ\n',Q);\n",
+"\n",
+"\n",
+"// (b)\n",
+"V3 = V1;\n",
+"// for adiabatic expansion\n",
+"// also\n",
+"\n",
+"P3 = P2*(V2/V3)^Gamma;// [kN/m^2]\n",
+"W = -(P3*V3-P2*V2)/(Gamma-1);// work done formula for adiabatic process,[kJ]\n",
+"// also, Q=0,so using Q=del_U+W\n",
+"del_U = -W;// [kJ]\n",
+"mprintf('\n (b) The change of the internal energy during the expansion is,del_U = %f kJ\n',del_U);\n",
+"\n",
+"// (c)\n",
+"// for ideal gas\n",
+"// cp-cv=R, and cp/cv=gamma, hence\n",
+"R = cp*(1-1/Gamma);// [kj/kg K]\n",
+"\n",
+"// now using ideal gas equation\n",
+"m = P1*V1/(R*T1);// mass of the gas,[kg]\n",
+"mprintf('\n (c) The mass of the gas is,m = %f kg\n',m);\n",
+"\n",
+"// There is calculation mistake in the book\n",
+"\n",
+"\n",
+"// End\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.15: heat_transfer_and_polytropic_heat_capacity.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.15');\n",
+"\n",
+"// aim : To determine \n",
+"// the heat transferred and polytropic specific heat capacity\n",
+"\n",
+"// Given values\n",
+"P1 = 1;// initial pressure, [MN/m^2]\n",
+"V1 = .003;// initial volume, [m^3]\n",
+"P2 = .1;// final pressure,[MN/m^2]\n",
+"cv = .718;// [kJ/kg*K]\n",
+"Gamma=1.4;// heat capacity ratio\n",
+"\n",
+"// solution\n",
+"// Given process is polytropic with\n",
+"n = 1.3;// polytropic index\n",
+"// hence\n",
+"V2 = V1*(P1/P2)^(1/n);// final volume,[m^3]\n",
+"W = (P1*V1-P2*V2)*10^3/(n-1);// work done,[kJ]\n",
+"// so\n",
+"Q = (Gamma-n)*W/(Gamma-1);// heat transferred,[kJ]\n",
+"\n",
+"mprintf('\n The heat received or rejected by the gas during this process is Q = %f kJ',Q);\n",
+"if(Q>0)\n",
+" disp('since Q>0, so heat is received by the gas')\n",
+"else\n",
+" disp('since Q<0, so heat is rejected by the gas')\n",
+"end\n",
+"\n",
+"// now\n",
+"cn = cv*(Gamma-n)/(n-1);// polytropic specific heat capacity,[kJ/kg K]\n",
+"mprintf('\n The polytropic specific heat capacity is cn = %f kJ/kg K\n',cn);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.16: pressures.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.16');\n",
+"\n",
+"// aim : To determine the \n",
+"// (a) initial partial pressure of the steam and air\n",
+"// (b) final partial pressure of the steam and air\n",
+"// (c) total pressure in the container after heating\n",
+"\n",
+"// Given values\n",
+"T1 = 273+39;// initial temperature,[K]\n",
+"P1 = 100;// pressure, [MN/m^2]\n",
+"T2 = 273+120.2;// final temperature,[K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// from the steam tables, the pressure of wet steam at 39 C is\n",
+"Pw1 = 7;// partial pressure of wet steam,[kN/m^2]\n",
+"// and by Dalton's law\n",
+"Pa1 = P1-Pw1;// initial pressure of air, [kN/m^2]\n",
+"\n",
+"mprintf('\n (a) The initial partial pressure of the steam is = %f kN/m^2',Pw1);\n",
+"mprintf('\n The initial partial pressure of the air is = %f kN/m^2\n',Pa1);\n",
+"\n",
+"// (b)\n",
+"// again from steam table, at 120.2 C the pressure of wet steam is\n",
+"Pw2 = 200;// [kN/m^2]\n",
+"\n",
+"// now since volume is constant so assuming air to be ideal gas so for air P/T=contant, hence\n",
+"Pa2 = Pa1*T2/T1 ;// [kN/m^2]\n",
+"\n",
+"mprintf(' \n(b) The final partial pressure of the steam is = %f kN/m^2',Pw2);\n",
+"mprintf('\n The final partial pressure of the air is = %f kN/m^2\n',Pa2);\n",
+"\n",
+"// (c)\n",
+"Pt = Pa2+Pw2;// using dalton's law, total pressure,[kN/m^2]\n",
+"mprintf('\n (c) The total pressure after heating is = %f kN/m^2\n',Pt);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.17: partial_pressure_and_mass.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.17');\n",
+"\n",
+"// aim : To determine \n",
+"// the partial pressure of the air and steam, and the mass of the air\n",
+"\n",
+"// Given values\n",
+"P1 = 660;// vaccum gauge pressure on condenser [mmHg]\n",
+"P = 765;// atmospheric pressure, [mmHg]\n",
+"x = .8;// dryness fraction \n",
+"T = 273+41.5;// temperature,[K]\n",
+"ms_dot = 1500;// condense rate of steam,[kg/h]\n",
+"R = .29;// [kJ/kg]\n",
+"\n",
+"// solution\n",
+"Pa = (P-P1)*.1334;// absolute pressure,[kN/m^2]\n",
+"// from steam table, at 41.5 C partial pressure of steam is\n",
+"Ps = 8;// [kN/m^2]\n",
+"// by dalton's law, partial pressure of air is\n",
+"Pg = Pa-Ps;// [kN/m^2]\n",
+"\n",
+"mprintf('\n The partial pressure of the air in the condenser is = %f kN/m^2\n',Pg);\n",
+"mprintf('\n The partial pressure of the steam in the condenser is = %f kN/m^2\n',Ps);\n",
+"\n",
+"// also\n",
+"vg = 18.1;// [m^3/kg]\n",
+"// so\n",
+"V = x*vg;// [m^3/kg]\n",
+"// The air associated with 1 kg of the steam will occupiy this same volume\n",
+"// for air, Pg*V=m*R*T,so\n",
+"m = Pg*V/(R*T);// [kg/kg steam]\n",
+"// hence\n",
+"ma = m*ms_dot;// [kg/h]\n",
+"\n",
+"mprintf('\n The mass of air which will associated with this steam is = %f kg\n',ma);\n",
+"\n",
+"// There is misprint in book\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.18: pressure_and_dryness_fraction.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.18');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a) final pressure\n",
+"// (b) final dryness fraction of the steam\n",
+"\n",
+"// Given values\n",
+"P1 = 130;// initial pressure, [kN/m^2]\n",
+"T1 = 273+75.9;// initial temperature, [K]\n",
+"x1 = .92;// initial dryness fraction\n",
+"T2 = 273+120.2;// final temperature, [K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// from steam table, at 75.9 C\n",
+"Pws = 40;// partial pressure of wet steam[kN/m^2]\n",
+"Pa = P1-Pws;// partial pressure of air, [kN/m^2]\n",
+"vg = 3.99// specific volume of the wet steam, [m^3/kg]\n",
+"// hence\n",
+"V1 = x1*vg;// [m^3/kg]\n",
+"V2 = V1/5;// [m^3/kg]\n",
+"// for air, mass is constant so, Pa*V1/T1=P2*V2/T2,also given ,V1/V2=5,so\n",
+"P2 = Pa*V1*T2/(V2*T1);// final pressure,[kN/m^2]\n",
+"\n",
+"// now for steam at 120.2 C\n",
+"Ps = 200;// final partial pressure of steam,[kN/m^2]\n",
+"// so by dalton's law total pressure in cylindert is\n",
+"Pt = P2+Ps;// [kN/m^2]\n",
+"mprintf('\n (a) The final pressure in the cylinder is = %f kN/m^2\n',Pt);\n",
+"\n",
+"// (b)\n",
+"// from steam table at 200 kN/m^2 \n",
+"vg = .885;// [m^3/kg]\n",
+"// hence\n",
+"x2 = V2/vg;// final dryness fraction of the steam\n",
+"mprintf('\n (b) The final dryness fraction of the steam is = %f\n ',x2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.19: adiabatic_index_and_change_of_internal_energy.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.19')\n",
+"\n",
+"// aim : To determine the \n",
+"// (a) Gamma,\n",
+"// (b) del_U\n",
+"\n",
+"// Given Values\n",
+"P1 = 1400;// [kN/m^2]\n",
+"P2 = 100;// [kN/m^2]\n",
+"P3 = 220;// [kN/m^2]\n",
+"T1 = 273+360;// [K]\n",
+"m = .23;// [kg]\n",
+"cp = 1.005;// [kJ/kg*K]\n",
+"\n",
+"// Solution\n",
+"T3 = T1;// since process 1-3 is isothermal\n",
+"\n",
+"// (a)\n",
+"// for process 1-3, P1*V1=P3*V3,so\n",
+"V3_by_V1 = P1/P3;\n",
+"// also process 1-2 is adiabatic,so P1*V1^(Gamma)=P2*V2^(Gamma),hence\n",
+"// and process process 2-3 is iso-choric so,V3=V2 and\n",
+"V2_by_V1 = V3_by_V1;\n",
+"// hence,\n",
+"Gamma = log(P1/P2)/log(P1/P3); // heat capacity ratio\n",
+"\n",
+"mprintf('\n (a) The value of adiabatic index Gamma is = %f\n',Gamma);\n",
+"\n",
+"// (b)\n",
+"cv = cp/Gamma;// [kJ/kg K]\n",
+"// for process 2-3,P3/T3=P2/T2,so\n",
+"T2 = P2*T3/P3;// [K]\n",
+"\n",
+"// now\n",
+"del_U = m*cv*(T2-T1);// [kJ]\n",
+"mprintf('\n (b) The change in internal energy during the adiabatic expansion is U2-U1 = %f kJ (This is loss of internal energy)\n',del_U);\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.1: pressure_exerted_and_difference_in_two_mercury_column_levels.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.1');\n",
+"\n",
+"// aim : To determine \n",
+"// new pressure exerted on the air and the difference in two mercury column level\n",
+"\n",
+"// Given values\n",
+"P1 = 765;// atmospheric pressure, [mmHg]\n",
+"V1 = 20000;// [mm^3]\n",
+"V2 = 17000;// [mm^3]\n",
+"\n",
+"// solution\n",
+"\n",
+"// using boyle's law P*V=constant\n",
+"// hence\n",
+"P2 = P1*V1/V2;// [mmHg]\n",
+"mprintf('\n The new pressure exerted on the air is = %f mmHg \n',P2);\n",
+"\n",
+"del_h = P2-P1;// difference in Height of mercury column level\n",
+"mprintf('\n The difference in the two mercury column level is = %f mm\n',del_h);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.20: mass_and_heat_transfer.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.20');\n",
+"\n",
+"// aim : To determine \n",
+"// the mass of oxygen and heat transferred\n",
+"\n",
+"// Given values\n",
+"V1 = 300;// [L]\n",
+"P1 = 3.1;// [MN/m^2]\n",
+"T1 = 273+18;// [K]\n",
+"P2 = 1.7;// [MN/m^2]\n",
+"T2 = 273+15;// [K]\n",
+"Gamma = 1.4; // heat capacity ratio\n",
+"// density condition\n",
+"P = .101325;// [MN/m^2]\n",
+"T = 273;// [K]\n",
+"V = 1;// [m^3]\n",
+"m = 1.429;// [kg]\n",
+"\n",
+"// hence\n",
+"R = P*V*10^3/(m*T);// [kJ/kg*K]\n",
+"// since volume is constant\n",
+"V2 = V1;// [L]\n",
+"// for the initial conditions in the cylinder,P1*V1=m1*R*T1\n",
+"m1 = P1*V1/(R*T1);// [kg]\n",
+"\n",
+"// after some of the gas is used\n",
+"m2 = P2*V2/(R*T2);// [kg]\n",
+"// The mass of oxygen remaining in cylinder is m2 kg,so\n",
+"// Mass of oxygen used is\n",
+"m_used = m1-m2;// [kg]\n",
+"mprintf('\n The mass of oxygen used = %f kg\n',m_used);\n",
+"\n",
+"// for non-flow process,Q=del_U+W\n",
+"// volume is constant so no external work is done so,Q=del_U\n",
+"cv = R/(Gamma-1);// [kJ/kg*K]\n",
+"\n",
+"// heat transfer is\n",
+"Q = m2*cv*(T1-T2);// (kJ)\n",
+"mprintf('\n The amount of heat transferred through the cylinder wall is = %f kJ\n',Q);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.21: work_done_change_of_internal_energy_and_heat_transfer.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.21');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a) work transferred during the compression\n",
+"// (b) change in internal energy\n",
+"// (c) heat transferred during the compression\n",
+"\n",
+"// Given values\n",
+"V1 = .1;// initial volume, [m^3]\n",
+"P1 = 120;// initial pressure, [kN/m^2]\n",
+"P2 = 1200; // final pressure, [kN/m^2]\n",
+"T1 = 273+25;// initial temperature, [K]\n",
+"cv = .72;// [kJ/kg*K]\n",
+"R = .285;// [kJ/kg*K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// given process is polytropic with\n",
+"n = 1.2; // polytropic index\n",
+"// hence\n",
+"V2 = V1*(P1/P2)^(1/n);// [m^3]\n",
+"W = (P1*V1-P2*V2)/(n-1);// workdone formula, [kJ]\n",
+"mprintf('\n (a) The work transferred during the compression is = %f kJ\n',W);\n",
+"\n",
+"// (b)\n",
+"// now mass is constant so,\n",
+"T2 = P2*V2*T1/(P1*V1);// [K]\n",
+"// using, P*V=m*R*T\n",
+"m = P1*V1/(R*T1);// [kg]\n",
+"\n",
+"// change in internal energy is\n",
+"del_U = m*cv*(T2-T1);// [kJ]\n",
+"mprintf('\n (b) The change in internal energy is = %f kJ\n',del_U);\n",
+"\n",
+"// (c)\n",
+"Q = del_U+W;// [kJ]\n",
+"mprintf('\n (c) The heat transferred during the compression is = %f kJ\n',Q);\n",
+"\n",
+"// End\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.22: pressure_and_specific_enthalpy.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.22');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a) new pressure of the air in the receiver\n",
+"// (b) specific enthalpy of air at 15 C\n",
+"\n",
+"// Given values\n",
+"V1 = .85;// [m^3]\n",
+"T1 = 15+273;// [K]\n",
+"P1 = 275;// pressure,[kN/m^2]\n",
+"m = 1.7;// [kg]\n",
+"cp = 1.005;// [kJ/kg*K]\n",
+"cv = .715;// [kJ/kg*K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"\n",
+"R = cp-cv;// [kJ/kg*K]\n",
+"// assuming m1 is original mass of the air, using P*V=m*R*T\n",
+"m1 = P1*V1/(R*T1);// [kg]\n",
+"m2 = m1+m;// [kg]\n",
+"// again using P*V=m*R*T\n",
+"// P2/P1=(m2*R*T2/V2)/(m1*R*T1/V1); and T1=T2,V1=V2,so\n",
+"P2 = P1*m2/m1;// [kN/m^2]\n",
+"mprintf('\n (a) The new pressure of the air in the receiver is = %f kN/m^2\n',P2);\n",
+"\n",
+"// (b)\n",
+"// for 1 kg of air, h2-h1=cp*(T1-T0)\n",
+"// and if 0 is chosen as the zero enthalpy, then\n",
+"h = cp*(T1-273);// [kJ/kg]\n",
+"mprintf('\n (b) The specific enthalpy of the air at 15 C is = %f kJ/kg\n',h);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.23: EX5_23.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.23');\n",
+"\n",
+"// aim : T determine the\n",
+"// (a) characteristic gas constant of the gas\n",
+"// (b) cp,\n",
+"// (c) cv,\n",
+"// (d) del_u \n",
+"// (e) work transfer\n",
+"\n",
+"// Given values\n",
+"P = 1;// [bar] \n",
+"T1 = 273+15;// [K]\n",
+"m = .9;// [kg]\n",
+"T2 = 273+250;// [K]\n",
+"Q = 175;// heat transfer,[kJ]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// using, P*V=m*R*T, given,\n",
+"m_by_V = 1.875;\n",
+"// hence\n",
+"R = P*100/(T1*m_by_V);// [kJ/kg*K]\n",
+"mprintf('\n (a) The characteristic gas constant of the gas is R = %f kJ/kg K\n',R);\n",
+"\n",
+"// (b)\n",
+"// using, Q=m*cp*(T2-T1)\n",
+"cp = Q/(m*(T2-T1));// [kJ/kg K]\n",
+"mprintf('\n (b) The specific heat capacity of the gas at constant pressure cp = %f kJ/kg K\n',cp);\n",
+"\n",
+"// (c)\n",
+"// we have, cp-cv=R,so\n",
+"cv = cp-R;// [kJ/kg*K]\n",
+"mprintf('\n (c) The specific heat capacity of the gas at constant volume cv = %f kJ/kg K\n',cv);\n",
+"\n",
+"// (d)\n",
+"del_U = m*cv*(T2-T1);// [kJ]\n",
+"mprintf('\n (d) The change in internal energy is = %f kJ\n',del_U);\n",
+"\n",
+"// (e)\n",
+"// using, Q=del_U+W\n",
+"W = Q-del_U;// [kJ]\n",
+"mprintf('\n (e) The work transfer is W = %f kJ\n',W);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.24: work_done_change_of_internal_energy_and_heat_transfer.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.24');\n",
+"\n",
+"// aim : To determine the\n",
+"// (a) work transfer,\n",
+"// (b)del_U and,\n",
+"// (c)heat transfer\n",
+"\n",
+"// Given values\n",
+"V1 = .15;// [m^3]\n",
+"P1 = 1200;// [kN/m^2]\n",
+"T1 = 273+120;// [K]\n",
+"P2 = 200;// [kN/m^2]\n",
+"cp = 1.006;//[kJ/kg K]\n",
+"cv = .717;// [kJ/kg K]\n",
+"\n",
+"// solution\n",
+"\n",
+"// (a)\n",
+"// Given, PV^1.32=constant, so it is polytropic process with\n",
+"n = 1.32;// polytropic index\n",
+"// hence\n",
+"V2 = V1*(P1/P2)^(1/n);// [m^3]\n",
+"// now, W\n",
+"W = (P1*V1-P2*V2)/(n-1);// [kJ]\n",
+"mprintf('\n (a) The work transfer is W = %f kJ\n',W);\n",
+"\n",
+"// (b)\n",
+"R = cp-cv;// [kJ/kg K]\n",
+"m = P1*V1/(R*T1);// gas law,[kg]\n",
+"// also for polytropic process\n",
+"T2 = T1*(P2/P1)^((n-1)/n);// [K]\n",
+"// now for gas,\n",
+"del_U = m*cv*(T2-T1);// [kJ]\n",
+"mprintf('\n (b) The change of internal energy is del_U = %f kJ\n',del_U);\n",
+"\n",
+"// (c)\n",
+"Q = del_U+W;// first law of thermodynamics,[kJ]\n",
+"mprintf('\n (c) The heat transfer Q = %f kJ\n',Q);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.26: volume.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.26');\n",
+"\n",
+"// aim : To determine\n",
+"// the volume of the pressure vessel and the volume of the gas before transfer\n",
+"\n",
+"// Given values\n",
+"\n",
+"P1 = 1400;// initial pressure,[kN/m^2]\n",
+"T1 = 273+85;// initial temperature,[K]\n",
+"\n",
+"P2 = 700;// final pressure,[kN/m^2]\n",
+"T2 = 273+60;// final temperature,[K]\n",
+"\n",
+"m = 2.7;// mass of the gas passes,[kg]\n",
+"cp = .88;// [kJ/kg]\n",
+"cv = .67;// [kJ/kg]\n",
+"\n",
+"// solution\n",
+"\n",
+"// steady flow equation is, u1+P1*V1+C1^2/2+Q=u2+P2*V2+C2^2/2+W [1], \n",
+"// given, there is no kinetic energy change and neglecting potential energy term\n",
+"W = 0;// no external work done\n",
+"// so final equation is,u1+P1*v1+Q=u2 [2]\n",
+"// also u2-u1=cv*(T2-T1)\n",
+"// hence Q=cv*(T2-T1)-P1*v1 [3]\n",
+"// and for unit mass P1*v1=R*T1=(cp-cv)*T1 [4]\n",
+"// so finally\n",
+"Q = cv*(T2-T1)-(cp-cv)*T1;// [kJ/kg]\n",
+"// so total heat transferred is\n",
+"Q = m*Q;// [kJ] \n",
+"\n",
+"// using eqn [4]\n",
+"v1 = (cp-cv)*T1/P1;// [m^3/kg]\n",
+"// Total volume is\n",
+"V1 = m*v1;// [m^3]\n",
+"\n",
+"// using ideal gas equation P1*V1/T1=P2*V2/T2\n",
+"V2 = P1*T2*V1/(P2*T1);// final volume,[m^3]\n",
+"\n",
+"mprintf('\n The volume of gas before transfer is = %f m^3\n',V1);\n",
+"mprintf('\n The volume of pressure vessel is = %f m^3\n',V2);\n",
+" \n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.2: volume.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.2');\n",
+"\n",
+"// aim : To determine \n",
+"// the new volume\n",
+"\n",
+"// Given values\n",
+"P1 = 300;// original pressure,[kN/m^2]\n",
+"V1 = .14;// original volume,[m^3]\n",
+"\n",
+"P2 = 60;// new pressure after expansion,[kn/m^2]\n",
+"\n",
+"// solution\n",
+"// since temperature is constant so using boyle's law P*V=constant\n",
+"V2 = V1*P1/P2;// [m^3]\n",
+"\n",
+"mprintf('\n The new volume after expansion is = %f m^3\n',V2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.3: volume.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.3');\n",
+"\n",
+"// aim : To determine \n",
+"// the new volume of the gas\n",
+"\n",
+"// Given values\n",
+"V1 = 10000;// [mm^3]\n",
+"T1 = 273+18;// [K]\n",
+"T2 = 273+85;// [K]\n",
+"\n",
+"// solution\n",
+"// since pressure exerted on the apparatus is constant so using charle's law V/T=constant\n",
+"// hence\n",
+"V2 = V1*T2/T1;// [mm^3]\n",
+"\n",
+"mprintf('\n The new volume of the gas trapped in the apparatus is = %f mm^3\n',V2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.4: temperature.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.4');\n",
+"\n",
+"// aim : To determine \n",
+"// the final temperature\n",
+"\n",
+"// Given values\n",
+"V1 = .2;// original volume,[m^3]\n",
+"T1 = 273+303;// original temperature, [K]\n",
+"V2 = .1;// final volume, [m^3]\n",
+"\n",
+"// solution\n",
+"// since pressure is constant, so using charle's law V/T=constant\n",
+"// hence\n",
+"T2 = T1*V2/V1;// [K]\n",
+"t2 = T2-273;// [C]\n",
+"mprintf('\n The final temperature of the gas is = %f C\n',t2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.5: volume.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.5');\n",
+"\n",
+"// aim : To determine \n",
+"// the new volume of the gas\n",
+"\n",
+"// Given values\n",
+"\n",
+"// initial codition\n",
+"P1 = 140;// [kN/m^2]\n",
+"V1 = .1;// [m^3]\n",
+"T1 = 273+25;// [K]\n",
+"\n",
+"// final condition\n",
+"P2 = 700;// [kN/m^2]\n",
+"T2 = 273+60;// [K]\n",
+"\n",
+"// by charasteristic equation, P1*V1/T1=P2*V2/T2\n",
+"\n",
+"V2=P1*V1*T2/(T1*P2);// final volume, [m^3]\n",
+"\n",
+"mprintf('\nThe new volume of the gas is = %f m^3\n',V2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.6: mass_and_temperature.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.6');\n",
+"\n",
+"// aim : To determine\n",
+"// the mas of the gas and new temperature\n",
+"\n",
+"// Given values\n",
+"P1 = 350;// [kN/m^2]\n",
+"V1 = .03;// [m^3]\n",
+"T1 = 273+35;// [K]\n",
+"R = .29;// Gas constant,[kJ/kg K]\n",
+"\n",
+"// solution\n",
+"// using charasteristic equation, P*V=m*R*T\n",
+"m = P1*V1/(R*T1);// [Kg]\n",
+"mprintf('\n The mass of the gas present is = %f kg\n',m);\n",
+"\n",
+"// Now the gas is compressed\n",
+"P2 = 1050;// [kN/m^2]\n",
+"V2 = V1;\n",
+"// since mass of the gas is constant so using, P*V/T=constant\n",
+"// hence\n",
+"T2 = T1*P2/P1// [K]\n",
+"t2 = T2-273;// [C]\n",
+"\n",
+"mprintf('\n The new temperature of the gas is = %f C\n',t2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.7: heat_transfer_and_pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.7');\n",
+"\n",
+"// aim : To determine \n",
+"// the heat transferred to the gas and its final pressure\n",
+"\n",
+"// Given values\n",
+"m = 2;// masss of the gas, [kg]\n",
+"V1 = .7;// volume,[m^3]\n",
+"T1 = 273+15;// original temperature,[K]\n",
+"T2 = 273+135;// final temperature,[K]\n",
+"cv = .72;// specific heat capacity at constant volume,[kJ/kg K]\n",
+"R = .29;// gas law constant,[kJ/kg K]\n",
+"\n",
+"// solution\n",
+"Q = m*cv*(T2-T1);// Heat transferred at constant volume,[kJ]\n",
+"mprintf('\n The heat transferred to the gas is = %f kJ\n',Q);\n",
+"\n",
+"// Now,using P1*V1=m*R*T1\n",
+"P1 = m*R*T1/V1;// [kN/m^2]\n",
+"\n",
+"// since volume of the system is constant, so P1/T1=P2/T2\n",
+"// hence\n",
+"P2 = P1*T2/T1;// final pressure,[kN/m^2]\n",
+"mprintf('\n The final pressure of the gas is = %f kN/m^2 \n',P2);\n",
+"\n",
+"// End"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.8: heat_transfer_and_work_done.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.8');\n",
+"\n",
+"// aim : To determine \n",
+"// the heat transferred from the gas and the work done on the gas\n",
+"\n",
+"// Given values\n",
+"P1 = 275;// pressure, [kN/m^2]\n",
+"V1 = .09;// volume,[m^3]\n",
+"T1 = 273+185;// initial temperature,[K]\n",
+"T2 = 273+15;// final temperature,[K]\n",
+"cp = 1.005;// specific heat capacity at constant pressure,[kJ/kg K]\n",
+"R = .29;// gas law constant,[kJ/kg K]\n",
+"\n",
+"// solution\n",
+"// using P1*V1=m*R*T1\n",
+"m = P1*V1/(R*T1);// mass of the gas\n",
+"\n",
+"// calculation of heat transfer\n",
+"Q = m*cp*(T2-T1);// Heat transferred at constant pressure,[kJ]\n",
+"mprintf('\n The heat transferred to the gas is = %f kJ\n',Q);\n",
+"\n",
+"// calculation of work done\n",
+"// Now,since pressure is constant so, V/T=constant\n",
+"// hence\n",
+"V2 = V1*T2/T1;// [m^3]\n",
+"\n",
+"W = P1*(V2-V1);// formula for work done at constant pressure,[kJ]\n",
+"mprintf('\n Work done on the gas during the process is = %f kJ\n',W);\n",
+"\n",
+"// End\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9: pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"disp('Example 5.9');\n",
+"\n",
+"// aim : To determine\n",
+"// the new pressure of the gas\n",
+"\n",
+"// Given values\n",
+"P1 = 300;// original pressure,[kN/m^2]\n",
+"T1 = 273+25;// original temperature,[K]\n",
+"T2 = 273+180;// final temperature,[K]\n",
+"\n",
+"// solution\n",
+"// since gas compressing according to the law,P*V^1.4=constant\n",
+"// so,for polytropic process,T1/T2=(P1/P2)^((n-1)/n),here n=1.4\n",
+"\n",
+"// hence\n",
+"P2 = P1*(T2/T1)^((1.4)/(1.4-1));// [kN/m^2]\n",
+"\n",
+"mprintf('\n The new pressure of the gas is = %f kN/m^2\n',P2);\n",
+"\n",
+"// End"
+ ]
+ }
+],
+"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
+}