Download polymers.py from dmsaylor/CHRIS: direct link, hf CLI and curl.
- Browser
- Download file 4.08 kB
-
https://huggingface.co/spaces/dmsaylor/CHRIS/resolve/main/polymers.py
- Command line
-
hf download hf://spaces/dmsaylor/CHRIS/polymers.py
-
curl -L -o polymers.py https://huggingface.co/spaces/dmsaylor/CHRIS/resolve/main/polymers.py
4.08 kB
| import numpy as np | |
| import pandas as pd | |
| def Polymers(): | |
| # Named polymer matrices and Ap values | |
| nPoly = 20 | |
| PolyData = np.zeros((nPoly,), dtype=[('name', 'a75'), ('Ap', 'f')]) | |
| PolyData[0] = ('Silicone', 16.9) | |
| PolyData[1] = ('Polyethylene (density <= 0.94 g/cm3)', 11.7) | |
| PolyData[2] = ('Polyethylene (density > 0.94 g/cm3)', 8.2) | |
| PolyData[3] = ('Polyethylene terephthalate', 2.6) | |
| PolyData[4] = ('Polyurethane (polyether)', 11.7) | |
| PolyData[5] = ('Polycarbonate', 2.6) | |
| PolyData[6] = ('Polyoxymethylene', 8.2) | |
| PolyData[7] = ('Poly(methyl methacrylate)', 2.6) | |
| PolyData[8] = ('Acrylonitrile butadiene styrene', 8.2) | |
| PolyData[9] = ('Polyether block amide', 11.7) | |
| PolyData[10] = ('Polyamide', 2.6) | |
| PolyData[11] = ('Polystyrene', 2.6) | |
| PolyData[12] = ('Polyvinyl chloride (plasticized)', 16.9) | |
| PolyData[13] = ('Polytetrafluoroethylene', 8.2) | |
| PolyData[14] = ('Polyvinyl acetate', 11.7) | |
| PolyData[15] = ('Polypropylene', 8.2) | |
| PolyData[16] = ('Polybutylene terephthalate', 2.6) | |
| PolyData[17] = ('Polyetheretherketone', 2.6) | |
| PolyData[18] = ('Fluorinated ethylene propylene', 8.2) | |
| PolyData[19] = ('Other polymer', None) | |
| # Convert the list to a format the html likes | |
| polymers = np.zeros(nPoly, dtype='object') | |
| Ap = np.zeros(nPoly) | |
| for i in range(nPoly): | |
| polymers[i] = PolyData[i][0].decode('UTF-8') | |
| Ap[i] = PolyData[i][1] | |
| return polymers, Ap | |
| def Polymers2(): | |
| """ | |
| Statistical 95% confidence level | |
| """ | |
| from functions import PowerLaw, Piringer | |
| PolyData = pd.read_csv('polymer_names.tsv', sep='\t') | |
| polymers = np.array(list(PolyData['Long_Name'])+['Other polymer']) | |
| categories = np.array(list(PolyData['New Class'])+[None]) | |
| params = {'G1': [50, PowerLaw, PowerLaw, [-13.243621036934327, -0.6666666666666666], [-9.14139696305177, -3.217613748314546]], | |
| 'G2': [50, PowerLaw, PowerLaw, [-11.670431142672907, -0.6666666666666666], [-4.207370125521433, -5.167139609862643]], | |
| 'P1': [50, Piringer, Piringer, [12.858060826417205], [12.881407288933005]], | |
| 'P2': [50, Piringer, Piringer, [12.212344151487486], [9.873221841354686]], | |
| 'P3': [50, Piringer, Piringer, [13.512912106353479], [8.164778517800128]], | |
| 'P4': [50, Piringer, Piringer, [12.055689556938795], [7.22846764330788]], | |
| 'R1': [209.3419053195988, PowerLaw, Piringer, [-8.090252515347814, -0.6], [17.3501680736803]], | |
| 'R2': [50, Piringer, Piringer, [14.180664904418675], [14.473277531089229]], | |
| None: [50, PowerLaw, PowerLaw, [-8.090252515347814, -0.6], [-8.090252515347814, -0.6]]} | |
| # None = new correlation for D in water at 37 °C, ln(alpha) = ln(3.07e-4) ~ -8.09, beta=-0.6 | |
| return polymers, categories, params | |
| def Polymers3(): | |
| """ | |
| 95th quantile bounds | |
| """ | |
| from functions import PowerLaw, Piringer | |
| PolyData = pd.read_csv('polymer_names.tsv', sep='\t') | |
| polymers = np.array(list(PolyData['Long_Name'])+['Other polymer']) | |
| categories = np.array(list(PolyData['New Class'])+[None]) | |
| params = {'G1': [50, PowerLaw, PowerLaw, [-13.502779929501807, -0.6666666666666666], [-10.253395603708231, -3.217613748314546]], | |
| 'G2': [50, PowerLaw, PowerLaw, [-12.76225708905239, -0.6666666666666666], [-5.160958746539876, -5.167139469939434]], | |
| 'P1': [50, Piringer, Piringer, [13.629303279781514], [12.079611631692895]], | |
| 'P2': [50, Piringer, Piringer, [13.290448761749992], [9.322679065204227]], | |
| 'P3': [50, Piringer, Piringer, [12.545823492654485], [7.933602214641137]], | |
| 'P4': [50, Piringer, Piringer, [11.156096930175831], [5.613951368217457]], | |
| 'R1': [96.8065922072269, PowerLaw, Piringer, [-8.12291795252817, -0.6], [16.206593376953126]], | |
| 'R2': [50, Piringer, Piringer, [14.072482049201522], [14.281527272781695]], | |
| None: [50, PowerLaw, PowerLaw, [-8.12291795252817, -0.6], [-8.12291795252817, -0.6]]} | |
| # None = new correlation for D in water at 37 °C, ln(alpha) = ln(2.967e-4) ~ -8.12, beta=-0.6 | |
| return polymers, categories, params | |