compb-dla-model/src/example_systems.rs
Joshua Coles 63d2bd9461
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
Add 3D support from the CLI
2023-03-04 20:37:41 +00:00

48 lines
1.5 KiB
Rust

use std::path::Path;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use crate::system::grid::{Position, VectorStorage};
use crate::system::model::DLASystem;
use crate::system::nd::{NDPosition, NDVectorStorage};
use crate::system::{GriddedPosition, Storage};
use crate::system::walker::{LocalRandomWalker, Walker};
pub fn execute<R: Rng, P: GriddedPosition, S: Storage<P>, W: Walker<P>>(sys: &mut DLASystem<R, P, S, W>, csv_path: &Path) {
while sys.running {
sys.update();
}
sys.export_data(csv_path)
.expect("Failed to write");
}
pub fn initial_config(seed: u64, max_particles: usize) -> DLASystem<SmallRng, Position, VectorStorage, LocalRandomWalker> {
DLASystem::new_g(
SmallRng::seed_from_u64(seed),
VectorStorage::new(1600),
LocalRandomWalker,
1.0,
max_particles,
)
}
pub fn stick_probability(seed: u64, max_particles: usize, stick_probability: f32) -> DLASystem<SmallRng, Position, VectorStorage, LocalRandomWalker> {
DLASystem::new_g(
SmallRng::seed_from_u64(seed),
VectorStorage::new(1600),
LocalRandomWalker,
stick_probability,
max_particles,
)
}
pub fn three_dimensional(seed: u64, max_particles: usize, stick_probability: f32) -> DLASystem<SmallRng, NDPosition<3>, NDVectorStorage<3>, LocalRandomWalker> {
DLASystem::new_g(
SmallRng::seed_from_u64(seed),
NDVectorStorage::new(1600),
LocalRandomWalker,
stick_probability,
max_particles,
)
}