diff --git a/Examples/Basic_cosmo_example.jl b/Examples/Basic_cosmo_example.jl new file mode 100644 index 0000000..a954c4c --- /dev/null +++ b/Examples/Basic_cosmo_example.jl @@ -0,0 +1,150 @@ +### A Pluto.jl notebook ### +# v0.19.36 + +using Markdown +using InteractiveUtils + +# ╔═╡ eb918f38-b7cc-11ee-1849-e9a292ae285b +begin + import Pkg + # activate the shared project environment + Pkg.activate(Base.current_project()) + # instantiate, i.e. make sure that all packages are downloaded + Pkg.instantiate() + + using Cosmic +end + +# ╔═╡ 1473e933-d04a-4a0b-90d8-ab33df9ff3ee +using Plots,LaTeXStrings + +# ╔═╡ 8d34d1a3-6a28-461c-9e03-cc047654ce84 +md"Now we can use Cosmic Package just use." + +# ╔═╡ ebf05ec9-dc2e-4ac9-a231-fd05e170e0a2 +md"The first step is to create your Cosmology system. I will be using Flat model." + +# ╔═╡ 667c6bda-f78c-4923-b93c-1942f5b1f258 +c = cosmology()#by default values will be taken. + +# ╔═╡ dc415649-5683-415e-a1b8-a31f48080d94 +md"The first value is h, then comes $\Omega_\Lambda$, then $\Omega_m$ and finally $\Omega_r$." + +# ╔═╡ 0314d0ad-d666-41fb-8e5a-bd4a0a497ba6 +cop = cosmology(Ωk =0.1)#For some other model can be used + +# ╔═╡ a2a0d4d9-46cc-4f18-9311-de22ea571b4e +md"For conversion between redshift and scale factor, there are two functions." + +# ╔═╡ 361cb06f-4e96-48a1-a23e-e38106ef4ed8 +a(100)#computes the scalefactor for z=100 + +# ╔═╡ 52930937-1f73-470d-b041-9558a11a7658 +redshift(0.0099099)#compute the redshift for a = 0.0099099 + +# ╔═╡ 5d11e724-326a-436f-94f4-211f99d30990 +md"To get the hubble's constant at some redshift use H(c::AbstractCosmology,z) as" + +# ╔═╡ 7e4c3515-02f7-498b-829f-23e78997fb70 +H(c,100)#takes your cosmology model and z + +# ╔═╡ 3aa50f1f-04e8-4d0d-a650-c0ef8e75089f +md"Let's try plotting $\frac{H(z)}{(1+z)}$ vs $z$." + +# ╔═╡ 2ee6b0bf-3511-4fea-8132-9896f5f112ec +begin + z_vals = range(0, 2.5, length=1000) + H_1z(z) = H(c,z)/(1+z) + H_vals = H_1z.(z_vals) + plot(z_vals,H_vals,lw=2.5, label="") + xlabel!(L"Redshift ($z$)") + ylabel!(L"$\frac{H(z)}{1+z}$") +end + +# ╔═╡ 4984ac71-b8eb-4085-a20a-9a2ac5f439a4 +md"We can also compute Hubble's distance. For that use hubble_distance(c,z) function." + +# ╔═╡ 2bb09fc2-f284-4d1e-8d58-55365d31dc20 +begin + # z_vals = range(0, 2.5, length=1000) + Hd_1z(z) = hubble_distance(c,z) + Hd_vals = Hd_1z.(z_vals) + plot(z_vals,Hd_vals,lw=2.5, label="") + xlabel!(L"Redshift ($z$)") + ylabel!(L"$H_d(z)$") +end + +# ╔═╡ d3e187e5-13ee-4edb-bfa0-25aee07b712e +md"We can also find the age of the universe at some certain z value." + +# ╔═╡ b02a5df0-b196-4418-84b0-52633d6e49e0 +age(c,0)#z = 0 means today's time. + +# ╔═╡ 511ade9b-ccf8-4edd-a5c5-edf2ba869815 +md"This gives us the age of the universe in sec. If you want to get the age in Gigayear, just convert it or else use ageGyr(c,z)." + +# ╔═╡ 7ed40ab7-c190-4bf0-bcf6-eccbb422784e +ageGyr(c,0)# age of our universe. + +# ╔═╡ ac2675fd-b0c9-4ba7-95eb-79f72bddc678 +md"For computing the scale factor as a function of time, there are two functions, scalefact_part and scalefact. The first one is efficient but it second one is more accurate. Both takes input in Gyr." + +# ╔═╡ f1b373f4-43bd-4312-bcaf-49ff3fc2d31a +scalefact_part(c,100) + +# ╔═╡ efabfaa1-f0bc-466a-bb98-49795c44e200 +scale_fact(c,100) + +# ╔═╡ b9dc315c-5a35-41fd-b27d-f1f9a4fc7e81 +md"Let's make a plot for both of them." + +# ╔═╡ 1e09ba10-91d6-46f0-bc8f-b9b1a82220fd +begin + tgyr = range(0.1,30.8,length=10_000) + dgf(t) = scale_fact(c,t) + a_vals = dgf.(tgyr) + plot(tgyr,a_vals,lw=2.5, label="using scale_fact") +end + +# ╔═╡ 12b9855f-3951-4ba9-acdf-65449b6c55bf +begin + dgf_part(t) = scalefact_part(c,t) + a_vals_part = dgf_part.(tgyr) + plot(tgyr,a_vals_part,lw=2.5, label="using scalefact_part") +end + +# ╔═╡ c4681d55-b75b-46c3-b5c1-789568890358 +plot!(tgyr,a_vals,lw=2.5, label="using scale_fact")#They are almost identical. + +# ╔═╡ dee6876a-5a84-437f-a953-881c441f34bf +plot!([13.807434539,13.807434539],[0,2.5],lc=:green,lw=2.5,label="t = 13.80743",ls=:dash) + +# ╔═╡ Cell order: +# ╠═eb918f38-b7cc-11ee-1849-e9a292ae285b +# ╟─8d34d1a3-6a28-461c-9e03-cc047654ce84 +# ╟─ebf05ec9-dc2e-4ac9-a231-fd05e170e0a2 +# ╠═667c6bda-f78c-4923-b93c-1942f5b1f258 +# ╟─dc415649-5683-415e-a1b8-a31f48080d94 +# ╠═0314d0ad-d666-41fb-8e5a-bd4a0a497ba6 +# ╟─a2a0d4d9-46cc-4f18-9311-de22ea571b4e +# ╠═361cb06f-4e96-48a1-a23e-e38106ef4ed8 +# ╠═52930937-1f73-470d-b041-9558a11a7658 +# ╟─5d11e724-326a-436f-94f4-211f99d30990 +# ╠═7e4c3515-02f7-498b-829f-23e78997fb70 +# ╟─3aa50f1f-04e8-4d0d-a650-c0ef8e75089f +# ╠═1473e933-d04a-4a0b-90d8-ab33df9ff3ee +# ╠═2ee6b0bf-3511-4fea-8132-9896f5f112ec +# ╟─4984ac71-b8eb-4085-a20a-9a2ac5f439a4 +# ╠═2bb09fc2-f284-4d1e-8d58-55365d31dc20 +# ╟─d3e187e5-13ee-4edb-bfa0-25aee07b712e +# ╠═b02a5df0-b196-4418-84b0-52633d6e49e0 +# ╟─511ade9b-ccf8-4edd-a5c5-edf2ba869815 +# ╠═7ed40ab7-c190-4bf0-bcf6-eccbb422784e +# ╟─ac2675fd-b0c9-4ba7-95eb-79f72bddc678 +# ╠═f1b373f4-43bd-4312-bcaf-49ff3fc2d31a +# ╠═efabfaa1-f0bc-466a-bb98-49795c44e200 +# ╠═b9dc315c-5a35-41fd-b27d-f1f9a4fc7e81 +# ╠═1e09ba10-91d6-46f0-bc8f-b9b1a82220fd +# ╠═12b9855f-3951-4ba9-acdf-65449b6c55bf +# ╠═c4681d55-b75b-46c3-b5c1-789568890358 +# ╠═dee6876a-5a84-437f-a953-881c441f34bf diff --git a/Project.toml b/Project.toml index a362ded..689b028 100644 --- a/Project.toml +++ b/Project.toml @@ -11,12 +11,13 @@ ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" [compat] -julia = "1" DifferentialEquations = "7.12.0 , 7.11.0, 7.6.0, 6.17.0" ForwardDiff = "0.10.36" +QuadGK = "2.9.4 , 2.9.3 , 2.9.2" ReverseDiff = "1.15.1" Roots = "2.0.22" -QuadGK = "2.9.4 , 2.9.3 , 2.9.2" +julia = "1" + [extras] Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/README.md b/README.md index 5fbfab6..2977e41 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,20 @@ [![Build Status](https://ci.appveyor.com/api/projects/status/github/aburousan/Cosmic.jl?svg=true)](https://ci.appveyor.com/project/aburousan/Cosmic-jl) [![Coverage](https://codecov.io/gh/aburousan/Cosmic.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/aburousan/Cosmic.jl) [![Coverage](https://coveralls.io/repos/github/aburousan/Cosmic.jl/badge.svg?branch=main)](https://coveralls.io/github/aburousan/Cosmic.jl?branch=main) + + +[Cosmic](https://github.com/aburousan/Cosmic.jl) provides functions for quick cosmological calculations, written in pure Julia. This will contains all the necessary functions following the **Cosmology** Book by **David Baumann**. This is build following a cosmology course in Indian Association for The Cultivation of Science. + +## Installation + +Bolt requires Julia 1.9+. To install, from the package prompt, run: + +``` +pkg> add https://github.com/aburousan/Cosmic.jl +``` +Then, to load the package + +```julia-repl +julia> using Cosmic +``` +To see examples, check the [Example](https://github.com/aburousan/Cosmic.jl/tree/main/Examples) folder (Specially the pluto notebook). diff --git a/docs/src/index.md b/docs/src/index.md index cd884ab..1b565e5 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -2,13 +2,32 @@ CurrentModule = Cosmic ``` -# cosmic +# Cosmic -Documentation for [cosmic](https://github.com/aburousan/cosmic.jl). +[Cosmic](https://github.com/aburousan/Cosmic.jl) provides functions for quick cosmological calculations, written in pure Julia. This will contains all the necessary functions following the **Cosmology** Book by **David Baumann**. +## Installation + +Bolt requires Julia 1.9+. To install, from the package prompt, run: + +``` +pkg> add https://github.com/aburousan/Cosmic.jl +``` +Then, to load the package + +```julia-repl +julia> using Cosmic +``` +To see examples, check the [Example](https://github.com/aburousan/Cosmic.jl/tree/main/Examples) folder (Specially the pluto notebook). +## Contributing + +If you would like to contribute to `Cosmic.jl`, head over to our [GitHub page](https://github.com/aburousan/Cosmic.jl) and open an issue or pull request! + +For any new features, we ask the contributors to add any relevant unit tests and bump the package version by one minor version. +Documentation for ```@index ``` ```@autodocs -Modules = [cosmic] +Modules = [Cosmic] ``` diff --git a/src/Basic_cosmo_example.html b/src/Basic_cosmo_example.html new file mode 100644 index 0000000..50abc62 --- /dev/null +++ b/src/Basic_cosmo_example.html @@ -0,0 +1,15 @@ + + + + + +
\ No newline at end of file