ThermodynamicCycle: for parameters & properties at each state of a cycle
by Gino J. A. de Andrade
(Federal University of Amazon)
gandrade@ufam.edu.br
by Gino J. A. de Andrade
(Federal University of Amazon)
gandrade@ufam.edu.br
Thermodynamic Cycle is a sequence of processes that a system undergoes then returning to its initial thermodynamic state. It is an idealized concept of process which is very useful to understand events in a period of time that the system didn’t change that much, (reversible). Actually, to be precise thermodynamic cycles don’t occur in nature, because of increasing entropy , thus, at last infinitesimal changes always occur. But in some cases, corresponding to well defined criteria it is possible to say that a sequence of processes is a thermodynamic cycle. Therefore There are numerous Thermodynamic cycles used currently, and each of them have its own application, for example power generation, air conditioning, air heating, and etc.
Introduction
Introduction
Thermodynamics is a fundamental field to understand thermal processes. In mechanics, laws of thermodynamics are fundamental for an objective comprehension of real processes, specially the second law of thermodynamics which is a criterion to determinate the direction of a process and whether it is possible to occur. Thermodynamics modeling are fundamental to increase the efficiency of thermal systems like: Power Plant generation, Refrigeration and air conditioning systems. By its turn increasing efficiency of a thermal system means less monetary cost and even less environment depletion, once, for instance, a more effective power plant needs less fuel to produce energy, thus it produces less pollution. Rankine Cycle represent 90% of total power generation around the world. So be able to better modeling thermodynamic cycles it is an attractive challenge. The present work is about two functions. The first one is the thermodynamic cycle which is a function that take with a few input values outputs all parameters and properties at each state for a thermodynamic cycle as an object. The other function takes the object from the Thermodynamic Cycle then outputs Thermodynamic Diagrams like temperature vs entropy and pressure vs entropy.
Data source
Data source
This subsection was added to supply some data that are necessary in liquid-vapor state
In[]:=
SetDirectory[NotebookDirectory[]];A=;fun[col_]:=Transpose@{A[[2;;,1]],A[[2;;,col]]};DataPxT=Transpose@{A[[2;;,1]],A[[2;;,2]]};DataTxP=Transpose@{A[[2;;,2]],A[[2;;,1]]};{DatavlxT,DatavvxT,DataulxT,DatauvxT,DatahlxT,DatahvxT,DataslxT,DatasvxT}=Table[Transpose@{A[[2;;,1]],A[[2;;,col]]},{col,3,10}];{press,Temp,vl,vv,ul,uv,hl,hv,sl,sv}=Interpolation[#,InterpolationOrder1]&/@{DataPxT,DataTxP,DatavlxT,DatavvxT,DataulxT,DatauvxT,DatahlxT,DatahvxT,DataslxT,DatasvxT};
Vapor quality
Vapor quality
To properly calculate thermodynamic states in the region of vapor - liquid it is necessary to introduce the vapor quality variable which is the ratio between the amount of vapor and the total mass of the mixture. The following function calculate that variable for each property
In[]:=
VaporQuality[property_,Fluid:"Water",Tempe_,PropKnown_]:=Module{vliq,vvap,qualityVapor,uliq,uvap,sliq,svap,hliq,hvap},Ifproperty"SpecificVolume",vliq=vl@Tempe;vvap=vv@Tempe;qualityVapor=//N;Ifproperty"InternalEnergy",uliq=ul@Tempe;uvap=uv@Tempe;qualityVapor=;//N;Ifproperty"Entropy",sliq=sl@Tempe;svap=sv@Tempe;qualityVapor=//N;Ifproperty"Enthalpy",hliq=hl@Tempe;hvap=hv@Tempe;qualityVapor=//N;Return[qualityVapor]
PropKnown-vliq
vvap-vliq
PropKnown-uliq
uvap-uliq
PropKnown-sliq
svap-sliq
PropKnown-hliq
hvap-hliq
Rankine object
Rankine object
The rankine cycle modelled here operates in vapor-liquid states, there are lots of variations but this shows a good view of how it works
In[]:=
ClearAll[ThermodynamicCycle];Options[ThermodynamicCycle]={};ThermodynamicCycle[cycle:"RankineCycle",fluid:"Water",Quantity[Phigh_,unitPhigh_],Quantity[Plow_,unitPlow_],Quantity[tBoiller_,unitBoiller_],opts:OptionsPattern[]]:=Module{p,T,T4,u,v,s,h,p1,p2,x2,eff,enthalpy,entropy,volume,temperature,pressure,wcycle,bwr,heatInput,heatOutput},If[unitPhigh"Bars",p1=Quantity[Phigh,unitPhigh];Goto[go1],p1=UnitConvert[Quantity[Phigh,unitPhigh],"Bars"]];Label[go1];If[unitPlow"Bars",p2=Quantity[Plow,unitPlow];Goto[go2],p2=UnitConvert[Quantity[Plow,unitPlow],"Bars"]];Label[go2];If[unitBoiller≠"DegreesCelsius",T4=UnitConvert[Quantity[tBoiller,unitBoiller],"DegreesCelsius"]];T4=Quantity[tBoiller,unitBoiller];T=Table[0,4];s=v=h=p=T;p[[1]]=p1[[1]];T[[1]]=Temp@p[[1]](*°C*);h[[1]]=hv@T[[1]];v[[1]]=vv@T[[1]];s[[1]]=sv@T[[1]](*kJ/kg.K*);p[[2]]=p2[[1]];T[[2]]=Temp@p[[2]];s[[2]]=s[[1]];x2=VaporQuality["Entropy","Water",T[[2]],s[[2]]];v[[2]]=(1-x2)vl[T[[2]]]+x2*vv[T[[2]]];h[[2]]=(1-x2)hl[T[[2]]]+x2*hv[T[[2]]];p[[3]]=p[[2]];T[[3]]=Temp@p[[3]];h[[3]]=hl@T[[3]];s[[3]]=sl@T[[3]];v[[3]]=vl@T[[3]];p[[4]]=p[[1]];h[[4]]=h[[3]]+v[[3]](p[[4]]-p[[3]]);s[[4]]=s[[3]];T[[4]]=T4[[1]];v[[4]]=QuantityMagnitude@ThermodynamicData["Water","SpecificVolume",{"Pressure"Quantity[p[[4]],"Bars"],"Temperature"Quantity[T[[4]],"DegreesCelsius"]}];enthalpy=Quantity[#,"Kilojoules"/"Kilograms"]&/@h;entropy=Quantity[#,"Kilojoules"/("Kilograms"*"Kelvins")]&/@s;volume=Quantity#,"Kilograms"&/@v;temperature=Quantity[#,"DegreesCelsius"]&/@T;pressure=Quantity[#,"Bars"]&/@p;eff=UnitConvert[((enthalpy〚1〛-enthalpy〚2〛)-(enthalpy〚4〛-enthalpy〚3〛))/(enthalpy〚1〛-enthalpy〚4〛),"Percent"];wcycle=(enthalpy〚1〛-enthalpy〚2〛)-(enthalpy〚4〛-enthalpy〚3〛);heatInput=(enthalpy〚1〛-enthalpy〚4〛);heatOutput=enthalpy2-enthalpy3;bwr=UnitConvert[(enthalpy〚4〛-enthalpy〚3〛)/(enthalpy〚1〛-enthalpy〚2〛),"Percent"];eff=UnitConvert[wcycle/heatInput,"Percent"];thermodynamicObject[<|"Cycle"cycle,"Fluid"fluid,"h1"enthalpy〚1〛,"h2"enthalpy〚2〛,"h3"enthalpy〚3〛,"h4"enthalpy〚4〛,"P1"pressure〚1〛,"P2"pressure〚2〛,"P3"pressure〚3〛,"P4"pressure〚4〛,"s1"entropy〚1〛,"s2"entropy〚2〛,"s3"entropy〚3〛,"s4"entropy〚4〛,"T1"temperature〚1〛,"T2"temperature〚2〛,"T3"temperature〚3〛,"T4"temperature〚4〛,"v1"volume〚1〛,"v2"volume〚2〛,"v3"volume〚3〛,"v4"volume〚4〛,"ThermalEfficiency"eff,"WorkCycle"(enthalpy〚1〛-enthalpy〚2〛)-(enthalpy〚4〛-enthalpy〚3〛),"HeatInput"heatInput,"BackWorkRatio"bwr,"HeatOutput"heatOutput|>]thermodynamicObject/:MakeBoxes[thermodynamicObject[___],_]:=ToBoxes[Defer[thermodynamicObject]["..."]];thermodynamicObject[data_Association][prop_String]:=data[prop]
3
"Meters"
Thus it is possible to know each parameter or property on four states.
The enthalpy at state one
So the enthalpy at four states of the cycle is :
Also the entropy for each state
All properties at each state
It outputs all parameters
Carnot object
Carnot object
Carnot cycle is shows the maximum efficiency of any cycle operating between two thermal reservoirs
The ThermodynamicCycle allows one to know each variable for all cycles modeled so far
Enthalpy at state one
Entropy at state two
Properties at each state
Otto Object
Otto Object
The otto cycle in this section is the cold-air standar which means that specific heat doesn't vary with temperature and there ins no combustion, the heat input comes from a external source
ThermodynamicCyclePlot
ThermodynamicCyclePlot
This function plots cycles from TherdynamicCycle
Otto plot
Otto plot
The functions ThermodynamicCycle and ThermodynamicCyclePlot are useful tools for those who are studying thermodynamics Cycle especially for mechanical engineering. Of course this is the first step in a the direction of a more vast function that is able to represent more cycles. Next step could be, variations of Rakine Cycle, Use the NMaximize combined with, And different fluids.