Heat Pump Optimization Problem

Main.MilkPasteurization History

Show minor edits - Show changes to output

May 02, 2021, at 07:05 PM by 10.35.117.248 -
Changed line 48 from:
#Inlet temperature (degC)
to:
# Inlet temperature (degC)
Changed line 51 from:
#Outlet temperature (degC)
to:
# Outlet temperature (degC)
Changed line 54 from:
#Pasteurization Temperature (degC), target temperature
to:
# Pasteurization Temperature (degC), target temperature
Changed lines 57-59 from:
#  Variables

#compressor work (kW)
to:
# Variables
# compressor work (kW)
Changed line 61 from:
#heat exchanger areas (m^2)
to:
# heat exchanger areas (m^2)
Changed lines 67-71 from:
t1 = m.Var(value = ti)            #Temperature 1 (degC)
t2 = m.Var(value = ti)            #Temperature 2 (degC)
te = m.Var(value = ti)            #Evaporator Temperature (degC)
tc = m.Var(value = ti)            #Condenser Temperature (degC)
Ctot = m.Var(value = 100000)      #Total Cost
to:
t1 = m.Var(value = ti)            # Temperature 1 (degC)
t2 = m.Var(value = ti)            # Temperature 2 (degC)
te = m.Var(value = ti)            # Evaporator Temperature (degC)
tc = m.Var(value = ti)            # Condenser Temperature (degC)
Ctot = m.Var(value = 100000)      # Total Cost
May 02, 2021, at 07:04 PM by 10.35.117.248 -
Changed lines 36-37 from:
# exchanger), size of the compressor, and temperatures t1, t2, te and tc
# that result in the minimum total cost
to:
#  exchanger), size of the compressor, and temperatures t1, t2, te and tc
#  that result in the minimum total cost
May 02, 2021, at 07:04 PM by 10.35.117.248 -
Changed lines 35-37 from:
#  areas of the heat exchangers (evaporator, condensers, and regenerative exchanger),
size of the compressor, and temperatures t1, t2, te and tc that result in the
#  minimum total costOptimize
to:
#  areas of the heat exchangers (evaporator, condensers, and regenerative
# exchanger), size of the compressor, and temperatures t1, t2, te and tc
#
that result in the minimum total cost
May 02, 2021, at 07:03 PM by 10.35.117.248 -
Added line 16:
Added lines 18-212:

----

'''Solution Help'''

%width=150px%Attach:gekko.png

See [[https://gekko.readthedocs.io/en/latest/|GEKKO documentation]] and [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|additional example problems]].

(:source lang=python:)
from gekko import GEKKO

#  Initialize Gekko model
m = GEKKO()

# Optimal heat pump and regenerative exchanger that minimizes the total present
#  worth of costs (capital cost and operating cost). Specifically, determine the
#  areas of the heat exchangers (evaporator, condensers, and regenerative exchanger),
#  size of the compressor, and temperatures t1, t2, te and tc that result in the
#  minimum total costOptimize

# Parameters
U = 0.6
Ureg = 0.5
mdotm = 4
cpm = 3.75
cpw = 1.00
intrate = 0.09
nper = 6

#Inlet temperature (degC)
ti = 7             

#Outlet temperature (degC)
to = 4

#Pasteurization Temperature (degC), target temperature
tp = 73

#  Variables

#compressor work (kW)
W = m.Var()

#heat exchanger areas (m^2)
Ae = m.Var(value = 10, lb = 1.0, ub = 1000)
Areg = m.Var(value = 10, lb = 1.0, ub = 1000)
Afc = m.Var(value = 10, lb = 1.0, ub = 1000)
Aac = m.Var(value = 10, lb = 1.0, ub = 1000)

t1 = m.Var(value = ti)            #Temperature 1 (degC)
t2 = m.Var(value = ti)            #Temperature 2 (degC)
te = m.Var(value = ti)            #Evaporator Temperature (degC)
tc = m.Var(value = ti)            #Condenser Temperature (degC)
Ctot = m.Var(value = 100000)      #Total Cost

# evaporator
Qe  = m.Var(value = 1)
dapp1e = m.Var(value = 1)
dapp2e = m.Var(value = 1)

# regenerative heat exchanger
Qreg = m.Var(value = 1)
dapp1reg = m.Var(value = 1)
dapp2reg = m.Var(value = 1)

# fore condenser
Qfc = m.Var(value = 1)
dapp1fc = m.Var(value = 1)
dapp2fc = m.Var(value = 1)

# after condenser
Qac = m.Var(value = 1)
dapp1ac = m.Var(value = 1)
dapp2ac = m.Var(value = 1)

# temps of approach
dappe = m.Var(lb = 0.1)    # >= 10
dappc = m.Var(lb = 0.1)    # >= 10
dappreg1 = m.Var(lb = 0.1)  # >= 10
dappreg2 = m.Var(lb = 0.1)  # >= 10

# ratios
ratio_e = m.Var(value = .05, lb = 0.001, ub = 0.999)
ratio_reg = m.Var(value = .05, lb = 0.000, ub = 1.0)
ratio_fc = m.Var(value = .05, lb = 0.001, ub = 0.999)
ratio_ac = m.Var(value = .05, lb = 0.001, ub = 0.999)

# Log-mean temperature differences
delte = m.Var(value = 1)
deltreg = m.Var(value = 1)
deltfc = m.Var(value = 1)
deltac = m.Var(value = 1)
 
# Coefficient Of Performance
COP = m.Var(value = 1)

# Intermediates
# Cost elec year at 4 hours per day
Celyear= m.Intermediate(W * 4.0 * 365.0 * 0.07)

# Cost total over time
# Multiplier is about 4.5 (instead of 6.0) because of the
# interest rate on unspent capital
mult = m.Intermediate((((1.0+intrate)**nper)-1.0) / (intrate*(1.0+intrate)**nper))
Celtot = m.Intermediate(Celyear * mult)

# Cost equipment
Cequip = m.Intermediate(Ae*200.0 +  Afc*200.0 + Aac*200.0 + Areg*200 + W*240.0)

#temperatures in Kelvin
TeK = m.Intermediate(te + 273)
TcK = m.Intermediate(tc + 273)

# Equations
m.Equations([
    # Total cost
    Ctot == Celtot + Cequip,
   
    # overall energy balance on regen heat exchanger
    # mdotm and cpm cancel from each term
    t1 + t2 == tp + ti,
   
    # log-mean temperature difference
    #  lmtd(thi,tco,tho,tci)
   
    # evaporator
    Qe == mdotm * cpm *(t2 - to),
    dapp1e == to - te,
    dapp2e == t2 - te,

    # regenerative heat exchanger
    Qreg == mdotm * cpm * (tp-t2),
    dapp1reg == t2 - ti,
    dapp2reg == tp - t1,

    # fore condenser
    Qfc == mdotm * cpm * (tp - t1),
    dapp1fc == tc - tp,
    dapp2fc == tc - t1,

    # after condenser
    Qac == W + mdotm * cpm * (ti - to),
    dapp1ac == tc - 35.0,
    dapp2ac == tc - 30.0,

    # approach temperatures
    dappe == to - te,        # Temp app evap
    dappc == tc - tp,        # Temp app fore cond
    dappreg1 == t2 - ti,      # Temp app reg1
    dappreg2 == tp - t1,      # Temp app reg2

    # ratios
    ratio_e  * dapp2e  == dapp1e,
    ratio_reg * dapp2reg == dapp1reg,
    ratio_fc  * dapp2fc  == dapp1fc,
    ratio_ac  * dapp2ac  == dapp1ac,
   
    # Log-mean Temperature Difference
    delte  * m.log(ratio_e)  == (dapp1e - dapp2e),
    #deltreg * m.log(ratio_reg) = (dapp1reg - dapp2reg)
    deltfc  * m.log(ratio_fc)  == (dapp1fc - dapp2fc),
    deltac  * m.log(ratio_ac)  == (dapp1ac - dapp2ac),
   
    # Average temperature difference
    #delte    = (dapp1e  + dapp2e)  / 2
    deltreg  == (dapp1reg + dapp2reg) / 2,
    #deltfc  = (dapp1fc  + dapp2fc)  / 2
    #deltac  = (dapp1ac  + dapp2ac)  / 2
   
    # coefficient of performance
    # 75% of Carnot Efficiency
    COP * (TcK-TeK) == 0.75 * TeK,
   
    # Work to compressor
    W * COP == Qe,
   
    # heat transferred for each exchanger
    Ae  * U    * delte  == Qe,
    Areg * Ureg * deltreg == Qreg,
    Afc  * U    * deltfc  == Qfc,
    Aac  * U    * deltac  == Qac
    ])

# objective function
m.Obj(Ctot)

# minimize ctot
m.options.SOLVER = 1
m.options.IMODE = 3

m.solve()

print('Minimum cost: ' + str(Ctot[0]))
(:sourceend:)
June 21, 2020, at 04:43 AM by 136.36.211.159 -
Deleted lines 16-34:

----

(:html:)
 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
January 11, 2013, at 02:20 PM by 69.169.188.188 -
Changed lines 16-35 from:
Attach:group50.png This assignment can be completed in groups of two. Additional guidelines on individual, collaborative, and group assignments are provided under the [[Main/CourseStandards | Expectations link]].
to:
Attach:group50.png This assignment can be completed in groups of two. Additional guidelines on individual, collaborative, and group assignments are provided under the [[Main/CourseStandards | Expectations link]].

----

(:html:)
 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
December 31, 2012, at 08:57 PM by 128.187.97.21 -
Deleted line 9:
Deleted line 10:
December 31, 2012, at 08:42 PM by 128.187.97.21 -
Added lines 1-18:
(:title Heat Pump Optimization Problem:)
(:keywords heat pump, nonlinear, optimization, engineering optimization, two-bar optimization, engineering design, interior point, active set, differential, algebraic, modeling language, university course:)
(:description Engineering design and optimization of a heat pump system for pasteurization of milk. Optimization principles are used to design the system.:)

In the pasteurization of milk the temperature is raised to 73°C, held for 20 sec., and then cooled. The milk arrives at a temperature of 7°C and is delivered from the pasteurizing process for packaging at a temperature of 4°C.

We will consider using a heat pump with a regenerative heat exchanger to do this. One possible cycle is shown in the figure below. The incoming milk is preheated in a regenerative heat exchanger and then heated further in the fore-condenser of the heat pump. As it exits the fore-condenser, the temperature of the milk is 73°C. Thereafter the milk is cooled as it flows through the other side of the regenerative heat exchanger and then through the evaporator of the heat pump.
 
[[Attach:heat_pump.pdf | Full Heat Pump Assignment]]

Attach:heat_pump.png

Find the optimal heat pump and regenerative exchanger that minimizes the total present worth of costs (capital cost and operating cost). Specifically, determine the areas of the heat exchangers (evaporator, condensers, and regenerative exchanger), size of the compressor, and temperatures t'_1_', t'_2_', t'_e_' and t'_c_' that result in the minimum total cost. Run the problem with no constraints on temperatures of approach (Case 1); then rerun with constraints that all temperatures of approach (evaporator, condensers, regenerative heat exchanger) are at least 10 °C (Case 2).

This problem is based on a problem from W. Stoecker, Design of Thermal Systems, 3rd ed.

----
Attach:group50.png This assignment can be completed in groups of two. Additional guidelines on individual, collaborative, and group assignments are provided under the [[Main/CourseStandards | Expectations link]].