Skip to content
Permalink
3618e19338
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
171 lines (118 sloc) 4.01 KB
"""
Authors:
Dominic Keeler, keeler0@purdue.edu
Noah Strawhacker, nstrawha@purdue.edu
Eddie Sun, sun1271@purdue.edu
Sam Norwood, snorwoo@purdue.edu
Description:
The following code determines the energy and mass change as fluid passes through
each component of the system.
"""
"""--------------- Imports ---------------"""
from math import pi, sqrt
"""--------------- Energy functions ---------------"""
def pumpEnergy(eOut, np):
# eIn = energy in
# np = pump loss coeff.
# eLost = energy lost
# eOut = energy out
eLost = eOut / (1 / (1 - np) - 1)
eIn = eOut + eLost
return(eIn)
def pipeEnergy(eIn, m, f, L, d):
# eIn = energy in
# p = fluid density
# m = mixture mass
# Q = volumetric flow rate
# t = time
# f = friction coeff.
# L = pipe length
# d = pipe diameter
# Elost = energy lost
# Eout = energy out
Q = EToQ(eIn, d, m)
eLost = m * (f * 8 * Q**2 * L) / (pi**2 * d**5)
eOut = eIn - eLost
return(eOut)
def valveEnergy(eIn, m, K, d):
# eIn = energy in
# p = fluid density
# m = mixture mass
# Q = volumetric flow rate
# t = time
# K = loss coeff.
# r = radius
# eLost = energy lost
# eOut = energy out
Q = EToQ(eIn, d, m)
eLost = m * (Q**2 * K) / (2 * (2 * pi * (d/2))**2)
eOut = eIn - eLost
return(eOut)
def bendEnergy(eIn, m, E, d):
# eIn = energy in
# p = fluid density
# m = mixture mass
# Q = volumetric flow rate
# t = time
# E = loss coeff.
# r = radius
# eLost = energy lost
# eOut = energy out
Q = EToQ(eIn, d, m)
eLost = m * (E * (Q / (pi * (d / 2)**2))**2) / 2
eOut = eIn - eLost
return(eOut)
# convert the needed energy into the needed flow rate
def EToQ(E, d, m):
# eOut = needed energy out
# d = pipe/valve/bend diameter
# m = mixture mass
# Q = resulting flow rate out
Q = (pi * (d / 2)**2) * sqrt(E / (0.5 * m))
return(Q)
# convert the needed flow rate into needed energy
def QToE(Q, d, m):
# eOut = needed energy out
# d = pipe/valve/bend diameter
# m = mixture mass
# Q = resulting flow rate out
E = 0.5 * m * (Q / (pi * (d / 2)**2))**2
return(E)
"""--------------- Mass functions ---------------"""
def fermentationMass(massIn, eff):
# all quantities are time derivatives in kg/s
sugarIn = 0.2 * massIn
fiberIn = 0.2 * massIn
waterIn = 0.6 * massIn
sugarOut = sugarIn * (1 - eff)
fiberOut = fiberIn
waterOut = waterIn
ethanolOut = 0.51 * sugarIn * eff
CO2Waste = 0.49 * sugarIn * eff
return(sugarOut, fiberOut, waterOut, ethanolOut, CO2Waste)
def filtrationMass(sugarIn, fiberIn, waterIn, ethanolIn, eff):
# all quantities are time derivatives in kg/s
sugarOut = sugarIn
fiberOut = fiberIn * (1 - eff)
waterOut = waterIn
ethanolOut = ethanolIn
fiberWaste = fiberIn * eff
return(sugarOut, fiberOut, waterOut, ethanolOut, fiberWaste)
def distillationMass(sugarIn, fiberIn, waterIn, ethanolIn, eff):
# all quantities are time derivatives in kg/s
sugarOut = (sugarIn * ethanolIn * ((1 / eff) - 1)) / (waterIn + sugarIn + fiberIn)
fiberOut = (fiberIn * ethanolIn * ((1 / eff) - 1)) / (waterIn + sugarIn + fiberIn)
waterOut = (waterIn * ethanolIn * ((1 / eff) - 1)) / (waterIn + sugarIn + fiberIn)
ethanolOut = ethanolIn
sugarWaste = sugarIn - sugarOut
fiberWaste = fiberIn - fiberOut
waterWaste = waterIn - waterOut
return(sugarOut, fiberOut, waterOut, ethanolOut, sugarWaste, fiberWaste, waterWaste)
def dehydrationMass(sugarIn, fiberIn, waterIn, ethanolIn, eff):
# all quantities are time derivatives in kg/s
sugarOut = sugarIn
fiberOut = fiberIn
waterOut = waterIn * (1 - eff)
ethanolOut = ethanolIn
waterWaste = waterIn * eff
return(sugarOut, fiberOut, waterOut, ethanolOut, waterWaste)