Changeset 849


Ignore:
Timestamp:
Oct 6, 2009, 4:37:24 PM (13 years ago)
Author:
mamuller
Message:

fixing packed column model

Location:
branches/gui/eml/stage_separators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/eml/stage_separators/column.mso

    r842 r849  
    17411741end
    17421742
     1743
     1744
     1745Model Packed_Section_ColumnBasic
     1746
     1747ATTRIBUTES
     1748        Pallete         = false;
     1749        Icon            = "icon/PackedSectionColumn";
     1750        Brief           = "Model of a packed column section.";
     1751        Info            =
     1752"== Model of a packed column section containing ==
     1753* NStages theoretical stages.
     1754       
     1755== Specify ==
     1756* the feed stream of each tray (Inlet);
     1757* the InletLiquid stream of the top tray;
     1758* the InletVapour stream of the bottom tray;
     1759* the total pressure drop (dP) of the section.
     1760       
     1761== Initial Conditions ==
     1762* the stages temperature (OutletLiquid.T);
     1763* the stages liquid holdup;
     1764* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     1765";
     1766       
     1767PARAMETERS
     1768
     1769        outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
     1770        outer NComp     as Integer      (Brief="Number of components");
     1771       
     1772        NumberOfFeeds                                           as Integer      (Brief="Number of Feed Stages",Default=3,Protected=true);
     1773        NumberOfStages                                          as Integer      (Brief="Number of Stages", Default=3);
     1774        FeedStageLocation(NumberOfFeeds)        as Integer      (Brief="Feed Stage Location",Default=2);
     1775       
     1776        PackingHeight           as length               (Brief="Height of packing");
     1777        #Just one heat supply for the whole column?
     1778        HeatSupply              as heat_rate    (Brief="Rate of heat supply");
     1779        ColumnDiameter  as length               (Brief="Column diameter");
     1780        VoidFraction            as fraction             (Brief="Void fraction of packing, (m^3 void space/m^3 packed bed)");
     1781        ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
     1782        AreaPerPackingVol as Real               (Brief="surface area per packing volume", Unit='m^2/m^3');
     1783       
     1784        hs                              as length                       (Brief="Height of the packing stage",Protected=true);
     1785       
     1786
     1787VARIABLES
     1788
     1789        INITIALIZATION  as InitializeStage      (Brief = "Column Model Initialization");
     1790       
     1791        in      LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
     1792        out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
     1793       
     1794        in      VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
     1795        out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
     1796         
     1797        LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
     1798        VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
     1799       
     1800        STAGES(NumberOfStages) as packedStage;
     1801        PressureDrop               as pressure;
     1802       
     1803SET
     1804        #trays outers
     1805        STAGES.ColumnDiameter = ColumnDiameter;
     1806        STAGES.AreaPerPackingVol = AreaPerPackingVol;
     1807        STAGES.VoidFraction = VoidFraction;
     1808        STAGES.hs = hs;
     1809        STAGES.ResistanceCoeff = ResistanceCoeff;
     1810
     1811        hs =PackingHeight/NumberOfStages;       
     1812        STAGES.V = hs * ColumnDiameter^2*3.14159/4;
     1813        STAGES.HeatSupply = HeatSupply;
     1814
     1815CONNECTIONS
     1816        #internals
     1817        STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
     1818        STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
     1819        #connectors
     1820        LiquidConnector to STAGES(1).InletLiquid;
     1821        VapourConnector to STAGES(NumberOfStages).InletVapour;
     1822
     1823EQUATIONS
     1824
     1825"PresureDrop"
     1826#       STAGES.deltaP = PressureDrop/NumberOfStages;
     1827        PressureDrop = STAGES(1).OutletLiquid.P - STAGES(NumberOfStages).OutletLiquid.P;
     1828
     1829#Pressure profile
     1830#       for j in [1:NumberOfStages-1] do
     1831#               STAGES(j).deltaP = STAGES(j+1).OutletVapour.P - STAGES(j).OutletVapour.P;
     1832#       end
     1833
     1834
     1835
     1836        LiquidConnector.F= LiquidInlet.F;
     1837        LiquidConnector.T = LiquidInlet.T;
     1838        LiquidConnector.P = LiquidInlet.P;
     1839        LiquidConnector.z = LiquidInlet.z;
     1840        LiquidConnector.v = LiquidInlet.v;
     1841        LiquidConnector.h = LiquidInlet.h;
     1842       
     1843        VapourConnector.F= VapourInlet.F;
     1844        VapourConnector.T = VapourInlet.T;
     1845        VapourConnector.P = VapourInlet.P;
     1846        VapourConnector.z = VapourInlet.z;
     1847        VapourConnector.v = VapourInlet.v;
     1848        VapourConnector.h = VapourInlet.h;
     1849       
     1850        LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
     1851        LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
     1852        LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
     1853        LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
     1854       
     1855        VapourOutlet.F= STAGES(1).OutletVapour.F;
     1856        VapourOutlet.T = STAGES(1).OutletVapour.T;
     1857        VapourOutlet.P = STAGES(1).OutletVapour.P;
     1858        VapourOutlet.z = STAGES(1).OutletVapour.z;
     1859
     1860#for i in [1:NumberOfStages] do
     1861
     1862##"Energy Balance"
     1863##      diff(STAGES(i).E) = ( STAGES(i).Inlet.F*STAGES(i).Inlet.h + STAGES(i).InletLiquid.F*STAGES(i).InletLiquid.h + STAGES(i).InletVapour.F*STAGES(i).InletVapour.h- STAGES(i).OutletLiquid.F*STAGES(i).OutletLiquid.h
     1864##      - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
     1865       
     1866##"Energy Holdup"
     1867##      STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
     1868       
     1869##"Geometry Constraint"
     1870##V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
     1871       
     1872##"Volume flow rate of vapor, m^3/m^2/s"
     1873##      #STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
     1874##      STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).InletVapour.F * STAGES(i).vV;
     1875       
     1876##"Liquid holdup"
     1877##      STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
     1878       
     1879##"Particle diameter"
     1880##      STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
     1881       
     1882##"Wall Factor"
     1883##      STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
     1884##     
     1885
     1886##"Reynolds number of the vapor stream"
     1887##      STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
     1888       
     1889##"Pressure drop and Vapor flow"
     1890##      STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
     1891
     1892##"Liquid holdup"
     1893##      STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/Gconst)^1/3;
     1894
     1895##"Area occupied by the liquid"
     1896##      STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
     1897
     1898#
     1899#"Vapour Flow"
     1900        #STAGES(1).InletVapour.F = STAGES(1).OutletVapour.F + STAGES(1).Inlet.F*STAGES(1).Inlet.v;
     1901
     1902#end
     1903
     1904INITIAL
     1905
     1906#*for i in 1:NumberOfStages do
     1907
     1908"The initial temperature of the STAGES"
     1909        STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
     1910
     1911"The Liquid Holdup of the STAGES"
     1912        STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
     1913
     1914end
     1915
     1916for i in 1:NComp-1 do
     1917       
     1918for j in 1:NumberOfStages do
     1919
     1920"The initial composition of the TRAYS"
     1921        STAGES(j).OutletLiquid.z(i) = INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) +(INITIALIZATION.BottomStageComposition(i)/sum(INITIALIZATION.BottomStageComposition)-INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) )*((j-1)/(NumberOfStages-1));
     1922
     1923end
     1924
     1925end
     1926*#
     1927end
     1928
     1929Model Packed_Section_Column     as Packed_Section_ColumnBasic
     1930
     1931        ATTRIBUTES
     1932        Pallete         = true;
     1933        Icon            = "icon/PackedSectionColumn";
     1934        Brief           = "Model of a packed column section.";
     1935        Info            =
     1936"== Model of a packed column section containing ==
     1937* NStages theoretical stages.
     1938       
     1939== Specify ==
     1940* the feed stream of each tray (Inlet);
     1941* the InletLiquid stream of the top tray;
     1942* the InletVapour stream of the bottom tray;
     1943* the total pressure drop (dP) of the section.
     1944       
     1945== Initial Conditions ==
     1946* the stages temperature (OutletLiquid.T);
     1947* the stages liquid holdup;
     1948* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     1949";
     1950
     1951SET
     1952        NumberOfFeeds = 1;
     1953
     1954VARIABLES
     1955       
     1956        in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
     1957
     1958EQUATIONS
     1959#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     1960# Equating Feed Tray Variables to Trays Variables
     1961#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     1962for i in 1:NumberOfStages do
     1963
     1964if   i equal FeedStageLocation(1) then   
     1965
     1966"FeedTrayTop Inlet Flow"       
     1967        FeedStage.F= STAGES(i).Inlet.F;
     1968
     1969"FeedTrayTop Inlet Temperature"
     1970        FeedStage.T = STAGES(i).Inlet.T;
     1971
     1972"FeedTrayTop Inlet Pressure"
     1973        FeedStage.P = STAGES(i).Inlet.P;
     1974
     1975"FeedTrayTop Inlet Composition"
     1976        FeedStage.z = STAGES(i).Inlet.z;
     1977
     1978"FeedTrayTop Inlet Vapour Fraction"
     1979        FeedStage.v = STAGES(i).Inlet.v;
     1980
     1981"FeedTrayTop Inlet Enthalpy"
     1982        FeedStage.h = STAGES(i).Inlet.h;
     1983
     1984else
     1985
     1986"Inlet Tray - Flow Sealed"
     1987    0*'mol/h'= STAGES(i).Inlet.F;
     1988       
     1989"Inlet Tray -  Temperature"
     1990    300*'K' = STAGES(i).Inlet.T;
     1991       
     1992"Inlet Tray -  Pressure"
     1993    1*'atm' = STAGES(i).Inlet.P;
     1994       
     1995"Inlet Tray -  Composition"
     1996    0.1 = STAGES(i).Inlet.z;
     1997       
     1998"Inlet Tray -  Vapour Fraction"
     1999    0 = STAGES(i).Inlet.v;
     2000       
     2001"Inlet Tray -  Enthalpy"
     2002    0*'J/mol' = STAGES(i).Inlet.h;
     2003
     2004end
     2005
     2006end
     2007
     2008end
     2009
     2010Model Packed_Section_Column2    as Packed_Section_ColumnBasic
     2011
     2012        ATTRIBUTES
     2013        Pallete         = true;
     2014        Icon            = "icon/PackedSectionColumn";
     2015        Brief           = "Model of a packed column section.";
     2016        Info            =
     2017"== Model of a packed column section containing ==
     2018* NStages theoretical stages.
     2019       
     2020== Specify ==
     2021* the feed stream of each tray (Inlet);
     2022* the InletLiquid stream of the top tray;
     2023* the InletVapour stream of the bottom tray;
     2024* the total pressure drop (dP) of the section.
     2025       
     2026== Initial Conditions ==
     2027* the stages temperature (OutletLiquid.T);
     2028* the stages liquid holdup;
     2029* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
     2030";
     2031
     2032SET
     2033        NumberOfFeeds = 2;
     2034
     2035VARIABLES
     2036       
     2037        in      FeedStageOne    as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
     2038        in      FeedStageTwo    as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
     2039
     2040EQUATIONS
     2041#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2042# Equating Feed Stage Variables to Stages Variables
     2043#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2044
     2045for i in 1:NumberOfStages do
     2046
     2047if   i equal FeedStageLocation(1) then   
     2048
     2049"FeedTrayTop Inlet Flow"       
     2050        FeedStageOne.F= STAGES(i).Inlet.F;
     2051
     2052"FeedTrayTop Inlet Temperature"
     2053        FeedStageOne.T = STAGES(i).Inlet.T;
     2054
     2055"FeedTrayTop Inlet Pressure"
     2056        FeedStageOne.P = STAGES(i).Inlet.P;
     2057
     2058"FeedTrayTop Inlet Composition"
     2059        FeedStageOne.z = STAGES(i).Inlet.z;
     2060
     2061"FeedTrayTop Inlet Vapour Fraction"
     2062        FeedStageOne.v = STAGES(i).Inlet.v;
     2063
     2064"FeedTrayTop Inlet Enthalpy"
     2065        FeedStageOne.h = STAGES(i).Inlet.h;
     2066
     2067else if   i equal FeedStageLocation(2) then   
     2068
     2069"FeedTrayBottom Inlet Flow"     
     2070        FeedStageTwo.F= STAGES(i).Inlet.F;
     2071
     2072"FeedTrayBottom Inlet Temperature"
     2073        FeedStageTwo.T = STAGES(i).Inlet.T;
     2074
     2075"FeedTrayBottom Inlet Pressure"
     2076        FeedStageTwo.P = STAGES(i).Inlet.P;
     2077
     2078"FeedTrayBottom Inlet Composition"
     2079        FeedStageTwo.z = STAGES(i).Inlet.z;
     2080
     2081"FeedTrayBottom Inlet Vapour Fraction"
     2082        FeedStageTwo.v = STAGES(i).Inlet.v;
     2083
     2084"FeedTrayBottom Inlet Enthalpy"
     2085        FeedStageTwo.h = STAGES(i).Inlet.h;
     2086
     2087else
     2088
     2089"Inlet Tray - Flow Sealed"
     2090    0*'mol/h'= STAGES(i).Inlet.F;
     2091       
     2092"Inlet Tray -  Temperature"
     2093    300*'K' = STAGES(i).Inlet.T;
     2094       
     2095"Inlet Tray -  Pressure"
     2096    1*'atm' = STAGES(i).Inlet.P;
     2097       
     2098"Inlet Tray -  Composition"
     2099    0.1 = STAGES(i).Inlet.z;
     2100       
     2101"Inlet Tray -  Vapour Fraction"
     2102    0 = STAGES(i).Inlet.v;
     2103       
     2104"Inlet Tray -  Enthalpy"
     2105    0*'J/mol' = STAGES(i).Inlet.h;
     2106
     2107end
     2108
     2109end
     2110
     2111end
     2112
     2113end
     2114
     2115Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
     2116        ATTRIBUTES
     2117        Pallete         = true;
     2118        Icon            = "icon/PackedDistillationKettleCond";
     2119        Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
     2120        Info            =
     2121"== Specify ==
     2122* the feed stream of each tray (Inlet);
     2123* the pump pressure difference;
     2124* the total pressure drop (dP) of the packing;
     2125* the heat supllied in reboiler and condenser;
     2126* the condenser vapor outlet flow (OutletVapour.F);
     2127* the reboiler liquid outlet flow (OutletLiquid.F);
     2128* both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
     2129       
     2130== Initial Conditions ==
     2131* the stages temperature (OutletLiquid.T);
     2132* the stages initial molar holdup;
     2133* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
     2134       
     2135* the condenser temperature (OutletLiquid.T);
     2136* the condenser liquid level (Level);
     2137* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
     2138       
     2139* the reboiler temperature (OutletLiquid.T);
     2140* the reboiler liquid level (Level);
     2141* (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
     2142";
     2143       
     2144PARAMETERS
     2145
     2146        #VapourFlow as Switcher (Valid = ["on", "off"], Hidden = true ,Default = "on");
     2147       
     2148VARIABLES
     2149#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2150# Column Devices
     2151#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     2152        CONDENSER       as condenser    (Brief="dymamic condenser");
     2153        REBOILER        as reboiler             (Brief="kettle reboiler");
     2154        SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
     2155        PUMP            as pump                 (Brief="pump in reflux stream");
     2156#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2157# Heat Ports
     2158#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     2159        in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
     2160        in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
     2161#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2162# Column Products
     2163#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
     2164        out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
     2165        out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
     2166        out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
     2167#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     2168# Column Connectors
     2169#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
     2170        in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
     2171        in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
     2172        in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
     2173                ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
     2174                ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
     2175
     2176CONNECTIONS
     2177
     2178#vapor
     2179        #REBOILER.OutletVapour          to STAGES(NumberOfStages).VapourConnector;
     2180        STAGES(1).OutletVapour          to CONDENSER.InletVapour;
     2181
     2182#liquid
     2183        CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
     2184        SPLITTER.Outlet2                                to PUMP.Inlet;
     2185        #PUMP.Outlet                                    to STAGES(1).InletLiquid;
     2186        STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
     2187
     2188#Connectors
     2189ConnectorHeatReboiler   to REBOILER.InletQ;
     2190ConnectorHeatCondenser  to CONDENSER.InletQ;
     2191
     2192CONDENSER.OutletVapour          to ConnectorCondenserVout;
     2193SPLITTER.Outlet1                to ConnectorSplitterOut;
     2194REBOILER.OutletLiquid           to ConnectorReboilerLout;
     2195
     2196EQUATIONS
     2197        HeatToReboiler  = ConnectorHeatReboiler;
     2198        HeatToCondenser = ConnectorHeatCondenser;
     2199       
     2200# Condenser Connector Equations
     2201        ConnectorCondenserVout.T = VapourDistillate.T;
     2202        ConnectorCondenserVout.P = VapourDistillate.P;
     2203        ConnectorCondenserVout.F = VapourDistillate.F;
     2204        ConnectorCondenserVout.z = VapourDistillate.z;
     2205
     2206# Splitter Connector Equations
     2207        ConnectorSplitterOut.T = LiquidDistillate.T;
     2208        ConnectorSplitterOut.P = LiquidDistillate.P;
     2209        ConnectorSplitterOut.F = LiquidDistillate.F;
     2210        ConnectorSplitterOut.z = LiquidDistillate.z;
     2211
     2212# Reboiler Connector Equations
     2213        ConnectorReboilerLout.T = BottomProduct.T;
     2214        ConnectorReboilerLout.P = BottomProduct.P;
     2215        ConnectorReboilerLout.F = BottomProduct.F;
     2216        ConnectorReboilerLout.z = BottomProduct.z;
     2217
     2218end
     2219
    17432220#*
    17442221Model Rectifier_subcooling as Section_ColumnBasicX
     
    23912868
    23922869*#
    2393 
    2394 Model Packed_Section_ColumnBasic
    2395 
    2396 ATTRIBUTES
    2397         Pallete         = false;
    2398         Icon            = "icon/PackedSectionColumn";
    2399         Brief           = "Model of a packed column section.";
    2400         Info            =
    2401 "== Model of a packed column section containing ==
    2402 * NStages theoretical stages.
    2403        
    2404 == Specify ==
    2405 * the feed stream of each tray (Inlet);
    2406 * the InletLiquid stream of the top tray;
    2407 * the InletVapour stream of the bottom tray;
    2408 * the total pressure drop (dP) of the section.
    2409        
    2410 == Initial Conditions ==
    2411 * the stages temperature (OutletLiquid.T);
    2412 * the stages liquid holdup;
    2413 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
    2414 ";
    2415        
    2416 PARAMETERS
    2417 
    2418         outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
    2419         outer NComp     as Integer      (Brief="Number of components");
    2420        
    2421         NumberOfFeeds                                           as Integer      (Brief="Number of Feed Stages",Default=3,Protected=true);
    2422         NumberOfStages                                          as Integer      (Brief="Number of Stages", Default=3);
    2423         FeedStageLocation(NumberOfFeeds)        as Integer      (Brief="Feed Stage Location",Default=2);
    2424        
    2425         PackingHeight           as length               (Brief="Height of packing");
    2426         HeatSupply                      as heat_rate    (Brief="Rate of heat supply");
    2427         ColumnDiameter          as length               (Brief="Column diameter");
    2428         VoidFraction            as Real                 (Brief="Void fraction of packing, (m^3 void space/m^3 packed bed)");
    2429         ResistanceCoeff         as positive     (Brief="Resistance coefficient on the liquid load", Default=1);
    2430         AreaPerPackingVol       as Real                 (Brief="surface area per packing volume", Unit='m^2/m^3');
    2431        
    2432         V                               as volume                       (Brief="Total Volume of the tray",Protected=true);
    2433         Pi                              as constant             (Brief="Pi Number",Default=3.14159265, Symbol = "\pi",Hidden=true);
    2434         Gconst                  as acceleration         (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
    2435         hs                              as length                       (Brief="Height of the packing stage",Protected=true);
    2436         ColumnArea              as area                         (Brief="Column Sectional Cross Area",Protected=true);
    2437 
    2438 VARIABLES
    2439 
    2440         INITIALIZATION  as InitializeStage      (Brief = "Column Model Initialization");
    2441        
    2442         in      LiquidInlet             as      stream                          (Brief="Liquid Inlet in the section", PosX=0.70, PosY=0);
    2443         out     VapourOutlet            as vapour_stream        (Brief="Vapour Outlet in the section", PosX=0.30, PosY=0);
    2444        
    2445         in              VapourInlet             as stream                               (Brief="Vapour Inlet in the section", PosX=0.30, PosY=1);
    2446         out     LiquidOutlet            as liquid_stream                (Brief="Liquid Outlet in the section", PosX=0.70, PosY=1);
    2447        
    2448         LiquidConnector as stream       (Brief="Liquid connection at the middle STAGES", PosX=0.75, PosY=1,Hidden=true);
    2449         VapourConnector as stream       (Brief="Vapour connection at the middle STAGES", PosX=0.55, PosY=0,Hidden=true);
    2450        
    2451         STAGES(NumberOfStages) as packedStage;
    2452         PressureDrop               as pressure;
    2453        
    2454 SET
    2455        
    2456         ColumnArea = 0.25*Pi*ColumnDiameter^2;
    2457         hs =PackingHeight/NumberOfStages;       
    2458         V = hs * ColumnArea;
    2459        
    2460 CONNECTIONS
    2461 
    2462         STAGES([2:NumberOfStages]).OutletVapour                 to STAGES([1:NumberOfStages-1]).InletVapour;
    2463         STAGES([1:NumberOfStages-1]).OutletLiquid       to STAGES([2:NumberOfStages]).InletLiquid;
    2464         LiquidConnector to STAGES(1).InletLiquid;
    2465         VapourConnector to STAGES(NumberOfStages).InletVapour;
    2466 
    2467 EQUATIONS
    2468 
    2469 "PresureDrop"
    2470         STAGES.deltaP = PressureDrop/NumberOfStages;
    2471 
    2472         LiquidConnector.F= LiquidInlet.F;
    2473         LiquidConnector.T = LiquidInlet.T;
    2474         LiquidConnector.P = LiquidInlet.P;
    2475         LiquidConnector.z = LiquidInlet.z;
    2476         LiquidConnector.v = LiquidInlet.v;
    2477         LiquidConnector.h = LiquidInlet.h;
    2478        
    2479         VapourConnector.F= VapourInlet.F;
    2480         VapourConnector.T = VapourInlet.T;
    2481         VapourConnector.P = VapourInlet.P;
    2482         VapourConnector.z = VapourInlet.z;
    2483         VapourConnector.v = VapourInlet.v;
    2484         VapourConnector.h = VapourInlet.h;
    2485        
    2486         LiquidOutlet.F= STAGES(NumberOfStages).OutletLiquid.F;
    2487         LiquidOutlet.T = STAGES(NumberOfStages).OutletLiquid.T;
    2488         LiquidOutlet.P = STAGES(NumberOfStages).OutletLiquid.P;
    2489         LiquidOutlet.z = STAGES(NumberOfStages).OutletLiquid.z;
    2490        
    2491         VapourOutlet.F= STAGES(1).OutletVapour.F;
    2492         VapourOutlet.T = STAGES(1).OutletVapour.T;
    2493         VapourOutlet.P = STAGES(1).OutletVapour.P;
    2494         VapourOutlet.z = STAGES(1).OutletVapour.z;
    2495 
    2496 for i in [1:NumberOfStages] do
    2497 
    2498 "Energy Balance"
    2499         diff(STAGES(i).E) = ( STAGES(i).Inlet.F*STAGES(i).Inlet.h + STAGES(i).InletLiquid.F*STAGES(i).InletLiquid.h + STAGES(i).InletVapour.F*STAGES(i).InletVapour.h- STAGES(i).OutletLiquid.F*STAGES(i).OutletLiquid.h
    2500         - STAGES(i).OutletVapour.F*STAGES(i).OutletVapour.h + HeatSupply );
    2501        
    2502 "Energy Holdup"
    2503         STAGES(i).E = STAGES(i).ML*STAGES(i).OutletLiquid.h + STAGES(i).MV*STAGES(i).OutletVapour.h - STAGES(i).OutletLiquid.P*V;
    2504        
    2505 "Geometry Constraint"
    2506         V*VoidFraction= STAGES(i).ML*STAGES(i).vL + STAGES(i).MV*STAGES(i).vV;
    2507        
    2508 "Volume flow rate of vapor, m^3/m^2/s"
    2509         #STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).OutletVapour.F * STAGES(i).vV;
    2510         STAGES(i).uV * ((ColumnArea)*VoidFraction - STAGES(i).Al) = STAGES(i).InletVapour.F * STAGES(i).vV;
    2511        
    2512 "Liquid holdup"
    2513         STAGES(i).hl = STAGES(i).ML*STAGES(i).vL/V/VoidFraction;
    2514        
    2515 "Particle diameter"
    2516         STAGES(i).dp = 6 * (1-VoidFraction)/AreaPerPackingVol;
    2517        
    2518 "Wall Factor"
    2519         STAGES(i).invK = (1 + (2*STAGES(i).dp/(3*ColumnDiameter*(1-VoidFraction))));
    2520        
    2521 "Reynolds number of the vapor stream"
    2522         STAGES(i).Rev*STAGES(i).invK = STAGES(i).dp*STAGES(i).uV*STAGES(i).rhoV / (STAGES(i).miV*(1-VoidFraction));
    2523        
    2524 "Pressure drop and Vapor flow"
    2525         STAGES(i).deltaP/hs  = ResistanceCoeff*AreaPerPackingVol*STAGES(i).uV^2*STAGES(i).rhoV*STAGES(i).invK / (2*(VoidFraction-STAGES(i).hl)^3);
    2526 
    2527 "Liquid holdup"
    2528         STAGES(i).hl = (12*STAGES(i).miL*AreaPerPackingVol^2*STAGES(i).uL/STAGES(i).rhoL/Gconst)^1/3;
    2529 
    2530 "Area occupied by the liquid"
    2531         STAGES(i).Al = STAGES(i).ML*STAGES(i).vL/hs;
    2532 
    2533 end
    2534 
    2535 INITIAL
    2536 
    2537 for i in 1:NumberOfStages do
    2538 
    2539 "The initial temperature of the STAGES"
    2540         STAGES(i).OutletLiquid.T = INITIALIZATION.TopStageTemperature+(INITIALIZATION.BottomStageTemperature-INITIALIZATION.TopStageTemperature)*((i-1)/(NumberOfStages-1));
    2541 
    2542 "The Liquid Holdup of the STAGES"
    2543         STAGES(i).ML = INITIALIZATION.LiquidMolarHoldup;
    2544 
    2545 end
    2546 
    2547 for i in 1:NComp-1 do
    2548        
    2549 for j in 1:NumberOfStages do
    2550 
    2551 "The initial composition of the TRAYS"
    2552         STAGES(j).OutletLiquid.z(i) = INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) +(INITIALIZATION.BottomStageComposition(i)/sum(INITIALIZATION.BottomStageComposition)-INITIALIZATION.TopStageComposition(i)/sum(INITIALIZATION.TopStageComposition) )*((j-1)/(NumberOfStages-1));
    2553 
    2554 end
    2555 
    2556 end
    2557 
    2558 end
    2559 
    2560 Model Packed_Section_Column     as Packed_Section_ColumnBasic
    2561 
    2562         ATTRIBUTES
    2563         Pallete         = true;
    2564         Icon            = "icon/PackedSectionColumn";
    2565         Brief           = "Model of a packed column section.";
    2566         Info            =
    2567 "== Model of a packed column section containing ==
    2568 * NStages theoretical stages.
    2569        
    2570 == Specify ==
    2571 * the feed stream of each tray (Inlet);
    2572 * the InletLiquid stream of the top tray;
    2573 * the InletVapour stream of the bottom tray;
    2574 * the total pressure drop (dP) of the section.
    2575        
    2576 == Initial Conditions ==
    2577 * the stages temperature (OutletLiquid.T);
    2578 * the stages liquid holdup;
    2579 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
    2580 ";
    2581 
    2582 SET
    2583         NumberOfFeeds = 1;
    2584 
    2585 VARIABLES
    2586        
    2587         in      FeedStage       as stream               (Brief="Feed stream", PosX=0, PosY=0.55);
    2588 
    2589 EQUATIONS
    2590 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2591 # Equating Feed Tray Variables to Trays Variables
    2592 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2593 for i in 1:NumberOfStages do
    2594 
    2595 if   i equal FeedStageLocation(1) then   
    2596 
    2597 "FeedTrayTop Inlet Flow"       
    2598         FeedStage.F= STAGES(i).Inlet.F;
    2599 
    2600 "FeedTrayTop Inlet Temperature"
    2601         FeedStage.T = STAGES(i).Inlet.T;
    2602 
    2603 "FeedTrayTop Inlet Pressure"
    2604         FeedStage.P = STAGES(i).Inlet.P;
    2605 
    2606 "FeedTrayTop Inlet Composition"
    2607         FeedStage.z = STAGES(i).Inlet.z;
    2608 
    2609 "FeedTrayTop Inlet Vapour Fraction"
    2610         FeedStage.v = STAGES(i).Inlet.v;
    2611 
    2612 "FeedTrayTop Inlet Enthalpy"
    2613         FeedStage.h = STAGES(i).Inlet.h;
    2614 
    2615 else
    2616 
    2617 "Inlet Tray - Flow Sealed"
    2618     0*'mol/h'= STAGES(i).Inlet.F;
    2619        
    2620 "Inlet Tray -  Temperature"
    2621     300*'K' = STAGES(i).Inlet.T;
    2622        
    2623 "Inlet Tray -  Pressure"
    2624     1*'atm' = STAGES(i).Inlet.P;
    2625        
    2626 "Inlet Tray -  Composition"
    2627     0.1 = STAGES(i).Inlet.z;
    2628        
    2629 "Inlet Tray -  Vapour Fraction"
    2630     0 = STAGES(i).Inlet.v;
    2631        
    2632 "Inlet Tray -  Enthalpy"
    2633     0*'J/mol' = STAGES(i).Inlet.h;
    2634 
    2635 end
    2636 
    2637 end
    2638 
    2639 end
    2640 
    2641 Model Packed_Section_Column2    as Packed_Section_ColumnBasic
    2642 
    2643         ATTRIBUTES
    2644         Pallete         = true;
    2645         Icon            = "icon/PackedSectionColumn";
    2646         Brief           = "Model of a packed column section.";
    2647         Info            =
    2648 "== Model of a packed column section containing ==
    2649 * NStages theoretical stages.
    2650        
    2651 == Specify ==
    2652 * the feed stream of each tray (Inlet);
    2653 * the InletLiquid stream of the top tray;
    2654 * the InletVapour stream of the bottom tray;
    2655 * the total pressure drop (dP) of the section.
    2656        
    2657 == Initial Conditions ==
    2658 * the stages temperature (OutletLiquid.T);
    2659 * the stages liquid holdup;
    2660 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each tray.
    2661 ";
    2662 
    2663 SET
    2664         NumberOfFeeds = 2;
    2665 
    2666 VARIABLES
    2667        
    2668         in      FeedStageOne    as stream               (Brief="Feed stream", PosX=0, PosY=0.45);
    2669         in      FeedStageTwo    as stream               (Brief="Feed stream", PosX=0, PosY=0.65);
    2670 
    2671 EQUATIONS
    2672 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2673 # Equating Feed Stage Variables to Stages Variables
    2674 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2675 
    2676 for i in 1:NumberOfStages do
    2677 
    2678 if   i equal FeedStageLocation(1) then   
    2679 
    2680 "FeedTrayTop Inlet Flow"       
    2681         FeedStageOne.F= STAGES(i).Inlet.F;
    2682 
    2683 "FeedTrayTop Inlet Temperature"
    2684         FeedStageOne.T = STAGES(i).Inlet.T;
    2685 
    2686 "FeedTrayTop Inlet Pressure"
    2687         FeedStageOne.P = STAGES(i).Inlet.P;
    2688 
    2689 "FeedTrayTop Inlet Composition"
    2690         FeedStageOne.z = STAGES(i).Inlet.z;
    2691 
    2692 "FeedTrayTop Inlet Vapour Fraction"
    2693         FeedStageOne.v = STAGES(i).Inlet.v;
    2694 
    2695 "FeedTrayTop Inlet Enthalpy"
    2696         FeedStageOne.h = STAGES(i).Inlet.h;
    2697 
    2698 else if   i equal FeedStageLocation(2) then   
    2699 
    2700 "FeedTrayBottom Inlet Flow"     
    2701         FeedStageTwo.F= STAGES(i).Inlet.F;
    2702 
    2703 "FeedTrayBottom Inlet Temperature"
    2704         FeedStageTwo.T = STAGES(i).Inlet.T;
    2705 
    2706 "FeedTrayBottom Inlet Pressure"
    2707         FeedStageTwo.P = STAGES(i).Inlet.P;
    2708 
    2709 "FeedTrayBottom Inlet Composition"
    2710         FeedStageTwo.z = STAGES(i).Inlet.z;
    2711 
    2712 "FeedTrayBottom Inlet Vapour Fraction"
    2713         FeedStageTwo.v = STAGES(i).Inlet.v;
    2714 
    2715 "FeedTrayBottom Inlet Enthalpy"
    2716         FeedStageTwo.h = STAGES(i).Inlet.h;
    2717 
    2718 else
    2719 
    2720 "Inlet Tray - Flow Sealed"
    2721     0*'mol/h'= STAGES(i).Inlet.F;
    2722        
    2723 "Inlet Tray -  Temperature"
    2724     300*'K' = STAGES(i).Inlet.T;
    2725        
    2726 "Inlet Tray -  Pressure"
    2727     1*'atm' = STAGES(i).Inlet.P;
    2728        
    2729 "Inlet Tray -  Composition"
    2730     0.1 = STAGES(i).Inlet.z;
    2731        
    2732 "Inlet Tray -  Vapour Fraction"
    2733     0 = STAGES(i).Inlet.v;
    2734        
    2735 "Inlet Tray -  Enthalpy"
    2736     0*'J/mol' = STAGES(i).Inlet.h;
    2737 
    2738 end
    2739 
    2740 end
    2741 
    2742 end
    2743 
    2744 end
    2745 
    2746 Model PackedDistillation_kettle_cond as Packed_Section_ColumnBasic
    2747         ATTRIBUTES
    2748         Pallete         = true;
    2749         Icon            = "icon/PackedDistillationKettleCond";
    2750         Brief           = "Model of a distillation column with dynamic condenser and dynamic reboiler.";
    2751         Info            =
    2752 "== Specify ==
    2753 * the feed stream of each tray (Inlet);
    2754 * the pump pressure difference;
    2755 * the total pressure drop (dP) of the packing;
    2756 * the heat supllied in reboiler and condenser;
    2757 * the condenser vapor outlet flow (OutletVapour.F);
    2758 * the reboiler liquid outlet flow (OutletLiquid.F);
    2759 * both splitter outlet flows OR one of the splitter outlet flows and the splitter frac.
    2760        
    2761 == Initial Conditions ==
    2762 * the stages temperature (OutletLiquid.T);
    2763 * the stages initial molar holdup;
    2764 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions for each stage;
    2765        
    2766 * the condenser temperature (OutletLiquid.T);
    2767 * the condenser liquid level (Level);
    2768 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions;
    2769        
    2770 * the reboiler temperature (OutletLiquid.T);
    2771 * the reboiler liquid level (Level);
    2772 * (NoComps - 1) OutletLiquid (OR OutletVapour) compositions.
    2773 ";
    2774        
    2775 PARAMETERS
    2776 
    2777         VapourFlow as Switcher  (Valid = ["on", "off"], Hidden = true ,Default = "on");
    2778        
    2779 VARIABLES
    2780 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2781 # Column Devices
    2782 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
    2783         CONDENSER       as condenser    (Brief="dymamic condenser");
    2784         REBOILER        as reboiler             (Brief="kettle reboiler");
    2785         SPLITTER        as splitter2            (Brief="splitter which separate reflux and distillate");
    2786         PUMP            as pump                 (Brief="pump in reflux stream");
    2787 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2788 # Heat Ports
    2789 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
    2790         in      HeatToReboiler  as power (Brief="Heat supplied to Reboiler",Protected = true, PosX=1, PosY=0.885);
    2791         in      HeatToCondenser as power (Brief="Heat supplied to Condenser", Protected = true, PosX=1, PosY=0.034);
    2792 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2793 # Column Products
    2794 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
    2795         out     VapourDistillate        as vapour_stream        (Brief="Vapour outlet stream From Top Condenser", PosX=0.66, PosY=0);
    2796         out     LiquidDistillate        as liquid_stream        (Brief="Liquid outlet stream From Top Splitter", PosX=1, PosY=0.20);
    2797         out     BottomProduct           as liquid_stream        (Brief="Liquid outlet stream From Reboiler", PosX=0.68, PosY=1);
    2798 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2799 # Column Connectors
    2800 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
    2801         in      ConnectorCondenserVout  as stream       (Brief="Connector for Vapour outlet stream From Top Condenser", Hidden=true);
    2802         in      ConnectorSplitterOut    as stream       (Brief="Connector for Liquid outlet stream From Top Splitter", Hidden=true);
    2803         in      ConnectorReboilerLout   as stream       (Brief="Connector for Liquid outlet stream From Reboiler", Hidden=true);
    2804                 ConnectorHeatReboiler   as power        (Brief="Heat supplied to Reboiler", Hidden=true);
    2805                 ConnectorHeatCondenser  as power        (Brief="Heat supplied to Condenser", Hidden=true);
    2806 
    2807 CONNECTIONS
    2808 
    2809 #vapor
    2810         REBOILER.OutletVapour           to STAGES(NumberOfStages).InletVapour;
    2811         STAGES(1).OutletVapour          to CONDENSER.InletVapour;
    2812 
    2813 #liquid
    2814         CONDENSER.OutletLiquid                          to SPLITTER.Inlet;     
    2815         SPLITTER.Outlet2                                to PUMP.Inlet;
    2816         PUMP.Outlet                                     to STAGES(1).InletLiquid;
    2817         STAGES(NumberOfStages).OutletLiquid     to REBOILER.InletLiquid;
    2818 
    2819 #Connectors
    2820 ConnectorHeatReboiler   to REBOILER.InletQ;
    2821 ConnectorHeatCondenser  to CONDENSER.InletQ;
    2822 
    2823 CONDENSER.OutletVapour          to ConnectorCondenserVout;
    2824 SPLITTER.Outlet1                to ConnectorSplitterOut;
    2825 REBOILER.OutletLiquid           to ConnectorReboilerLout;
    2826 
    2827 EQUATIONS
    2828         HeatToReboiler  = ConnectorHeatReboiler;
    2829         HeatToCondenser = ConnectorHeatCondenser;
    2830        
    2831 # Condenser Connector Equations
    2832         ConnectorCondenserVout.T = VapourDistillate.T;
    2833         ConnectorCondenserVout.P = VapourDistillate.P;
    2834         ConnectorCondenserVout.F = VapourDistillate.F;
    2835         ConnectorCondenserVout.z = VapourDistillate.z;
    2836 
    2837 # Splitter Connector Equations
    2838         ConnectorSplitterOut.T = LiquidDistillate.T;
    2839         ConnectorSplitterOut.P = LiquidDistillate.P;
    2840         ConnectorSplitterOut.F = LiquidDistillate.F;
    2841         ConnectorSplitterOut.z = LiquidDistillate.z;
    2842 
    2843 # Reboiler Connector Equations
    2844         ConnectorReboilerLout.T = BottomProduct.T;
    2845         ConnectorReboilerLout.P = BottomProduct.P;
    2846         ConnectorReboilerLout.F = BottomProduct.F;
    2847         ConnectorReboilerLout.z = BottomProduct.z;
    2848 
    2849 end
    2850 
  • branches/gui/eml/stage_separators/tray.mso

    r735 r849  
    298298";     
    299299       
     300       
    300301PARAMETERS
    301302
    302303outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
    303304outer NComp as Integer;
    304 
    305         PPwater as Plugin(Brief="Physical Properties",Type="PP",Components = [ "water" ],
    306                 LiquidModel = "PR",
    307                 VapourModel = "PR"
    308         );
    309        
     305#*     
     306outer ColumnDiameter            as length               (Brief="Column diameter");
     307outer AreaPerPackingVol as Real (Brief="Surface area per packing volume", Unit='m^2/m^3');
     308outer VoidFraction as fraction (Brief="Void fraction of packing, m^3/m^3");
     309outer hs as length (Brief="Height of the packing stage");
     310outer ResistanceCoeff as positive (Brief="Resistance coefficient on the liquid load", Default = 0.6);
     311*#
     312        ColumnDiameter          as length               (Brief="Column diameter");
     313        AreaPerPackingVol as Real (Brief="Surface area per packing volume", Unit='m^2/m^3');
     314        VoidFraction as fraction (Brief="Void fraction of packing, m^3/m^3");
     315        hs as length (Brief="Height of the packing stage");
     316        ResistanceCoeff as positive (Brief="Resistance coefficient on the liquid load", Default = 0.6);
     317
     318        V as volume (Brief="Total volume of the tray");
     319        HeatSupply      as heat_rate    (Brief="Rate of heat supply");
     320        Gconst          as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
    310321        Mw(NComp)       as molweight    (Brief = "Component Mol Weight");
     322        VapourFlow as Switcher (Valid=["on", "off"], Default = "on");
     323       
    311324       
    312325VARIABLES
    313326
    314327        Inlet                   as stream                               (Brief="Feed stream", PosX=0, PosY=0.4932, Symbol="_{in}");
    315 in      InletLiquid                     as stream                               (Brief="Inlet liquid stream", PosX=0.5195, PosY=0, Symbol="_{inL}");
    316 in      InletVapour                     as stream                               (Brief="Inlet vapour stream", PosX=0.4994, PosY=1, Symbol="_{inV}");
     328
     329in      InletLiquid     as stream                               (Brief="Inlet liquid stream", PosX=0.5195, PosY=0, Symbol="_{inL}");
     330in      InletVapour     as stream                               (Brief="Inlet vapour stream", PosX=0.4994, PosY=1, Symbol="_{inV}");
    317331out     OutletLiquid    as liquid_stream        (Brief="Outlet liquid stream", PosX=0.8277, PosY=1, Symbol="_{outL}");
    318332out     OutletVapour    as vapour_stream        (Brief="Outlet vapour stream", PosX=0.8043, PosY=0, Symbol="_{outV}");
     
    326340       
    327341        miL as viscosity (Brief="Liquid dynamic viscosity", DisplayUnit='kg/m/s');
    328         miV as viscosity (Brief="Vapor dynamic viscosity", DisplayUnit='kg/m/s');
     342#       miV as viscosity (Brief="Vapor dynamic viscosity", DisplayUnit='kg/m/s');
    329343        rhoL as dens_mass;
    330344        rhoV as dens_mass;
    331345       
    332         deltaP as pressure;
    333        
    334         uL as velocity (Brief="volume flow rate of liquid, m^3/m^2/s", Lower=-10, Upper=100);
    335         uV as velocity (Brief="volume flow rate of vapor, m^3/m^2/s", Lower=-10, Upper=100);
    336         dp as length (Brief="Particle diameter", Default=1e-3, Lower=0, Upper=10);
    337         invK as positive (Brief="Wall factor", Default=1, Upper=10);
    338         Rev as Real (Brief="Reynolds number of the vapor stream", Default=4000);
    339         Al as area (Brief="Area occupied by the liquid", Default=0.001, Upper=1);
    340         hl as positive (Brief="Column holdup", Unit='m^3/m^3', Default=0.01,Upper=10);
     346        deltaP as pressure (Lower = -10);
     347       
     348        uL as velocity (Brief="volume flow rate of liquid, m^3/m^2/s", Lower=0, Upper=100);
     349        uV as velocity (Brief="volume flow rate of vapor, m^3/m^2/s", Lower=-0, Upper=100);
     350        #dp as length (Brief="Particle diameter", Default=1e-3, Lower=0, Upper=10);
     351        #invK as positive (Brief="Wall factor", Default=1, Upper=10);
     352        #Rev as Real (Brief="Reynolds number of the vapor stream", Default=4000);
     353        Al as area (Brief="Area occupied by the liquid", Default=0.001, Upper=10);
     354        hl as positive (Brief="Column holdup", Unit='m^3/m^3', Default=0.04,Upper=1);
     355
    341356
    342357SET
    343358        Mw = PP.MolecularWeight();
    344359
     360
    345361EQUATIONS
    346362
     
    348364        diff(M)=Inlet.F*Inlet.z + InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
    349365
     366"Energy Balance"
     367    diff(E) = ( Inlet.F*Inlet.h + InletLiquid.F*InletLiquid.h + InletVapour.F*InletVapour.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + HeatSupply);
     368
    350369"Molar Holdup"
    351370        M = ML*OutletLiquid.z + MV*OutletVapour.z;
    352371       
     372"Energy Holdup"
     373    E = ML*OutletLiquid.h + MV*OutletVapour.h - OutletLiquid.P*V;       
     374       
    353375"Mol fraction normalisation"
    354376        sum(OutletLiquid.z)= 1.0;
     377        sum(OutletLiquid.z)=sum(OutletVapour.z);
    355378       
    356379"Liquid Volume"
     
    369392        OutletLiquid.P = OutletVapour.P;
    370393       
     394"Geometry Constraint"
     395    V*VoidFraction = ML*vL + MV*vV;
     396
    371397"Liquid Density"
    372398        rhoL = PP.LiquidDensity(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
     
    378404        miL = PP.LiquidViscosity(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
    379405
    380 "Vapour viscosity"
    381         miV = PP.VapourViscosity(InletVapour.T, InletVapour.P, InletVapour.z);
     406#"Vapour viscosity"
     407#       miV = PP.VapourViscosity(InletVapour.T, InletVapour.P, InletVapour.z);
     408
     409"Area occupied by the liquid"
     410        Al = ML*vL/hs;
    382411
    383412"Volume flow rate of liquid, m^3/m^2/s"
    384413        uL * Al = OutletLiquid.F * vL;
    385414       
    386         deltaP = InletVapour.P - OutletVapour.P;
     415"Volume flow rate of vapour, m^3/m^2/s"
     416        uV * (V*VoidFraction/hs - Al) = InletVapour.F * vV;
     417       
     418"Liquid holdup"
     419    hl*V*VoidFraction = ML*vL;
     420
     421"Liquid velocity as a function of liquid holdup, Billet (4-27)"
     422        hl^3 = (12/Gconst) * AreaPerPackingVol^2 * (miL/rhoL) * uL;
     423               
     424        switch VapourFlow
     425                case "on":
     426                        "Pressure drop and Vapor flow, Billet (4-58)"
     427                                deltaP/hs  = ResistanceCoeff * (AreaPerPackingVol/2 + 2/ColumnDiameter) * 1/((VoidFraction-hl)^3) * (uV^2) * rhoV;
     428   
     429            when InletVapour.F < 1e-6 * 'kmol/h' switchto "off";
     430
     431
     432        case "off":
     433                        InletVapour.F = 0 * 'mol/s';
     434                        when deltaP > 1e-4 * 'atm' switchto "on";
     435    end
     436       
     437"Pressure profile"
     438    deltaP = InletVapour.P - OutletVapour.P;
    387439       
    388440end
Note: See TracChangeset for help on using the changeset viewer.