Skip to content

Commit

Permalink
Pipeline Design Code (#229)
Browse files Browse the repository at this point in the history
* Add new data to pipe database

* beginning of pipe changes

* finished pipe class, moving onto elbow

* Add pipe database to design folder

* Refactor constants

* initial elbow functionality

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* pipeline stuff

* Remove props.json

* Can now find headloss and flow of pipelines made from pipes and elbows

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Tee Functionality

* Rename elbow to fitting

* Rename file

* Pipe class errors

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Rep ok made for pipe components

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Printing functionality in Pipes

* Pipeline documentation

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Updating ent to utilize new Pipe format

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Implemented new Pipe in all components

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* Pipeline Testing and Sphinx Documentation

Co-authored-by: Oliver Leung <oal22@cornell.edu>

* drain pipe id test

* test fixes

* Fix test precision error

* Add back deprecated core/pipe testing

* Increase test coverage

* Increment version to 0.1.5

* Remove unused pipeline module

* Remove core pipe documentation

* Add comment on deprecation

* Fix >80 char line

* Disable codecov comments

* Remove unnecessary __init__.py from tests

* Fix import statements

* Fix tests

* Ignore play.py in testing coverage
  • Loading branch information
oliver-leung authored Aug 7, 2019
1 parent 361ef3e commit 07ddbfa
Show file tree
Hide file tree
Showing 32 changed files with 995 additions and 353 deletions.
1 change: 0 additions & 1 deletion aguaclara/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from aguaclara.core.head_loss import *
from aguaclara.core.materials import *
from aguaclara.core.physchem import *
from aguaclara.core.pipeline import *
from aguaclara.core.pipes import *
from aguaclara.core.utility import *

Expand Down
98 changes: 49 additions & 49 deletions aguaclara/core/data/pipe_database.csv
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
NDinch,ODinch,NDmm,ODmm,Used,SCH40Wall
0.125,0.404,6,10.26,0,0.068
0.25,0.54,8,13.72,0,0.088
0.375,0.675,10,17.15,0,0.091
0.5,0.84,15,21.34,1,0.109
0.75,1.05,20,26.67,0,0.113
1,1.315,25,33.4,1,0.133
1.25,1.66,32,42.16,0,0.14
1.5,1.9,40,48.26,0,0.145
2,2.375,50,60.33,1,0.154
2.5,2.875,65,73.03,0,0.203
3,3.5,80,88.9,1,0.216
3.5,4,90,101.6,0,0.226
4,4.5,100,114.3,1,0.237
4.5,5,115,127,0,0.247
5,5.563,125,141.3,0,0.258
6,6.625,150,168.28,1,0.28
7,7.625,,193.68,0,0.301
8,8.625,200,219.08,1,0.322
9,9.625,,244.48,0,0.342
10,10.75,250,273.05,1,0.365
12,12.75,300,323.85,1,0.375
14,14,350,355.6,0,0.375
16,16,400,406.4,1,0.375
18,18,450,457.2,1,0.375
20,20,500,508,0,0.375
22,22,550,558.8,0,0.375
24,24,600,609.6,1,0.375
26,26,650,660.4,0,0.375
28,28,700,711.2,0,0.375
30,30,750,762,1,0.375
32,32,800,812.8,0,0.375
34,34,850,863.6,0,0.375
36,36,900,914.4,1,0.375
40,40,1000,1016,0,0.375
42,42,1050,1066.8,0,0.375
44,44,1100,1117.6,0,0.375
46,46,1150,1168.4,0,0.375
48,48,1200,1219.2,1,0.375
52,52,1300,1320.8,0,0.375
56,56,1400,1422.4,0,0.375
60,60,1500,1524,1,0.375
64,64,1600,1625.6,0,0.375
68,68,1700,1727.2,0,0.375
72,72,1800,1828.8,1,0.375
76,76,1900,1930.4,0,0.375
80,80,2000,2032,0,0.375
88,88,2200,2235.2,0,0.375
92,92,2300,2336.8,0,0.375
NDinch,ODinch,NDmm,ODmm,Used,SCH40Wall,ID_SCH40
0.125,0.404,6,10.26,0,0.068,0.268
0.25,0.54,8,13.72,0,0.088,0.364
0.375,0.675,10,17.15,0,0.091,0.493
0.5,0.84,15,21.34,1,0.109,0.622
0.75,1.05,20,26.67,0,0.113,0.824
1,1.315,25,33.4,1,0.133,1.049
1.25,1.66,32,42.16,0,0.14,1.38
1.5,1.9,40,48.26,0,0.145,1.61
2,2.375,50,60.33,1,0.154,2.067
2.5,2.875,65,73.03,0,0.203,2.469
3,3.5,80,88.9,1,0.216,3.068
3.5,4,90,101.6,0,0.226,3.548
4,4.5,100,114.3,1,0.237,4.026
4.5,5,115,127,0,0.247,4.506
5,5.563,125,141.3,0,0.258,5.047
6,6.625,150,168.28,1,0.28,6.065
7,7.625,,193.68,0,0.301,7.023
8,8.625,200,219.08,1,0.322,7.981
9,9.625,,244.48,0,0.342,8.941
10,10.75,250,273.05,1,0.365,10.02
12,12.75,300,323.85,1,0.375,12
14,14,350,355.6,0,0.375,13.25
16,16,400,406.4,1,0.375,15.25
18,18,450,457.2,1,0.375,17.25
20,20,500,508,0,0.375,19.25
22,22,550,558.8,0,0.375,21.25
24,24,600,609.6,1,0.375,23.25
26,26,650,660.4,0,0.375,25.25
28,28,700,711.2,0,0.375,27.25
30,30,750,762,1,0.375,29.25
32,32,800,812.8,0,0.375,31.25
34,34,850,863.6,0,0.375,33.25
36,36,900,914.4,1,0.375,35.25
40,40,1000,1016,0,0.375,39.25
42,42,1050,1066.8,0,0.375,41.25
44,44,1100,1117.6,0,0.375,43.25
46,46,1150,1168.4,0,0.375,45.25
48,48,1200,1219.2,1,0.375,47.25
52,52,1300,1320.8,0,0.375,51.25
56,56,1400,1422.4,0,0.375,55.25
60,60,1500,1524,1,0.375,59.25
64,64,1600,1625.6,0,0.375,63.25
68,68,1700,1727.2,0,0.375,67.25
72,72,1800,1828.8,1,0.375,71.25
76,76,1900,1930.4,0,0.375,75.25
80,80,2000,2032,0,0.375,79.25
88,88,2200,2235.2,0,0.375,87.25
92,92,2300,2336.8,0,0.375,91.25
10 changes: 8 additions & 2 deletions aguaclara/core/physchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ def headloss_manifold(FlowRate, Diam, Length, KMinor, Nu, PipeRough, NumOutlets)
)
)

def elbow_minor_loss(q, id_, k):
vel = q / area_circle(id_)
minor_loss = k * vel ** 2 / (2 * con.GRAVITY)
return minor_loss.to(u.m)

@u.wraps(u.m**3/u.s, [u.m, u.m], False)
@ut.list_handler()
Expand Down Expand Up @@ -800,6 +804,8 @@ def horiz_chan_h(q, w, hl, l, nu, eps, manifold):

def pipe_flow_nd(q, sdr, hl, l, nu, eps, k):
i = 0
while q > flow_pipe(pipe.ID_SDR_all_available(sdr)[i], hl, l, nu, eps, k):
id_sdr_all_available = pipe.ID_SDR_all_available(sdr)
while q > flow_pipe(id_sdr_all_available[i], hl, l, nu, eps, k):
i_d = id_sdr_all_available[i]
i += 1
return pipe.ND_SDR_available(pipe.ID_SDR_all_available(sdr)[i], sdr)
return pipe.ND_SDR_available(i_d, sdr)
84 changes: 0 additions & 84 deletions aguaclara/core/pipeline.py

This file was deleted.

14 changes: 7 additions & 7 deletions aguaclara/core/pipes.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""This file contains functions which convert between the nominal, inner, and
outer diameters of pipes based on their standard dimension ratio (SDR).
"""

#Let's begin to create the pipe database
# https://docs.python.org/2/library/csv.html
from aguaclara.core.units import u
import numpy as np
import pandas as pd
# load the pipedb from a csv file

import os.path
dir_path = os.path.dirname(__file__)
csv_path = os.path.join(dir_path, 'data/pipe_database.csv')
with open(csv_path) as pipedbfile:
pipedb = pd.read_csv(pipedbfile)

""""""
# TODO: Add a deprecation warning for this once manifold design code has been
# implemented. The socket_depth and cap_thickness functions are used in
# a manifold calculation in sed_tank, and can also be transferred to pipeline
# design code once manifold design code has been implemented.

class Pipe:


Expand All @@ -30,12 +30,12 @@ def od(self):

@property
def id_sdr(self):
return self.od.magnitude * (self.sdr - 2) / self.sdr
return (self.od.magnitude * (self.sdr - 2) / self.sdr) * u.inch

@property
def id_sch40(self):
myindex = (np.abs(np.array(pipedb['NDinch']) - self.nd.magnitude)).argmin()
return (pipedb.iloc[myindex, 1] - 2 * (pipedb.iloc[myindex, 5]))
return (pipedb.iloc[myindex, 1] - 2 * (pipedb.iloc[myindex, 5])) * u.inch

@u.wraps(u.inch, u.inch, False)
def OD(ND):
Expand Down
12 changes: 12 additions & 0 deletions aguaclara/core/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def stepceil_with_units(param, step, unit):
counter += step * unit
return counter

# TODO: I'm not sure if these next two functions work for unsorted arrays, so it
# would be good to check in the future -Oliver Leung (oal22), 19 Jul '19

def floor_nearest(x, array):
"""Get the nearest element of a NumPy array less than or equal to a value.
Expand Down Expand Up @@ -217,6 +220,15 @@ def min(*args):
"""Like :func:`max`, but the minimum of the quantites."""
return _minmax(*args, func = np.min)

def get_sdr(spec):
"""Get the SDR of a string ``spec`` with the form \"sdrXX\".
Args:
- ``spec (str)``: The specification string to be parsed."""
if spec[:3] != "sdr":
raise ValueError('Not a valid SDR.')
return int(spec[3:])

def list_handler(HandlerResult="nparray"):
"""Wraps a function to handle list inputs."""
def decorate(func):
Expand Down
13 changes: 10 additions & 3 deletions aguaclara/design/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ def serialize_properties(self):
'__doc__',
'__module__',
'__weakref__',
'subcomponents'
'subcomponents',
'__abstractmethods__',
'_abc_cache',
'_abc_negative_cache',
'_abc_negative_cache_version',
'_abc_registry'
]
# Get all of the object's fields
for var_name in dir(self):
Expand Down Expand Up @@ -114,12 +119,14 @@ def print_properties(self):
"""Print the serialized properties with pretty indentation."""
pprint(self.serialize_properties())

def write_properties_to_file(self, filename):
def write_properties_to_file(self):
"""Append the properties of a component to a file. If it does not exist,
then the file is created.
Args:
- ``filename (str)``: The name of the file
"""
json.dump(self.serialize_properties(), open(filename, mode='a'),
filename = "props.json"
json.dump(self.serialize_properties(), open(filename, mode='w'),
indent = 4)
print("Properties of component can be found in file props.json")
19 changes: 19 additions & 0 deletions aguaclara/design/data/fitting_database.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
size,id_inch,socket_depth,Used
0.125,0.417,0.5,0
0.25,0.552,0.5,0
0.375,0.687,0.594,0
0.5,0.848,0.688,1
0.75,1.058,0.719,0
1,1.325,0.875,1
1.25,1.67,0.938,0
1.5,1.912,1.094,0
2,2.387,1.156,1
2.5,2.889,1.75,0
3,3.516,1.875,1
3.5,4.016,2,0
4,4.518,2,1
5,5.583,3,0
6,6.647,3,1
8,8.655,4,1
10,10.78,5,1
12,12.78,6,1
49 changes: 49 additions & 0 deletions aguaclara/design/data/pipe_database.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
NDinch,ODinch,NDmm,ODmm,Used,SCH40Wall,ID_SCH40
0.125,0.404,6,10.26,0,0.068,0.268
0.25,0.54,8,13.72,0,0.088,0.364
0.375,0.675,10,17.15,0,0.091,0.493
0.5,0.84,15,21.34,1,0.109,0.622
0.75,1.05,20,26.67,0,0.113,0.824
1,1.315,25,33.4,1,0.133,1.049
1.25,1.66,32,42.16,0,0.14,1.38
1.5,1.9,40,48.26,0,0.145,1.61
2,2.375,50,60.33,1,0.154,2.067
2.5,2.875,65,73.03,0,0.203,2.469
3,3.5,80,88.9,1,0.216,3.068
3.5,4,90,101.6,0,0.226,3.548
4,4.5,100,114.3,1,0.237,4.026
4.5,5,115,127,0,0.247,4.506
5,5.563,125,141.3,0,0.258,5.047
6,6.625,150,168.28,1,0.28,6.065
7,7.625,,193.68,0,0.301,7.023
8,8.625,200,219.08,1,0.322,7.981
9,9.625,,244.48,0,0.342,8.941
10,10.75,250,273.05,1,0.365,10.02
12,12.75,300,323.85,1,0.375,12
14,14,350,355.6,0,0.375,13.25
16,16,400,406.4,1,0.375,15.25
18,18,450,457.2,1,0.375,17.25
20,20,500,508,0,0.375,19.25
22,22,550,558.8,0,0.375,21.25
24,24,600,609.6,1,0.375,23.25
26,26,650,660.4,0,0.375,25.25
28,28,700,711.2,0,0.375,27.25
30,30,750,762,1,0.375,29.25
32,32,800,812.8,0,0.375,31.25
34,34,850,863.6,0,0.375,33.25
36,36,900,914.4,1,0.375,35.25
40,40,1000,1016,0,0.375,39.25
42,42,1050,1066.8,0,0.375,41.25
44,44,1100,1117.6,0,0.375,43.25
46,46,1150,1168.4,0,0.375,45.25
48,48,1200,1219.2,1,0.375,47.25
52,52,1300,1320.8,0,0.375,51.25
56,56,1400,1422.4,0,0.375,55.25
60,60,1500,1524,1,0.375,59.25
64,64,1600,1625.6,0,0.375,63.25
68,68,1700,1727.2,0,0.375,67.25
72,72,1800,1828.8,1,0.375,71.25
76,76,1900,1930.4,0,0.375,75.25
80,80,2000,2032,0,0.375,79.25
88,88,2200,2235.2,0,0.375,87.25
92,92,2300,2336.8,0,0.375,91.25
Loading

0 comments on commit 07ddbfa

Please sign in to comment.