Esempio n. 1
0
 def __init__(self,inlet,mdot):
     import ammonia_props
     amm = ammonia_props.AmmoniaProps()
     
     self.inlet = inlet
     self.mdot = mdot
     
     liquid = amm.props2(P = inlet.P, x = inlet.x, Qu = 0)
     vapor = amm.props2(P = inlet.P, x = inlet.x, Qu = 1)
     if liquid.T == vapor.T:
         pass
         #q,T = self._q, self.T
     # Determine what enthalpy to give at saturation temperature, since
     # at saturation temperature, rounding depends whether
     # the user intends heating or cooling.
     if inlet.h < liquid.h:
         self.h_sat = liquid.h
     elif inlet.h > vapor.h:
         self.h_sat = vapor.h
     else:
         self.h_sat = inlet.h
     
     Tmin,Tmax = 200,400
     minstate = amm.props2(P = inlet.P, x = inlet.x, T = Tmin)
     maxstate = amm.props2(P = inlet.P, x = inlet.x, T = Tmax)
     h_min,h_max = minstate.h, maxstate.h
     q_points = []
     T_points = []
     for h in np.linspace(h_min, h_max):
         q_points.append(mdot * (h - inlet.h))
         state = amm.props2(P = inlet.P, x = inlet.x, h = h)
         T_points.append(state.T)
     self.q = scipy.interpolate.PchipInterpolator(T_points, q_points)
     self.T = scipy.interpolate.PchipInterpolator(q_points, T_points)
Esempio n. 2
0
def residualsAmmonia(T,P,x,deltaT=1e-4,deltaP=1e-4):
    myprops = ammonia_props.AmmoniaProps()
    f1 = myprops.props(123)
    state1 = f1(T,P,x)
    state2 = f1(T,P+deltaP,x)
    state3 = f1(T+deltaT,P,x)
    dhdp_T = (state2.h - state1.h) / deltaP
    dvdT_p = (state3.v - state1.v) / deltaT
    a = dhdp_T - (state1.v - T * dvdT_p)
    cp = f1.massSpecificHeat(T=T, P=P, x=x)
    dhdT_p = (state3.h - state1.h) / deltaT
    b = dhdT_p - cp
    print(state1)
    print(state2)
    print(state3)
    print("a = {}. b = {}".format(a,b))
    return a,b
Esempio n. 3
0
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 18 14:42:55 2015

@author: nfette
"""
from __future__ import print_function
import ammonia_props
from hw2_1 import CelsiusToKelvin as C2K

if __name__ == "__main__":
    print("(a) Mixture properties from TPx:")
    myprops = ammonia_props.AmmoniaProps()
    f1 = myprops.props('TPx')
    T, P, x = C2K(50.), 10., 0.0  # K, bar, dim
    state = f1(T, P, x)
    print(state)
    print(f1.getOutputUnits())

    print("(b) ... in molar units:")
    Meff = state.molarMass()
    hbar = state.h * Meff
    print("Meff = {} kg/kmol".format(Meff))
    print("hbar = {} kJ/kmol".format(hbar))

    print("(c) Partial component enthalpies")
    dhdx = f1.dhdxetc(T=T, P=P, x=x)
    print("{} kJ/kg".format(dhdx))

    print("(d) Enthalpy of mixing")
    x = state.x
Esempio n. 4
0
import numpy
import matplotlib.pyplot as plt
import ammonia_props
amm = ammonia_props.AmmoniaProps()

P0 = 1.0
x_range = numpy.linspace(0, 1, 101)
p_min = numpy.empty_like(x_range)
p_min.fill(numpy.nan)
t_out = p_min.copy()
for i, x in enumerate(x_range):
    try:
        P = P0
        for j in range(20):
            state = amm.props2(x=x, P=P, Qu=0)
            P *= 0.8
    except:
        pass
    p_min[i] = P
    t_out[i] = state.T

plt.figure()
plt.plot(x_range, p_min)
plt.figure()
plt.plot(x_range, t_out)

plt.show()