David Saylor commited on
Commit
ac3f130
·
1 Parent(s): 67140f0

updated function names

Browse files
Files changed (4) hide show
  1. color_module/colors.py +20 -42
  2. exposure_module/exposure.py +15 -43
  3. functions.py +3 -20
  4. polymers.py +36 -0
color_module/colors.py CHANGED
@@ -1,34 +1,15 @@
1
  import numpy as np
2
  from flask import render_template, request
3
- from functions import *
4
  from . import blueprint
 
5
 
6
- # Named polymer matrices and category numbers
7
- nPoly = 20
8
- PolyData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('Category', 'i')])
9
- PolyData[0] = ('Silicone', 0)
10
- PolyData[1] = ('Polyethylene (density <= 0.94 g/cm3)', 1)
11
- PolyData[2] = ('Polyethylene (density > 0.94 g/cm3)', 2)
12
- PolyData[3] = ('Polyethylene terephthalate', 3)
13
- PolyData[4] = ('Polyurethane (polyether)', 1)
14
- PolyData[5] = ('Polycarbonate', 3)
15
- PolyData[6] = ('Polyoxymethylene', 2)
16
- PolyData[7] = ('Poly(methyl methacrylate)', 3)
17
- PolyData[8] = ('Acrylonitrile butadiene styrene', 2)
18
- PolyData[9] = ('Polyether block amide', 1)
19
- PolyData[10] = ('Polyamide', 3)
20
- PolyData[11] = ('Polystyrene', 3)
21
- PolyData[12] = ('Polyvinyl chloride (plasticized)', 0)
22
- PolyData[13] = ('Polytetrafluoroethylene', 2)
23
- PolyData[14] = ('Polyvinyl acetate', 1)
24
- PolyData[15] = ('Polypropylene', 2)
25
- PolyData[16] = ('Polybutylene terephthalate', 3)
26
- PolyData[17] = ('Polyetheretherketone', 3)
27
- PolyData[18] = ('Fluorinated ethylene propylene', 2)
28
- PolyData[19] = ('Other polymer', 4)
29
 
 
30
  nCA = 14
31
- caData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('TI', 'd'), ('MW', 'd')])
32
  caData[0] = ('Titanium dioxide (CAS#:13463-67-7)', 1.0, 1100.)
33
  caData[1] = ('Carbon black (CAS#:1333-86-4)', 2.0, 1100.)
34
  caData[2] = ('Pigment brown 24 (CAS#:68186-90-3)', 0.5, 1100.)
@@ -44,15 +25,11 @@ caData[11] = ('Other metal oxide color additive', 1.0, 1100.0)
44
  caData[12] = ('Other non-metal oxide color additive', 1.0, 1100.0)
45
  caData[13] = ('Other compound (non-color additive)', 1.0, 1100.0)
46
 
47
- polymers = np.zeros(nPoly, dtype='object')
48
- for i in range(nPoly):
49
- polymers[i] = PolyData[i][0].decode('UTF-8')
50
-
51
  CAs = np.zeros(nCA, dtype='object')
52
  caMW = np.zeros(nCA, dtype='object')
53
  for i in range(nCA):
54
  CAs[i] = caData[i][0].decode('UTF-8')
55
- for i in range(nCA):
56
  caMW[i] = caData[i][2]
57
 
58
  @blueprint.route('/color', methods=['GET'])
@@ -103,15 +80,16 @@ def app_post():
103
  else:
104
  TTC = 0.0015
105
 
106
- assume1 = request.form.get("assume1") is not None
107
- assume2 = request.form.get("assume2") is not None
108
- assume3 = request.form.get("assume3") is not None
109
- assume4 = request.form.get("assume4") is not None
110
- assume5 = request.form.get("assume5") is not None
111
 
112
- assume = np.array((assume1, assume2, assume3, assume4, assume5))
 
 
 
113
 
114
- release, diff = calcexposure(MW, amount, vol, area, time, pIndex, PolyData)
115
 
116
  if caIndex > 10:
117
  MOS = TTC / release
@@ -120,11 +98,11 @@ def app_post():
120
 
121
  iMOS = TTC / impurity
122
 
123
- release = sigfigs(release, 2)
124
- MOS = sigfigs(MOS, 2)
125
- diff = sigfigs(diff, 2)
126
- iMOS = sigfigs(iMOS, 2)
127
- impurity = sigfigs(impurity, 2)
128
 
129
  return render_template('report.html', polymers=polymers, pIndex=pIndex, caIndex=caIndex, release=release,
130
  assume=assume,
 
1
  import numpy as np
2
  from flask import render_template, request
3
+ from functions import SigFigs, Piringer, WilkeChang, SheetRelease
4
  from . import blueprint
5
+ from polymers import Polymers
6
 
7
+ # load polymer data including Ap values
8
+ polymers, Ap = Polymers()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # load color additive information
11
  nCA = 14
12
+ caData = np.zeros((nCA,), dtype=[('name', 'a75'), ('TI', 'd'), ('MW', 'd')])
13
  caData[0] = ('Titanium dioxide (CAS#:13463-67-7)', 1.0, 1100.)
14
  caData[1] = ('Carbon black (CAS#:1333-86-4)', 2.0, 1100.)
15
  caData[2] = ('Pigment brown 24 (CAS#:68186-90-3)', 0.5, 1100.)
 
25
  caData[12] = ('Other non-metal oxide color additive', 1.0, 1100.0)
26
  caData[13] = ('Other compound (non-color additive)', 1.0, 1100.0)
27
 
28
+ # convert to a format the html likes
 
 
 
29
  CAs = np.zeros(nCA, dtype='object')
30
  caMW = np.zeros(nCA, dtype='object')
31
  for i in range(nCA):
32
  CAs[i] = caData[i][0].decode('UTF-8')
 
33
  caMW[i] = caData[i][2]
34
 
35
  @blueprint.route('/color', methods=['GET'])
 
80
  else:
81
  TTC = 0.0015
82
 
83
+ assume = np.array((request.form.get("assume1") is not None, request.form.get("assume2") is not None,
84
+ request.form.get("assume3") is not None, request.form.get("assume4") is not None,
85
+ request.form.get("assume5") is not None))
 
 
86
 
87
+ if not np.isnan(Ap[pIndex]):
88
+ diff = Piringer(MW, Ap[pIndex])
89
+ else:
90
+ diff = WilkeChang(MW)
91
 
92
+ release = SheetRelease(amount, vol, area, time, diff)
93
 
94
  if caIndex > 10:
95
  MOS = TTC / release
 
98
 
99
  iMOS = TTC / impurity
100
 
101
+ release = SigFigs(release, 2)
102
+ MOS = SigFigs(MOS, 2)
103
+ diff = SigFigs(diff, 2)
104
+ iMOS = SigFigs(iMOS, 2)
105
+ impurity = SigFigs(impurity, 2)
106
 
107
  return render_template('report.html', polymers=polymers, pIndex=pIndex, caIndex=caIndex, release=release,
108
  assume=assume,
exposure_module/exposure.py CHANGED
@@ -1,42 +1,18 @@
1
  import numpy as np
2
  from flask import render_template, request
3
- from functions import *
4
  from . import blueprint
 
5
 
6
- # Named polymer matrices and category numbers
7
- nPoly = 20
8
- PolyData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('Ap', 'f')])
9
- PolyData[0] = ('Silicone', 16.9)
10
- PolyData[1] = ('Polyethylene (density <= 0.94 g/cm3)', 11.7)
11
- PolyData[2] = ('Polyethylene (density > 0.94 g/cm3)', 8.2)
12
- PolyData[3] = ('Polyethylene terephthalate', 2.6)
13
- PolyData[4] = ('Polyurethane (polyether)', 11.7)
14
- PolyData[5] = ('Polycarbonate', 2.6)
15
- PolyData[6] = ('Polyoxymethylene', 8.2)
16
- PolyData[7] = ('Poly(methyl methacrylate)', 3)
17
- PolyData[8] = ('Acrylonitrile butadiene styrene', 8.2)
18
- PolyData[9] = ('Polyether block amide', 11.7)
19
- PolyData[10] = ('Polyamide', 2.6)
20
- PolyData[11] = ('Polystyrene', 2.6)
21
- PolyData[12] = ('Polyvinyl chloride (plasticized)', 16.9)
22
- PolyData[13] = ('Polytetrafluoroethylene', 8.2)
23
- PolyData[14] = ('Polyvinyl acetate', 11.7)
24
- PolyData[15] = ('Polypropylene', 8.2)
25
- PolyData[16] = ('Polybutylene terephthalate', 2.6)
26
- PolyData[17] = ('Polyetheretherketone', 2.6)
27
- PolyData[18] = ('Fluorinated ethylene propylene', 8.2)
28
- PolyData[19] = ('Other polymer', None)
29
-
30
- # Convert the list to a format the html likes
31
- polymers = np.zeros(nPoly, dtype='object')
32
- for i in range(nPoly):
33
- polymers[i] = PolyData[i][0].decode('UTF-8')
34
 
35
  # load the index page for the exposure module
36
  @blueprint.route('/exposure', methods=['GET'])
37
  def exposure():
38
  return render_template('exposure_index.html', polymers=polymers)
39
 
 
40
  # build the report page for the exposure module
41
  @blueprint.route('/exposure', methods=['POST'])
42
  def exp_post():
@@ -60,26 +36,22 @@ def exp_post():
60
  else:
61
  TTC = 0.0015
62
 
63
- assume1 = request.form.get("assume1") is not None
64
- assume2 = request.form.get("assume2") is not None
65
- assume3 = request.form.get("assume3") is not None
66
- assume4 = request.form.get("assume4") is not None
67
- assume5 = request.form.get("assume5") is not None
68
- assume = np.array((assume1, assume2, assume3, assume4, assume5))
69
 
70
- Ap = PolyData[pIndex][1]
71
- if not np.isnan(Ap):
72
- diff = piringer(MW, Ap)
73
  else:
74
- diff = wilkechang(MW)
75
 
76
  release = SheetRelease(amount, vol, area, time, diff)
77
 
78
  MOS = TTC / release
79
 
80
- release = sigfigs(release, 2)
81
- MOS = sigfigs(MOS, 2)
82
- diff = sigfigs(diff, 2)
83
 
84
  # Generate the rate plot using matplotlib
85
  tarray = np.arange(1., 31., 1.)
@@ -88,4 +60,4 @@ def exp_post():
88
 
89
  return render_template('exposure_report.html', polymers=polymers, pIndex=pIndex, release=release,
90
  assume=assume, area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
91
- MOS=MOS, chemName=chemName, image=pngImageB64String)
 
1
  import numpy as np
2
  from flask import render_template, request
3
+ from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
4
  from . import blueprint
5
+ from polymers import Polymers
6
 
7
+ # load polymer data including Ap values
8
+ polymers, Ap = Polymers()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # load the index page for the exposure module
11
  @blueprint.route('/exposure', methods=['GET'])
12
  def exposure():
13
  return render_template('exposure_index.html', polymers=polymers)
14
 
15
+
16
  # build the report page for the exposure module
17
  @blueprint.route('/exposure', methods=['POST'])
18
  def exp_post():
 
36
  else:
37
  TTC = 0.0015
38
 
39
+ assume = np.array((request.form.get("assume1") is not None, request.form.get("assume2") is not None,
40
+ request.form.get("assume3") is not None, request.form.get("assume4") is not None,
41
+ request.form.get("assume5") is not None))
 
 
 
42
 
43
+ if not np.isnan(Ap[pIndex]):
44
+ diff = Piringer(MW, Ap[pIndex])
 
45
  else:
46
+ diff = WilkeChang(MW)
47
 
48
  release = SheetRelease(amount, vol, area, time, diff)
49
 
50
  MOS = TTC / release
51
 
52
+ release = SigFigs(release, 2)
53
+ MOS = SigFigs(MOS, 2)
54
+ diff = SigFigs(diff, 2)
55
 
56
  # Generate the rate plot using matplotlib
57
  tarray = np.arange(1., 31., 1.)
 
60
 
61
  return render_template('exposure_report.html', polymers=polymers, pIndex=pIndex, release=release,
62
  assume=assume, area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
63
+ MOS=MOS, chemName=chemName, image=pngImageB64String)
functions.py CHANGED
@@ -7,15 +7,15 @@ import matplotlib.pyplot as plt
7
  import io
8
  import base64
9
 
10
- def sigfigs(number, n):
11
 
12
  return round(number, n - int(math.floor(math.log10(math.fabs(number)))) - 1)
13
 
14
- def piringer(Mw, Ap):
15
 
16
  return 1e4 * np.exp(Ap - 0.1351 * Mw ** (2. / 3.) + 0.003 * Mw - 10454. / 310.)
17
 
18
- def wilkechang(Mw):
19
 
20
  Va = 4.76 + 1.32 * Mw
21
  return 7.4e-8 * (18. * 2.6) ** 0.5 * 310. / 0.6913 / Va ** 0.6
@@ -69,20 +69,3 @@ def RatePlot(tarray, rates):
69
 
70
  return pngImageB64String
71
 
72
- def calcexposure(MW, amount, vol, area, time, pIndex, PolyData):
73
- Ap = np.array((16.9, 11.7, 8.2, 2.6))
74
- L = vol / area
75
- if PolyData[pIndex][1] < 4:
76
- D = 1e4 * np.exp(Ap[PolyData[pIndex][1]] - 0.1351 * MW ** (2. / 3.) + 0.003 * MW - 10454. / 310.)
77
- else:
78
- Va = 4.76 + 1.32 * MW
79
- D = 7.4e-8 * (18. * 2.6) ** 0.5 * 310. / 0.6913 / Va ** 0.6
80
-
81
- D = D * 3600.
82
- tau = D * time / L ** 2.
83
- if tau <= 0.5:
84
- release = 2. * amount * np.sqrt(tau / np.pi)
85
- else:
86
- release = amount * (1. - (8. / (np.pi ** 2.)) * np.exp(-tau * np.pi ** 2. / 4.))
87
-
88
- return release, D
 
7
  import io
8
  import base64
9
 
10
+ def SigFigs(number, n):
11
 
12
  return round(number, n - int(math.floor(math.log10(math.fabs(number)))) - 1)
13
 
14
+ def Piringer(Mw, Ap):
15
 
16
  return 1e4 * np.exp(Ap - 0.1351 * Mw ** (2. / 3.) + 0.003 * Mw - 10454. / 310.)
17
 
18
+ def WilkeChang(Mw):
19
 
20
  Va = 4.76 + 1.32 * Mw
21
  return 7.4e-8 * (18. * 2.6) ** 0.5 * 310. / 0.6913 / Va ** 0.6
 
69
 
70
  return pngImageB64String
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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