Crates.io | cosmocalc |
lib.rs | cosmocalc |
version | 0.2.0 |
source | src |
created_at | 2022-09-09 02:18:11.847501 |
updated_at | 2022-09-16 18:06:05.865991 |
description | A library for cosmological physics calculations |
homepage | |
repository | https://github.com/redshiftzero/cosmocalc.rs |
max_upload_size | |
id | 661420 |
size | 38,077 |
A library for computing quantities in cosmology in the Rust programming language
let cosmology = FLRWCosmology::two_component(0.286, 0.714, 69.6);
z = Redshift::new(2.0);
let d_c = cosmology.radial_comoving_distance(z);
let d_m = cosmology.transverse_comoving_distance(z);
let d_a = cosmology.angular_diameter_distance(z);
let d_l = cosmology.luminosity_distance(z);
let v = cosmology.comoving_volume(z);
let omega_m = 0.299;
let omega_de = 0.7;
let omega_baryon = 0.05;
let H_0 = 69.6;
let T_CMB0 = 2.7255;
let omegas = OmegaFactors::new(omega_m, omega_de, omega_baryon).unwrap();
let cosmology = FLRWCosmology::new(
None,
None,
H_0,
omegas,
Some(T_CMB0),
Some(PositiveFloat(0.)),
Some(vec![]),
)
.unwrap();
z = Redshift::new(2.0);
let t = cosmology.lookback_time(z);
let omega_at_z = cosmology.omega_tot(z);
let omega_de_at_z = cosmology.omega_de(z);
let critical_density_at_z = cosmology.critical_density(z);
let T_CMB_at_z = cosmology.T_CMB(z);
let T_nu_at_z = cosmology.T_nu(z);
let d_H = cosmology.hubble_distance();
let t_H = cosmology.hubble_time();
let expansion_rate_at_z = cosmology.H(z);
let a_z = cosmology.scale_factor(z);
This project requires Rust
. Once installed:
cargo build
cargo test
Run criterion
benchmarks using:
cargo bench
This will generate a report at target/criterion/report/index.html
.