summaryrefslogtreecommitdiff
path: root/src/simulation/twoxtwo_level.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/twoxtwo_level.rs')
-rw-r--r--src/simulation/twoxtwo_level.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/simulation/twoxtwo_level.rs b/src/simulation/twoxtwo_level.rs
new file mode 100644
index 0000000..8a34167
--- /dev/null
+++ b/src/simulation/twoxtwo_level.rs
@@ -0,0 +1,40 @@
+use super::c64;
+use super::s_5_fibration::*;
+use super::time_evolution::State;
+use ndarray::prelude::*;
+
+pub struct TwoXTwoLevel {
+ state: Array2<c64>,
+}
+
+impl TwoXTwoLevel {
+ pub fn new(alpha: c64, beta: c64, delta: c64, gamma: c64) -> TwoXTwoLevel {
+ TwoXTwoLevel {
+ state: array![[alpha], [beta], [gamma], [delta]],
+ }
+ }
+}
+
+impl State for TwoXTwoLevel {
+ fn fibrate(&self) -> Vec<f64> {
+ let mut conjugate = self
+ .state
+ .to_owned()
+ .into_shape((4, 1))
+ .expect("Invalid shape cast during fibartion");
+ for val in conjugate.iter_mut() {
+ *val = val.conj();
+ }
+
+ 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,
+ ]
+ }
+
+ fn evolve<G: super::time_evolution::MatrixGen>(mut self, t: f64) -> Self {
+ self.state = self.state.dot(&G::gen(t));
+ self
+ }
+}