necsim-rust

Spatially explicit biodiversity simulations using a parallel library written in Rust

https://github.com/juntyr/necsim-rust

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    3 of 11 committers (27.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.8%) to scientific vocabulary

Keywords

biodiversity cuda mpi necsim rust simulation

Keywords from Contributors

mesh sequences interactive hacking network-simulation
Last synced: 6 months ago · JSON representation

Repository

Spatially explicit biodiversity simulations using a parallel library written in Rust

Basic Info
Statistics
  • Stars: 2
  • Watchers: 5
  • Forks: 2
  • Open Issues: 8
  • Releases: 1
Topics
biodiversity cuda mpi necsim rust simulation
Created over 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

necsim-rust   CI Status Rust Doc License Status Code Coverage Binder Demo Gitpod Ready-to-Code DOI

Introduction

necsim-rust is a Rust reimplementation of the C++ library necsim and its Python wrapper pycoalescence, which are used to run neutral coalescence biodiversity simulations.

necsim-rust aims to provide a smaller, more concise subset of the functionality of necsim and pycoalescence but be easier to use and extend. For instance, necsim-rust contains the classical coalescence algorithm. Additionally, it implements two Gillespie-based algorithms and a novel independent algorithm with a CPU and a CUDA variant. Furthermore, necsim-rust can use MPI to parallelise the simulation.

necsim-rust is built in a modular way to reduce code duplication and allow the user (and other programmers) to plug together different components to customise the simulated scenario, the algorithm it is simulated with as well as finer implementation details. Currently, necsim-rust supports four built-in scenarios: - non-spatial model - spatially implicit model with migration from a non-spatial metacommunity to a non-spatial local community - spatially explicit (almost) infinite model with Gaussian Normal dispersal - spatially-explicit simulation with habitat and dispersal maps

Prerequisites

First, you need to clone the necsim-rust GitHub repository: shell git clone https://github.com/juntyr/necsim-rust.git necsim-rust is written in the Rust language, which must be installed in your PATH first. necsim-rust includes a rust-toolchain file that configures Rust to use a working nightly toolchain version and install all components required for compilation. If you want to use necsim-rust on a target different than x86_64-unknown-linux-gnu, please update the rust-toolchain config file accordingly.

The necsim-plugins-species reporter depends on libsqlite3-dev, and the necsim-plugins-tskit reporter and the necsim-partitioning-mpi parallelisation backend (enabled with the mpi-partitioning feature) depend on libclang-dev. You can install these optional packages using shell sudo apt-get install libclang-dev libsqlite3-dev

Installation

To install rustcoalescence, you need to decide which algorithms you want to compile with it. You can enable the provided algorithms by enabling their corresponding features. For instance, to compile all CPU-based algorithms with all scenarios, you can use shell cargo install --path rustcoalescence --locked --features gillespie-algorithms --features independent-algorithm --features all-scenarios To install with CUDA support, you first need to ensure that the dynamic CUDA libraries are in the LD_LIBRARY_PATH and enable the cuda-algorithm feature: shell LIBRARY_PATH="$LD_LIBRARY_PATH" cargo install --path rustcoalescence --locked [...] --features cuda-algorithm To compile with MPI support, you need to enable the mpi-partitioning feature: shell cargo install --path rustcoalescence --locked [...] --features mpi-partitioning After compilation, you can then run rustcoalescence using: shell rustcoalescence [...] If you want to use any of the provided reporter analysis plugins, you have to compile them manually. For instance, to compile the common plugin which includes the Biodiversity(), Counter(), Execution(), Progress() and Verbose() reporters, you can run: ```shell

cargo build --release --manifest-path necsim/plugins/common/Cargo.toml ```

Compiling for Development

If you want to compile the library for development, you can use any of the above installation commands, but replace shell cargo install --path rustcoalescence --locked [...] with shell cargo build --release [...]

Running rustcoalescence

rustcoalescence has two subcommands: simulate and replay and accepts command-line arguments in the following format: shell rustcoalescence <SUBCOMMAND> args.. Here, args.. is a configuration string in RON format, which can also directly be read from a configuration file: shell rustcoalescence <SUBCOMMAND> "$(<config.ron)" Please refer to docs/simulate.ron and docs/replay.ron for a detailed description of all configuration options. ./simulate.ron and ./replay.ron also provide example configurations.

Project structure

necsim-rust consists of the following crates: - necsim/: this folder contains the core declaration of the simulation and implementation of its components - core/: necsim-core declares the core structs, simulation cogs traits, as well as the generic Simulation. - maths/: necsim-core-maths declares the required f64 intrinsics for simulating in a no-std environment, and provides a default implementation. - bond/: necsim-core-bond declares helper data types which guarantee a limited value range and are used for encoding preconditions through data types. - impls/: - no-std/: necsim-impls-no-std contains the implementations of cogs that do not require the Rust standard library - std/: necsim-impls-std contains the implementations of cogs that do require the Rust standard library - cuda/: necsim-impls-cuda contains the implementations of CUDA specific cogs - plugins/: - core/: necsim-plugins-core implements the reporter plugin system and provides the functionality to export and load plugins - common/: necsim-plugins-common implements common analysis reporters, e.g. to measure biodiversity, print a progress bar, etc. - metacommunity/: necsim-plugins-metacommunity implements a reporter which measures migrations to a static external metacommunity, which can be simulated separately using the non-spatial scenario - csv/: necsim-plugins-csv implements a reporter which records events in a CSV file - species/: necsim-plugins-species produces an SQLite database which lists the parent-child relationships of all simulated individuals as well as their species - partitioning/: - core/: necsim-partitioning-core declares the core partitioning traits - monolithic/: necsim-partitioning-monolithic implements monolithic, i.e. non-parallel partitioning - mpi/: necsim-partitioning-mpi implements the MPI-based partitioning backend - threads/: necsim-partitioning-threads implements the multithreading-based partitioning backend - rustcoalescence/: rustcoalescence provides the command-line interface. - scenarios/: rustcoalescence-scenarios contains the glue code to put together the cogs for the built-in scenarios. It is specifically built only for reducing code duplication in rustcoalescence, not for giving a minimal example of how to construct a simulation. - algorithms/: - gillespie/: rustcoalescence-algorithms-gillespie contains the glue code to put together the cogs for the two monolithic Gillespie coalescence algorithms. It is specifically built only for reducing code duplication in rustcoalescence, not for giving a minimal example of how to construct a simulation. - src/gillespie: GillespieAlgorithm (also known as the classical algorithm) is a good allrounder that is built on Gillespie's "next-reaction" method. While it includes a specialised implementation for uniform turnover rates, it generally uses a dynamic alias method sampler (individual-based) to pick the next event. Therefore, it performs better on habitats with a high probability to disperse to a different location (i.e. small per-location demes). - src/event_skipping: EventSkippingAlgorithm is a specialised mathematically correct algorithm that skips self-dispersal events without coalescence. It is built on Gillespie's "next-reaction" method and uses a dynamic alias method sampler (location-based) to pick the next event. Therefore, it is very fast on habitats with high self-dispersal probabilities (i.e. large per-location demes), or when the speciation probability is very small. - independent/: rustcoalescence-algorithms-independent contains the glue code to put together the cogs for the independent coalescence algorithm on the CPU. The algorithm treats the simulation as an embarrassingly parallel problem. It can also be used to simulate subdomains of the simulation separately and piece the results back afterwards without loss of consistency. - cuda/: rustcoalescence-algorithms-cuda contains the glue code to put together the cogs for the independent coalescence algorithm on a CUDA 3.5 capable GPU. The algorithm treats the simulation as an embarrassingly parallel problem. It can also be used to simulate subdomains of the simulation separately and piece the results back afterwards without loss of consistency.

GDAL GeoTiff compatibility

pycoalescence and necsim both used GDAL to load habitat, dispersal and turnover maps. As rustcoalescence is more strict about type checking the TIFF files, you can use the following commands to convert and compress your GeoTIFF files: shell gdalwarp -ot Uint32 -co "COMPRESS=LZW" -dstnodata 0 -to "SRC_METHOD=NO_GEOTRANSFORM" -to "DST_METHOD=NO_GEOTRANSFORM" input_habitat.tif output_habitat.tif gdalwarp -ot Float64 -co "COMPRESS=LZW" -dstnodata 0 -to "SRC_METHOD=NO_GEOTRANSFORM" -to "DST_METHOD=NO_GEOTRANSFORM" input_dispersal.tif output_dispersal.tif gdalwarp -ot Float64 -co "COMPRESS=LZW" -dstnodata 0 -to "SRC_METHOD=NO_GEOTRANSFORM" -to "DST_METHOD=NO_GEOTRANSFORM" input_turnover.tif output_turnover.tif

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Owner

  • Name: Juniper Tyree
  • Login: juntyr
  • Kind: user
  • Location: Helsinki
  • Company: University of Helsinki

PhD researcher at UH with a passion for the environment and Rust. Graduate of MEng Computing at ICL and MSc Theoretical & Computational Methods at UH.

GitHub Events

Total
  • Issues event: 1
  • Watch event: 1
  • Push event: 3
  • Pull request review event: 3
Last Year
  • Issues event: 1
  • Watch event: 1
  • Push event: 3
  • Pull request review event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 773
  • Total Committers: 11
  • Avg Commits per committer: 70.273
  • Development Distribution Score (DDS): 0.722
Past Year
  • Commits: 19
  • Committers: 4
  • Avg Commits per committer: 4.75
  • Development Distribution Score (DDS): 0.263
Top Committers
Name Email Commits
Moritz Langenstein m****7@i****k 215
Momo Langenstein m****n@h****i 168
dependabot[bot] 4****] 164
Momo Langenstein m****7@i****k 118
Moritz Langenstein m****7@i****k 34
Juniper Langenstein j****n@h****i 24
Momo Langenstein 5****n 23
Juniper Tyree j****e@h****i 18
Moritz Langenstein 5****n 5
Juniper Tyree 5****r 3
NicoFirbas n****s@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 4
  • Total pull requests: 106
  • Average time to close issues: 11 months
  • Average time to close pull requests: 26 days
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 1.0
  • Average comments per pull request: 2.08
  • Merged pull requests: 48
  • Bot issues: 1
  • Bot pull requests: 93
Past Year
  • Issues: 1
  • Pull requests: 8
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 month
  • Issue authors: 1
  • Pull request authors: 3
  • Average comments per issue: 0.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • juntyr (4)
  • github-actions[bot] (2)
Pull Request Authors
  • dependabot[bot] (93)
  • juntyr (16)
  • NicoFirbas (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (93)

Dependencies

Cargo.lock cargo
  • 157 dependencies
necsim/core/Cargo.toml cargo
  • contracts 0.6.3
  • serde 1.0
necsim/core/bond/Cargo.toml cargo
  • serde 1.0
necsim/impls/cuda/Cargo.toml cargo
  • contracts 0.6.3
  • serde 1.0
necsim/impls/no-std/Cargo.toml cargo
  • contracts 0.6.3
  • displaydoc 0.2
  • final 0.1.1
  • fnv 1.0
  • hashbrown 0.12
  • libm 0.2
  • log 0.4
  • rand_core 0.6
  • serde 1.0
  • slab 0.4
necsim/impls/std/Cargo.toml cargo
  • anyhow 1.0
  • bincode 1.3
  • contracts 0.6.3
  • glob 0.3
  • pcg_rand 0.13
  • rand_core 0.6
  • serde 1.0
  • thiserror 1.0
necsim/partitioning/core/Cargo.toml cargo
  • anyhow 1.0
  • contracts 0.6.3
  • serde 1.0
necsim/partitioning/monolithic/Cargo.toml cargo
  • anyhow 1.0
  • contracts 0.6.3
  • serde 1.0
necsim/partitioning/mpi/Cargo.toml cargo
  • anyhow 1.0
  • contracts 0.6.3
  • humantime-serde 1.1
  • memoffset 0.6
  • serde 1.0
  • serde_derive_state 0.4
  • serde_state 0.4
  • thiserror 1.0
necsim/plugins/common/Cargo.toml cargo
  • contracts 0.6.3
  • log 0.4
  • serde 1.0
necsim/plugins/core/Cargo.toml cargo
  • erased-serde 0.3
  • libloading 0.7
  • log 0.4
  • process_path 0.1
  • serde 1.0
necsim/plugins/csv/Cargo.toml cargo
  • serde 1.0
necsim/plugins/metacommunity/Cargo.toml cargo
  • fnv 1.0
  • log 0.4
  • rand 0.8
  • serde 1.0
necsim/plugins/species/Cargo.toml cargo
  • base32 0.4
  • bincode 1.3
  • fnv 1.0
  • log 0.4
  • rusqlite 0.27
  • serde 1.0
necsim/plugins/statistics/Cargo.toml cargo
  • serde 1.0
necsim/plugins/tskit/Cargo.toml cargo
  • findshlibs 0.10
  • fnv 1.0
  • git-version 0.3
  • rustc_version 0.4
  • semver 1.0
  • serde 1.0
  • serde_json 1.0
  • tskit 0.9.0
  • uname 0.1
rustcoalescence/Cargo.toml cargo
  • adler 1.0
  • anyhow 1.0
  • base32 0.4
  • bincode 1.3
  • colored 2.0
  • derive_builder 0.11
  • fnv 1.0
  • getrandom 0.2
  • log 0.4
  • serde 1.0
  • serde_derive_state 0.4
  • serde_path_to_error 0.1
  • serde_state 0.4
  • structopt 0.3
  • thiserror 1.0
  • tiny-keccak 2.0
rustcoalescence/algorithms/Cargo.toml cargo
  • anyhow 1.0
  • serde 1.0
rustcoalescence/algorithms/cuda/Cargo.toml cargo
  • serde 1.0
  • serde_derive_state 0.4
  • serde_state 0.4
  • thiserror 1.0
rustcoalescence/algorithms/gillespie/Cargo.toml cargo
  • serde 1.0
  • serde_derive_state 0.4
  • serde_state 0.4
rustcoalescence/algorithms/independent/Cargo.toml cargo
  • serde 1.0
  • serde_derive_state 0.4
  • serde_state 0.4
rustcoalescence/scenarios/Cargo.toml cargo
  • anyhow 1.0
  • displaydoc 0.2
  • log 0.4
  • serde 1.0
  • thiserror 1.0
  • tiff 0.7
.github/workflows/ci.yml actions
  • actions/checkout v2 composite
.github/workflows/coverage.yml actions
  • actions/checkout v2 composite
  • codecov/codecov-action v1 composite
.github/workflows/fossa.yml actions
  • actions/checkout v2 composite
  • fossa-contrib/fossa-action v1 composite
.github/workflows/rebase.yml actions
  • linhbn123/rebase-pull-requests v1.0.1 composite
.github/workflows/rustdoc.yml actions
  • actions/checkout v2 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/security.yml actions
  • actions-rs/audit-check v1 composite
  • actions/checkout v2 composite
Cargo.toml cargo
necsim/core/maths/Cargo.toml cargo
rustcoalescence/algorithms/cuda/cpu-kernel/Cargo.toml cargo
rustcoalescence/algorithms/cuda/gpu-kernel/Cargo.toml cargo