dyntri_core/lib.rs
1//! # Dynamical Triangulation
2//! Dynamical Triangulation (DT) in Rust.
3//!
4//! The `dyntri-core` crate aims to form a base and provide standard triangulation
5//! and graph structures, which DT generators can use to provide interoperability
6//! and make use of the provided observables.
7//! This crate provides triangulation functionality for arbirary dimensions using Rust _const generics_.
8//!
9//! ## Triangulation Generators
10//! Currently, there are two companion crates [`dyntri-edt2d`](https://crates.io/crates/dyntri-edt2d)
11//! and [`dyntri-cdt2d`](https://crates.io/crates/dyntri-cdt2d) that provide implementations
12//! of 2D Euclidean and Causal Dynamical Triangulation (EDT/CDT) generators respectively.
13//!
14//! ## Using the crate
15//! The central structures of this crate are the [Triangulation](triangulation::Triangulation)
16//! and [CausalTriangulation](triangulation::CausalTriangulation), providing
17//! the base functionality to work with triangulations. These are designed to work for any dimension,
18//! and there are also aliases for the most common use cases:
19//! - [Triangulation2D](triangulation::Triangulation2D)
20//! - [Triangulation3D](triangulation::Triangulation3D)
21//! - [Triangulation4D](triangulation::Triangulation4D)
22//! - [CausalTriangulation2D](triangulation::CausalTriangulation2D)
23//! - [CausalTriangulation3D](triangulation::CausalTriangulation3D)
24//! - [CausalTriangulation4D](triangulation::CausalTriangulation4D)
25//!
26//! Additionally, there is the [Graph](graph::Graph) structure, which provides a standard graph
27//! implementation. This [Graph](graph::Graph) implements most of the interesting
28//! [quantities/observables](graph::observables), like the sphere volume profile and the
29//! average sphere distance, as well as many breadth-first search functions that can be used
30//! for many distance based measurements like correlations.
31//!
32//! ## Example of use
33//! Here is an example using the [`dyntri-edt2d`](https://crates.io/crates/dyntri-edt2d)
34//! generator. Crucially a [Triangulation2D](triangulation::Triangulation2D)
35//! `triangulation` is constructed, which can then be used to perform any measurement one would like.
36//! ```
37//! use dyntri_edt2d::generator::random_uniform_triangulation;
38//! use dyntri_core::graph::observables::asd;
39//! # use rand::SeedableRng;
40//! use rand_xoshiro::Xoshiro256StarStar;
41//!
42//! // Create RNG
43//! let mut rng = Xoshiro256StarStar::seed_from_u64(42);
44//!
45//! // Generate an 2D EDT triangulation using direct sampling (as [`PlanarMap`])
46//! let planar_map = random_uniform_triangulation(1000, &mut rng);
47//! // Construct triangulation
48//! let triangulation = planar_map.construct_triangulation();
49//! // Check the Euler characteristic formula for spherical topology
50//! assert_eq!(triangulation.num_vertices(), 1000 / 2 + 2);
51//!
52//! // Get the vertex graph of the triangulation
53//! let graph = triangulation.vertex_graph();
54//! // Measure the average sphere distance (epsilon=0)
55//! let asd = asd::asd(&graph, 0, 10);
56//! println!("{:?}", asd);
57//! ```
58//!
59//! ## Implementing custom generator
60//! To make use of `dyntri-core` using a custom generator, all one needs to do is implement
61//! a function to construct a [Triangulation](triangulation::Triangulation) or
62//! [CausalTriangulation2D](triangulation::CausalTriangulation) from
63//! whatever generator one has.
64//! From these all the functionality coming from this crate is available.
65//! If so desired one can also directly implement the construction of a [Graph](graph::Graph)
66//! from one's generator, which may be more effecient then indirectly constructing it
67//! from a triangulation.
68
69pub mod graph;
70pub mod triangulation;