Remove slight divergence
This commit is contained in:
parent
639be88ce1
commit
0752370ee7
@ -13,6 +13,14 @@ path = "src/main.rs"
|
||||
name = "ui"
|
||||
path = "src/ui.rs"
|
||||
|
||||
# Set the default for crate.
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
||||
# Set the default for dependencies.
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.1.8", features = ["derive"] }
|
||||
bevy = { version = "0.9.1", features = ["dynamic"] }
|
||||
|
||||
@ -3,6 +3,7 @@ use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::ops::Add;
|
||||
use std::path::PathBuf;
|
||||
use nd_array::Array;
|
||||
use rand::prelude::*;
|
||||
|
||||
@ -22,7 +23,7 @@ struct Cli {
|
||||
seed: u64,
|
||||
max_particles: usize,
|
||||
stick_probability: f32,
|
||||
csv_path: String,
|
||||
csv_path: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -38,6 +39,6 @@ fn main() {
|
||||
sys.update();
|
||||
}
|
||||
|
||||
sys.export_data()
|
||||
sys.export_data(&cli.csv_path)
|
||||
.expect("Failed to write");
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use rand::prelude::*;
|
||||
use crate::system::{DIM, Position};
|
||||
use crate::system::storage::{Storage, VectorStorage};
|
||||
@ -34,7 +35,7 @@ impl<R: Rng, S: Storage, W: Walker<R>> DLASystem<R, S, W> {
|
||||
max_particles,
|
||||
running: true,
|
||||
|
||||
storage: VectorStorage::new(1600, 2),
|
||||
storage: VectorStorage::new(6000, 2),
|
||||
walker: LocalRandomWalker,
|
||||
particles: vec![],
|
||||
active_particle: None,
|
||||
@ -68,19 +69,19 @@ impl<R: Rng, S: Storage, W: Walker<R>> DLASystem<R, S, W> {
|
||||
.clone()
|
||||
.expect("No active particle");
|
||||
|
||||
if self.check_stick(current_position) {
|
||||
self.deposit(current_position);
|
||||
self.active_particle = None;
|
||||
return;
|
||||
}
|
||||
|
||||
let next_position = self.walker.walk(&mut self.rng, current_position);
|
||||
let distance = next_position.abs();
|
||||
|
||||
if distance > self.kill_circle {
|
||||
self.active_particle = None;
|
||||
} else if !self.storage.at(&next_position) {
|
||||
self.active_particle.replace(next_position);
|
||||
if self.check_stick(&next_position) {
|
||||
self.deposit(&next_position);
|
||||
self.active_particle = None;
|
||||
return;
|
||||
} else {
|
||||
self.active_particle.replace(next_position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,8 +124,8 @@ impl<R: Rng, S: Storage, W: Walker<R>> DLASystem<R, S, W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn export_data(&self) -> io::Result<()> {
|
||||
let mut file = File::create("out.csv")?;
|
||||
pub fn export_data(&self, path: &Path) -> io::Result<()> {
|
||||
let mut file = File::create(path)?;
|
||||
writeln!(&mut file, "x, y")?;
|
||||
|
||||
for particle in &self.particles {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user