{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# On finding the right topologies for a given reaction\n", "\n", "[Molecular dimensions of adsorptives](http://pubs.acs.org/doi/abs/10.1021/ja973906m)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 5000;\n", " window._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"

\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"

\\n\"+\n", " \"\\n\"+\n", " \"\\n\"+\n", " \"from bokeh.resources import INLINE\\n\"+\n", " \"output_notebook(resources=INLINE)\\n\"+\n", " \"\\n\"+\n", " \"
\"}};\n", "\n", " function display_loaded() {\n", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"3f029d3b-28ca-428b-8cdd-7eb2cb5d4f64\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._bokeh_is_loading > 0) {\n", " console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " }\n", " if (js_urls == null || js_urls.length === 0) {\n", " run_callbacks();\n", " return null;\n", " }\n", " console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " window._bokeh_is_loading = js_urls.length;\n", " for (var i = 0; i < js_urls.length; i++) {\n", " var url = js_urls[i];\n", " var s = document.createElement('script');\n", " s.src = url;\n", " s.async = false;\n", " s.onreadystatechange = s.onload = function() {\n", " window._bokeh_is_loading--;\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: all BokehJS libraries loaded\");\n", " run_callbacks()\n", " }\n", " };\n", " s.onerror = function() {\n", " console.warn(\"failed to load library \" + url);\n", " };\n", " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " }\n", " };var element = document.getElementById(\"3f029d3b-28ca-428b-8cdd-7eb2cb5d4f64\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '3f029d3b-28ca-428b-8cdd-7eb2cb5d4f64' but no matching script tag was found. \")\n", " return false;\n", " }\n", "\n", " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " \n", " function(Bokeh) {\n", " \n", " document.getElementById(\"3f029d3b-28ca-428b-8cdd-7eb2cb5d4f64\").textContent = \"BokehJS is loading...\";\n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"3f029d3b-28ca-428b-8cdd-7eb2cb5d4f64\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", " run_inline_js();\n", " } else {\n", " load_libs(js_urls, function() {\n", " console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", "}(this));" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import math\n", "import pandas as pd\n", "\n", "from bokeh.io import output_notebook\n", "from bokeh.plotting import figure, show, output_file\n", "from bokeh.charts import Bar\n", "from bokeh.charts.attributes import cat\n", "from bokeh.models import HoverTool, ColumnDataSource, FixedTicker\n", "from bokeh.palettes import Category10, Set1, Spectral\n", "\n", "output_notebook()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def assign_label(rings):\n", " '''\n", " assign string labels to a list of ints\n", " matching the usual zeolite pore size labels\n", " '''\n", "\n", " if max(rings) == 8:\n", " return 's'\n", " elif max(rings) == 10:\n", " if 8 in rings:\n", " return 'ms'\n", " else:\n", " return 'm'\n", " elif max(rings) == 12:\n", " if 10 in rings and 8 in rings:\n", " return 'lms'\n", " elif 10 in rings:\n", " return 'lm'\n", " elif 8 in rings:\n", " return 'ls'\n", " else:\n", " return 'l'\n", " elif max(rings) > 12:\n", " return 'x'\n", " else:\n", " return None\n", " \n", "def are_all_even(lst):\n", " 'check if all the elements of a list are even numbers'\n", "\n", " return all(x % 2 == 0 for x in lst)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from zefram import get_session, get_table, framework, Framework, RingSize\n", "\n", "df = get_table('frameworks')\n", "\n", "df.loc[:, 'Rings'] = [[r.size for r in framework(row['code']).ring_sizes] for i, row in df.iterrows()]\n", "# get the largest ring\n", "df.loc[:, 'max_ring'] = df['Rings'].apply(max)\n", "# assign a string label\n", "df.loc[:, 'ring_label'] = df.Rings.apply(assign_label)\n", "df.loc[:, 'alpo_possible'] = df.Rings.apply(are_all_even)\n", "df.rename(columns={'lcd': 'Largest cavity dia.', 'pld': 'Pore limiting dia.',\n", " 'maxdsi': 'Max dia. of inc. sphere'}, inplace=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Select the frameworks based on the ranges of parameters\n", "\n", "- pore limiting diameter in the range [3.5, 4.5]\n", "- largest cavity diameter in the range [5.5, 6.5]" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codePore limiting dia.Largest cavity dia.ring_labelRingsalpo_possible
8AFN3.75.9s[8, 6, 4]True
19APD3.85.6s[8, 6, 4]True
25ATT4.36.1s[8, 6, 4]True
28AWO4.35.8s[8, 6, 4]True
34BOF4.36.2m[10, 6, 5, 4]False
38BRE3.55.9s[8, 6, 5, 4]False
41CAS3.55.7s[8, 6, 5]False
42CDO3.96.4s[8, 5]False
44CGF3.56.4ms[10, 8, 6, 4]True
55DFT4.35.7s[8, 6, 4]True
59EDI4.16.4s[8, 4]True
63EPI4.16.1s[8, 5, 4]False
74GIS3.95.6s[8, 4]True
84IHW4.06.2s[8, 6, 5, 4]False
104JOZ3.95.6s[8, 4, 3]False
106JSN4.05.8s[8, 6, 4]True
108JST3.86.0m[10, 6, 3]False
154OWE4.46.4s[8, 6, 4]True
158PHI4.36.0s[8, 4]True
162PUN4.26.2lms[12, 10, 8, 4, 3]False
192SIV4.46.0s[8, 4]True
195SOS4.25.5ls[12, 8, 6, 4, 3]False
203STW4.16.1ms[10, 8, 5, 4]False
208THO4.15.8s[8, 4]True
213UEI4.46.2s[8, 6, 4]True
\n", "
" ], "text/plain": [ " code Pore limiting dia. Largest cavity dia. ring_label \\\n", "8 AFN 3.7 5.9 s \n", "19 APD 3.8 5.6 s \n", "25 ATT 4.3 6.1 s \n", "28 AWO 4.3 5.8 s \n", "34 BOF 4.3 6.2 m \n", "38 BRE 3.5 5.9 s \n", "41 CAS 3.5 5.7 s \n", "42 CDO 3.9 6.4 s \n", "44 CGF 3.5 6.4 ms \n", "55 DFT 4.3 5.7 s \n", "59 EDI 4.1 6.4 s \n", "63 EPI 4.1 6.1 s \n", "74 GIS 3.9 5.6 s \n", "84 IHW 4.0 6.2 s \n", "104 JOZ 3.9 5.6 s \n", "106 JSN 4.0 5.8 s \n", "108 JST 3.8 6.0 m \n", "154 OWE 4.4 6.4 s \n", "158 PHI 4.3 6.0 s \n", "162 PUN 4.2 6.2 lms \n", "192 SIV 4.4 6.0 s \n", "195 SOS 4.2 5.5 ls \n", "203 STW 4.1 6.1 ms \n", "208 THO 4.1 5.8 s \n", "213 UEI 4.4 6.2 s \n", "\n", " Rings alpo_possible \n", "8 [8, 6, 4] True \n", "19 [8, 6, 4] True \n", "25 [8, 6, 4] True \n", "28 [8, 6, 4] True \n", "34 [10, 6, 5, 4] False \n", "38 [8, 6, 5, 4] False \n", "41 [8, 6, 5] False \n", "42 [8, 5] False \n", "44 [10, 8, 6, 4] True \n", "55 [8, 6, 4] True \n", "59 [8, 4] True \n", "63 [8, 5, 4] False \n", "74 [8, 4] True \n", "84 [8, 6, 5, 4] False \n", "104 [8, 4, 3] False \n", "106 [8, 6, 4] True \n", "108 [10, 6, 3] False \n", "154 [8, 6, 4] True \n", "158 [8, 4] True \n", "162 [12, 10, 8, 4, 3] False \n", "192 [8, 4] True \n", "195 [12, 8, 6, 4, 3] False \n", "203 [10, 8, 5, 4] False \n", "208 [8, 4] True \n", "213 [8, 6, 4] True " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "criteria = {'Pore limiting dia.': [3.5, 4.5],\n", " 'Largest cavity dia.': [5.5, 6.5]}\n", "\n", "masks = {}\n", "for k, v in criteria.items():\n", " vmin, vmax = sorted(v)\n", " masks[k] = (df[k] >= vmin) & (df[k] < vmax)\n", " \n", "mask = pd.concat(list(masks.values()), axis=1).all(axis=1)\n", "df.loc[mask, ['code', 'Pore limiting dia.','Largest cavity dia.', 'ring_label', 'Rings', 'alpo_possible']]" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "### tighter criteria\n", "\n", "- pore limiting diameter in the range [3.7, 4.3]\n", "- largest cavity diameter in the range [5.7, 6.3]" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codePore limiting dia.Largest cavity dia.ring_labelRingsalpo_possible
8AFN3.75.9s[8, 6, 4]True
63EPI4.16.1s[8, 5, 4]False
84IHW4.06.2s[8, 6, 5, 4]False
106JSN4.05.8s[8, 6, 4]True
108JST3.86.0m[10, 6, 3]False
162PUN4.26.2lms[12, 10, 8, 4, 3]False
203STW4.16.1ms[10, 8, 5, 4]False
208THO4.15.8s[8, 4]True
\n", "
" ], "text/plain": [ " code Pore limiting dia. Largest cavity dia. ring_label \\\n", "8 AFN 3.7 5.9 s \n", "63 EPI 4.1 6.1 s \n", "84 IHW 4.0 6.2 s \n", "106 JSN 4.0 5.8 s \n", "108 JST 3.8 6.0 m \n", "162 PUN 4.2 6.2 lms \n", "203 STW 4.1 6.1 ms \n", "208 THO 4.1 5.8 s \n", "\n", " Rings alpo_possible \n", "8 [8, 6, 4] True \n", "63 [8, 5, 4] False \n", "84 [8, 6, 5, 4] False \n", "106 [8, 6, 4] True \n", "108 [10, 6, 3] False \n", "162 [12, 10, 8, 4, 3] False \n", "203 [10, 8, 5, 4] False \n", "208 [8, 4] True " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "criteria = {'Pore limiting dia.': [3.7, 4.3],\n", " 'Largest cavity dia.': [5.7, 6.3]}\n", "\n", "masks = {}\n", "for k, v in criteria.items():\n", " vmin, vmax = sorted(v)\n", " masks[k] = (df[k] >= vmin) & (df[k] < vmax)\n", " \n", "mask = pd.concat(list(masks.values()), axis=1).all(axis=1)\n", "df.loc[mask, ['code', 'Pore limiting dia.','Largest cavity dia.', 'ring_label', 'Rings', 'alpo_possible']]" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "### Max diameter of a sphere \n", "\n", "- pore limiting diameter in the range [3.7, 4.3]\n", "- maximum diameter of a sphere that can be included in the range [5.7, 6.3]" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codePore limiting dia.Largest cavity dia.Max dia. of inc. spherering_labelRingsalpo_possible
42CDO3.96.45.78s[8, 5]False
59EDI4.16.45.72s[8, 4]True
65ESV3.76.96.22s[8, 6, 5, 4]False
153OSO4.26.76.07x[14, 8, 3]False
215UOS4.26.55.85ms[10, 8, 6, 5, 4]False
228ZON4.06.55.83s[8, 6, 4]True
\n", "
" ], "text/plain": [ " code Pore limiting dia. Largest cavity dia. Max dia. of inc. sphere \\\n", "42 CDO 3.9 6.4 5.78 \n", "59 EDI 4.1 6.4 5.72 \n", "65 ESV 3.7 6.9 6.22 \n", "153 OSO 4.2 6.7 6.07 \n", "215 UOS 4.2 6.5 5.85 \n", "228 ZON 4.0 6.5 5.83 \n", "\n", " ring_label Rings alpo_possible \n", "42 s [8, 5] False \n", "59 s [8, 4] True \n", "65 s [8, 6, 5, 4] False \n", "153 x [14, 8, 3] False \n", "215 ms [10, 8, 6, 5, 4] False \n", "228 s [8, 6, 4] True " ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "criteria = {'Pore limiting dia.': [3.7, 4.3],\n", " 'Max dia. of inc. sphere': [5.7, 6.3]}\n", "\n", "masks = {}\n", "for k, v in criteria.items():\n", " vmin, vmax = sorted(v)\n", " masks[k] = (df[k] >= vmin) & (df[k] < vmax)\n", " \n", "mask = pd.concat(list(masks.values()), axis=1).all(axis=1)\n", "df.loc[mask, ['code', 'Pore limiting dia.', 'Largest cavity dia.',\n", " 'Max dia. of inc. sphere', 'ring_label', 'Rings', 'alpo_possible']]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }