{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c9cb873f-868b-4de7-8fcd-babd0b5b2927",
   "metadata": {},
   "source": [
    "# Born Species \n",
    "\n",
    "In this section, we explain how MobsPy deals with meta-species in the products that do not have an equal match in the reactants. Firstly, we refer to these species as born species, as these species have no matching meta-species in the reactants to define their state in the products.\n",
    "Without a reactant to define its state, MobsPy chooses only to create the reaction with the default state of this meta-species. \n",
    "\n",
    "As a reminder, the default state is created by combining the first characteristic added to all the inheritors of a meta-species.\n",
    "\n",
    "Finally, queries can also be performed on the Born Species to specify the desired state. An example follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3fa4c83e-e241-4a82-aa9b-e6c1334c9eeb",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Compiling model\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Species\n",
      "Something.big.old,0\n",
      "Something.big.young,0\n",
      "Something.small.old,0\n",
      "Something.small.young,0\n",
      "\n",
      "Mappings\n",
      "Something :\n",
      "Something.big.old\n",
      "Something.big.young\n",
      "Something.small.old\n",
      "Something.small.young\n",
      "\n",
      "Parameters\n",
      "volume,1\n",
      "\n",
      "Reactions\n",
      "reaction_0,{'re': [], 'pr': [(1, 'Something.big.young')], 'kin': '1 * volume'}\n",
      "reaction_1,{'re': [], 'pr': [(1, 'Something.small.young')], 'kin': '1 * volume'}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from mobspy import *\n",
    "\n",
    "Age, Size = BaseSpecies()\n",
    "\n",
    "Age.young, Age.old\n",
    "Size.small, Size.big\n",
    "\n",
    "Something = Age*Size\n",
    "\n",
    "Zero >> Something [1]\n",
    "Zero >> Something.big [1]\n",
    "\n",
    "S_1 = Simulation(Something)\n",
    "print(S_1.compile())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "819b0242-9ed9-4c17-8add-2fca1a1f5749",
   "metadata": {},
   "source": [
    "However, if one wants to define one reaction for each state of the Born Species, the All operator is available. If a Born Species has this operator applied to it, it will result in the change from a single reaction for the default state to the one previously described. The all operator is also compatible with dot operator queries, allowing one to filter the state space.\n",
    "An example of usage follows: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "59ddce43-f862-4264-a70e-915c4b8a1d48",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Compiling model\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Species\n",
      "Something.big.old,0\n",
      "Something.big.young,0\n",
      "Something.small.old,0\n",
      "Something.small.young,0\n",
      "\n",
      "Mappings\n",
      "Something :\n",
      "Something.big.old\n",
      "Something.big.young\n",
      "Something.small.old\n",
      "Something.small.young\n",
      "\n",
      "Parameters\n",
      "volume,1\n",
      "\n",
      "Reactions\n",
      "reaction_0,{'re': [], 'pr': [(1, 'Something.big.old')], 'kin': '1 * volume'}\n",
      "reaction_1,{'re': [], 'pr': [(1, 'Something.big.old')], 'kin': '2 * volume'}\n",
      "reaction_2,{'re': [], 'pr': [(1, 'Something.big.young')], 'kin': '1 * volume'}\n",
      "reaction_3,{'re': [], 'pr': [(1, 'Something.big.young')], 'kin': '2 * volume'}\n",
      "reaction_4,{'re': [], 'pr': [(1, 'Something.small.old')], 'kin': '1 * volume'}\n",
      "reaction_5,{'re': [], 'pr': [(1, 'Something.small.young')], 'kin': '1 * volume'}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from mobspy import *\n",
    "\n",
    "Age, Size = BaseSpecies()\n",
    "\n",
    "Age.young, Age.old\n",
    "Size.small, Size.big\n",
    "\n",
    "Something = Age*Size\n",
    "\n",
    "Zero >> All[Something] [1]\n",
    "Zero >> All[Something.big] [2]\n",
    "\n",
    "S_1 = Simulation(Something)\n",
    "print(S_1.compile())"
   ]
  }
 ],
 "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.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
