{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 12 : Flywheel Energy storage"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex: 12.1 Pg: 849"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " (a) the compressed sir temperature is 1162 degree C \n",
      " (b) the storage time is 7.71 hour \n",
      " (c) the total energy storage is 2426 MWh \n",
      " (d) the total energy delivered by the peaking turbine is 1455 MWh\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "#Input data\n",
    "V=64000#Volume in m**3\n",
    "Q=8300#Discharge in m**3/hr\n",
    "p1=1#Pressure in bar\n",
    "T1=20+273#Temperature in K\n",
    "p2=100#Pressure in bar\n",
    "pn=70#Polytropic efficiency in percent\n",
    "pt=60#Peaking turbine efficiency in percent\n",
    "g=1.4#Ratio of specific heats\n",
    "cp=1.005#Specific heat in kJ/kg.K\n",
    "R=0.287#Gas constant in kJ/kg.K\n",
    "\n",
    "#Calculations\n",
    "T2sT1=(p2/p1)**((g-1)/g)#Temperature ratio \n",
    "T2s=(T1*T2sT1)#Temperature in K\n",
    "T21=(T2s-T1)/(pn/100)#Difference in Temperatures in K\n",
    "T2=(T21+T1)-273#Temperature in degree C\n",
    "v=(R*T1)/(p2*100)#Specific volume in m**3/kg\n",
    "mf=(Q/(v*3600))#Mass flow rate in kg/s\n",
    "E=(mf*cp*T21)/1000#Rate of energy storage in MW\n",
    "t=(V/Q)#Storage time in hour\n",
    "tE=(E*t)#Total energy storage in MWh\n",
    "Ed=(tE*(pt/100))#Total energy delivered by the peaking turbine in MWh\n",
    "\n",
    "#Output\n",
    "print \" (a) the compressed sir temperature is %3.0f degree C \\n (b) the storage time is %3.2f hour \\n (c) the total energy storage is %3.0f MWh \\n (d) the total energy delivered by the peaking turbine is %3.0f MWh\"%(T2,t,tE,Ed)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex: 12.2 Pg: 850"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " (a) the storage time is 13.969 h \n",
      " (b) the total energy stored in the accumulator is 16678.8 MWh \n",
      " (c) the total energy that can be delivered by the peaking turbine is 4002.92 MWh\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import log\n",
    "#Input data\n",
    "V=175000#Volume in m**3\n",
    "d=4#Diameter in m\n",
    "U=1.5#Overall heat transfer coefficient in W/m**2.K\n",
    "p2=2#Pressure in bar\n",
    "p1=20#Pressure in bar\n",
    "Ta=20#Ambient temperature in degree C\n",
    "cp=4.35#Specific heta of water in kJ/kg.K\n",
    "e=96#Efficiency in percent\n",
    "ppe=25#Peaking plant efficiency in percent\n",
    "\n",
    "#Calculations\n",
    "#At 20 bar\n",
    "T1=212.37#Saturation temperature in degree C\n",
    "hf1=908.5#Enthalpy in kJ/kg\n",
    "vf1=0.0011766#Specific volume in m**3/kg\n",
    "#At 2 bar\n",
    "T2=120.23#Saturation temperature in degree C\n",
    "hf2=504.8#Enthalpy in kJ/kg\n",
    "vf2=0.0010605#Specific volume in m**3/kg\n",
    "ad=(1/2)*((1/vf1)+(1/vf2))#Average density of water in kg/m**3\n",
    "tc=(d*ad*cp*1000)/(4*U*3600)#Time constant in h\n",
    "ts=(log(1/(1-((1-((e/100)))/((T1-Ta)/(T1-T2))))))*tc#Storage time in h\n",
    "m=(V/vf1)#Mass of water needed in kg\n",
    "E=(m*(hf1-hf2))/(3600*10**3)#Total energy stored in MWh\n",
    "Ed=(E*(e/100)*(ppe/100))#Energy delivered in MWh\n",
    "\n",
    "#Output\n",
    "print \" (a) the storage time is %3.3f h \\n (b) the total energy stored in the accumulator is %3.1f MWh \\n (c) the total energy that can be delivered by the peaking turbine is %3.2f MWh\"%(ts,E,Ed)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}