From 53f66593bd91cd54a3cc59124ef8db3f27c6b802 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 13 Dec 2019 14:40:15 +0100 Subject: Add hamilton function --- src/simulation/hamiltonians.rs | 31 +++++++++++++++++++++++++++++++ src/simulation/mod.rs | 1 + src/simulation/twoxtwo_level.rs | 3 +++ 3 files changed, 35 insertions(+) create mode 100644 src/simulation/hamiltonians.rs (limited to 'src/simulation') diff --git a/src/simulation/hamiltonians.rs b/src/simulation/hamiltonians.rs new file mode 100644 index 0000000..03d8d1f --- /dev/null +++ b/src/simulation/hamiltonians.rs @@ -0,0 +1,31 @@ +use super::c64; +use ndarray::prelude::*; + +pub fn X0() -> Array2 { + array![ + [ + c64::new(1.0, 0.0), + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + ], + [ + c64::new(0.0, 0.0), + c64::new(1.0, 0.0), + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + ], + [ + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + c64::new(-1.0, 0.0), + c64::new(0.0, 0.0), + ], + [ + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + c64::new(0.0, 0.0), + c64::new(-1.0, 0.0), + ] + ] +} diff --git a/src/simulation/mod.rs b/src/simulation/mod.rs index 641444e..c72f275 100644 --- a/src/simulation/mod.rs +++ b/src/simulation/mod.rs @@ -1,3 +1,4 @@ +pub mod hamiltonians; pub mod s_5_fibration; pub mod time_evolution; pub mod two_level; diff --git a/src/simulation/twoxtwo_level.rs b/src/simulation/twoxtwo_level.rs index 8a34167..62425c8 100644 --- a/src/simulation/twoxtwo_level.rs +++ b/src/simulation/twoxtwo_level.rs @@ -25,11 +25,14 @@ impl State for TwoXTwoLevel { for val in conjugate.iter_mut() { *val = val.conj(); } + let v = conjugate.dot(&X3().dot(&self.state))[(0, 0)]; vec![ conjugate.dot(&X0().dot(&self.state))[(0, 0)].re, conjugate.dot(&X1().dot(&self.state))[(0, 0)].re, conjugate.dot(&X2().dot(&self.state))[(0, 0)].re, + v.re, + v.im, ] } -- cgit v1.2.3-70-g09d2