Skip to main content

quantrs2_sim/topological_quantum_simulation/
fibonaccianyons_traits.rs

1//! # FibonacciAnyons - Trait Implementations
2//!
3//! This module contains trait implementations for `FibonacciAnyons`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Default`
8//! - `AnyonModelImplementation`
9//!
10//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
11
12use scirs2_core::ndarray::{Array1, Array2, Array3, Array4, Axis};
13use scirs2_core::Complex64;
14use std::f64::consts::PI;
15
16use super::functions::AnyonModelImplementation;
17use super::types::{AnyonType, FibonacciAnyons};
18
19impl Default for FibonacciAnyons {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25impl AnyonModelImplementation for FibonacciAnyons {
26    fn get_anyon_types(&self) -> Vec<AnyonType> {
27        self.anyon_types.clone()
28    }
29    fn fusion_coefficients(&self, a: &AnyonType, b: &AnyonType, c: &AnyonType) -> Complex64 {
30        match (a.label.as_str(), b.label.as_str(), c.label.as_str()) {
31            ("tau", "tau", "vacuum" | "tau") => Complex64::new(1.0, 0.0),
32            ("vacuum", _, label) | (_, "vacuum", label) if label == a.label || label == b.label => {
33                Complex64::new(1.0, 0.0)
34            }
35            _ => Complex64::new(0.0, 0.0),
36        }
37    }
38    fn braiding_matrix(&self, a: &AnyonType, b: &AnyonType) -> Array2<Complex64> {
39        if a.label == "tau" && b.label == "tau" {
40            let phi = f64::midpoint(1.0, 5.0_f64.sqrt());
41            let phase = Complex64::new(0.0, 1.0) * (4.0 * PI / 5.0).exp();
42            Array2::from_shape_vec(
43                (2, 2),
44                vec![
45                    phase,
46                    Complex64::new(0.0, 0.0),
47                    Complex64::new(0.0, 0.0),
48                    phase * Complex64::new(-1.0 / phi, 0.0),
49                ],
50            )
51            .expect("FibonacciAnyons::braiding_matrix: 2x2 matrix shape is always valid")
52        } else {
53            Array2::eye(1)
54        }
55    }
56    fn f_matrix(
57        &self,
58        _a: &AnyonType,
59        _b: &AnyonType,
60        _c: &AnyonType,
61        _d: &AnyonType,
62    ) -> Array2<Complex64> {
63        let phi = f64::midpoint(1.0, 5.0_f64.sqrt());
64        let inv_phi = 1.0 / phi;
65        Array2::from_shape_vec(
66            (2, 2),
67            vec![
68                Complex64::new(inv_phi, 0.0),
69                Complex64::new(inv_phi.sqrt(), 0.0),
70                Complex64::new(inv_phi.sqrt(), 0.0),
71                Complex64::new(-inv_phi, 0.0),
72            ],
73        )
74        .expect("FibonacciAnyons::f_matrix: 2x2 matrix shape is always valid")
75    }
76    fn is_abelian(&self) -> bool {
77        false
78    }
79    fn name(&self) -> &'static str {
80        "Fibonacci Anyons"
81    }
82}