2个不稳定版本
0.2.0 | 2022年9月16日 |
---|---|
0.1.0 | 2022年9月9日 |
#443 in 科学
38KB
685 行
cosmocalc.rs
使用Rust编程语言进行宇宙学计算量的库
特性
宇宙距离计算
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);
开发者
开发设置
此项目需要Rust
。安装完成后
cargo build
cargo test
基准测试
使用criterion
基准测试运行
cargo bench
这将在target/criterion/report/index.html
生成报告。
依赖项
~180KB