summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/main.rs b/src/main.rs
index ab88302..773ea72 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,44 +1,42 @@
pub mod plot;
mod simulation;
+use num_complex::Complex;
use plot::Graph;
+use simulation::time_evolution::*;
+use simulation::*;
+
+struct StaticHamiltonion;
+
+impl MatrixGen for StaticHamiltonion {
+ fn gen(_t: f64) -> ndarray::Array2<c64> {
+ let mut b = unsafe { ndarray::Array2::<c64>::uninitialized((4, 4)) };
+ expm::expm(&simulation::hamiltonians::X0(), &mut b);
+ b
+ }
+}
fn main() {
- println!("Hello, world!");
- plot::Gnuplot::plot3d(
- &[
- [
- 0.14285714285714296,
- 0.5714285714285717,
- 0.0,
- 0.5714285714285717,
- 0.5714285714285717,
- 0.0,
- ],
- [
- 0.11910591478146304,
- 0.5652016093730936,
- -0.01707887122942119,
- 0.6464319082591804,
- 0.498191752207936,
- 0.0002,
- ],
- [
- 0.21910591478146304,
- 0.7652016093730936,
- -0.01707887122942119,
- 0.6464319082591804,
- 0.498191752207936,
- 0.0002,
- ],
- [
- 0.01910591478146304,
- 0.8652016093730936,
- -0.01707887122942119,
- 0.6464319082591804,
- 0.498191752207936,
- 0.0002,
- ],
- ],
- 1,
- )
+ let dt = 1.0;
+ let iterations = 100;
+
+ let state = simulation::twoxtwo_level::TwoXTwoLevel::new(
+ Complex::new(0.0, 0.0),
+ Complex::new(0.0, 0.0),
+ Complex::new(0.0, 0.0),
+ Complex::new(0.0, 0.0),
+ );
+ let trace = Vec::new();
+ for i in 0..iterations {
+ state.evolve::<StaticHamiltonion>(i as f64 * dt);
+ let fibre = state.fibrate();
+ trace.push([
+ fibre[0],
+ fibre[1],
+ fibre[2],
+ 0.0,
+ 0.0,
+ i as f64 / iterations as f64,
+ ]);
+ }
+ plot::Gnuplot::plot3d(&trace, 1)
}