Skip to content

Commit

Permalink
Merge pull request #59 from Cornell-QCA/fusion
Browse files Browse the repository at this point in the history
Closes #46
  • Loading branch information
Haadi-Khan authored Jun 22, 2024
2 parents cd2452d + e373e16 commit 7774d21
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/tests/test_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,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]);
51 changes: 51 additions & 0 deletions src/fusion/fusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>{
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<u32> {

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
Expand Down Expand Up @@ -268,4 +311,12 @@ impl Fusion {
_ => false,
}
}
fn minimum_possible_anyons(&self, qubits: u32, anyon_model: &AnyonModel) -> PyResult<Vec<u32>>{
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"))
}

}
}

0 comments on commit 7774d21

Please sign in to comment.