diff options
author | Dennis Kobert <dennis@kobert.dev> | 2019-12-13 04:00:31 +0100 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2019-12-13 04:00:31 +0100 |
commit | de571765f161a49129fd9e34150f6a892f388bdc (patch) | |
tree | d3f49cb6bbfdeff9378fda2fe901a6796269330c /src/simulation/twoxtwo_level.rs | |
parent | 1daf4f35a5dd2f500d95541797661c518f4e2713 (diff) |
Add fibartion matrices
Diffstat (limited to 'src/simulation/twoxtwo_level.rs')
-rw-r--r-- | src/simulation/twoxtwo_level.rs | 40 |
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 + } +} |