{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains course material from [CBE30338](https://jckantor.github.io/CBE30338)\n", "by Jeffrey Kantor (jeff at nd.edu); the content is available [on Github](https://github.com/jckantor/CBE30338.git).\n", "The text is released under the [CC-BY-NC-ND-4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode),\n", "and code is released under the [MIT license](https://opensource.org/licenses/MIT).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Fed-Batch Bioreactor](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/02.07-Fed-Batch-Bioreactor.ipynb) | [Contents](toc.ipynb) | [Linearization](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/03.00-Linearization.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Model Library"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 185,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.integrate import odeint,ode\n",
"\n",
"class GravityTank():\n",
" \n",
" def __init__(self, A=1, Cv=1, h = 0):\n",
" self.A = A\n",
" self.Cv = Cv\n",
" self.Qin = 0\n",
" self._h = h\n",
" self.IC = self._h\n",
" \n",
" def deriv(self,h,t):\n",
" h = max(0,h)\n",
" self._h = h\n",
" return (self.Qin/self.A - self.Cv*np.sqrt(h)/self.A)\n",
" \n",
" @property\n",
" def Qin(self):\n",
" return self._Qin\n",
" \n",
" @Qin.setter\n",
" def Qin(self,Qin):\n",
" self._Qin = Qin\n",
" \n",
" @property\n",
" def Qout(self):\n",
" return self.Cv*np.sqrt(self._h)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 186,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"[ "
]
}
],
"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.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}