Quite a mess
This commit is contained in:
+36
-13
@@ -1,24 +1,34 @@
|
||||
#![feature(array_zip)]
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod system;
|
||||
mod example_systems;
|
||||
|
||||
use clap::Parser;
|
||||
use crate::example_systems::{execute, stick_probability, three_dimensional};
|
||||
use crate::system::model::DLASystem;
|
||||
use crate::example_systems::{drive_system, stick_probability, three_dimensional, write_csv, write_json};
|
||||
|
||||
#[derive(clap::ValueEnum, Clone, Debug)]
|
||||
enum PreConfiguredSystem {
|
||||
Grid2,
|
||||
Grid3,
|
||||
Hex
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
#[arg(short, long, default_value_t = 2)]
|
||||
dim: u32,
|
||||
#[arg(value_enum, long, default_value_t = PreConfiguredSystem::Grid2)]
|
||||
mode: PreConfiguredSystem,
|
||||
|
||||
#[arg(short, long)]
|
||||
max_frames: Option<usize>,
|
||||
|
||||
seed: u64,
|
||||
max_particles: usize,
|
||||
stick_probability: f32,
|
||||
csv_path: PathBuf,
|
||||
output: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -26,27 +36,40 @@ fn main() {
|
||||
|
||||
println!("Running: {:?}", cli);
|
||||
|
||||
match cli.dim {
|
||||
2 => {
|
||||
match cli.mode {
|
||||
PreConfiguredSystem::Grid2 => {
|
||||
let mut sys = stick_probability(
|
||||
cli.seed,
|
||||
cli.max_particles,
|
||||
cli.stick_probability,
|
||||
);
|
||||
|
||||
execute(&mut sys, &cli.csv_path);
|
||||
},
|
||||
drive_system(&mut sys, cli.max_frames);
|
||||
write_csv(&mut sys, &cli.output);
|
||||
}
|
||||
|
||||
3 => {
|
||||
PreConfiguredSystem::Grid3 => {
|
||||
let mut sys = three_dimensional(
|
||||
cli.seed,
|
||||
cli.max_particles,
|
||||
cli.stick_probability,
|
||||
);
|
||||
|
||||
execute(&mut sys, &cli.csv_path);
|
||||
},
|
||||
drive_system(&mut sys, cli.max_frames);
|
||||
|
||||
n => panic!("Model not compiled with {n} dimensional support")
|
||||
write_json(&mut sys, &cli.output);
|
||||
}
|
||||
|
||||
PreConfiguredSystem::Hex => {
|
||||
let mut sys = three_dimensional(
|
||||
cli.seed,
|
||||
cli.max_particles,
|
||||
cli.stick_probability,
|
||||
);
|
||||
|
||||
drive_system(&mut sys, cli.max_frames);
|
||||
|
||||
write_json(&mut sys, &cli.output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user