Skip to content
Snippets Groups Projects
notebook_BHBH.ipynb 568 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a544d28c-c2e1-4c6a-b55b-8caec440743f",
   "metadata": {},
   "source": [
    "# Example use case: Binary black hole systems\n",
    "TODO: introduce the notebook\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e32dcdee",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from binarycpython.utils.functions import temp_dir\n",
    "from binarycpython.utils.run_system_wrapper import run_system\n",
    "TMP_DIR = temp_dir(\"notebooks\", \"notebook_BHBH\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b2abab48-433d-4936-8434-14804c52c9f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "      TIME      M1       M2   K1  K2           SEP        PER   ECC  R1/ROL1 R2/ROL2  TYPE RANDOM_SEED=30441 RANDOM_COUNT=0\n",
      "     0.0000   60.000    0.000  1  15            -1       -1   -1.00   0.000   0.000  \"INITIAL \"\n",
      "     6.1193   28.792    0.000  1  15            -1       -1   -1.00   0.000   0.000  \"Start Carbon Star 1\"\n",
      "     6.6492   26.756    0.000  2  15            -1       -1   -1.00   0.000   0.000  \"OFF_MS\"\n",
      "     6.6492   26.756    0.000  2  15            -1       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     6.6588   26.687    0.000  4  15            -1       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.2135    9.972    0.000  7  15            -1       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.2135    9.972    0.000  7  15            -1       -1   -1.00   0.000   0.000  \"End Carbon Star 1\"\n",
      "     7.3695    9.813    0.000  8  15            -1       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3967    8.827    0.000 14  15            -1       -1   -1.00   0.000   0.000  Randbuf=14439 - Mers(0)=0.354981 - Mers(1)=0.764989 - Mers(2)=0.550575 - Mers(3)=0.162006 \n",
      "     7.3967    8.827    0.000 14  15            -1       -1   -1.00   0.000   0.000  SN kick Ib/c (SN type 11 11, pre-explosion M=9.78488 Mc\"CO\"=7.23513 type=8) -> kick 1(190) vk=218.134 vr=0 omega=1.01791 phi=0.101323 -> vn=218.134 ; final sep 0 ecc -1 (random count 0) - Runaway v=(114.552,184.683,18.7769) |v|=218.134 : companion v=(0,0,0), |v|=0 ; - , dm(exploder) = 0.957894, dm(companion) = 0\n",
      "     7.3967    8.827    0.000 14  15            -1       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3967    8.827    0.000 14  15            -1       -1   -1.00   0.000   0.000  \"SN\"\n",
      " 15000.0000    8.827    0.000 14  15            -1       -1   -1.00   0.000   0.000  \"MAX_TIME\"\n",
      "\n"
     ]
    }
   ],
   "source": [
    "log_filename = \"log_file\"\n",
    "output = run_system(M_1=60, \n",
    "                    BH_prescription='BH_BELCZYNSKI',\n",
    "                    log_filename=log_filename, \n",
    "                    api_log_filename_prefix=TMP_DIR)\n",
    "with open(log_filename, 'r') as f:\n",
    "    print(f.read())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "937ad254-9672-4675-820b-41744f90b60c",
   "metadata": {},
   "source": [
    "Now we start a binary in a very wide orbit, so the stars do not interact (except by a little wind accretion). This makes a \"14 14\", i.e. BH+BH, pair."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "029fc3f2-f09a-49af-a32b-248505738f2e",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "      TIME      M1       M2   K1  K2           SEP        PER   ECC  R1/ROL1 R2/ROL2  TYPE RANDOM_SEED=35895 RANDOM_COUNT=0\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.009   0.009  \"INITIAL \"\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.009   0.009  \"BEG_SYMB\"\n",
      "     4.3583   42.081   35.930  1   1          3971     8.98 y  0.00   0.023   0.014  \"Start tidal lock 1\"\n",
      "     4.3928   41.632   35.894  1   1        3995.8      9.1 y  0.00   0.023   0.014  \"End tidal lock 1\"\n",
      "     6.1199   28.792   28.776  1   1        5374.9     16.5 y  0.00   0.014   0.014  \"Start Carbon Star 1\"\n",
      "     6.4219   27.615   27.603  1   1        5603.4     17.9 y  0.00   0.013   0.013  \"Start tidal lock 2\"\n",
      "     6.5403   27.157   27.151  1   1        5696.9     18.5 y  0.00   0.012   0.012  \"End tidal lock 2\"\n",
      "     6.6475   26.763   26.731  2   1        5791.5     19.1 y  0.00   0.010   0.011  \"TYPE_CHNGE\"\n",
      "     6.6548   26.730   26.729  2   1        5794.3     19.1 y  0.00   0.203   0.010  \"Start tidal lock 2\"\n",
      "     6.6550   26.728   26.729  2   1        5794.5     19.1 y  0.00   0.225   0.010  \"q-inv\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"OFF_MS\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"TYPE_CHNGE\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"End tidal lock 2\"\n",
      "     6.6556   26.721   26.728  2   2          5796     19.1 y  0.00   0.282   0.011  \"Start tidal lock 2\"\n",
      "     6.6559   26.716   26.727  2   2        5796.6     19.1 y  0.00   0.321   0.013  \"End tidal lock 2\"\n",
      "     6.6571   26.691   26.724  4   2        5798.4     19.2 y  0.00   0.546   0.021  \"TYPE_CHNGE\"\n",
      "     6.6649   26.502   26.683  4   4          5812     19.3 y  0.00   0.548   0.543  \"TYPE_CHNGE\"\n",
      "     7.1021   15.167   15.598  4   4        7342.9       36 y  0.00   0.588   0.574  \"Start Carbon Star 2\"\n",
      "     7.2663   10.178   10.480  4   4        8828.2     57.9 y  0.00   0.000   0.460  \"END_SYMB\"\n",
      "     7.2670   10.171   10.458  7   4        8837.8       58 y  0.00   0.000   0.455  \"TYPE_CHNGE\"\n",
      "     7.2670   10.171   10.458  7   4        8837.8       58 y  0.00   0.000   0.455  \"End Carbon Star 1\"\n",
      "     7.2671   10.171   10.454  4   4        8840.9       58 y  0.00   0.000   0.454  \"TYPE_CHNGE\"\n",
      "     7.2671   10.171   10.454  4   4        8840.9       58 y  0.00   0.000   0.454  \"Start Carbon Star 1\"\n",
      "     7.2672   10.170   10.450  7   4        8840.6       58 y  0.00   0.000   0.453  \"TYPE_CHNGE\"\n",
      "     7.2672   10.170   10.450  7   4        8840.6       58 y  0.00   0.000   0.453  \"End Carbon Star 1\"\n",
      "     7.2673   10.170   10.446  4   4        8843.6     58.1 y  0.00   0.000   0.452  \"TYPE_CHNGE\"\n",
      "     7.2673   10.170   10.446  4   4        8843.6     58.1 y  0.00   0.000   0.452  \"Start Carbon Star 1\"\n",
      "     7.2674   10.169   10.442  7   4        8843.3     58.1 y  0.00   0.000   0.451  \"TYPE_CHNGE\"\n",
      "     7.2674   10.169   10.442  7   4        8843.3     58.1 y  0.00   0.000   0.451  \"End Carbon Star 1\"\n",
      "     7.2676   10.169   10.438  4   4        8846.3     58.1 y  0.00   0.000   0.450  \"TYPE_CHNGE\"\n",
      "     7.2676   10.169   10.438  4   4        8846.3     58.1 y  0.00   0.000   0.450  \"Start Carbon Star 1\"\n",
      "     7.2677   10.168   10.435  7   4          8846     58.1 y  0.00   0.000   0.448  \"TYPE_CHNGE\"\n",
      "     7.2677   10.168   10.435  7   4          8846     58.1 y  0.00   0.000   0.448  \"End Carbon Star 1\"\n",
      "     7.2678   10.168   10.431  4   4        8848.8     58.2 y  0.00   0.000   0.447  \"TYPE_CHNGE\"\n",
      "     7.2678   10.168   10.431  4   4        8848.8     58.2 y  0.00   0.000   0.447  \"Start Carbon Star 1\"\n",
      "     7.2679   10.167   10.427  7   4        8848.6     58.2 y  0.00   0.000   0.446  \"TYPE_CHNGE\"\n",
      "     7.2679   10.167   10.427  7   4        8848.6     58.2 y  0.00   0.000   0.446  \"End Carbon Star 1\"\n",
      "     7.2680   10.167   10.424  4   4        8851.3     58.2 y  0.00   0.000   0.445  \"TYPE_CHNGE\"\n",
      "     7.2680   10.167   10.424  4   4        8851.3     58.2 y  0.00   0.000   0.445  \"Start Carbon Star 1\"\n",
      "     7.2681   10.166   10.420  7   4          8851     58.2 y  0.00   0.000   0.444  \"TYPE_CHNGE\"\n",
      "     7.2681   10.166   10.420  7   4          8851     58.2 y  0.00   0.000   0.444  \"End Carbon Star 1\"\n",
      "     7.2682   10.166   10.417  4   4        8853.7     58.2 y  0.00   0.000   0.442  \"TYPE_CHNGE\"\n",
      "     7.2682   10.166   10.417  4   4        8853.7     58.2 y  0.00   0.000   0.442  \"Start Carbon Star 1\"\n",
      "     7.2683   10.165   10.413  7   4        8853.5     58.2 y  0.00   0.000   0.441  \"TYPE_CHNGE\"\n",
      "     7.2683   10.165   10.413  7   4        8853.5     58.2 y  0.00   0.000   0.441  \"End Carbon Star 1\"\n",
      "     7.2684   10.165   10.410  4   4        8856.1     58.3 y  0.00   0.000   0.440  \"TYPE_CHNGE\"\n",
      "     7.2684   10.165   10.410  4   4        8856.1     58.3 y  0.00   0.000   0.440  \"Start Carbon Star 1\"\n",
      "     7.2685   10.164   10.407  7   4        8855.8     58.3 y  0.00   0.000   0.439  \"TYPE_CHNGE\"\n",
      "     7.2685   10.164   10.407  7   4        8855.8     58.3 y  0.00   0.000   0.439  \"End Carbon Star 1\"\n",
      "     7.2686   10.164   10.404  4   4        8858.4     58.3 y  0.00   0.000   0.437  \"TYPE_CHNGE\"\n",
      "     7.2686   10.164   10.404  4   4        8858.4     58.3 y  0.00   0.000   0.437  \"Start Carbon Star 1\"\n",
      "     7.2687   10.163   10.400  7   4        8858.1     58.3 y  0.00   0.000   0.436  \"TYPE_CHNGE\"\n",
      "     7.2687   10.163   10.400  7   4        8858.1     58.3 y  0.00   0.000   0.436  \"End Carbon Star 1\"\n",
      "     7.2688   10.163   10.397  4   4        8860.6     58.3 y  0.00   0.000   0.434  \"TYPE_CHNGE\"\n",
      "     7.2688   10.163   10.397  4   4        8860.6     58.3 y  0.00   0.000   0.434  \"Start Carbon Star 1\"\n",
      "     7.2689   10.162   10.394  7   4        8860.4     58.3 y  0.00   0.000   0.433  \"TYPE_CHNGE\"\n",
      "     7.2689   10.162   10.394  7   4        8860.4     58.3 y  0.00   0.000   0.433  \"End Carbon Star 1\"\n",
      "     7.2690   10.162   10.391  4   4        8862.8     58.4 y  0.00   0.000   0.432  \"TYPE_CHNGE\"\n",
      "     7.2690   10.162   10.391  4   4        8862.8     58.4 y  0.00   0.000   0.432  \"Start Carbon Star 1\"\n",
      "     7.2691   10.161   10.388  7   4        8862.5     58.4 y  0.00   0.000   0.430  \"TYPE_CHNGE\"\n",
      "     7.2691   10.161   10.388  7   4        8862.5     58.4 y  0.00   0.000   0.430  \"End Carbon Star 1\"\n",
      "     7.2692   10.162   10.385  4   4        8864.9     58.4 y  0.00   0.000   0.429  \"TYPE_CHNGE\"\n",
      "     7.2692   10.162   10.385  4   4        8864.9     58.4 y  0.00   0.000   0.429  \"Start Carbon Star 1\"\n",
      "     7.2693   10.161   10.382  7   4        8864.7     58.4 y  0.00   0.000   0.427  \"TYPE_CHNGE\"\n",
      "     7.2693   10.161   10.382  7   4        8864.7     58.4 y  0.00   0.000   0.427  \"End Carbon Star 1\"\n",
      "     7.2694   10.161   10.379  4   4          8867     58.4 y  0.00   0.000   0.425  \"TYPE_CHNGE\"\n",
      "     7.2694   10.161   10.379  4   4          8867     58.4 y  0.00   0.000   0.425  \"Start Carbon Star 1\"\n",
      "     7.2695   10.160   10.376  7   4        8866.8     58.4 y  0.00   0.000   0.424  \"TYPE_CHNGE\"\n",
      "     7.2695   10.160   10.376  7   4        8866.8     58.4 y  0.00   0.000   0.424  \"End Carbon Star 1\"\n",
      "     7.2696   10.160   10.373  4   4        8869.1     58.4 y  0.00   0.000   0.422  \"TYPE_CHNGE\"\n",
      "     7.2696   10.160   10.373  4   4        8869.1     58.4 y  0.00   0.000   0.422  \"Start Carbon Star 1\"\n",
      "     7.2697   10.159   10.370  7   4        8868.9     58.4 y  0.00   0.000   0.420  \"TYPE_CHNGE\"\n",
      "     7.2697   10.159   10.370  7   4        8868.9     58.4 y  0.00   0.000   0.420  \"End Carbon Star 1\"\n",
      "     7.2698   10.159   10.368  4   4        8871.1     58.5 y  0.00   0.000   0.419  \"TYPE_CHNGE\"\n",
      "     7.2698   10.159   10.368  4   4        8871.1     58.5 y  0.00   0.000   0.419  \"Start Carbon Star 1\"\n",
      "     7.2699   10.158   10.365  7   4        8870.9     58.5 y  0.00   0.000   0.417  \"TYPE_CHNGE\"\n",
      "     7.2699   10.158   10.365  7   4        8870.9     58.5 y  0.00   0.000   0.417  \"End Carbon Star 1\"\n",
      "     7.2700   10.158   10.362  4   4        8873.1     58.5 y  0.00   0.000   0.415  \"TYPE_CHNGE\"\n",
      "     7.2700   10.158   10.362  4   4        8873.1     58.5 y  0.00   0.000   0.415  \"Start Carbon Star 1\"\n",
      "     7.2700   10.157   10.359  7   4        8872.9     58.5 y  0.00   0.000   0.413  \"TYPE_CHNGE\"\n",
      "     7.2700   10.157   10.359  7   4        8872.9     58.5 y  0.00   0.000   0.413  \"End Carbon Star 1\"\n",
      "     7.2701   10.157   10.357  4   4        8875.1     58.5 y  0.00   0.000   0.411  \"TYPE_CHNGE\"\n",
      "     7.2701   10.157   10.357  4   4        8875.1     58.5 y  0.00   0.000   0.411  \"Start Carbon Star 1\"\n",
      "     7.2702   10.156   10.354  7   4        8874.8     58.5 y  0.00   0.000   0.409  \"TYPE_CHNGE\"\n",
      "     7.2702   10.156   10.354  7   4        8874.8     58.5 y  0.00   0.000   0.409  \"End Carbon Star 1\"\n",
      "     7.2703   10.157   10.352  4   4          8877     58.6 y  0.00   0.000   0.407  \"TYPE_CHNGE\"\n",
      "     7.2703   10.157   10.352  4   4          8877     58.6 y  0.00   0.000   0.407  \"Start Carbon Star 1\"\n",
      "     7.2704   10.156   10.349  7   4        8876.7     58.6 y  0.00   0.000   0.405  \"TYPE_CHNGE\"\n",
      "     7.2704   10.156   10.349  7   4        8876.7     58.6 y  0.00   0.000   0.405  \"End Carbon Star 1\"\n",
      "     7.2705   10.156   10.346  4   4        8878.9     58.6 y  0.00   0.000   0.403  \"TYPE_CHNGE\"\n",
      "     7.2705   10.156   10.346  4   4        8878.9     58.6 y  0.00   0.000   0.403  \"Start Carbon Star 1\"\n",
      "     7.2706   10.155   10.344  7   4        8878.6     58.6 y  0.00   0.000   0.400  \"TYPE_CHNGE\"\n",
      "     7.2706   10.155   10.344  7   4        8878.6     58.6 y  0.00   0.000   0.400  \"End Carbon Star 1\"\n",
      "     7.2706   10.155   10.342  4   4        8880.7     58.6 y  0.00   0.000   0.398  \"TYPE_CHNGE\"\n",
      "     7.2706   10.155   10.342  4   4        8880.7     58.6 y  0.00   0.000   0.398  \"Start Carbon Star 1\"\n",
      "     7.2707   10.154   10.339  7   4        8880.5     58.6 y  0.00   0.000   0.396  \"TYPE_CHNGE\"\n",
      "     7.2707   10.154   10.339  7   4        8880.5     58.6 y  0.00   0.000   0.396  \"End Carbon Star 1\"\n",
      "     7.2708   10.154   10.337  4   4        8882.6     58.6 y  0.00   0.000   0.393  \"TYPE_CHNGE\"\n",
      "     7.2708   10.154   10.337  4   4        8882.6     58.6 y  0.00   0.000   0.393  \"Start Carbon Star 1\"\n",
      "     7.2709   10.153   10.334  7   4        8882.3     58.6 y  0.00   0.000   0.391  \"TYPE_CHNGE\"\n",
      "     7.2709   10.153   10.334  7   4        8882.3     58.6 y  0.00   0.000   0.391  \"End Carbon Star 1\"\n",
      "     7.2710   10.153   10.332  4   4        8884.4     58.7 y  0.00   0.000   0.388  \"TYPE_CHNGE\"\n",
      "     7.2710   10.153   10.332  4   4        8884.4     58.7 y  0.00   0.000   0.388  \"Start Carbon Star 1\"\n",
      "     7.2710   10.152   10.330  7   4        8884.2     58.7 y  0.00   0.000   0.386  \"TYPE_CHNGE\"\n",
      "     7.2710   10.152   10.330  7   4        8884.2     58.7 y  0.00   0.000   0.386  \"End Carbon Star 1\"\n",
      "     7.2711   10.152   10.327  4   4        8886.2     58.7 y  0.00   0.000   0.383  \"TYPE_CHNGE\"\n",
      "     7.2711   10.152   10.327  4   4        8886.2     58.7 y  0.00   0.000   0.383  \"Start Carbon Star 1\"\n",
      "     7.2712   10.152   10.325  7   4          8886     58.7 y  0.00   0.000   0.380  \"TYPE_CHNGE\"\n",
      "     7.2712   10.152   10.325  7   4          8886     58.7 y  0.00   0.000   0.380  \"End Carbon Star 1\"\n",
      "     7.2713   10.152   10.323  4   4        8887.9     58.7 y  0.00   0.000   0.377  \"TYPE_CHNGE\"\n",
      "     7.2713   10.152   10.323  4   4        8887.9     58.7 y  0.00   0.000   0.377  \"Start Carbon Star 1\"\n",
      "     7.2714   10.151   10.320  7   4        8887.7     58.7 y  0.00   0.000   0.374  \"TYPE_CHNGE\"\n",
      "     7.2714   10.151   10.320  7   4        8887.7     58.7 y  0.00   0.000   0.374  \"End Carbon Star 1\"\n",
      "     7.2714   10.151   10.318  4   4        8889.7     58.7 y  0.00   0.000   0.371  \"TYPE_CHNGE\"\n",
      "     7.2714   10.151   10.318  4   4        8889.7     58.7 y  0.00   0.000   0.371  \"Start Carbon Star 1\"\n",
      "     7.2715   10.150   10.316  7   4        8889.5     58.7 y  0.00   0.000   0.368  \"TYPE_CHNGE\"\n",
      "     7.2715   10.150   10.316  7   4        8889.5     58.7 y  0.00   0.000   0.368  \"End Carbon Star 1\"\n",
      "     7.2716   10.150   10.314  4   4        8891.4     58.8 y  0.00   0.000   0.365  \"TYPE_CHNGE\"\n",
      "     7.2716   10.150   10.314  4   4        8891.4     58.8 y  0.00   0.000   0.365  \"Start Carbon Star 1\"\n",
      "     7.2717   10.149   10.312  7   4        8891.2     58.8 y  0.00   0.000   0.361  \"TYPE_CHNGE\"\n",
      "     7.2717   10.149   10.312  7   4        8891.2     58.8 y  0.00   0.000   0.361  \"End Carbon Star 1\"\n",
      "     7.2718   10.149   10.310  4   4        8893.1     58.8 y  0.00   0.000   0.358  \"TYPE_CHNGE\"\n",
      "     7.2718   10.149   10.310  4   4        8893.1     58.8 y  0.00   0.000   0.358  \"Start Carbon Star 1\"\n",
      "     7.2718   10.148   10.308  7   4        8892.9     58.8 y  0.00   0.000   0.355  \"TYPE_CHNGE\"\n",
      "     7.2718   10.148   10.308  7   4        8892.9     58.8 y  0.00   0.000   0.355  \"End Carbon Star 1\"\n",
      "     7.2719   10.148   10.306  4   4        8894.8     58.8 y  0.00   0.000   0.351  \"TYPE_CHNGE\"\n",
      "     7.2719   10.148   10.306  4   4        8894.8     58.8 y  0.00   0.000   0.351  \"Start Carbon Star 1\"\n",
      "     7.2720   10.147   10.304  7   4        8894.6     58.8 y  0.00   0.000   0.347  \"TYPE_CHNGE\"\n",
      "     7.2720   10.147   10.304  7   4        8894.6     58.8 y  0.00   0.000   0.347  \"End Carbon Star 1\"\n",
      "     7.2721   10.147   10.302  4   4        8896.5     58.8 y  0.00   0.000   0.343  \"TYPE_CHNGE\"\n",
      "     7.2721   10.147   10.302  4   4        8896.5     58.8 y  0.00   0.000   0.343  \"Start Carbon Star 1\"\n",
      "     7.2721   10.147   10.300  7   4        8896.3     58.8 y  0.00   0.000   0.340  \"TYPE_CHNGE\"\n",
      "     7.2721   10.147   10.300  7   4        8896.3     58.8 y  0.00   0.000   0.340  \"End Carbon Star 1\"\n",
      "     7.2722   10.147   10.298  4   4        8898.2     58.9 y  0.00   0.000   0.335  \"TYPE_CHNGE\"\n",
      "     7.2722   10.147   10.298  4   4        8898.2     58.9 y  0.00   0.000   0.335  \"Start Carbon Star 1\"\n",
      "     7.2723   10.146   10.296  7   4        8897.9     58.9 y  0.00   0.000   0.331  \"TYPE_CHNGE\"\n",
      "     7.2723   10.146   10.296  7   4        8897.9     58.9 y  0.00   0.000   0.331  \"End Carbon Star 1\"\n",
      "     7.2724   10.146   10.294  4   4        8899.8     58.9 y  0.00   0.000   0.327  \"TYPE_CHNGE\"\n",
      "     7.2724   10.146   10.294  4   4        8899.8     58.9 y  0.00   0.000   0.327  \"Start Carbon Star 1\"\n",
      "     7.2724   10.145   10.292  7   4        8899.6     58.9 y  0.00   0.000   0.323  \"TYPE_CHNGE\"\n",
      "     7.2724   10.145   10.292  7   4        8899.6     58.9 y  0.00   0.000   0.323  \"End Carbon Star 1\"\n",
      "     7.2725   10.145   10.290  4   4        8901.5     58.9 y  0.00   0.000   0.318  \"TYPE_CHNGE\"\n",
      "     7.2725   10.145   10.290  4   4        8901.5     58.9 y  0.00   0.000   0.318  \"Start Carbon Star 1\"\n",
      "     7.2726   10.144   10.288  7   4        8901.2     58.9 y  0.00   0.000   0.314  \"TYPE_CHNGE\"\n",
      "     7.2726   10.144   10.288  7   4        8901.2     58.9 y  0.00   0.000   0.314  \"End Carbon Star 1\"\n",
      "     7.2727   10.144   10.286  4   4        8903.1     58.9 y  0.00   0.000   0.309  \"TYPE_CHNGE\"\n",
      "     7.2727   10.144   10.286  4   4        8903.1     58.9 y  0.00   0.000   0.309  \"Start Carbon Star 1\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"TYPE_CHNGE\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"BEG_SYMB\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"End Carbon Star 1\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"TYPE_CHNGE\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"END_SYMB\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"Start Carbon Star 1\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"TYPE_CHNGE\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"BEG_SYMB\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"End Carbon Star 1\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"TYPE_CHNGE\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"END_SYMB\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"Start Carbon Star 1\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"TYPE_CHNGE\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"BEG_SYMB\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"End Carbon Star 1\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"TYPE_CHNGE\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"END_SYMB\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"Start Carbon Star 1\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"TYPE_CHNGE\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"BEG_SYMB\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"End Carbon Star 1\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"TYPE_CHNGE\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"END_SYMB\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"Start Carbon Star 1\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"TYPE_CHNGE\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"BEG_SYMB\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"End Carbon Star 1\"\n",
      "     7.2734   10.139   10.268  7   4        8911.4       59 y  0.00   0.000   0.253  \"END_SYMB\"\n",
      "     7.2773   10.136   10.217  7   4          8934     59.4 y  0.00   0.000   0.020  \"BEG_SYMB\"\n",
      "     7.2800   10.134   10.167  7   7        8949.5     59.6 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.2800   10.134   10.167  7   7        8949.5     59.6 y  0.00   0.000   0.000  \"End Carbon Star 2\"\n",
      "     7.3729   10.039   10.072  8   7        9043.1     60.8 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3781   10.034   10.067  8   8        9047.9     60.9 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  Randbuf=69569 - Mers(0)=0.911093 - Mers(1)=0.184829 - Mers(2)=0.636985 - Mers(3)=0.611763 - Mers(4)=0.837816 \n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  SN kick Ib/c (SN type 11 11, pre-explosion M=10.0118 Mc\"CO\"=7.4101 type=8) -> kick 1(190) vk=183.098 vr=20.5462 omega=5.26416 phi=0.22543 -> vn=192.531 ; final sep -102.908 ecc -1 (random count 0) - Runaway v=(105.9,-150.89,-34.7432) |v|=187.589 : companion v=(-9.90695,-1.03221,-0.104427), |v|=9.96112 ; - , dm(exploder) = 0.511114, dm(companion) = 0\n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  \"DISRUPT \"\n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  \"END_SYMB\"\n",
      "     7.3995    9.501   10.045 14   8       -102.91       -1   -1.00   0.000   0.000  \"SN\"\n",
      "     7.4046    9.501    9.586 14  14       -102.91       -1   -1.00   0.000   0.000  Mers(5)=0.776523 - Mers(6)=0.809662 - Mers(7)=0.448242 - Mers(8)=0.54439 \n",
      "     7.4046    9.501    9.586 14  14       -102.91       -1   -1.00   0.000   0.000  SN kick Ib/c (SN type 11 11, pre-explosion M=10.0399 Mc\"CO\"=7.43173 type=8) -> kick 1(190) vk=384.535 vr=0 omega=3.4205 phi=-0.103702 -> vn=384.535 ; final sep -102.908 ecc -1 (random count 5) - Runaway v=(-379.582,-106.329,10.8544) |v|=384.535 : companion v=(-5.13796e-51,-1.27569e-103,2.85406e-105), |v|=5.13796e-51 ; - , dm(exploder) = 0.454268, dm(companion) = 0\n",
      "     7.4046    9.501    9.586 14  14       -102.91       -1   -1.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.4046    9.501    9.586 14  14       -102.91       -1   -1.00   0.000   0.000  \"SN\"\n",
      " 15000.0000    9.501    9.586 14  14       -102.91       -1   -1.00   0.000   0.000  \"MAX_TIME\"\n",
      "\n"
     ]
    }
   ],
   "source": [
    "output = run_system(M_1=60, \n",
    "                    M_2=40,\n",
    "                    orbital_period=2000, # days\n",
    "                    BH_prescription='BH_BELCZYNSKI',\n",
    "                    log_filename=log_filename, \n",
    "                    wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n",
    "                    api_log_filename_prefix=TMP_DIR)\n",
    "with open(log_filename, 'r') as f:\n",
    "    print(f.read())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a36dbc9a-73f9-40ab-a54d-2b5555c49f12",
   "metadata": {},
   "source": [
    "So let's write a function to detect BHBH pairs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3ee47de3-bef9-4f87-ab69-702b27f7728d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BHBH system is unbound\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# BHBH detector : returns BHBH system data, or None if not found \n",
    "def BHBH(filename):\n",
    "    vb = False # set to True for debugging\n",
    "    with open(filename, 'r') as f:\n",
    "        for line in f.readlines():\n",
    "            data = line.split()\n",
    "            if vb == True:\n",
    "                print ('data line ', line)\n",
    "                print ('length ' + str(len(data)))\n",
    "            if len(data) >= 10 and data[0] != 'TIME': \n",
    "                stellar_type1 = int(data[3])\n",
    "                stellar_type2 = int(data[4])\n",
    "            \n",
    "                # remember: stellar type 14 == BH\n",
    "                if stellar_type1 == 14 and stellar_type2 == 14:\n",
    "                    # BHBH system\n",
    "                    if vb == True:\n",
    "                        print ('FOUND BHBH system')\n",
    "                        print (line)\n",
    "                    names = ['time','M1','M2','K1','K2','separation']\n",
    "                    d = {}\n",
    "                    for name in names:\n",
    "                        d[name] = float(data.pop(0))\n",
    "                        if vb == True:\n",
    "                            print(data)\n",
    "                    f.close()\n",
    "                    return d\n",
    "\n",
    "data = BHBH(log_filename)\n",
    "if data == None or len(data) == 0:\n",
    "    print(\"Oops: no data found\")\n",
    "if data['separation'] < 0.0:\n",
    "    print(\"BHBH system is unbound\")\n",
    "else:\n",
    "    print(\"BHBH system is bound\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8018ef52-093d-45ac-a00b-5fb721db3adb",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'M_1': 60, 'M_2': 40, 'orbital_period': 2000, 'BH_prescription': 'BH_FRYER12_RAPID', 'wind_mass_loss': 'WIND_ALGORITHM_BINARY_C_2020'}\n",
      "system 1 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -510.17}\n",
      "System 1 has separation -510.17\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -60.265}\n",
      "System 2 has separation -60.265\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -301.45}\n",
      "System 3 has separation -301.45\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -261.9}\n",
      "System 4 has separation -261.9\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -898.13}\n",
      "System 5 has separation -898.13\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -553.0}\n",
      "System 6 has separation -553.0\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -276.4}\n",
      "System 7 has separation -276.4\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -163.54}\n",
      "System 8 has separation -163.54\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -122.69}\n",
      "System 9 has separation -122.69\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -158.09}\n",
      "System 10 has separation -158.09\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -239.54}\n",
      "System 11 has separation -239.54\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -231.49}\n",
      "System 12 has separation -231.49\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -142.44}\n",
      "System 13 has separation -142.44\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -341.55}\n",
      "System 14 has separation -341.55\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -2421.7}\n",
      "System 15 has separation -2421.7\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -125.38}\n",
      "System 16 has separation -125.38\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -28369.0}\n",
      "System 17 has separation -28369.0\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -402.88}\n",
      "System 18 has separation -402.88\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -213.0}\n",
      "System 19 has separation -213.0\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -128.5}\n",
      "System 20 has separation -128.5\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -399.4}\n",
      "System 21 has separation -399.4\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -921.08}\n",
      "System 22 has separation -921.08\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -296.23}\n",
      "System 23 has separation -296.23\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -321.6}\n",
      "System 24 has separation -321.6\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -1876.7}\n",
      "System 25 has separation -1876.7\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -118.2}\n",
      "System 26 has separation -118.2\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -146.34}\n",
      "System 27 has separation -146.34\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -20447.0}\n",
      "System 28 has separation -20447.0\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -51.421}\n",
      "System 29 has separation -51.421\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -115.29}\n",
      "System 30 has separation -115.29\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -52.004}\n",
      "System 31 has separation -52.004\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -113.05}\n",
      "System 32 has separation -113.05\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -196.73}\n",
      "System 33 has separation -196.73\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -141.15}\n",
      "System 34 has separation -141.15\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -97.711}\n",
      "System 35 has separation -97.711\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -151.78}\n",
      "System 36 has separation -151.78\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -165.28}\n",
      "System 37 has separation -165.28\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -857.02}\n",
      "System 38 has separation -857.02\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -207.0}\n",
      "System 39 has separation -207.0\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -96.881}\n",
      "System 40 has separation -96.881\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -450.85}\n",
      "System 41 has separation -450.85\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -58.875}\n",
      "System 42 has separation -58.875\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -89.881}\n",
      "System 43 has separation -89.881\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -187.79}\n",
      "System 44 has separation -187.79\n",
      "system 45 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -640.75}\n",
      "System 45 has separation -640.75\n",
      "system 46 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -384.58}\n",
      "System 46 has separation -384.58\n",
      "system 47 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -95.184}\n",
      "System 47 has separation -95.184\n",
      "system 48 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -19622.0}\n",
      "System 48 has separation -19622.0\n",
      "system 49 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -306.87}\n",
      "System 49 has separation -306.87\n",
      "system 50 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -444.87}\n",
      "System 50 has separation -444.87\n",
      "system 51 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -143.29}\n",
      "System 51 has separation -143.29\n",
      "system 52 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -117.81}\n",
      "System 52 has separation -117.81\n",
      "system 53 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -728.44}\n",
      "System 53 has separation -728.44\n",
      "system 54 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -706.96}\n",
      "System 54 has separation -706.96\n",
      "system 55 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -241.67}\n",
      "System 55 has separation -241.67\n",
      "system 56 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -803.32}\n",
      "System 56 has separation -803.32\n",
      "system 57 / 100\n",
      "None\n",
      "system 58 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -140.9}\n",
      "System 58 has separation -140.9\n",
      "system 59 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -2439.0}\n",
      "System 59 has separation -2439.0\n",
      "system 60 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -235.82}\n",
      "System 60 has separation -235.82\n",
      "system 61 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -210.06}\n",
      "System 61 has separation -210.06\n",
      "system 62 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -12522.0}\n",
      "System 62 has separation -12522.0\n",
      "system 63 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -91.149}\n",
      "System 63 has separation -91.149\n",
      "system 64 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -117.6}\n",
      "System 64 has separation -117.6\n",
      "system 65 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -285.39}\n",
      "System 65 has separation -285.39\n",
      "system 66 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -320.08}\n",
      "System 66 has separation -320.08\n",
      "system 67 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -1360.5}\n",
      "System 67 has separation -1360.5\n",
      "system 68 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -1398.2}\n",
      "System 68 has separation -1398.2\n",
      "system 69 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -246.91}\n",
      "System 69 has separation -246.91\n",
      "system 70 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -147.77}\n",
      "System 70 has separation -147.77\n",
      "system 71 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -386.49}\n",
      "System 71 has separation -386.49\n",
      "system 72 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -208.84}\n",
      "System 72 has separation -208.84\n",
      "system 73 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -254.0}\n",
      "System 73 has separation -254.0\n",
      "system 74 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -142.09}\n",
      "System 74 has separation -142.09\n",
      "system 75 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -1882.9}\n",
      "System 75 has separation -1882.9\n",
      "system 76 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -123.45}\n",
      "System 76 has separation -123.45\n",
      "system 77 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -87.56}\n",
      "System 77 has separation -87.56\n",
      "system 78 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -128.24}\n",
      "System 78 has separation -128.24\n",
      "system 79 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -132.86}\n",
      "System 79 has separation -132.86\n",
      "system 80 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -164.58}\n",
      "System 80 has separation -164.58\n",
      "system 81 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -65.79}\n",
      "System 81 has separation -65.79\n",
      "system 82 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -184.42}\n",
      "System 82 has separation -184.42\n",
      "system 83 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -240.35}\n",
      "System 83 has separation -240.35\n",
      "system 84 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -129.51}\n",
      "System 84 has separation -129.51\n",
      "system 85 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -127.93}\n",
      "System 85 has separation -127.93\n",
      "system 86 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -199.57}\n",
      "System 86 has separation -199.57\n",
      "system 87 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -267.16}\n",
      "System 87 has separation -267.16\n",
      "system 88 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -18139.0}\n",
      "System 88 has separation -18139.0\n",
      "system 89 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -103.48}\n",
      "System 89 has separation -103.48\n",
      "system 90 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -274.74}\n",
      "System 90 has separation -274.74\n",
      "system 91 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -180.54}\n",
      "System 91 has separation -180.54\n",
      "system 92 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -80.117}\n",
      "System 92 has separation -80.117\n",
      "system 93 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -274.32}\n",
      "System 93 has separation -274.32\n",
      "system 94 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -1254.8}\n",
      "System 94 has separation -1254.8\n",
      "system 95 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -167.76}\n",
      "System 95 has separation -167.76\n",
      "system 96 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -122.65}\n",
      "System 96 has separation -122.65\n",
      "system 97 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -172.51}\n",
      "System 97 has separation -172.51\n",
      "system 98 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -557.64}\n",
      "System 98 has separation -557.64\n",
      "system 99 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -3082.6}\n",
      "System 99 has separation -3082.6\n",
      "system 100 / 100\n",
      "{'time': 7.4046, 'M1': 5.851, 'M2': 5.873, 'K1': 14.0, 'K2': 14.0, 'separation': -154.61}\n",
      "System 100 has separation -154.61\n"
     ]
    }
   ],
   "source": [
    "def search_for_BHBH(maxcount,**opts):\n",
    "    print(opts)\n",
    "    found = False\n",
    "    count = 0\n",
    "    while found == False and count < maxcount:\n",
    "        count = count + 1\n",
    "        print(\"system {} / {}\".format(count,maxcount))\n",
    "        output = run_system(**opts,\n",
    "                            log_filename=log_filename, \n",
    "                            api_log_filename_prefix=TMP_DIR,\n",
    "                            )\n",
    "        data = BHBH(log_filename)\n",
    "        print (data)\n",
    "        \n",
    "        if data == None or len(data) == 0:\n",
    "            # no BHBH found  \n",
    "            found = False\n",
    "        else:\n",
    "            print(\"System {count} has separation {sep}\".format(count=count,sep=data['separation']))\n",
    "            if data['separation'] > 0.0:\n",
    "                # found bound BHBH system\n",
    "                print('Found bound BHBH system')\n",
    "                found = True\n",
    "        \n",
    "                # show the log file\n",
    "                with open(log_filename, 'r') as f:\n",
    "                    print(f.read())\n",
    "\n",
    "args = dict(\n",
    "            M_1=60, \n",
    "            M_2=40,\n",
    "            orbital_period=2000, # days\n",
    "            BH_prescription='BH_FRYER12_RAPID',\n",
    "            wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n",
    "           )\n",
    "search_for_BHBH(100,**args)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c885143-db79-4fed-b4c4-0bd846e24f7d",
   "metadata": {},
   "source": [
    "How can we help the system become a BHBH merger? We can try turning off SN kicks."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3085ba82-430e-48f0-bca3-b19231e6109d",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'M_1': 60, 'M_2': 40, 'orbital_period': 2000, 'BH_prescription': 'BH_BELCZYNSKI', 'wind_mass_loss': 'WIND_ALGORITHM_BINARY_C_2020', 'sn_kick_dispersion_II': 0, 'sn_kick_dispersion_IBC': 0, 'sn_kick_dispersion_GRB_COLLAPSAR': 0}\n",
      "{'time': 7.4046, 'M1': 9.501, 'M2': 9.586, 'K1': 14.0, 'K2': 14.0, 'separation': 9548.9}\n",
      "System 1 has separation 9548.9\n",
      "      TIME      M1       M2   K1  K2           SEP        PER   ECC  R1/ROL1 R2/ROL2  TYPE RANDOM_SEED=32620 RANDOM_COUNT=0\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.009   0.009  \"INITIAL \"\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.009   0.009  \"BEG_SYMB\"\n",
      "     4.3583   42.081   35.930  1   1          3971     8.98 y  0.00   0.023   0.014  \"Start tidal lock 1\"\n",
      "     4.3928   41.632   35.894  1   1        3995.8      9.1 y  0.00   0.023   0.014  \"End tidal lock 1\"\n",
      "     6.1199   28.792   28.776  1   1        5374.9     16.5 y  0.00   0.014   0.014  \"Start Carbon Star 1\"\n",
      "     6.4219   27.615   27.603  1   1        5603.4     17.9 y  0.00   0.013   0.013  \"Start tidal lock 2\"\n",
      "     6.5403   27.157   27.151  1   1        5696.9     18.5 y  0.00   0.012   0.012  \"End tidal lock 2\"\n",
      "     6.6475   26.763   26.731  2   1        5791.5     19.1 y  0.00   0.010   0.011  \"TYPE_CHNGE\"\n",
      "     6.6548   26.730   26.729  2   1        5794.3     19.1 y  0.00   0.203   0.010  \"Start tidal lock 2\"\n",
      "     6.6550   26.728   26.729  2   1        5794.5     19.1 y  0.00   0.225   0.010  \"q-inv\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"OFF_MS\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"TYPE_CHNGE\"\n",
      "     6.6552   26.725   26.729  2   2        5795.5     19.1 y  0.00   0.246   0.010  \"End tidal lock 2\"\n",
      "     6.6556   26.721   26.728  2   2          5796     19.1 y  0.00   0.282   0.011  \"Start tidal lock 2\"\n",
      "     6.6559   26.716   26.727  2   2        5796.6     19.1 y  0.00   0.321   0.013  \"End tidal lock 2\"\n",
      "     6.6571   26.691   26.724  4   2        5798.4     19.2 y  0.00   0.546   0.021  \"TYPE_CHNGE\"\n",
      "     6.6649   26.502   26.683  4   4          5812     19.3 y  0.00   0.548   0.543  \"TYPE_CHNGE\"\n",
      "     7.1021   15.167   15.598  4   4        7342.9       36 y  0.00   0.588   0.574  \"Start Carbon Star 2\"\n",
      "     7.2663   10.178   10.480  4   4        8828.2     57.9 y  0.00   0.000   0.460  \"END_SYMB\"\n",
      "     7.2670   10.171   10.458  7   4        8837.8       58 y  0.00   0.000   0.455  \"TYPE_CHNGE\"\n",
      "     7.2670   10.171   10.458  7   4        8837.8       58 y  0.00   0.000   0.455  \"End Carbon Star 1\"\n",
      "     7.2671   10.171   10.454  4   4        8840.9       58 y  0.00   0.000   0.454  \"TYPE_CHNGE\"\n",
      "     7.2671   10.171   10.454  4   4        8840.9       58 y  0.00   0.000   0.454  \"Start Carbon Star 1\"\n",
      "     7.2672   10.170   10.450  7   4        8840.6       58 y  0.00   0.000   0.453  \"TYPE_CHNGE\"\n",
      "     7.2672   10.170   10.450  7   4        8840.6       58 y  0.00   0.000   0.453  \"End Carbon Star 1\"\n",
      "     7.2673   10.170   10.446  4   4        8843.6     58.1 y  0.00   0.000   0.452  \"TYPE_CHNGE\"\n",
      "     7.2673   10.170   10.446  4   4        8843.6     58.1 y  0.00   0.000   0.452  \"Start Carbon Star 1\"\n",
      "     7.2674   10.169   10.442  7   4        8843.3     58.1 y  0.00   0.000   0.451  \"TYPE_CHNGE\"\n",
      "     7.2674   10.169   10.442  7   4        8843.3     58.1 y  0.00   0.000   0.451  \"End Carbon Star 1\"\n",
      "     7.2676   10.169   10.438  4   4        8846.3     58.1 y  0.00   0.000   0.450  \"TYPE_CHNGE\"\n",
      "     7.2676   10.169   10.438  4   4        8846.3     58.1 y  0.00   0.000   0.450  \"Start Carbon Star 1\"\n",
      "     7.2677   10.168   10.435  7   4          8846     58.1 y  0.00   0.000   0.448  \"TYPE_CHNGE\"\n",
      "     7.2677   10.168   10.435  7   4          8846     58.1 y  0.00   0.000   0.448  \"End Carbon Star 1\"\n",
      "     7.2678   10.168   10.431  4   4        8848.8     58.2 y  0.00   0.000   0.447  \"TYPE_CHNGE\"\n",
      "     7.2678   10.168   10.431  4   4        8848.8     58.2 y  0.00   0.000   0.447  \"Start Carbon Star 1\"\n",
      "     7.2679   10.167   10.427  7   4        8848.6     58.2 y  0.00   0.000   0.446  \"TYPE_CHNGE\"\n",
      "     7.2679   10.167   10.427  7   4        8848.6     58.2 y  0.00   0.000   0.446  \"End Carbon Star 1\"\n",
      "     7.2680   10.167   10.424  4   4        8851.3     58.2 y  0.00   0.000   0.445  \"TYPE_CHNGE\"\n",
      "     7.2680   10.167   10.424  4   4        8851.3     58.2 y  0.00   0.000   0.445  \"Start Carbon Star 1\"\n",
      "     7.2681   10.166   10.420  7   4          8851     58.2 y  0.00   0.000   0.444  \"TYPE_CHNGE\"\n",
      "     7.2681   10.166   10.420  7   4          8851     58.2 y  0.00   0.000   0.444  \"End Carbon Star 1\"\n",
      "     7.2682   10.166   10.417  4   4        8853.7     58.2 y  0.00   0.000   0.442  \"TYPE_CHNGE\"\n",
      "     7.2682   10.166   10.417  4   4        8853.7     58.2 y  0.00   0.000   0.442  \"Start Carbon Star 1\"\n",
      "     7.2683   10.165   10.413  7   4        8853.5     58.2 y  0.00   0.000   0.441  \"TYPE_CHNGE\"\n",
      "     7.2683   10.165   10.413  7   4        8853.5     58.2 y  0.00   0.000   0.441  \"End Carbon Star 1\"\n",
      "     7.2684   10.165   10.410  4   4        8856.1     58.3 y  0.00   0.000   0.440  \"TYPE_CHNGE\"\n",
      "     7.2684   10.165   10.410  4   4        8856.1     58.3 y  0.00   0.000   0.440  \"Start Carbon Star 1\"\n",
      "     7.2685   10.164   10.407  7   4        8855.8     58.3 y  0.00   0.000   0.439  \"TYPE_CHNGE\"\n",
      "     7.2685   10.164   10.407  7   4        8855.8     58.3 y  0.00   0.000   0.439  \"End Carbon Star 1\"\n",
      "     7.2686   10.164   10.404  4   4        8858.4     58.3 y  0.00   0.000   0.437  \"TYPE_CHNGE\"\n",
      "     7.2686   10.164   10.404  4   4        8858.4     58.3 y  0.00   0.000   0.437  \"Start Carbon Star 1\"\n",
      "     7.2687   10.163   10.400  7   4        8858.1     58.3 y  0.00   0.000   0.436  \"TYPE_CHNGE\"\n",
      "     7.2687   10.163   10.400  7   4        8858.1     58.3 y  0.00   0.000   0.436  \"End Carbon Star 1\"\n",
      "     7.2688   10.163   10.397  4   4        8860.6     58.3 y  0.00   0.000   0.434  \"TYPE_CHNGE\"\n",
      "     7.2688   10.163   10.397  4   4        8860.6     58.3 y  0.00   0.000   0.434  \"Start Carbon Star 1\"\n",
      "     7.2689   10.162   10.394  7   4        8860.4     58.3 y  0.00   0.000   0.433  \"TYPE_CHNGE\"\n",
      "     7.2689   10.162   10.394  7   4        8860.4     58.3 y  0.00   0.000   0.433  \"End Carbon Star 1\"\n",
      "     7.2690   10.162   10.391  4   4        8862.8     58.4 y  0.00   0.000   0.432  \"TYPE_CHNGE\"\n",
      "     7.2690   10.162   10.391  4   4        8862.8     58.4 y  0.00   0.000   0.432  \"Start Carbon Star 1\"\n",
      "     7.2691   10.161   10.388  7   4        8862.5     58.4 y  0.00   0.000   0.430  \"TYPE_CHNGE\"\n",
      "     7.2691   10.161   10.388  7   4        8862.5     58.4 y  0.00   0.000   0.430  \"End Carbon Star 1\"\n",
      "     7.2692   10.162   10.385  4   4        8864.9     58.4 y  0.00   0.000   0.429  \"TYPE_CHNGE\"\n",
      "     7.2692   10.162   10.385  4   4        8864.9     58.4 y  0.00   0.000   0.429  \"Start Carbon Star 1\"\n",
      "     7.2693   10.161   10.382  7   4        8864.7     58.4 y  0.00   0.000   0.427  \"TYPE_CHNGE\"\n",
      "     7.2693   10.161   10.382  7   4        8864.7     58.4 y  0.00   0.000   0.427  \"End Carbon Star 1\"\n",
      "     7.2694   10.161   10.379  4   4          8867     58.4 y  0.00   0.000   0.425  \"TYPE_CHNGE\"\n",
      "     7.2694   10.161   10.379  4   4          8867     58.4 y  0.00   0.000   0.425  \"Start Carbon Star 1\"\n",
      "     7.2695   10.160   10.376  7   4        8866.8     58.4 y  0.00   0.000   0.424  \"TYPE_CHNGE\"\n",
      "     7.2695   10.160   10.376  7   4        8866.8     58.4 y  0.00   0.000   0.424  \"End Carbon Star 1\"\n",
      "     7.2696   10.160   10.373  4   4        8869.1     58.4 y  0.00   0.000   0.422  \"TYPE_CHNGE\"\n",
      "     7.2696   10.160   10.373  4   4        8869.1     58.4 y  0.00   0.000   0.422  \"Start Carbon Star 1\"\n",
      "     7.2697   10.159   10.370  7   4        8868.9     58.4 y  0.00   0.000   0.420  \"TYPE_CHNGE\"\n",
      "     7.2697   10.159   10.370  7   4        8868.9     58.4 y  0.00   0.000   0.420  \"End Carbon Star 1\"\n",
      "     7.2698   10.159   10.368  4   4        8871.1     58.5 y  0.00   0.000   0.419  \"TYPE_CHNGE\"\n",
      "     7.2698   10.159   10.368  4   4        8871.1     58.5 y  0.00   0.000   0.419  \"Start Carbon Star 1\"\n",
      "     7.2699   10.158   10.365  7   4        8870.9     58.5 y  0.00   0.000   0.417  \"TYPE_CHNGE\"\n",
      "     7.2699   10.158   10.365  7   4        8870.9     58.5 y  0.00   0.000   0.417  \"End Carbon Star 1\"\n",
      "     7.2700   10.158   10.362  4   4        8873.1     58.5 y  0.00   0.000   0.415  \"TYPE_CHNGE\"\n",
      "     7.2700   10.158   10.362  4   4        8873.1     58.5 y  0.00   0.000   0.415  \"Start Carbon Star 1\"\n",
      "     7.2700   10.157   10.359  7   4        8872.9     58.5 y  0.00   0.000   0.413  \"TYPE_CHNGE\"\n",
      "     7.2700   10.157   10.359  7   4        8872.9     58.5 y  0.00   0.000   0.413  \"End Carbon Star 1\"\n",
      "     7.2701   10.157   10.357  4   4        8875.1     58.5 y  0.00   0.000   0.411  \"TYPE_CHNGE\"\n",
      "     7.2701   10.157   10.357  4   4        8875.1     58.5 y  0.00   0.000   0.411  \"Start Carbon Star 1\"\n",
      "     7.2702   10.156   10.354  7   4        8874.8     58.5 y  0.00   0.000   0.409  \"TYPE_CHNGE\"\n",
      "     7.2702   10.156   10.354  7   4        8874.8     58.5 y  0.00   0.000   0.409  \"End Carbon Star 1\"\n",
      "     7.2703   10.157   10.352  4   4          8877     58.6 y  0.00   0.000   0.407  \"TYPE_CHNGE\"\n",
      "     7.2703   10.157   10.352  4   4          8877     58.6 y  0.00   0.000   0.407  \"Start Carbon Star 1\"\n",
      "     7.2704   10.156   10.349  7   4        8876.7     58.6 y  0.00   0.000   0.405  \"TYPE_CHNGE\"\n",
      "     7.2704   10.156   10.349  7   4        8876.7     58.6 y  0.00   0.000   0.405  \"End Carbon Star 1\"\n",
      "     7.2705   10.156   10.346  4   4        8878.9     58.6 y  0.00   0.000   0.403  \"TYPE_CHNGE\"\n",
      "     7.2705   10.156   10.346  4   4        8878.9     58.6 y  0.00   0.000   0.403  \"Start Carbon Star 1\"\n",
      "     7.2706   10.155   10.344  7   4        8878.6     58.6 y  0.00   0.000   0.400  \"TYPE_CHNGE\"\n",
      "     7.2706   10.155   10.344  7   4        8878.6     58.6 y  0.00   0.000   0.400  \"End Carbon Star 1\"\n",
      "     7.2706   10.155   10.342  4   4        8880.7     58.6 y  0.00   0.000   0.398  \"TYPE_CHNGE\"\n",
      "     7.2706   10.155   10.342  4   4        8880.7     58.6 y  0.00   0.000   0.398  \"Start Carbon Star 1\"\n",
      "     7.2707   10.154   10.339  7   4        8880.5     58.6 y  0.00   0.000   0.396  \"TYPE_CHNGE\"\n",
      "     7.2707   10.154   10.339  7   4        8880.5     58.6 y  0.00   0.000   0.396  \"End Carbon Star 1\"\n",
      "     7.2708   10.154   10.337  4   4        8882.6     58.6 y  0.00   0.000   0.393  \"TYPE_CHNGE\"\n",
      "     7.2708   10.154   10.337  4   4        8882.6     58.6 y  0.00   0.000   0.393  \"Start Carbon Star 1\"\n",
      "     7.2709   10.153   10.334  7   4        8882.3     58.6 y  0.00   0.000   0.391  \"TYPE_CHNGE\"\n",
      "     7.2709   10.153   10.334  7   4        8882.3     58.6 y  0.00   0.000   0.391  \"End Carbon Star 1\"\n",
      "     7.2710   10.153   10.332  4   4        8884.4     58.7 y  0.00   0.000   0.388  \"TYPE_CHNGE\"\n",
      "     7.2710   10.153   10.332  4   4        8884.4     58.7 y  0.00   0.000   0.388  \"Start Carbon Star 1\"\n",
      "     7.2710   10.152   10.330  7   4        8884.2     58.7 y  0.00   0.000   0.386  \"TYPE_CHNGE\"\n",
      "     7.2710   10.152   10.330  7   4        8884.2     58.7 y  0.00   0.000   0.386  \"End Carbon Star 1\"\n",
      "     7.2711   10.152   10.327  4   4        8886.2     58.7 y  0.00   0.000   0.383  \"TYPE_CHNGE\"\n",
      "     7.2711   10.152   10.327  4   4        8886.2     58.7 y  0.00   0.000   0.383  \"Start Carbon Star 1\"\n",
      "     7.2712   10.152   10.325  7   4          8886     58.7 y  0.00   0.000   0.380  \"TYPE_CHNGE\"\n",
      "     7.2712   10.152   10.325  7   4          8886     58.7 y  0.00   0.000   0.380  \"End Carbon Star 1\"\n",
      "     7.2713   10.152   10.323  4   4        8887.9     58.7 y  0.00   0.000   0.377  \"TYPE_CHNGE\"\n",
      "     7.2713   10.152   10.323  4   4        8887.9     58.7 y  0.00   0.000   0.377  \"Start Carbon Star 1\"\n",
      "     7.2714   10.151   10.320  7   4        8887.7     58.7 y  0.00   0.000   0.374  \"TYPE_CHNGE\"\n",
      "     7.2714   10.151   10.320  7   4        8887.7     58.7 y  0.00   0.000   0.374  \"End Carbon Star 1\"\n",
      "     7.2714   10.151   10.318  4   4        8889.7     58.7 y  0.00   0.000   0.371  \"TYPE_CHNGE\"\n",
      "     7.2714   10.151   10.318  4   4        8889.7     58.7 y  0.00   0.000   0.371  \"Start Carbon Star 1\"\n",
      "     7.2715   10.150   10.316  7   4        8889.5     58.7 y  0.00   0.000   0.368  \"TYPE_CHNGE\"\n",
      "     7.2715   10.150   10.316  7   4        8889.5     58.7 y  0.00   0.000   0.368  \"End Carbon Star 1\"\n",
      "     7.2716   10.150   10.314  4   4        8891.4     58.8 y  0.00   0.000   0.365  \"TYPE_CHNGE\"\n",
      "     7.2716   10.150   10.314  4   4        8891.4     58.8 y  0.00   0.000   0.365  \"Start Carbon Star 1\"\n",
      "     7.2717   10.149   10.312  7   4        8891.2     58.8 y  0.00   0.000   0.361  \"TYPE_CHNGE\"\n",
      "     7.2717   10.149   10.312  7   4        8891.2     58.8 y  0.00   0.000   0.361  \"End Carbon Star 1\"\n",
      "     7.2718   10.149   10.310  4   4        8893.1     58.8 y  0.00   0.000   0.358  \"TYPE_CHNGE\"\n",
      "     7.2718   10.149   10.310  4   4        8893.1     58.8 y  0.00   0.000   0.358  \"Start Carbon Star 1\"\n",
      "     7.2718   10.148   10.308  7   4        8892.9     58.8 y  0.00   0.000   0.355  \"TYPE_CHNGE\"\n",
      "     7.2718   10.148   10.308  7   4        8892.9     58.8 y  0.00   0.000   0.355  \"End Carbon Star 1\"\n",
      "     7.2719   10.148   10.306  4   4        8894.8     58.8 y  0.00   0.000   0.351  \"TYPE_CHNGE\"\n",
      "     7.2719   10.148   10.306  4   4        8894.8     58.8 y  0.00   0.000   0.351  \"Start Carbon Star 1\"\n",
      "     7.2720   10.147   10.304  7   4        8894.6     58.8 y  0.00   0.000   0.347  \"TYPE_CHNGE\"\n",
      "     7.2720   10.147   10.304  7   4        8894.6     58.8 y  0.00   0.000   0.347  \"End Carbon Star 1\"\n",
      "     7.2721   10.147   10.302  4   4        8896.5     58.8 y  0.00   0.000   0.343  \"TYPE_CHNGE\"\n",
      "     7.2721   10.147   10.302  4   4        8896.5     58.8 y  0.00   0.000   0.343  \"Start Carbon Star 1\"\n",
      "     7.2721   10.147   10.300  7   4        8896.3     58.8 y  0.00   0.000   0.340  \"TYPE_CHNGE\"\n",
      "     7.2721   10.147   10.300  7   4        8896.3     58.8 y  0.00   0.000   0.340  \"End Carbon Star 1\"\n",
      "     7.2722   10.147   10.298  4   4        8898.2     58.9 y  0.00   0.000   0.335  \"TYPE_CHNGE\"\n",
      "     7.2722   10.147   10.298  4   4        8898.2     58.9 y  0.00   0.000   0.335  \"Start Carbon Star 1\"\n",
      "     7.2723   10.146   10.296  7   4        8897.9     58.9 y  0.00   0.000   0.331  \"TYPE_CHNGE\"\n",
      "     7.2723   10.146   10.296  7   4        8897.9     58.9 y  0.00   0.000   0.331  \"End Carbon Star 1\"\n",
      "     7.2724   10.146   10.294  4   4        8899.8     58.9 y  0.00   0.000   0.327  \"TYPE_CHNGE\"\n",
      "     7.2724   10.146   10.294  4   4        8899.8     58.9 y  0.00   0.000   0.327  \"Start Carbon Star 1\"\n",
      "     7.2724   10.145   10.292  7   4        8899.6     58.9 y  0.00   0.000   0.323  \"TYPE_CHNGE\"\n",
      "     7.2724   10.145   10.292  7   4        8899.6     58.9 y  0.00   0.000   0.323  \"End Carbon Star 1\"\n",
      "     7.2725   10.145   10.290  4   4        8901.5     58.9 y  0.00   0.000   0.318  \"TYPE_CHNGE\"\n",
      "     7.2725   10.145   10.290  4   4        8901.5     58.9 y  0.00   0.000   0.318  \"Start Carbon Star 1\"\n",
      "     7.2726   10.144   10.288  7   4        8901.2     58.9 y  0.00   0.000   0.314  \"TYPE_CHNGE\"\n",
      "     7.2726   10.144   10.288  7   4        8901.2     58.9 y  0.00   0.000   0.314  \"End Carbon Star 1\"\n",
      "     7.2727   10.144   10.286  4   4        8903.1     58.9 y  0.00   0.000   0.309  \"TYPE_CHNGE\"\n",
      "     7.2727   10.144   10.286  4   4        8903.1     58.9 y  0.00   0.000   0.309  \"Start Carbon Star 1\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"TYPE_CHNGE\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"BEG_SYMB\"\n",
      "     7.2727   10.143   10.284  7   4        8902.9     58.9 y  0.00   0.000   0.304  \"End Carbon Star 1\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"TYPE_CHNGE\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"END_SYMB\"\n",
      "     7.2728   10.143   10.282  4   4        8904.8       59 y  0.00   0.000   0.299  \"Start Carbon Star 1\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"TYPE_CHNGE\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"BEG_SYMB\"\n",
      "     7.2729   10.142   10.281  7   4        8904.5       59 y  0.00   0.000   0.294  \"End Carbon Star 1\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"TYPE_CHNGE\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"END_SYMB\"\n",
      "     7.2730   10.142   10.279  4   4        8906.4       59 y  0.00   0.000   0.288  \"Start Carbon Star 1\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"TYPE_CHNGE\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"BEG_SYMB\"\n",
      "     7.2730   10.141   10.277  7   4        8906.2       59 y  0.00   0.000   0.283  \"End Carbon Star 1\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"TYPE_CHNGE\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"END_SYMB\"\n",
      "     7.2731   10.141   10.275  4   4        8908.1       59 y  0.00   0.000   0.277  \"Start Carbon Star 1\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"TYPE_CHNGE\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"BEG_SYMB\"\n",
      "     7.2732   10.140   10.274  7   4        8907.8       59 y  0.00   0.000   0.272  \"End Carbon Star 1\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"TYPE_CHNGE\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"END_SYMB\"\n",
      "     7.2733   10.140   10.272  4   4        8909.7       59 y  0.00   0.000   0.266  \"Start Carbon Star 1\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"TYPE_CHNGE\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"BEG_SYMB\"\n",
      "     7.2734   10.139   10.270  7   4        8909.4       59 y  0.00   0.000   0.260  \"End Carbon Star 1\"\n",
      "     7.2734   10.139   10.268  7   4        8911.4       59 y  0.00   0.000   0.253  \"END_SYMB\"\n",
      "     7.2773   10.136   10.217  7   4          8934     59.4 y  0.00   0.000   0.020  \"BEG_SYMB\"\n",
      "     7.2800   10.134   10.167  7   7        8949.5     59.6 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.2800   10.134   10.167  7   7        8949.5     59.6 y  0.00   0.000   0.000  \"End Carbon Star 2\"\n",
      "     7.3729   10.039   10.072  8   7        9043.1     60.8 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3781   10.034   10.067  8   8        9047.9     60.9 y  0.00   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3995    9.501   10.045 14   8        9310.2     64.4 y  0.03   0.000   0.000  Randbuf=60101 - Mers(0)=0.246604 - Mers(1)=0.283972 - Mers(2)=0.469524 - Mers(3)=0.55473 - Mers(4)=0.379292 \n",
      "     7.3995    9.501   10.045 14   8        9310.2     64.4 y  0.03   0.000   0.000  SN kick Ib/c (SN type 11 11, pre-explosion M=10.0118 Mc\"CO\"=7.4101 type=8) -> kick 1(0) vk=0 vr=20.5462 omega=2.38316 phi=0.109679 -> vn=20.5462 ; final sep 9310.19 ecc 0.0261496 (random count 0) - Runaway v=(0,0,0) |v|=0 : companion v=(0,0,0), |v|=0 ; - , dm(exploder) = 0.511114, dm(companion) = 0\n",
      "     7.3995    9.501   10.045 14   8        9310.2     64.4 y  0.03   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.3995    9.501   10.045 14   8        9310.2     64.4 y  0.03   0.000   0.000  \"SN\"\n",
      "     7.4011    9.501   10.043 14   8        9308.7     64.4 y  0.03   0.000   0.000  \"END_SYMB\"\n",
      "     7.4046    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  Mers(5)=0.107187 - Mers(6)=0.679223 - Mers(7)=0.238584 - Mers(8)=0.860402 - Mers(9)=0.891056 \n",
      "     7.4046    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  SN kick Ib/c (SN type 11 11, pre-explosion M=10.0399 Mc\"CO\"=7.43173 type=8) -> kick 1(0) vk=0 vr=20.4186 omega=5.59867 phi=0.804961 -> vn=20.4186 ; final sep 9548.86 ecc 0.0474572 (random count 5) - Runaway v=(0,0,0) |v|=0 : companion v=(0,0,0), |v|=0 ; - , dm(exploder) = 0.454268, dm(companion) = 0\n",
      "     7.4046    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  \"TYPE_CHNGE\"\n",
      "     7.4046    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  \"SN\"\n",
      "     7.4146    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  \"END_SYMB\"\n",
      " 15000.0000    9.501    9.586 14  14        9548.9     67.7 y  0.05   0.000   0.000  \"MAX_TIME\"\n",
      "\n"
     ]
    }
   ],
   "source": [
    "args = dict(\n",
    "            M_1=60, \n",
    "            M_2=40,\n",
    "            orbital_period=2000, # days    \n",
    "            BH_prescription='BH_BELCZYNSKI',\n",
    "            wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n",
    "            sn_kick_dispersion_II=0,\n",
    "            sn_kick_dispersion_IBC=0,\n",
    "            sn_kick_dispersion_GRB_COLLAPSAR=0,\n",
    "           )\n",
    "search_for_BHBH(1,**args)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "558b899e-4201-4f46-8b59-dc65b81b05d1",
   "metadata": {},
   "source": [
    "You should now have found a BHBH system but usually they have very wide orbits. This is caused by mass loss before, and during, the supernova. \n",
    "\n",
    "We can reduce the former by setting the wind mass loss to zero. This can be done unphysically by setting wind_mass_loss=0, or you can reduce the massive-star winds by setting the metallicity to be small, e.g. $10^{-3}$. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d39256ed-d72c-440a-99f3-d86005bd8214",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'M_1': 60, 'M_2': 40, 'metallicity': 0.001, 'orbital_period': 2000, 'BH_prescription': 'BH_BELCZYNSKI', 'wind_mass_loss': 'WIND_ALGORITHM_BINARY_C_2020', 'sn_kick_dispersion_II': 0, 'sn_kick_dispersion_IBC': 0, 'sn_kick_dispersion_GRB_COLLAPSAR': 0}\n",
      "{'time': 6.5064, 'M1': 19.536, 'M2': 11.468, 'K1': 14.0, 'K2': 14.0, 'separation': 6493.9}\n",
      "System 1 has separation 6493.9\n",
      "      TIME      M1       M2   K1  K2           SEP        PER   ECC  R1/ROL1 R2/ROL2  TYPE RANDOM_SEED=53854 RANDOM_COUNT=0\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.006   0.006  \"INITIAL \"\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.006   0.006  \"Start Carbon Star 1\"\n",
      "     0.0000   60.000   40.000  1   1        3101.2     5.48 y  0.00   0.006   0.006  \"BEG_SYMB\"\n",
      "     3.8674   57.840   39.505  2   1        3185.7     5.78 y  0.00   0.017   0.010  \"TYPE_CHNGE\"\n",
      "     3.8704   57.600   39.509  2   1        3192.2      5.8 y  0.00   0.393   0.010  \"Start tidal lock 1\"\n",
      "     3.8704   57.592   39.509  2   1        3192.4      5.8 y  0.00   0.418   0.010  \"End tidal lock 1\"\n",
      "     3.8706   57.568   39.510  4   1          3193     5.81 y  0.00   0.496   0.010  \"TYPE_CHNGE\"\n",
      "     3.8910   54.510   39.758  4   1        3246.3     6.04 y  0.00   1.000   0.010  \"BEG_RCHE 1>2\"\n",
      "     3.9650   42.495   42.571  4   1        3223.5     6.29 y  0.00   1.913   0.009  \"q-inv\"\n",
      "     4.0585   24.961   50.453  4   1        3211.5     6.65 y  0.00   0.999   0.007  \"END_RCHE 1!>2\"\n",
      "     4.0649   24.747   50.479  7   1        3216.1     6.67 y  0.00   0.002   0.007  \"TYPE_CHNGE\"\n",
      "     4.0649   24.747   50.479  7   1        3216.1     6.67 y  0.00   0.002   0.007  \"End Carbon Star 1\"\n",
      "     4.2967   19.576   50.392  7   1        3429.9     7.61 y  0.00   0.001   0.007  \"BEG_BSS \"\n",
      "     4.2996   19.512   50.390 14   1        3462.2     7.73 y  0.00   0.000   0.007  Randbuf=59616 - Mers(0)=0.665406 - Mers(1)=0.861368 - Mers(2)=0.162038 - Mers(3)=0.282234 - Mers(4)=0.0511173 \n",
      "     4.2996   19.512   50.390 14   1        3462.2     7.73 y  0.00   0.000   0.007  SN kick Ib/c (SN type 11 11, pre-explosion M=19.5117 Mc\"CO\"=14.7326 type=8) -> kick 1(0) vk=0 vr=62.0717 omega=0.32118 phi=-0.450629 -> vn=62.0717 ; final sep 3462.21 ecc 0 (random count 0) - Runaway v=(0,0,0) |v|=0 : companion v=(0,0,0), |v|=0 ; - , dm(exploder) = 0, dm(companion) = 0\n",
      "     4.2996   19.512   50.390 14   1        3462.2     7.73 y  0.00   0.000   0.007  \"TYPE_CHNGE\"\n",
      "     4.2996   19.512   50.390 14   1        3462.2     7.73 y  0.00   0.000   0.007  \"SN\"\n",
      "     4.3096   19.512   50.386 14   1        3462.1     7.73 y  0.00   0.000   0.007  \"END_SYMB\"\n",
      "     5.9074   19.512   49.493 14   2        3507.6     7.93 y  0.00   0.000   0.012  \"OFF_MS\"\n",
      "     5.9074   19.512   49.493 14   2        3507.6     7.93 y  0.00   0.000   0.012  \"TYPE_CHNGE\"\n",
      "     5.9074   19.512   49.493 14   2        3507.6     7.93 y  0.00   0.000   0.012  \"END_BSS\"\n",
      "     5.9113   19.512   49.242 14   4        3529.1     8.02 y  0.00   0.000   0.223  \"TYPE_CHNGE\"\n",