{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "06bbc3e6-9dae-4017-bda8-6aa59cff6299",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cantera as ct\n",
    "from scipy.optimize import fsolve"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5a82b32e-17ea-45b2-a49e-9617f3cf409e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2326.90561111113"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gas = ct.Solution('gri30.yaml')\n",
    "P = 101325.0\n",
    "Tr = 300.0\n",
    "Xr = 'CH4:1, O2:2, N2:7.52'\n",
    "Xp = 'CO2:1, H2O:2, N2:7.52'\n",
    "\n",
    "gas.TPX = Tr, P, Xr\n",
    "hr = gas.h\n",
    "\n",
    "#gas.equilibrate(\"HP\")    # uncomment these to get Tp with equilibrium products instead of PCC\n",
    "#Xp = gas.X\n",
    "\n",
    "def F(Tp):\n",
    "    gas.TPX = Tp[0], P, Xp\n",
    "    hp = gas.h\n",
    "    return hr - hp\n",
    "\n",
    "Tpguess = np.array([2000.0])\n",
    "\n",
    "Tp = fsolve(F, Tpguess)[0]\n",
    "\n",
    "Tp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8092cfdf-9275-4d2d-b2b1-035a1ef06cf4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
