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