David Saylor commited on
Commit ·
55e7549
1
Parent(s): 130530b
broke out exposure calculation into different functions, added comments, and moved polymer input to a separate .py file
Browse files- CHRIS.py +19 -47
- functions.py +35 -0
- polymers.py +36 -0
CHRIS.py
CHANGED
|
@@ -1,35 +1,10 @@
|
|
| 1 |
from flask import Flask, render_template, request
|
| 2 |
import numpy as np
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
# Named polymer matrices and category numbers
|
| 11 |
-
nPoly = 20
|
| 12 |
-
PolyData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('Category', 'i')])
|
| 13 |
-
PolyData[0] = ('Silicone', 0)
|
| 14 |
-
PolyData[1] = ('Polyethylene (density <= 0.94 g/cm3)', 1)
|
| 15 |
-
PolyData[2] = ('Polyethylene (density > 0.94 g/cm3)', 2)
|
| 16 |
-
PolyData[3] = ('Polyethylene terephthalate', 3)
|
| 17 |
-
PolyData[4] = ('Polyurethane (polyether)', 1)
|
| 18 |
-
PolyData[5] = ('Polycarbonate', 3)
|
| 19 |
-
PolyData[6] = ('Polyoxymethylene', 2)
|
| 20 |
-
PolyData[7] = ('Poly(methyl methacrylate)', 3)
|
| 21 |
-
PolyData[8] = ('Acrylonitrile butadiene styrene', 2)
|
| 22 |
-
PolyData[9] = ('Polyether block amide', 1)
|
| 23 |
-
PolyData[10] = ('Polyamide', 3)
|
| 24 |
-
PolyData[11] = ('Polystyrene', 3)
|
| 25 |
-
PolyData[12] = ('Polyvinyl chloride (plasticized)', 0)
|
| 26 |
-
PolyData[13] = ('Polytetrafluoroethylene', 2)
|
| 27 |
-
PolyData[14] = ('Polyvinyl acetate', 1)
|
| 28 |
-
PolyData[15] = ('Polypropylene', 2)
|
| 29 |
-
PolyData[16] = ('Polybutylene terephthalate', 3)
|
| 30 |
-
PolyData[17] = ('Polyetheretherketone', 3)
|
| 31 |
-
PolyData[18] = ('Fluorinated ethylene propylene', 2)
|
| 32 |
-
PolyData[19] = ('Other polymer', 4)
|
| 33 |
|
| 34 |
# Named color additives, TI values, and Mw
|
| 35 |
nCA = 14
|
|
@@ -49,10 +24,6 @@ caData[11] = ('Other metal oxide color additive', 1.0, 1100.0)
|
|
| 49 |
caData[12] = ('Other non-metal oxide color additive', 1.0, 1100.0)
|
| 50 |
caData[13] = ('Other compound (non-color additive)', 1.0, 1100.0)
|
| 51 |
|
| 52 |
-
polymers = np.zeros(nPoly, dtype='object')
|
| 53 |
-
for i in range(nPoly):
|
| 54 |
-
polymers[i] = PolyData[i][0].decode('UTF-8')
|
| 55 |
-
|
| 56 |
CAs = np.zeros(nCA, dtype='object')
|
| 57 |
caMW = np.zeros(nCA, dtype='object')
|
| 58 |
for i in range(nCA):
|
|
@@ -61,7 +32,7 @@ for i in range(nCA):
|
|
| 61 |
caMW[i] = caData[i][2]
|
| 62 |
|
| 63 |
app = Flask(__name__)
|
| 64 |
-
app.debug =
|
| 65 |
|
| 66 |
|
| 67 |
@app.route('/', methods=['GET'])
|
|
@@ -114,15 +85,16 @@ def app_post():
|
|
| 114 |
else:
|
| 115 |
TTC = 0.0015
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
assume4 = request.form.get("assume4") is not None
|
| 121 |
-
assume5 = request.form.get("assume5") is not None
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
release
|
| 126 |
|
| 127 |
if caIndex > 10:
|
| 128 |
MOS = TTC / release
|
|
@@ -131,11 +103,11 @@ def app_post():
|
|
| 131 |
|
| 132 |
iMOS = TTC / impurity
|
| 133 |
|
| 134 |
-
release =
|
| 135 |
-
MOS =
|
| 136 |
-
diff =
|
| 137 |
-
iMOS =
|
| 138 |
-
impurity =
|
| 139 |
|
| 140 |
return render_template('report.html', polymers=polymers, pIndex=pIndex, caIndex=caIndex, release=release,
|
| 141 |
assume=assume,
|
|
|
|
| 1 |
from flask import Flask, render_template, request
|
| 2 |
import numpy as np
|
| 3 |
+
from functions import SigFigs, Piringer, WilkeChang, SheetRelease
|
| 4 |
+
from polymers import Polymers
|
| 5 |
+
|
| 6 |
+
# load polymer data including Ap values
|
| 7 |
+
polymers, Ap = Polymers()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Named color additives, TI values, and Mw
|
| 10 |
nCA = 14
|
|
|
|
| 24 |
caData[12] = ('Other non-metal oxide color additive', 1.0, 1100.0)
|
| 25 |
caData[13] = ('Other compound (non-color additive)', 1.0, 1100.0)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
CAs = np.zeros(nCA, dtype='object')
|
| 28 |
caMW = np.zeros(nCA, dtype='object')
|
| 29 |
for i in range(nCA):
|
|
|
|
| 32 |
caMW[i] = caData[i][2]
|
| 33 |
|
| 34 |
app = Flask(__name__)
|
| 35 |
+
app.debug = True
|
| 36 |
|
| 37 |
|
| 38 |
@app.route('/', methods=['GET'])
|
|
|
|
| 85 |
else:
|
| 86 |
TTC = 0.0015
|
| 87 |
|
| 88 |
+
assume = np.array((request.form.get("assume1") is not None, request.form.get("assume2") is not None,
|
| 89 |
+
request.form.get("assume3") is not None, request.form.get("assume4") is not None,
|
| 90 |
+
request.form.get("assume5") is not None))
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
if not np.isnan(Ap[pIndex]):
|
| 93 |
+
diff = Piringer(MW, Ap[pIndex])
|
| 94 |
+
else:
|
| 95 |
+
diff = WilkeChang(MW)
|
| 96 |
|
| 97 |
+
release = SheetRelease(amount, vol, area, time, diff)
|
| 98 |
|
| 99 |
if caIndex > 10:
|
| 100 |
MOS = TTC / release
|
|
|
|
| 103 |
|
| 104 |
iMOS = TTC / impurity
|
| 105 |
|
| 106 |
+
release = SigFigs(release, 2)
|
| 107 |
+
MOS = SigFigs(MOS, 2)
|
| 108 |
+
diff = SigFigs(diff, 2)
|
| 109 |
+
iMOS = SigFigs(iMOS, 2)
|
| 110 |
+
impurity = SigFigs(impurity, 2)
|
| 111 |
|
| 112 |
return render_template('report.html', polymers=polymers, pIndex=pIndex, caIndex=caIndex, release=release,
|
| 113 |
assume=assume,
|
functions.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def SigFigs(number, n):
|
| 6 |
+
|
| 7 |
+
return round(number, n - int(math.floor(math.log10(math.fabs(number)))) - 1)
|
| 8 |
+
|
| 9 |
+
def Piringer(Mw, Ap):
|
| 10 |
+
# Semi-empirical model for D(Mw) given polymer property Ap- Toxicol. Sci. 2019, 172 (1), 201–212.
|
| 11 |
+
T = 310.
|
| 12 |
+
return 1e4 * np.exp(Ap - 0.1351 * Mw ** (2. / 3.) + 0.003 * Mw - 10454. / T)
|
| 13 |
+
|
| 14 |
+
def WilkeChang(Mw):
|
| 15 |
+
# Semi-empirical model for D(Mw) assuming diffusion in water
|
| 16 |
+
Va = 4.76 + 1.32 * Mw # molecular volume as a function of Mw assuming linear alkanes as worst case
|
| 17 |
+
T = 310.
|
| 18 |
+
MwH2O = 18.
|
| 19 |
+
viscosity = 0.6913
|
| 20 |
+
alpha = 2.6
|
| 21 |
+
|
| 22 |
+
return 7.4e-8 * (MwH2O * alpha) ** 0.5 * T / viscosity / Va ** 0.6
|
| 23 |
+
|
| 24 |
+
def SheetRelease(amount, vol, area, time, D):
|
| 25 |
+
|
| 26 |
+
# analytical solution(s) to Fick's law for a plane sheet
|
| 27 |
+
L = vol / area
|
| 28 |
+
D = D * 3600. # convert seconds to hours
|
| 29 |
+
tau = D * time / L ** 2. # dimensionless time
|
| 30 |
+
if tau <= 0.2:
|
| 31 |
+
release = 2. * amount * np.sqrt(tau / np.pi)
|
| 32 |
+
else:
|
| 33 |
+
release = amount * (1. - (8. / (np.pi ** 2.)) * np.exp(-tau * np.pi ** 2. / 4.))
|
| 34 |
+
|
| 35 |
+
return release
|
polymers.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
def Polymers():
|
| 4 |
+
|
| 5 |
+
# Named polymer matrices and Ap values
|
| 6 |
+
nPoly = 20
|
| 7 |
+
PolyData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('Ap', 'f')])
|
| 8 |
+
PolyData[0] = ('Silicone', 16.9)
|
| 9 |
+
PolyData[1] = ('Polyethylene (density <= 0.94 g/cm3)', 11.7)
|
| 10 |
+
PolyData[2] = ('Polyethylene (density > 0.94 g/cm3)', 8.2)
|
| 11 |
+
PolyData[3] = ('Polyethylene terephthalate', 2.6)
|
| 12 |
+
PolyData[4] = ('Polyurethane (polyether)', 11.7)
|
| 13 |
+
PolyData[5] = ('Polycarbonate', 2.6)
|
| 14 |
+
PolyData[6] = ('Polyoxymethylene', 8.2)
|
| 15 |
+
PolyData[7] = ('Poly(methyl methacrylate)', 3)
|
| 16 |
+
PolyData[8] = ('Acrylonitrile butadiene styrene', 8.2)
|
| 17 |
+
PolyData[9] = ('Polyether block amide', 11.7)
|
| 18 |
+
PolyData[10] = ('Polyamide', 2.6)
|
| 19 |
+
PolyData[11] = ('Polystyrene', 2.6)
|
| 20 |
+
PolyData[12] = ('Polyvinyl chloride (plasticized)', 16.9)
|
| 21 |
+
PolyData[13] = ('Polytetrafluoroethylene', 8.2)
|
| 22 |
+
PolyData[14] = ('Polyvinyl acetate', 11.7)
|
| 23 |
+
PolyData[15] = ('Polypropylene', 8.2)
|
| 24 |
+
PolyData[16] = ('Polybutylene terephthalate', 2.6)
|
| 25 |
+
PolyData[17] = ('Polyetheretherketone', 2.6)
|
| 26 |
+
PolyData[18] = ('Fluorinated ethylene propylene', 8.2)
|
| 27 |
+
PolyData[19] = ('Other polymer', None)
|
| 28 |
+
|
| 29 |
+
# Convert the list to a format the html likes
|
| 30 |
+
polymers = np.zeros(nPoly, dtype='object')
|
| 31 |
+
Ap = np.zeros(nPoly)
|
| 32 |
+
for i in range(nPoly):
|
| 33 |
+
polymers[i] = PolyData[i][0].decode('UTF-8')
|
| 34 |
+
Ap[i] = PolyData[i][1]
|
| 35 |
+
|
| 36 |
+
return polymers, Ap
|