{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Factor out the demonstration of the trigger function from the top of the main simulation notebook\n",
    "+ add a few more plots and explanations about how and why it works"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "\n",
    "from cadCAD.configuration.utils import config_sim\n",
    "from model.parts.utils import *\n",
    "from model.parts.sys_params import * \n",
    "\n",
    "sim_config = config_sim({\n",
    "    'N': 1,\n",
    "    'T': range(100), #day \n",
    "    'M': params,\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "for reference: max conviction = 5.25318713934522in log10 units\n"
     ]
    }
   ],
   "source": [
    "supply = initial_values['supply']\n",
    "alpha = sim_config[0]['M']['alpha']\n",
    "\n",
    "mcv = supply/(1-alpha)\n",
    "print('for reference: max conviction = '+str(np.log10(mcv))+'in log10 units')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "supply_sweep = trigger_sweep('effective_supply',trigger_threshold, sim_config[0]['M'], supply)\n",
    "alpha_sweep = trigger_sweep('alpha',trigger_threshold, sim_config[0]['M'], supply)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 114996 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 4 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "trigger_grid(supply_sweep, alpha_sweep)"
   ]
  }
 ],
 "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.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
