diff --git a/tutorials/cosmology/cosmology.ipynb b/tutorials/cosmology/cosmology.ipynb index 86af8c0..ebfdc79 100644 --- a/tutorials/cosmology/cosmology.ipynb +++ b/tutorials/cosmology/cosmology.ipynb @@ -206,19 +206,7 @@ } ], "source": [ - "# CAMB PERTURBATIONS\n", - "camb_linear = CAMBLinearPerturbations(background=camb_instance, redshifts=z)\n", - "camb_nonlinear = CAMBNonLinearPerturbations(background=camb_instance, redshifts=z, \n", - " nonlinear_model='mead2016')\n", - "\n", - "linear_pk_camb = camb_linear.matter_power_spectrum(z, ks)\n", - "nonlinear_pk_camb = camb_nonlinear.matter_power_spectrum(z, ks)\n", - "plt.loglog(ks, linear_pk_camb[0, :], label= 'linear')\n", - "plt.loglog(ks, nonlinear_pk_camb[0, :], label= 'nonlinear')\n", - "plt.xlabel('k (1/Mpc)', fontsize = 16)\n", - "plt.ylabel('P(k)', fontsize = 16)\n", - "plt.legend(fontsize = 16)\n", - "plt.title(\"CAMB Power Spectrum\", fontsize = 16)" + "# CAMB PERTURBATIONS\ncamb_linear = CAMBLinearPerturbations(background=camb_instance, redshifts=z)\ncamb_nonlinear = CAMBNonLinearPerturbations(background=camb_instance, linearperturbations=None, redshifts=z, \n nonlinear_model='mead2016')\n\nlinear_pk_camb = camb_linear.matter_power_spectrum(z, ks)\nnonlinear_pk_camb = camb_nonlinear.matter_power_spectrum(z, ks)\nplt.loglog(ks, linear_pk_camb[0, :], label= 'linear')\nplt.loglog(ks, nonlinear_pk_camb[0, :], label= 'nonlinear')\nplt.xlabel('k (1/Mpc)', fontsize = 16)\nplt.ylabel('P(k)', fontsize = 16)\nplt.legend(fontsize = 16)\nplt.title(\"CAMB Power Spectrum\", fontsize = 16)" ] }, { @@ -252,6 +240,7 @@ "# k-array\n", "class_linear = CLASSLinearPerturbations(background=class_instance, redshifts=z)\n", "class_nonlinear = CLASSNonLinearPerturbations(background=class_instance, \n", + " linearperturbations=None, \n", " redshifts=z, \n", " nonlinear_model='hmcode', hmcode_version=2016)\n", "linear_pk_class = class_linear.matter_power_spectrum(z, ks)\n", @@ -325,4 +314,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/tutorials/cosmology/neutrinos.ipynb b/tutorials/cosmology/neutrinos.ipynb index 3d7d9e4..81b196f 100644 --- a/tutorials/cosmology/neutrinos.ipynb +++ b/tutorials/cosmology/neutrinos.ipynb @@ -26,11 +26,11 @@ "- `mnu = 0.02, 0.04, 0.06`, `N_ur = 3.044`, `N_mnu = 3` (non-degenerate neutrinos)\n", "\n", "### Backends validated in this notebook\n", - "- cloelib[camb] ✅\n", - "- cloelib[class] ✅\n", - "- comet ✅\n", - "- HMCode2020Emu ✅\n", - "- Jax Cosmology ✅\n", + "- cloelib[camb] \u2705\n", + "- cloelib[class] \u2705\n", + "- comet \u2705\n", + "- HMCode2020Emu \u2705\n", + "- Jax Cosmology \u2705\n", "\n", "\n", - " -->\n", - "## 📑 Notebook Table of Contents\n", + " -->\n", + "## \ud83d\udcd1 Notebook Table of Contents\n", "\n", "- [Set-up](#Set-up)\n", " - [Fiducial Cosmology](#fiducial-cosmology)\n", @@ -410,6 +410,7 @@ "\n", "cloeclass_M1_linear = CLASSLinearPerturbations(background=cloeclass_M1, redshifts=zs)\n", "cloeclass_M1_nonlinear = CLASSNonLinearPerturbations(background=cloeclass_M1, \n", + " linearperturbations=None, \n", " redshifts=zs, \n", " nonlinear_model='hmcode')\n", "\n", @@ -453,6 +454,7 @@ "\n", "cloeclass_M2_linear = CLASSLinearPerturbations(background=cloeclass_M2, redshifts=zs)\n", "cloeclass_M2_nonlinear = CLASSNonLinearPerturbations(background=cloeclass_M2, \n", + " linearperturbations=None, \n", " redshifts=zs, \n", " nonlinear_model='hmcode')\n", "\n", @@ -503,6 +505,7 @@ "\n", "cloeclass_M3_linear = CLASSLinearPerturbations(background=cloeclass_M3, redshifts=zs)\n", "cloeclass_M3_nonlinear = CLASSNonLinearPerturbations(background=cloeclass_M3, \n", + " linearperturbations=None, \n", " redshifts=zs, \n", " nonlinear_model='hmcode')\n", "\n", @@ -897,31 +900,7 @@ "metadata": {}, "outputs": [], "source": [ - "cloecamb_M1 = CAMBBackground(\n", - " H0=cosmo_dict['H0'], \n", - " Omega_b0=cosmo_dict['Omega_b'], \n", - " Omega_cdm0=cosmo_dict['Omega_c'], \n", - " Omega_k0=cosmo_dict['Omega_k'], \n", - " As=cosmo_dict['As'], \n", - " ns=cosmo_dict['ns'], \n", - " mnu=cosmo_dict['mnu'], \n", - " w0=cosmo_dict['w0'], \n", - " wa=cosmo_dict['wa'], \n", - " N_mnu=0, # No massive neutrinos\n", - " gamma_MG=0.0\n", - ")\n", - "\n", - "# background quantities\n", - "cloecamb_M1_Hubble = cloecamb_M1.hubble_parameter(zs)\n", - "cloecamb_M1_chi = cloecamb_M1.comoving_distance(zs)\n", - "\n", - "cloecamb_M1_linear = CAMBLinearPerturbations(background=cloecamb_M1, redshifts=zs)\n", - "cloecamb_M1_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M1, \n", - " redshifts=zs, \n", - " nonlinear_model='mead2020')\n", - "\n", - "cloecamb_M1_pk = cloecamb_M1_linear.matter_power_spectrum(0, ks)\n", - "cloecamb_M1_pk_nl = cloecamb_M1_nonlinear.matter_power_spectrum(0, ks)" + "cloecamb_M1 = CAMBBackground(\n H0=cosmo_dict['H0'], \n Omega_b0=cosmo_dict['Omega_b'], \n Omega_cdm0=cosmo_dict['Omega_c'], \n Omega_k0=cosmo_dict['Omega_k'], \n As=cosmo_dict['As'], \n ns=cosmo_dict['ns'], \n mnu=cosmo_dict['mnu'], \n w0=cosmo_dict['w0'], \n wa=cosmo_dict['wa'], \n N_mnu=0, # No massive neutrinos\n gamma_MG=0.0\n)\n\n# background quantities\ncloecamb_M1_Hubble = cloecamb_M1.hubble_parameter(zs)\ncloecamb_M1_chi = cloecamb_M1.comoving_distance(zs)\n\ncloecamb_M1_linear = CAMBLinearPerturbations(background=cloecamb_M1, redshifts=zs)\ncloecamb_M1_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M1, \n linearperturbations=None,\n redshifts=zs, \n nonlinear_model='mead2020')\n\ncloecamb_M1_pk = cloecamb_M1_linear.matter_power_spectrum(0, ks)\ncloecamb_M1_pk_nl = cloecamb_M1_nonlinear.matter_power_spectrum(0, ks)" ] }, { @@ -940,33 +919,7 @@ "metadata": {}, "outputs": [], "source": [ - "cloecamb_M2 = CAMBBackground(\n", - " H0=cosmo_dict['H0'], \n", - " Omega_b0=cosmo_dict['Omega_b'], \n", - " Omega_cdm0=cosmo_dict['Omega_c'], \n", - " Omega_k0=cosmo_dict['Omega_k'], \n", - " As=cosmo_dict['As'], \n", - " ns=cosmo_dict['ns'], \n", - " mnu=0.12, \n", - " w0=cosmo_dict['w0'], \n", - " wa=cosmo_dict['wa'], \n", - " N_mnu=1, # one massive neutrinos\n", - " gamma_MG=0.0\n", - ")\n", - "\n", - "print(\"N_eff for M2:\", cloecamb_M2.N_eff)\n", - "\n", - "# background quantities\n", - "cloecamb_M2_Hubble = cloecamb_M2.hubble_parameter(zs)\n", - "cloecamb_M2_chi = cloecamb_M2.comoving_distance(zs)\n", - "\n", - "cloecamb_M2_linear = CAMBLinearPerturbations(background=cloecamb_M2, redshifts=zs)\n", - "cloecamb_M2_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M2, \n", - " redshifts=zs, \n", - " nonlinear_model='mead2020')\n", - "\n", - "cloecamb_M2_pk = cloecamb_M2_linear.matter_power_spectrum(0, ks)\n", - "cloecamb_M2_pk_nl = cloecamb_M2_nonlinear.matter_power_spectrum(0, ks)" + "cloecamb_M2 = CAMBBackground(\n H0=cosmo_dict['H0'], \n Omega_b0=cosmo_dict['Omega_b'], \n Omega_cdm0=cosmo_dict['Omega_c'], \n Omega_k0=cosmo_dict['Omega_k'], \n As=cosmo_dict['As'], \n ns=cosmo_dict['ns'], \n mnu=0.12, \n w0=cosmo_dict['w0'], \n wa=cosmo_dict['wa'], \n N_mnu=1, # one massive neutrinos\n gamma_MG=0.0\n)\n\nprint(\"N_eff for M2:\", cloecamb_M2.N_eff)\n\n# background quantities\ncloecamb_M2_Hubble = cloecamb_M2.hubble_parameter(zs)\ncloecamb_M2_chi = cloecamb_M2.comoving_distance(zs)\n\ncloecamb_M2_linear = CAMBLinearPerturbations(background=cloecamb_M2, redshifts=zs)\ncloecamb_M2_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M2, \n linearperturbations=None,\n redshifts=zs, \n nonlinear_model='mead2020')\n\ncloecamb_M2_pk = cloecamb_M2_linear.matter_power_spectrum(0, ks)\ncloecamb_M2_pk_nl = cloecamb_M2_nonlinear.matter_power_spectrum(0, ks)" ] }, { @@ -985,40 +938,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%time\n", - "cloecamb_M3 = CAMBBackground(\n", - " H0=cosmo_dict['H0'], \n", - " Omega_b0=cosmo_dict['Omega_b'], \n", - " Omega_cdm0=cosmo_dict['Omega_c'], \n", - " Omega_k0=cosmo_dict['Omega_k'], \n", - " As=cosmo_dict['As'], \n", - " ns=cosmo_dict['ns'], \n", - " mnu=[0.02, 0.04, 0.06],\n", - " w0=cosmo_dict['w0'], \n", - " wa=cosmo_dict['wa'], \n", - " N_mnu=3, # one massive neutrinos\n", - " gamma_MG=0.0\n", - ")\n", - "\n", - "# higher accuracy for more detailed neutrinos:\n", - "cloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.AccuracyBoost = 3\n", - "cloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.lAccuracyBoost = 3\n", - "cloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.k_eta_max_scalar = 10000.0\n", - "cloecamb_M3.interface_args[\"CAMBparams\"].Transfer.kmax = 50.0\n", - "\n", - "print(\"N_eff for M3:\", cloecamb_M3.N_eff)\n", - "\n", - "# background quantities\n", - "cloecamb_M3_Hubble = cloecamb_M3.hubble_parameter(zs)\n", - "cloecamb_M3_chi = cloecamb_M3.comoving_distance(zs)\n", - "\n", - "cloecamb_M3_linear = CAMBLinearPerturbations(background=cloecamb_M3, redshifts=zs)\n", - "cloecamb_M3_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M3, \n", - " redshifts=zs, \n", - " nonlinear_model='mead2020')\n", - "\n", - "cloecamb_M3_pk = cloecamb_M3_linear.matter_power_spectrum(0, ks)\n", - "cloecamb_M3_pk_nl = cloecamb_M3_nonlinear.matter_power_spectrum(0, ks)" + "%%time\ncloecamb_M3 = CAMBBackground(\n H0=cosmo_dict['H0'], \n Omega_b0=cosmo_dict['Omega_b'], \n Omega_cdm0=cosmo_dict['Omega_c'], \n Omega_k0=cosmo_dict['Omega_k'], \n As=cosmo_dict['As'], \n ns=cosmo_dict['ns'], \n mnu=[0.02, 0.04, 0.06],\n w0=cosmo_dict['w0'], \n wa=cosmo_dict['wa'], \n N_mnu=3, # one massive neutrinos\n gamma_MG=0.0\n)\n\n# higher accuracy for more detailed neutrinos:\ncloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.AccuracyBoost = 3\ncloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.lAccuracyBoost = 3\ncloecamb_M3.interface_args[\"CAMBparams\"].Accuracy.k_eta_max_scalar = 10000.0\ncloecamb_M3.interface_args[\"CAMBparams\"].Transfer.kmax = 50.0\n\nprint(\"N_eff for M3:\", cloecamb_M3.N_eff)\n\n# background quantities\ncloecamb_M3_Hubble = cloecamb_M3.hubble_parameter(zs)\ncloecamb_M3_chi = cloecamb_M3.comoving_distance(zs)\n\ncloecamb_M3_linear = CAMBLinearPerturbations(background=cloecamb_M3, redshifts=zs)\ncloecamb_M3_nonlinear = CAMBNonLinearPerturbations(background=cloecamb_M3, \n linearperturbations=None,\n redshifts=zs, \n nonlinear_model='mead2020')\n\ncloecamb_M3_pk = cloecamb_M3_linear.matter_power_spectrum(0, ks)\ncloecamb_M3_pk_nl = cloecamb_M3_nonlinear.matter_power_spectrum(0, ks)" ] }, { @@ -2058,4 +1978,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/validation/validation_CosmoSIS.ipynb b/validation/validation_CosmoSIS.ipynb index 51cc07d..9d81d49 100644 --- a/validation/validation_CosmoSIS.ipynb +++ b/validation/validation_CosmoSIS.ipynb @@ -150,25 +150,7 @@ "metadata": {}, "outputs": [], "source": [ - "# CAMB is used here as the external code to compute background and perturbations\n", - "background = CAMBBackground(H0 = cosmo_dict['H0'], \n", - " Omega_cdm0 = cosmo_dict['Omega_c'], \n", - " Omega_b0 = cosmo_dict['Omega_b'], \n", - " w0 = cosmo_dict['w0'], \n", - " wa = cosmo_dict['wa'], \n", - " Omega_k0 = cosmo_dict['Omega_k'], \n", - " ns = cosmo_dict['ns'], \n", - " As = cosmo_dict['As'],\n", - " mnu = cosmo_dict['mnu'],\n", - " N_mnu = 0,\n", - " gamma_MG=0\n", - " )\n", - "\n", - "linear_perturbations = CAMBLinearPerturbations(background, zs)\n", - "pk_lin_cloe = linear_perturbations.matter_power_spectrum(0, ks) #(z, k)\n", - "\n", - "nonlinear_perturbations = CAMBNonLinearPerturbations(background, zs, nonlinear_model = cosmo_dict['halofit_version']) \n", - "pk_nonlin_cloe = nonlinear_perturbations.matter_power_spectrum(0, ks)" + "# CAMB is used here as the external code to compute background and perturbations\nbackground = CAMBBackground(H0 = cosmo_dict['H0'], \n Omega_cdm0 = cosmo_dict['Omega_c'], \n Omega_b0 = cosmo_dict['Omega_b'], \n w0 = cosmo_dict['w0'], \n wa = cosmo_dict['wa'], \n Omega_k0 = cosmo_dict['Omega_k'], \n ns = cosmo_dict['ns'], \n As = cosmo_dict['As'],\n mnu = cosmo_dict['mnu'],\n N_mnu = 0,\n gamma_MG=0\n )\n\nlinear_perturbations = CAMBLinearPerturbations(background, zs)\npk_lin_cloe = linear_perturbations.matter_power_spectrum(0, ks) #(z, k)\n\nnonlinear_perturbations = CAMBNonLinearPerturbations(background, None, zs, nonlinear_model = cosmo_dict['halofit_version']) \npk_nonlin_cloe = nonlinear_perturbations.matter_power_spectrum(0, ks)" ] }, { @@ -634,4 +616,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/validation/validation_ccl.ipynb b/validation/validation_ccl.ipynb index 47b477c..651d167 100644 --- a/validation/validation_ccl.ipynb +++ b/validation/validation_ccl.ipynb @@ -154,25 +154,7 @@ "metadata": {}, "outputs": [], "source": [ - "# CAMB is used here as the external code to compute background and perturbations\n", - "background = CAMBBackground(H0 = cosmo_dict['H0'], \n", - " Omega_cdm0 = cosmo_dict['Omega_c'], \n", - " Omega_b0 = cosmo_dict['Omega_b'], \n", - " w0 = cosmo_dict['w0'], \n", - " wa = cosmo_dict['wa'], \n", - " Omega_k0 = cosmo_dict['Omega_k'], \n", - " ns = cosmo_dict['ns'], \n", - " As = cosmo_dict['As'],\n", - " mnu = cosmo_dict['mnu'],\n", - " N_mnu = 0,\n", - " gamma_MG=0\n", - " )\n", - "\n", - "linear_perturbations = CAMBLinearPerturbations(background, zs)\n", - "pk_lin_cloe = linear_perturbations.matter_power_spectrum(0, ks) #(z, k)\n", - "\n", - "nonlinear_perturbations = CAMBNonLinearPerturbations(background, zs, nonlinear_model = cosmo_dict['halofit_version']) \n", - "pk_nonlin_cloe = nonlinear_perturbations.matter_power_spectrum(0, ks)" + "# CAMB is used here as the external code to compute background and perturbations\nbackground = CAMBBackground(H0 = cosmo_dict['H0'], \n Omega_cdm0 = cosmo_dict['Omega_c'], \n Omega_b0 = cosmo_dict['Omega_b'], \n w0 = cosmo_dict['w0'], \n wa = cosmo_dict['wa'], \n Omega_k0 = cosmo_dict['Omega_k'], \n ns = cosmo_dict['ns'], \n As = cosmo_dict['As'],\n mnu = cosmo_dict['mnu'],\n N_mnu = 0,\n gamma_MG=0\n )\n\nlinear_perturbations = CAMBLinearPerturbations(background, zs)\npk_lin_cloe = linear_perturbations.matter_power_spectrum(0, ks) #(z, k)\n\nnonlinear_perturbations = CAMBNonLinearPerturbations(background, None, zs, nonlinear_model = cosmo_dict['halofit_version']) \npk_nonlin_cloe = nonlinear_perturbations.matter_power_spectrum(0, ks)" ] }, { @@ -1049,4 +1031,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file