From 592a2cc51d997de14e271a70d647c8fe621dccf8 Mon Sep 17 00:00:00 2001 From: rishi763 <55810666+rishi763@users.noreply.github.com> Date: Sat, 22 Jun 2024 02:29:01 +0000 Subject: [PATCH 1/2] Closes #46 --- src/fusion/fusion.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/fusion/fusion.rs b/src/fusion/fusion.rs index a8520ed..5574eb2 100644 --- a/src/fusion/fusion.rs +++ b/src/fusion/fusion.rs @@ -165,6 +165,49 @@ impl Fusion { .zip(self.ising_canonical_topo_charge(init_charge).iter()) .all(|(a, b)| *b <= 0 || *a > 0) } + + /// + /// Returns number of sigmas that can be in the initial topological charges of anyons to exactly a certain number of qubits for the Ising model + /// + pub fn ising_possible_sigmas(&self, qubits:u32) -> Vec{ + vec![2*qubits+1, 2*qubits+2] + } + /// + /// Returns number of taus that can be in the initial topological charges of anyons to exactly a certain number of qubits for the Fibonacci model + /// + /// Precondition: Requires qubits <=30 + pub fn fibonacci_possible_taus(&self, qubits:u32) -> Vec { + + if qubits ==0{ + return vec![0,1,2,3]; + } + + let mut possible_taus = Vec::new(); + + let mut n = 1; + + + // We have that the fibonacci recurrence gives us that tau^n = a + b * tau + let mut a = 0; + let mut b = 1; + + // Checks that b < 2^(qubits+1) meaning as otherwise fusing to tau would result in too many qubits + while b < 1 << (qubits+1) { + + // If b >= 2^qubits we have that this will give exactly 'qubits' qubits + if (1 << (qubits)) <= b{ + possible_taus.push(n); + } + + b=a+b; + a=b-a; + + n+=1; + } + // Accounts for the case that we can also fuse to vaccuum + possible_taus.push(n); + possible_taus + } } /// Python Facing Methods From e373e16452a7caae45cc2eb0a938bd7bf646f779 Mon Sep 17 00:00:00 2001 From: rishi763 <55810666+rishi763@users.noreply.github.com> Date: Sat, 22 Jun 2024 21:55:14 +0000 Subject: [PATCH 2/2] Wrote tests and interface for #46 --- python/tests/test_fusion.py | 12 ++++++++++++ src/fusion/fusion.rs | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/python/tests/test_fusion.py b/python/tests/test_fusion.py index 5f6937a..f6d6320 100644 --- a/python/tests/test_fusion.py +++ b/python/tests/test_fusion.py @@ -67,3 +67,15 @@ def test_verify_fusion_result(state): assert not fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Vacuum), AnyonModel.Ising) assert not fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Psi), AnyonModel.Ising) assert fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Sigma), AnyonModel.Ising) + +@pytest.mark.fusion +def test_minimum_possible_anyons(state): + + fusion = Fusion(state) + + assert (fusion.minimum_possible_anyons(10, AnyonModel.Ising) == [21,22]) + assert (fusion.minimum_possible_anyons(5, AnyonModel.Ising) == [11,12]) + + + assert(fusion.minimum_possible_anyons(10, AnyonModel.Fibonacci) == [17,18]); + assert(fusion.minimum_possible_anyons(0, AnyonModel.Fibonacci) == [0,1,2,3]); diff --git a/src/fusion/fusion.rs b/src/fusion/fusion.rs index 5574eb2..9f94dc9 100644 --- a/src/fusion/fusion.rs +++ b/src/fusion/fusion.rs @@ -311,4 +311,12 @@ impl Fusion { _ => false, } } + fn minimum_possible_anyons(&self, qubits: u32, anyon_model: &AnyonModel) -> PyResult>{ + match anyon_model{ + AnyonModel::Ising => Ok(self.ising_possible_sigmas(qubits)), + AnyonModel::Fibonacci => Ok(self.fibonacci_possible_taus(qubits)), + _ => Err(PyValueError::new_err("This model is not supported yet")) + } + + } }