Skip to content

Commit

Permalink
Merge pull request #197 from AguaClara/v0.0.24
Browse files Browse the repository at this point in the history
v0.0.24: Changes to floc_model, tube_sizing, and Sphinx documentation
  • Loading branch information
HannahSi authored Apr 9, 2019
2 parents 9a2405e + deba2ff commit 34a4b63
Show file tree
Hide file tree
Showing 42 changed files with 1,325 additions and 1,151 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ deploy:
skip-cleanup: true
github-token: "$GITHUB_TOKEN"
keep-history: true
local-dir: docs/build
local-dir: docs/build/html
target-branch: gh-pages
on:
tags: true
19 changes: 15 additions & 4 deletions aguaclara/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@

from aguaclara.core.units import unit_registry as u

# NOTE: "#: <optional_description>" required for Sphinx autodocumentation

#: Gravitational constant
GRAVITY = 9.80665 * u.m / u.s ** 2

#: Density of water
WATER_DENSITY = 1000 * u.kg / u.m ** 3
#: Kinematic viscosity of water
WATER_NU = 1 * 10 ** -6 * u.m ** 2 / u.s

#: Atmospheric pressure
ATM_P = 1 * u.atm
#: Average kinematic viscosity of air
AIR_NU = 12 * u.mm ** 2 / u.s
AIR_DENSITY = 1.204 * u.kg / u.mm ** 3

# The influence of viscosity on mixing in jet reactors
#: The influence of viscosity on mixing in jet reactors
JET_ROUND_RATIO = 0.08
# Estimate for plane jets in the flocculator and sed tank jet reverser.
#: An estimate for plane jet ratios in the flocculator and sed tank jet reverser
JET_PLANE_RATIO = 0.0124

#:
LFP_FLOW_MAX = 16.1 * u.L / u.s

FITTING_S_MIN = 5 * u.cm # Between fittings and tank wall in a tank.
#: Between fittings and tank wall in a tank.
FITTING_S_MIN = 5 * u.cm
#:
CHANNEL_W_MIN = 15 * u.cm

#:
VC_ORIFICE_RATIO = 0.63

#:
K_KOZENY = 5
3 changes: 2 additions & 1 deletion aguaclara/core/data/unit_definitions.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Created on Fri June 23 2017

author: Sage Weber-Shirk
Author: Sage Weber-Shirk

Last modified: Mon Jun 26 2017
By: Sage Weber-Shirk
Expand All @@ -12,3 +12,4 @@ NTU = 1.47 * (mg / L)
dollar = [money] = USD
lempira = dollar * 0.0427 = HNL
equivalent = mole = eq
rev = revolution
6 changes: 6 additions & 0 deletions aguaclara/core/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
"""
from aguaclara.core.units import unit_registry as u

#:
PVC_PIPE_ROUGH = 0.12 * u.mm

#:
CONCRETE_PIPE_ROUGH = 2 * u.mm
#:
CONCRETE_DENSITY = 2400 * (u.kg / u.m ** 3)
#:
CONCRETE_THICKNESS_MIN = 5 * u.cm

#:
REBAR_D = 0.5 * u.inch
#:
ACRYLIC_T = 1 * u.cm
8 changes: 3 additions & 5 deletions aguaclara/core/physchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import numpy as np
from scipy import interpolate, integrate

gravity = 9.80665 * u.m/u.s**2
"""Define the gravitational constant, in m/s²."""
gravity = con.GRAVITY

###################### Simple geometry ######################
"""A few equations for useful geometry.
Expand All @@ -31,8 +30,9 @@ def diam_circle(AreaCircle):
return np.sqrt(4 * AreaCircle / np.pi)

######################### Hydraulics #########################
RE_TRANSITION_PIPE = 2100

RE_TRANSITION_PIPE = 2100
""" """
K_KOZENY = con.K_KOZENY

WATER_DENSITY_TABLE = [(273.15, 278.15, 283.15, 293.15, 303.15, 313.15,
Expand Down Expand Up @@ -78,8 +78,6 @@ def viscosity_kinematic(temp):
If given units, the function will automatically convert to Kelvin.
If not given units, the function will assume Kelvin.
TODO: This should return meter ** 2 / second.
"""
ut.check_range([temp, ">0", "Temperature in Kelvin"])
return (viscosity_dynamic(temp).magnitude
Expand Down
26 changes: 16 additions & 10 deletions aguaclara/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@
import numpy

@u.wraps(u.m**3/u.s, [u.m, u.m, None, u.m], False)
def flow_pipeline(diameters: numpy.ndarray, lengths: numpy.ndarray, k_minors: numpy.ndarray, target_headloss: float,
def flow_pipeline(diameters, lengths, k_minors, target_headloss,
nu=con.WATER_NU, pipe_rough=mats.PVC_PIPE_ROUGH):
"""
This function takes a single pipeline with multiple sections, each potentially with different diameters,
lengths and minor loss coefficients and determines the flow rate for a given headloss.
Args:
diameters: list of diameters, where the i_th diameter corresponds to the i_th pipe section
lengths: list of diameters, where the i_th diameter corresponds to the i_th pipe section
k_minors: list of diameters, where the i_th diameter corresponds to the i_th pipe section
target_headloss: a single headloss describing the total headloss through the system
nu: The fluid dynamic viscosity of the fluid. Defaults to water at room temperature (1 * 10**-6 * m**2/s)
pipe_rough: The pipe roughness. Defaults to PVC roughness.
Returns:
flow: the total flow through the system
:param diameters: list of diameters, where the i_th diameter corresponds to the i_th pipe section
:type diameters: numpy.ndarray
:param lengths: list of diameters, where the i_th diameter corresponds to the i_th pipe section
:type lengths: numpy.ndarray
:param k_minors: list of diameters, where the i_th diameter corresponds to the i_th pipe section
:type k_minors: numpy.ndarray
:param target_headloss: a single headloss describing the total headloss through the system
:type target_headloss: float
:param nu: The fluid dynamic viscosity of the fluid. Defaults to water at room temperature (1 * 10**-6 * m**2/s)
:type nu: float
:param pipe_rough: The pipe roughness. Defaults to PVC roughness.
:type pipe_rough: float
:return: the total flow through the system
:rtype: float
"""

# Ensure all the arguments except total headloss are the same length
Expand Down
75 changes: 45 additions & 30 deletions aguaclara/core/units.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
"""Module containing global `pint` unit registry.
The `pint` module supports arithmetic involving *physical quantities*
each of which has a magnitude and units, for example 1 cm or 3 kg.
The units of a quantity come from a `pint` *unit registry*, and it
appears that `pint` supports arithmetic operations only on quantities
whose units come from the same unit registry (an attempt to perform
an operation on quantities whose units come from different unit
registries raises an exception). This module contains a single global
unit registry `unit_registry` that can be used by any number of other
modules.
"""Module containing global ``pint`` unit registry.
The ``pint`` package supports arithmetic involving **physical quantities**
each of which has a magnitude and units, for example 1 cm or 3 kg m/s^2.
The units of a quantity come from ``pint``'s **unit registry**. This module
contains a single global unit registry ``unit_registry`` that can be used by any
number of other modules. The ``aguaclara`` has also defined and added some of
its own units to the ``unit_registry``:
* NTU = 1.47 * (mg / L)
* dollar = [money] = USD
* lempira = dollar * 0.0427 = HNL
* equivalent = mole = eq
* rev = revolution
:Examples:
>>> from aguaclara.core.units import unit_registry as u
>>> rpm = 10 * u.rev/u.min
>>> rpm
<Quantity(10.0, 'rev / minute')>
>>> rpm.magnitude
10.0
>>> rpm.units
<Unit('rev / minute')>
>>> rpm.to(u.rad/u.s)
<Quantity(1.0471975511965976, 'radian / second')>
"""

import os
Expand All @@ -20,6 +35,7 @@
system='mks',
autoconvert_offset_to_baseunit=True
)
"""A global unit registry that can be used by any of other module."""

# default formatting includes 4 significant digits.
# This can be overridden on a per-print basis with
Expand All @@ -31,28 +47,27 @@
"data", "unit_definitions.txt"))


def set_sig_figs(n: int):
def set_sig_figs(n):
"""Set the default number of significant figures used to print pint,
pandas and numpy values quantities. Defaults to 4.
Args:
n: number of significant figures to display
Example:
import aguaclara
from aguaclara.units import unit_registry as u
h=2.5532532522352543*u.m
e = 25532532522352543*u.m
print('h before sigfig adjustment: ',h)
print('e before sigfig adjustment: ',e)
aguaclara.units.set_sig_figs(10)
print('h after sigfig adjustment: ',h)
print('e after sigfig adjustment: ',e)
h before sigfig adjustment: 2.553 meter
e before sigfig adjustment: 2.553e+16 meter
h after sigfig adjustment: 2.553253252 meter
e after sigfig adjustment: 2.553253252e+16 meter
:param n: number of significant figures to display
:type n: int
:Examples:
>>> from aguaclara.core.units import set_sig_figs, unit_registry as u
>>> h = 2.5532532522352543*u.m
>>> e = 25532532522352543*u.m
>>> print('h before sigfig adjustment:',h)
h before sigfig adjustment: 2.553 meter
>>> print('e before sigfig adjustment:',e)
e before sigfig adjustment: 2.553e+16 meter
>>> set_sig_figs(10)
>>> print('h after sigfig adjustment:',h)
h after sigfig adjustment: 2.553253252 meter
>>> print('e after sigfig adjustment:',e)
e after sigfig adjustment: 2.553253252e+16 meter
"""
unit_registry.default_format = '.' + str(n) + 'g'
pd.options.display.float_format = ('{:,.' + str(n) + '}').format
11 changes: 5 additions & 6 deletions aguaclara/core/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@


def round_sf(number, digits):
"""Returns inputted value rounded to number
of significant figures desired.
"""Returns inputted value rounded to number of significant figures desired.
Parameters:
number: Value to be rounded
digits: number of significant digits
to be rounded to.
:param number: Value to be rounded
:type number: float
:param digits: number of significant digits to be rounded to.
:type digits: int
"""
units = None
try:
Expand Down
5 changes: 4 additions & 1 deletion aguaclara/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
# from aguaclara.design.floc import Flocculator
import aguaclara.design.human_access as ha

import aguaclara.research.procoda_parser as pp
import aguaclara.research.environmental_processes_analysis as epa
import aguaclara.research.floc_model as fm
import aguaclara.research.procoda_parser as procoda_parser
import aguaclara.research.peristaltic_pump as peristaltic_pump
import aguaclara.research.stock_qc as stock_qc

def set_sig_figs(n=4):
"""Set the number of significant figures used to print Pint, Pandas, and
Expand Down
27 changes: 27 additions & 0 deletions aguaclara/research/data/3_stop_tubing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Color Diameter (mm)
orange-black 0.13
orange-red 0.19
orange-blue 0.25
orange-green 0.38
green-yellow 0.44
orange-yellow 0.51
white-yellow 0.57
orange-white 0.64
black-black 0.76
orange-orange 0.89
white-black 0.95
white-white 1.02
white-red 1.09
red-red 1.14
red-grey 1.22
grey-grey 1.3
yellow-yellow 1.42
yellow-blue 1.52
blue-blue 1.65
blue-green 1.75
green-green 1.85
purple-purple 2.06
purple-black 2.29
purple-orange 2.54
purple-white 2.79
black-white 3.17
10 changes: 10 additions & 0 deletions aguaclara/research/data/LS_tubing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Number Flow (mL/rev)
13 .06
14 .21
15 1.6
16 .8
17 2.8
18 3.8
24 2.8
35 3.8
36 4.8
1 change: 0 additions & 1 deletion aguaclara/research/data/tubing_data.txt

This file was deleted.

Loading

0 comments on commit 34a4b63

Please sign in to comment.