Skip to content

Commit

Permalink
Add last three notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Aug 1, 2020
1 parent 673d07a commit 646d50b
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dev/prerelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

mod_spec = importlib.util.spec_from_file_location("make_test_stubs", os.path.join(test_dir, "make_test_stubs.py"))
make_test_stubs = importlib.util.module_from_spec(mod_spec)
#mod_spec.loader.exec_module(make_test_stubs)
mod_spec.loader.exec_module(make_test_stubs)

import pytest
os.chdir(main_dir)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 7.20 Steam at Sonic Velocity"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given: A header contains 170 psi saturated steam which feeds a pulp stock digester through 30 feet of 2\" sched40 pipe. It includes 1 standard 90 degree elbow, a fully open conventional plug type disc global valve. The initial pressure in the digester is atmospheric.\n",
"\n",
"Find the initial flow rate in pounds/hour."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The mass flow rate is found to be 11626.328806003183 pound / hour\n"
]
}
],
"source": [
"from fluids.units import *\n",
"from math import pi\n",
"from CoolProp.CoolProp import PropsSI\n",
"P1 = 170*u.psi\n",
"P2_spec = P2 = 1*u.atm\n",
"L = 30*u.foot\n",
"NPS, D_pipe, Do_pipe, t = nearest_pipe(NPS=2, schedule=40)\n",
"A = 0.25*pi*D_pipe**2\n",
"\n",
"fd = 0.019 # assumed, initial guess\n",
"Re = 1e6 # also assumed\n",
"mu = 1.8e-8*u.Pa*u.s\n",
"\n",
"rho = 5.988612037578836*u.kg/u.m**3 # Density at inlet from steam tables\n",
"roughness = 0.0018*u.inch\n",
"\n",
"for i in range(5):\n",
" K = K_from_f(fd=fd, L=L, D=D_pipe)\n",
" K += entrance_sharp()\n",
" K += exit_normal()\n",
" K += K_globe_valve_Crane(D1=D_pipe, D2=D_pipe)\n",
" K += bend_rounded(Di=D_pipe, angle=90*u.degrees, fd=fd, \n",
" Re=Re, roughness=roughness, method='Crane')\n",
" \n",
" # lump the losses together for the `isothermal_gas` function\n",
" fd_tot = f_from_K(L=L, D=D_pipe, K=K)\n",
" \n",
" P2_choke = P_isothermal_critical_flow(P=P1, fd=fd_tot, D=D_pipe, L=L)\n",
" if P2_choke.to_base_units().magnitude > P2_spec.to_base_units().magnitude:\n",
" P2 = P2_choke\n",
" else:\n",
" P2 = P2_spec\n",
" \n",
" m = isothermal_gas(rho=rho, fd=fd_tot, P1=P1, P2=P2, L=L, D=D_pipe)\n",
" Q = m/rho\n",
" v = Q/A\n",
" # update friction factor\n",
" Re = Reynolds(D=D_pipe, rho=rho, mu=mu, V=v)\n",
" fd = friction_factor(Re=Re, eD=roughness/D_pipe)\n",
"\n",
"# choke pressure found to be 3 bar instead of 2.5 in Crane example\n",
"print('The mass flow rate is found to be %s' %(m.to(u.lb/u.hour)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The values given in Crane are 11770 and 11160 lb/hour for the Darcy and the Sonic Velocity and Continuity equations."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 7.32 NPSH Available Calculation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given that a pump is located 30 feet above sea level, has a NPSHr of 20' at a flow rate of 400 gpm, and is fed by a tank of 60 deg F water with a surface pressure of 5 psig and a liquid level 25' below the suction of the pump.\n",
"\n",
"The head losses in the suction pipeline are 6'.\n",
"\n",
"Find the NPSH available and compare it to the NPSHr. A NPSHr margin ratio is required."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\\[13.887316780096477\\ foot\\]"
],
"text/latex": [
"$13.887316780096477\\ \\mathrm{foot}$"
],
"text/plain": [
"13.887316780096477 <Unit('foot')>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from fluids.units import *\n",
"rho = 62.364*u.lb/u.ft**3\n",
"P_tank = 5*u.psi + 1*u.atm\n",
"Psat = 0.256*u.psi\n",
"H_tank = 5*u.foot\n",
"H_pipe = 30*u.foot\n",
"dH = H_pipe - H_tank\n",
"\n",
"head_loss = 6*u.foot\n",
"\n",
"NPSHa = ((P_tank-Psat)/rho/u.gravity) - dH - head_loss\n",
"(NPSHa).to(u.foot)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The NPSHa is beneath the NPSHr. The requested pressure can be calculated as follows:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\\[26.0\\ foot\\]"
],
"text/latex": [
"$26.0\\ \\mathrm{foot}$"
],
"text/plain": [
"26.0 <Unit('foot')>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"20*u.foot*1.3"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 7.33 Pump Affinity Rules"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given: For the 6\" impeller trim on the curve below, the pump produces 126' of head and 400 gpm while running at 3500 rpm. The brake horsepower is 17.5 hp in that case.\n",
"\n",
"Find the flow rate, head, and power of this operating point if the speed is changed to 1700 rpm."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(194.28571428571428 <Unit('gallon / minute')>,\n",
" 29.725714285714286 <Unit('foot')>,\n",
" 2.0053061224489794 <Unit('horsepower')>)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from fluids.units import *\n",
"head1 = 126*u.foot\n",
"Q1 = 400*u.gal/u.min\n",
"rpm1 = 3500*u.rpm\n",
"power1 = 17.5*u.hp\n",
"\n",
"rpm2 = 1700*u.rpm\n",
"\n",
"Q2 = rpm2/rpm1*Q1\n",
"head2 = head1*(rpm2/rpm1)**2\n",
"power2 = power1*(rpm2/rpm1)**3\n",
"\n",
"Q2, head2, power2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The values match those given in Crane."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
3 changes: 3 additions & 0 deletions fluids/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def c_ideal_gas(T: float, k: float, MW: float) -> float: ...
def dP_from_K(K: float, rho: float, V: float) -> float: ...


def f_from_K(K: float, L: float, D: float) -> float: ...


def gravity(latitude: float, H: float) -> float: ...


Expand Down

0 comments on commit 646d50b

Please sign in to comment.