<commit_before>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Uncomment lines below for the (verbose) debugging mode\n",
    "import pycalphad.log\n",
    "#pycalphad.log.debug_mode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from pycalphad.eq.equilibrium import Equilibrium\n",
    "from pycalphad import Database, Model\n",
    "import pycalphad.variables as v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 38 ms, sys: 0 ns, total: 38 ms\n",
      "Wall time: 37.7 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(array([3591, 1006, 5682, 2436, 4374, 6936, 2931, 5802]),\n",
       " array([ 0.11224937,  0.14165979,  0.10047531,  0.09860901,  0.13792843,\n",
       "         0.12772303,  0.14882468,  0.13253037]),\n",
       " array([-4165.11157302, -4229.04645189, -3877.83231148, -3726.86923601,\n",
       "        -4402.80114695, -4335.43202344, -4625.88199278, -4599.39818723]))"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db_rose = Database('bigrose.tdb')\n",
    "my_phases_rose = ['TEST']\n",
    "comps = ['H', 'HE', 'LI', 'BE', 'C', 'N', 'O', 'F']#, 'NE'] \n",
    "conds = dict()\n",
    "for comp in comps[:-1]:\n",
    "    conds[v.X(comp)] = 1/len(comps)\n",
    "#%lprun -f Equilibrium.get_starting_simplex\n",
    "#%time Equilibrium(db_rose, comps, my_phases_rose, conds, T=1000.0, pdens=1000)\n",
    "from pycalphad.eq.energy_surf import energy_surf\n",
    "from pycalphad.eq.geometry import lower_convex_hull\n",
    "df = energy_surf(db_rose, comps, my_phases_rose, T=1000.0, pdens=1000)\n",
    "#%lprun -f lower_convex_hull\n",
    "%time lower_convex_hull(df, comps, conds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2.39 s, sys: 0 ns, total: 2.39 s\n",
      "Wall time: 2.39 s\n",
      "Molar Gibbs Energy:    -9.608807E+04\n",
      "Potentials:\n",
      "T=1400.0\n",
      "Molar Composition:\n",
      "X(AL)=5.500000E-01    X(FE)=4.500000E-01\n",
      "\n",
      "AL5FE4#1    1.000000E+00\n",
      "Mole fractions:    AL 5.500000E-01    FE 4.500000E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    AL 5.500000E-01    FE 4.500000E-01\n",
      "\n"
     ]
    }
   ],
   "source": [
    "db_alfe = Database('alfe_sei.TDB')\n",
    "my_phases_alfe = ['LIQUID', 'FCC_A1', 'HCP_A3', 'AL5FE2', 'AL2FE', 'AL13FE4', 'AL5FE4']\n",
    "\n",
    "%time eq = Equilibrium(db_alfe, ['AL', 'FE', 'VA'] , my_phases_alfe, {v.X('AL'): 0.55}, T=1400.0, pdens=1000)\n",
    "print(eq)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Molar Gibbs Energy:    -5.704270E+03\n",
      "Potentials:\n",
      "T=1000.0\n",
      "Molar Composition:\n",
      "X(B)=1.111111E-01    X(BE)=1.111111E-01    X(C)=1.111111E-01    X(F)=1.111111E-01    X(H)=1.111111E-01    X(HE)=1.111111E-01    X(LI)=1.111111E-01    X(N)=1.111111E-01    X(O)=1.111111E-01\n",
      "\n",
      "TEST#1    2.215425E-01\n",
      "Mole fractions:    B 4.954670E-01    BE 1.250168E-03    C 1.587727E-03    F 4.954630E-01    H 9.016275E-04    HE 1.247493E-03    LI 1.246296E-03    N 1.588200E-03    O 1.248537E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 4.954670E-01    BE 1.250168E-03    C 1.587727E-03    F 4.954630E-01    H 9.016275E-04    HE 1.247493E-03    LI 1.246296E-03    N 1.588200E-03    O 1.248537E-03\n",
      "\n",
      "TEST#2    2.215429E-01\n",
      "Mole fractions:    B 1.250208E-03    BE 4.954612E-01    C 1.587798E-03    F 1.248528E-03    H 9.023082E-04    HE 1.248831E-03    LI 1.246863E-03    N 1.588060E-03    O 4.954662E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.250208E-03    BE 4.954612E-01    C 1.587798E-03    F 1.248528E-03    H 9.023082E-04    HE 1.248831E-03    LI 1.246863E-03    N 1.588060E-03    O 4.954662E-01\n",
      "\n",
      "TEST#3    1.676904E-01\n",
      "Mole fractions:    B 2.358592E-03    BE 2.358533E-03    C 6.532821E-01    F 2.360567E-03    H 3.295414E-01    HE 2.357613E-03    LI 2.361843E-03    N 3.022214E-03    O 2.357131E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 2.358592E-03    BE 2.358533E-03    C 6.532821E-01    F 2.360567E-03    H 3.295414E-01    HE 2.357613E-03    LI 2.361843E-03    N 3.022214E-03    O 2.357131E-03\n",
      "\n",
      "TEST#4    5.955189E-14\n",
      "Mole fractions:    B 9.148972E-02    BE 7.264360E-04    C 1.507967E-02    F 1.396235E-01    H 1.666384E-04    HE 5.075512E-02    LI 2.636222E-03    N 3.587897E-01    O 3.407330E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 9.148972E-02    BE 7.264360E-04    C 1.507967E-02    F 1.396235E-01    H 1.666384E-04    HE 5.075512E-02    LI 2.636222E-03    N 3.587897E-01    O 3.407330E-01\n",
      "\n",
      "TEST#5    2.257692E-14\n",
      "Mole fractions:    B 4.071061E-02    BE 2.212966E-02    C 3.958098E-02    F 0.000000E+00    H 6.622933E-02    HE 0.000000E+00    LI 2.788074E-02    N 8.034687E-01    O 0.000000E+00\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 4.071061E-02    BE 2.212966E-02    C 3.958098E-02    F 0.000000E+00    H 6.622933E-02    HE 0.000000E+00    LI 2.788074E-02    N 8.034687E-01    O 0.000000E+00\n",
      "\n",
      "TEST#6    2.712233E-14\n",
      "Mole fractions:    B 1.259186E-02    BE 5.889862E-01    C 0.000000E+00    F 1.140138E-02    H 1.080788E-02    HE 3.452906E-01    LI 1.178135E-02    N 0.000000E+00    O 1.914072E-02\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.259186E-02    BE 5.889862E-01    C 0.000000E+00    F 1.140138E-02    H 1.080788E-02    HE 3.452906E-01    LI 1.178135E-02    N 0.000000E+00    O 1.914072E-02\n",
      "\n",
      "TEST#7    2.215428E-01\n",
      "Mole fractions:    B 1.247905E-03    BE 1.249910E-03    C 1.586560E-03    F 1.248034E-03    H 9.000097E-04    HE 4.954657E-01    LI 4.954643E-01    N 1.588310E-03    O 1.249255E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.247905E-03    BE 1.249910E-03    C 1.586560E-03    F 1.248034E-03    H 9.000097E-04    HE 4.954657E-01    LI 4.954643E-01    N 1.588310E-03    O 1.249255E-03\n",
      "\n",
      "TEST#8    1.676814E-01\n",
      "Mole fractions:    B 2.356585E-03    BE 2.360662E-03    C 3.023528E-03    F 2.361885E-03    H 3.295008E-01    HE 2.360739E-03    LI 2.362549E-03    N 6.533147E-01    O 2.358547E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 2.356585E-03    BE 2.360662E-03    C 3.023528E-03    F 2.361885E-03    H 3.295008E-01    HE 2.360739E-03    LI 2.362549E-03    N 6.533147E-01    O 2.358547E-03\n",
      "\n",
      "TEST#9    3.624956E-14\n",
      "Mole fractions:    B 1.171741E-01    BE 4.713683E-04    C 8.225310E-04    F 1.071021E-04    H 3.645134E-01    HE 1.573215E-02    LI 7.188303E-03    N 4.629450E-01    O 3.104610E-02\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.171741E-01    BE 4.713683E-04    C 8.225310E-04    F 1.071021E-04    H 3.645134E-01    HE 1.573215E-02    LI 7.188303E-03    N 4.629450E-01    O 3.104610E-02\n",
      "\n"
     ]
    }
   ],
   "source": [
    "db_rose = Database('bigrose.tdb')\n",
    "my_phases_rose = ['TEST']\n",
    "comps = ['H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F']#, 'NE'] \n",
    "conds = dict()\n",
    "for comp in comps[:-1]:\n",
    "    conds[v.X(comp)] = 1/len(comps)\n",
    "%lprun -f Equilibrium.__init__ eq = Equilibrium(db_rose, comps, my_phases_rose, conds, T=1000.0, pdens=1000)\n",
    "print(eq)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "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.3.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
<commit_msg>DOC: Update equilibrium test notebook to reflect newest lower_convex_hull<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Uncomment lines below for the (verbose) debugging mode\n",
    "import pycalphad.log\n",
    "#pycalphad.log.debug_mode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from pycalphad.eq.equilibrium import Equilibrium\n",
    "from pycalphad import Database, Model\n",
    "import pycalphad.variables as v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 12 ms, sys: 0 ns, total: 12 ms\n",
      "Wall time: 11.9 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(array([[3591, 1006, 5682, 2436, 4374, 6936, 2931, 5802]]),\n",
       " array([[ 0.11224937,  0.14165979,  0.10047531,  0.09860901,  0.13792843,\n",
       "          0.12772303,  0.14882468,  0.13253037]]),\n",
       " array([[-4165.11157302, -4229.04645189, -3877.83231148, -3726.86923601,\n",
       "         -4402.80114695, -4335.43202344, -4625.88199278, -4599.39818723]]))"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db_rose = Database('bigrose.tdb')\n",
    "my_phases_rose = ['TEST']\n",
    "comps = ['H', 'HE', 'LI', 'BE', 'C', 'N', 'O', 'F']#, 'NE'] \n",
    "conds = dict()\n",
    "for comp in comps[:-1]:\n",
    "    conds[v.X(comp)] = 1/len(comps)\n",
    "#%lprun -f Equilibrium.get_starting_simplex\n",
    "#%time Equilibrium(db_rose, comps, my_phases_rose, conds, T=1000.0, pdens=1000)\n",
    "from pycalphad.eq.energy_surf import energy_surf\n",
    "from pycalphad.eq.geometry import lower_convex_hull\n",
    "df = energy_surf(db_rose, comps, my_phases_rose, T=1000.0, pdens=1000)\n",
    "#%lprun -f lower_convex_hull\n",
    "%time lower_convex_hull(df, comps, conds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.88 s, sys: 2 ms, total: 1.89 s\n",
      "Wall time: 1.89 s\n",
      "Molar Gibbs Energy:    -9.608807E+04\n",
      "Potentials:\n",
      "T=1400.0\n",
      "Molar Composition:\n",
      "X(AL)=5.500000E-01    X(FE)=4.500000E-01\n",
      "\n",
      "AL5FE4#1    1.000000E+00\n",
      "Mole fractions:    AL 5.500000E-01    FE 4.500000E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    AL 5.500000E-01    FE 4.500000E-01\n",
      "\n"
     ]
    }
   ],
   "source": [
    "db_alfe = Database('alfe_sei.TDB')\n",
    "my_phases_alfe = ['LIQUID', 'FCC_A1', 'HCP_A3', 'AL5FE2', 'AL2FE', 'AL13FE4', 'AL5FE4']\n",
    "df = energy_surf(db_alfe, ['AL', 'FE', 'VA'], my_phases_alfe, T=1000.0, pdens=1000)\n",
    "lower_convex_hull(df, ['AL', 'FE', 'VA'], {v.X('AL'): 0.55})\n",
    "%time eq = Equilibrium(db_alfe, ['AL', 'FE', 'VA'] , my_phases_alfe, {v.X('AL'): 0.55}, T=1400.0, pdens=1000)\n",
    "print(eq)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Molar Gibbs Energy:    -5.670882E+03\n",
      "Potentials:\n",
      "T=1000.0\n",
      "Molar Composition:\n",
      "X(B)=1.111111E-01    X(BE)=1.111111E-01    X(C)=1.111111E-01    X(F)=1.111111E-01    X(H)=1.111111E-01    X(HE)=1.111111E-01    X(LI)=1.111111E-01    X(N)=1.111111E-01    X(O)=1.111111E-01\n",
      "\n",
      "TEST#1    1.375042E-01\n",
      "Mole fractions:    B 7.986183E-01    BE 2.512804E-02    C 2.515886E-02    F 2.518920E-02    H 2.516472E-02    HE 2.520179E-02    LI 2.514393E-02    N 2.516624E-02    O 2.522888E-02\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 7.986183E-01    BE 2.512804E-02    C 2.515886E-02    F 2.518920E-02    H 2.516472E-02    HE 2.520179E-02    LI 2.514393E-02    N 2.516624E-02    O 2.522888E-02\n",
      "\n",
      "TEST#2    2.604730E-13\n",
      "Mole fractions:    B 0.000000E+00    BE 3.519841E-09    C 1.430248E-01    F 3.131788E-02    H 2.507174E-01    HE 5.171356E-02    LI 1.058271E-08    N 5.232263E-01    O 0.000000E+00\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 0.000000E+00    BE 3.519841E-09    C 1.430248E-01    F 3.131788E-02    H 2.507174E-01    HE 5.171356E-02    LI 1.058271E-08    N 5.232263E-01    O 0.000000E+00\n",
      "\n",
      "TEST#3    2.156867E-01\n",
      "Mole fractions:    B 1.504925E-03    BE 1.249046E-03    C 4.956400E-01    F 1.249419E-03    H 4.953636E-01    HE 1.246239E-03    LI 1.247917E-03    N 1.247622E-03    O 1.251289E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.504925E-03    BE 1.249046E-03    C 4.956400E-01    F 1.249419E-03    H 4.953636E-01    HE 1.246239E-03    LI 1.247917E-03    N 1.247622E-03    O 1.251289E-03\n",
      "\n",
      "TEST#4    2.159600E-01\n",
      "Mole fractions:    B 1.499917E-03    BE 4.948969E-01    C 1.248636E-03    F 4.953698E-01    H 1.247657E-03    HE 1.248554E-03    LI 1.339430E-03    N 1.900890E-03    O 1.248148E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.499917E-03    BE 4.948969E-01    C 1.248636E-03    F 4.953698E-01    H 1.247657E-03    HE 1.248554E-03    LI 1.339430E-03    N 1.900890E-03    O 1.248148E-03\n",
      "\n",
      "TEST#5    0.000000E+00\n",
      "Mole fractions:    B 2.386493E-01    BE 1.432747E-01    C 0.000000E+00    F 8.236216E-02    H 2.509815E-01    HE 0.000000E+00    LI 0.000000E+00    N 0.000000E+00    O 2.847324E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 2.386493E-01    BE 1.432747E-01    C 0.000000E+00    F 8.236216E-02    H 2.509815E-01    HE 0.000000E+00    LI 0.000000E+00    N 0.000000E+00    O 2.847324E-01\n",
      "\n",
      "TEST#6    9.257445E-07\n",
      "Mole fractions:    B 4.630148E-01    BE 7.010059E-03    C 0.000000E+00    F 5.714943E-04    H 1.048476E-08    HE 3.161595E-02    LI 4.977877E-01    N 1.021893E-08    O 0.000000E+00\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 4.630148E-01    BE 7.010059E-03    C 0.000000E+00    F 5.714943E-04    H 1.048476E-08    HE 3.161595E-02    LI 4.977877E-01    N 1.021893E-08    O 0.000000E+00\n",
      "\n",
      "TEST#7    2.155148E-01\n",
      "Mole fractions:    B 1.505653E-03    BE 1.112159E-03    C 1.252235E-03    F 9.693693E-04    H 1.248197E-03    HE 4.957341E-01    LI 4.956761E-01    N 1.250121E-03    O 1.252073E-03\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.505653E-03    BE 1.112159E-03    C 1.252235E-03    F 9.693693E-04    H 1.248197E-03    HE 4.957341E-01    LI 4.956761E-01    N 1.250121E-03    O 1.252073E-03\n",
      "\n",
      "TEST#8    1.966327E-13\n",
      "Mole fractions:    B 8.589054E-09    BE 6.772888E-02    C 0.000000E+00    F 1.631148E-02    H 8.928604E-10    HE 2.159058E-01    LI 5.801056E-02    N 0.000000E+00    O 6.420433E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 8.589054E-09    BE 6.772888E-02    C 0.000000E+00    F 1.631148E-02    H 8.928604E-10    HE 2.159058E-01    LI 5.801056E-02    N 0.000000E+00    O 6.420433E-01\n",
      "\n",
      "TEST#9    2.153334E-01\n",
      "Mole fractions:    B 1.506062E-03    BE 1.248574E-03    C 9.714644E-04    F 8.777872E-04    H 1.249597E-03    HE 1.250545E-03    LI 1.250622E-03    N 4.955182E-01    O 4.961272E-01\n",
      "Sublattice 1: 1.0 sites\n",
      "    B 1.506062E-03    BE 1.248574E-03    C 9.714644E-04    F 8.777872E-04    H 1.249597E-03    HE 1.250545E-03    LI 1.250622E-03    N 4.955182E-01    O 4.961272E-01\n",
      "\n"
     ]
    }
   ],
   "source": [
    "db_rose = Database('bigrose.tdb')\n",
    "my_phases_rose = ['TEST']\n",
    "comps = ['H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F']#, 'NE'] \n",
    "conds = dict()\n",
    "for comp in comps[:-1]:\n",
    "    conds[v.X(comp)] = 1/len(comps)\n",
    "%lprun -f Equilibrium.__init__ eq = Equilibrium(db_rose, comps, my_phases_rose, conds, T=1000.0, pdens=1000)\n",
    "print(eq)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "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.3.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}

{'fraction_non_alphanumeric': 0.18210449356054215, 'fraction_numerical': 0.23002080872841799, 'mean_word_length': 2.021066938498131, 'pattern_counts': {'":': 138, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1758745', 'n_tokens_mistral': 10713, 'n_tokens_neox': 8200, 'n_words': 1539}