Skip to content

Commit

Permalink
Merge pull request #5 from gaetanfacchinetti/injection
Browse files Browse the repository at this point in the history
Injection
  • Loading branch information
gaetanfacchinetti committed Nov 9, 2023
2 parents b4a3d13 + ac94d99 commit d82c6cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ Flags related to the effective parametrisation:

### 3. run_lightcone arguments

- `coarsen_factor`: *integer* that redifines the redshift steps to match with the table of **DarkHistory**. Note that if we use energy deposition through the templates this value can be arbitrary. Be default it is set to 16 to match with the nominal redshift step definition of 21cmFAST.
- `coarsen_factor`: *integer* redifines the redshift steps to match with the table of **DarkHistory**. Note that if we use energy deposition through the templates this value can be arbitrary. Be default it is set to 16 to match with the nominal redshift step definition of 21cmFAST.
- `verbose_ntbk`: *boolean* if `True` outputs more information during the run, which can be useful when running 21cmFAST on small boxed in a notebook.
- `output_exotic_data`: *boolean* if `True` gives a second output to the `run_lightcone()` function in the form of a dictionnary. This dictionnary contains the deposition fractions `'f'`, electron fraction `'x'`, gaz temperature `'Tm'` at every redshifts in `'z'`.
- `heating_rate_output`: *string* that defines a file where to save the the heating rate due to exotic energy injection and astrophycial energy injection. If nothing specified, the heating rates are not saved.
- `heating_rate_output`: *string* defines a file where to save the the heating rate due to exotic energy injection and astrophycial energy injection. If nothing specified, the heating rates are not saved.

## Using exo21cmFAST

Expand Down
23 changes: 9 additions & 14 deletions examples/example_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'p21c' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb Cellule 11\u001b[0m in \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m lightcone_templates, output_exotic_energy_injection_templates \u001b[39m=\u001b[39m p21c\u001b[39m.\u001b[39mrun_lightcone(\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m redshift \u001b[39m=\u001b[39m \u001b[39m5\u001b[39m, \u001b[39m# Minimal value of redshift -> Here we will go slightly lower (cannot go below z = 4 for DarkHistory)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2'>3</a>\u001b[0m user_params \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mBOX_LEN\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m50\u001b[39m, \u001b[39m# Default value: 300 (Box length Mpc) 1000\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDIM\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39mNone\u001b[39;00m, \u001b[39m# Default value: None / gives DIM=3*HII_DIM (High resolution) None\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mHII_DIM\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m20\u001b[39m, \u001b[39m# Default value: 200 (HII cell resolution) 350\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m },\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m astro_params \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_LOG10_MASS\u001b[39m\u001b[39m\"\u001b[39m : np\u001b[39m.\u001b[39mlog10(\u001b[39m1.3e+8\u001b[39m), \u001b[39m# DM mass in eV\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_LOG10_LIFETIME\u001b[39m\u001b[39m\"\u001b[39m : np\u001b[39m.\u001b[39mlog10(\u001b[39m1e+26\u001b[39m), \u001b[39m# Lifetime | relevant only if DM_PROCESS = 'decay'\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m \n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=11'>12</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_FHEAT_APPROX_PARAM_LOG10_F0\u001b[39m\u001b[39m\"\u001b[39m : np\u001b[39m.\u001b[39mlog10(\u001b[39m0.1531\u001b[39m), \u001b[39m# Parameter to feed to the template of fheat\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=12'>13</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_FHEAT_APPROX_PARAM_A\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39m0.003209\u001b[39m, \u001b[39m# Parameter to feed to the template of fheat\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=13'>14</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_FHEAT_APPROX_PARAM_B\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39m0.1295\u001b[39m, \u001b[39m# Parameter to feed to the template of fheat\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=14'>15</a>\u001b[0m \n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=15'>16</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mLOG10_XION_at_Z_HEAT_MAX\u001b[39m\u001b[39m\"\u001b[39m : np\u001b[39m.\u001b[39mlog10(\u001b[39m0.0031\u001b[39m), \u001b[39m# Ionization fraction at redshift z = Z_HEAT_MAX = 35 (or max_redshift)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=16'>17</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mLOG10_TK_at_Z_HEAT_MAX\u001b[39m\u001b[39m\"\u001b[39m : np\u001b[39m.\u001b[39mlog10(\u001b[39m118\u001b[39m) \u001b[39m# Temperature in K at redshift z = Z_HEAT_MAX = 35 (or max_redshift)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=17'>18</a>\u001b[0m },\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=18'>19</a>\u001b[0m flag_options \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=19'>20</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mUSE_TS_FLUCT\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39mTrue\u001b[39;00m, \u001b[39m# Turn on IGM spin temperature fluctuations\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=20'>21</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mUSE_DM_ENERGY_INJECTION\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39mTrue\u001b[39;00m, \u001b[39m# Turn on DM energy injection\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=21'>22</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mUSE_DM_EFFECTIVE_DEP_FUNCS\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39mTrue\u001b[39;00m , \u001b[39m# Treat the energy injection with approximate templates (instead of DarkHistory)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=22'>23</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_PROCESS\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39m'\u001b[39m\u001b[39mdecay\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m# Energy injection process 'swave', 'decay', ... \u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=23'>24</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_PRIMARY\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39m'\u001b[39m\u001b[39melec_delta\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m# Primary particles (see list in user_params description)\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=24'>25</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_BACKREACTION\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39mTrue\u001b[39;00m, \u001b[39m# Turns on backreaction \u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=25'>26</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mDM_FHEAT_APPROX_SHAPE\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39m'\u001b[39m\u001b[39mschechter\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m# Shape of the template for f_heat\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=26'>27</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mUSE_CUSTOM_INIT_COND\u001b[39m\u001b[39m\"\u001b[39m : \u001b[39mTrue\u001b[39;00m \u001b[39m# Forces the code to use the init conditions defined in astro_params\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=27'>28</a>\u001b[0m },\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=28'>29</a>\u001b[0m lightcone_quantities \u001b[39m=\u001b[39m (),\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=29'>30</a>\u001b[0m global_quantities \u001b[39m=\u001b[39m (\u001b[39m'\u001b[39m\u001b[39mbrightness_temp\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mdensity\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mxH_box\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mx_e_box\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mTs_box\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mTk_box\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=30'>31</a>\u001b[0m verbose_ntbk \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m,\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=31'>32</a>\u001b[0m direc\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39m./cache\u001b[39m\u001b[39m'\u001b[39m, \n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bnic5/home/ulb/physth_fi/gfacchin/exo21cmFAST_release/exo21cmFAST/examples/example_notebook.ipynb#X13sdnNjb2RlLXJlbW90ZQ%3D%3D?line=32'>33</a>\u001b[0m )\n",
"\u001b[0;31mNameError\u001b[0m: name 'p21c' is not defined"
]
}
],
"outputs": [],
"source": [
"lightcone_templates, output_exotic_energy_injection_templates = p21c.run_lightcone(\n",
" redshift = 5, # Minimal value of redshift -> Here we will go slightly lower (cannot go below z = 4 for DarkHistory)\n",
Expand Down Expand Up @@ -279,6 +267,13 @@
"ax.legend([line1, line2], [r\"$\\rm T_{\\rm S}$\", r\"$\\rm T_{\\rm K}$\"])\n",
"fig.savefig('figures/global_TS_TK_with_templates.pdf', bbox_inches='tight')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit d82c6cd

Please sign in to comment.