diff --git a/src/example_systems.rs b/src/example_systems.rs index f68e0d9..a5e6667 100644 --- a/src/example_systems.rs +++ b/src/example_systems.rs @@ -1,9 +1,20 @@ +use std::path::Path; use rand::rngs::SmallRng; -use rand::SeedableRng; +use rand::{Rng, SeedableRng}; use crate::system::grid::{Position, VectorStorage}; use crate::system::model::DLASystem; use crate::system::nd::{NDPosition, NDVectorStorage}; -use crate::system::walker::LocalRandomWalker; +use crate::system::{GriddedPosition, Storage}; +use crate::system::walker::{LocalRandomWalker, Walker}; + +pub fn execute, W: Walker

>(sys: &mut DLASystem, 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 { DLASystem::new_g( diff --git a/src/main.rs b/src/main.rs index e1f4b58..57fbb0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,14 @@ mod system; mod example_systems; use clap::Parser; -use crate::example_systems::stick_probability; +use crate::example_systems::{execute, stick_probability, three_dimensional}; +use crate::system::model::DLASystem; #[derive(Parser, Debug)] struct Cli { + #[arg(short, long, default_value_t = 2)] + dim: u32, + seed: u64, max_particles: usize, stick_probability: f32, @@ -21,16 +25,27 @@ fn main() { println!("Running: {:?}", cli); - let mut sys = stick_probability( - cli.seed, - cli.max_particles, - cli.stick_probability - ); + match cli.dim { + 2 => { + let mut sys = stick_probability( + cli.seed, + cli.max_particles, + cli.stick_probability, + ); - while sys.running { - sys.update(); + execute(&mut sys, &cli.csv_path); + }, + + 3 => { + let mut sys = three_dimensional( + cli.seed, + cli.max_particles, + cli.stick_probability, + ); + + execute(&mut sys, &cli.csv_path); + }, + + n => panic!("Model not compiled with {n} dimensional support") } - - sys.export_data(&cli.csv_path) - .expect("Failed to write"); } diff --git a/src/system/hexagonal.rs b/src/system/hexagonal.rs index 5d78df3..cf99272 100644 --- a/src/system/hexagonal.rs +++ b/src/system/hexagonal.rs @@ -1,5 +1,4 @@ use std::ops::Add; -use bevy::render::color::HexColorError::Hex; use rand::Rng; use crate::system::GriddedPosition; use serde::{Serialize, Deserialize};