{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 1:\n", "\n", "You and your friend have an assignment from your boss to analyze how fast a secret chemical $A$ can react into another secret chemical $B$. \n", "\n", "$$A \\to B$$\n", "\n", "You and your buddy have run an experiment for the reaction in a batch reactor and got this data points below. We assume your friend likes Python as much as you do and as a good friend he has imported everything into Python arrays.\n", "\n", "```python\n", "time_array = array([ 0., 125., 250., 375., 500., 625., 750., 875., 1000.,\n", " 1125., 1250., 1375., 1500., 1625., 1750., 1875., 2000., 2125.,\n", " 2250., 2375., 2500., 2625., 2750., 2875.])\n", " \n", "C_A_array = array([10.28148623, 8.92676003, 7.47370739, 7.20498621, 6.01448975,\n", " 4.85174028, 4.68868558, 4.01410753, 3.94055544, 3.04186757,\n", " 2.40544184, 2.62290428, 2.18704979, 1.31502537, 1.03730156,\n", " 2.28837979, 0.45062549, 1.43886825, 1.26808295, 1.24125421,\n", " 0.28353151, 0.90117414, 0.74132173, 0.73710597])\n", "```\n", "\n", "You know that `time_array` corresponds to time and `C_A_array` to $C_A(t)$.\n", "\n", "You also know that it is the first order reaction, i.e:\n", "\n", "$-r_A = k C_A$\n", "\n", "Now $\\dfrac{d C_A}{dt} = - k C_A$ and the solution is $C_A(t) = C_{A0} \\cdot e^{-k t}$\n", "\n", "Your boss says that you and your friend need to give him a reaction constant $k$ otherwise your whole company won't be able to deliver a new product and will experience significant difficulties (especially after the recent tax reform). You suspect $C_{A0} = 10 moles$, but it would be nice to check that as well.\n", "\n", "What should we do?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 2:\n", "\n", "Fitting another function:\n", "\n", "\n", "$dC_A/dt = - k$\n", "\n", "The exact solution here would be\n", "\n", "$C_A =C_{A0} - kt$\n", "\n", "Our Experimental data is:\n", "\n", "```python\n", "import numpy as np\n", "time_array = np.array([ 0. , 0.30612245, 0.6122449 , 0.91836735, 1.2244898 ,\n", " 1.53061224, 1.83673469, 2.14285714, 2.44897959, 2.75510204,\n", " 3.06122449, 3.36734694, 3.67346939, 3.97959184, 4.28571429,\n", " 4.59183673, 4.89795918, 5.20408163, 5.51020408, 5.81632653,\n", " 6.12244898, 6.42857143, 6.73469388, 7.04081633, 7.34693878,\n", " 7.65306122, 7.95918367, 8.26530612, 8.57142857, 8.87755102,\n", " 9.18367347, 9.48979592, 9.79591837, 10.10204082, 10.40816327,\n", " 10.71428571, 11.02040816, 11.32653061, 11.63265306, 11.93877551,\n", " 12.24489796, 12.55102041, 12.85714286, 13.16326531, 13.46938776,\n", " 13.7755102 , 14.08163265, 14.3877551 , 14.69387755, 15. ])\n", "\n", "C_A_array = np.array([10.07639696, 9.91832079, 9.88786894, 9.86452614, 9.94122765,\n", " 9.84390408, 9.67133 , 9.83831594, 9.85882335, 9.80157275,\n", " 9.84539316, 9.55091516, 9.61587477, 9.66549779, 9.49617392,\n", " 9.55431562, 9.35852625, 9.49039332, 9.38783532, 9.44147304,\n", " 9.40256963, 9.29987479, 9.14910022, 9.40193543, 9.15306236,\n", " 9.35110886, 9.21753824, 9.04908686, 9.23874406, 9.02922114,\n", " 9.01426505, 9.07687961, 9.03789781, 8.74373902, 8.93811106,\n", " 8.89792648, 8.92497756, 8.9052101 , 8.69154187, 8.83577787,\n", " 8.6515694 , 8.8865218 , 8.43442155, 8.63970657, 8.5779596 ,\n", " 8.6386648 , 8.64805349, 8.37248495, 8.60161561, 8.64226331])\n", "```\n", "\n", "We need to find C_A0 and k ?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 3:\n", "\n", "Your boss asked you to try another reaction and get parameters from there.\n", "\n", "$$2A ->B$$\n", "\n", "Your boss told you that it is probably a second order reaction $-r_A = k [C_A]^2$.\n", "\n", "Your friend has helped you out with the design equation and the exact solution for the current system:\n", "\n", "$dC_A/dt = - k C_A = -k C^2_A$\n", "\n", "The exact solution here would be\n", "\n", "$1/C_A = kt + 1/C_{A0}$\n", "\n", "Your friend suggested that it would be better to plot $1/C_A$ instead of $C_A$. You think it is a great idea. Conveniently, your data is presented in the neccesseary format:\n", "\n", "Time:\n", "\n", "```python\n", "time_array = array([ 0. , 0.41666667, 0.83333333, 1.25 , 1.66666667,\n", " 2.08333333, 2.5 , 2.91666667, 3.33333333, 3.75 ,\n", " 4.16666667, 4.58333333, 5. , 5.41666667, 5.83333333,\n", " 6.25 , 6.66666667, 7.08333333, 7.5 , 7.91666667,\n", " 8.33333333, 8.75 , 9.16666667, 9.58333333, 10. ])\n", "```\n", "\n", "and $1/C_A(time)$:\n", "\n", "```python\n", "CA_inv_array = array([0.09955774, 0.10041539, 0.10164106, 0.10040534, 0.10151214,\n", " 0.1027833 , 0.10252228, 0.10259392, 0.10369246, 0.10371607,\n", " 0.10400771, 0.10517007, 0.10549644, 0.10558765, 0.10639114,\n", " 0.10600782, 0.10506377, 0.10734534, 0.10655902, 0.10820498,\n", " 0.1077726 , 0.10985819, 0.10912644, 0.11053292, 0.10939707])\n", "```\n", "\n", "Your task is to find parameters $k$ and $C_A0$ from the experimental data.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "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.4" } }, "nbformat": 4, "nbformat_minor": 2 }