Hi all! I’ve been trying the tutorial on implementing Hamiltonian simulations on StrawberryFields posted at Hamiltonian simulation — Strawberry Fields. I’m currently working on implementing such simulations for more complex Hamiltonians in the sense that there are terms involving more than 2 creation/annihilation operators. Is there any way I could add more customized gates to the source code?

Additionally, if I get it correctly, the TFBackend and FockBackend in StrawberryFields give me any cutoff I want but bosonic-qiskit only allows cutoff that are powers of 2 to be implementable on qiskit. However, bosonic-qiskit allows the creation of qumodes that have different Fock cutoffs while StrawberryFields only allows one Fock cutoff applied to all qumodes - is there anyway I can circumvent this? Thanks for any help you can provide!

and use a “stock” operation as a guideline for creating your custom one .

… but bosonic-qiskit only allows cutoff that are powers of 2 to be implementable on qiskit. However, bosonic-qiskit allows the creation of qumodes that have different Fock cutoffs while StrawberryFields only allows one Fock cutoff applied to all qumodes - is there anyway I can circumvent this?

Do you mean more than 2 in the sense of more than 2 modes, or in the sense of cubic and higher order Hamiltonians?

Thanks a lot for your reply! I’ve been trying the past two days on trying to implement what you said, but to be honest I’m really new to python and github. As for the C2QA Bosonic-qiskit package I mentioned above, the instructions told me to add functions that correspond to the gate I desire in two .py files, which was straightforward enough for me to follow (and I could make a single-mode Kerr gate which is not yet available in that package). However, when I looked at the ops.py file that you suggested, I was confused with where to start with. For example, if I want to make a four-mode gate, let’s call it J, where J(z) = \exp{\left(z(a_1a_2^\dagger+a_1^\dagger a_2)(a_3a_4^\dagger+a_3^\dagger a_4)\right)} (each smaller bracket does look like a two-mode beamsplitter), then what should I do? (I would really appreciate if you could explain what a “stock” operation is too!)

For the second question… what I meant was, can I create a 2-mode Program where the Fock cutoff for the first mode is, say, 5, and that for the second mode is 10?

Thanks for any clarification and help you can provide again!

Look at what’s in one of our other software packages called thewalrus — The Walrus Documentation — The Walrus 0.21.0-dev documentation — (the beamsplitter defined there), adjust as needed but define your new function in the same scope as your custom operation (don’t create something new inside thewalrus), then utilize it in your custom operation akin to what BSgate does with thewalrus’ beamsplitter function

Define the operator in the exponent in a finite dimensional space (i.e., with some artificially large cutoffs) and then use the matrix exponential function from scipy. If the cutoffs are large enough you can then truncate after the exponentiation and chances are your tensor is somewhat correct. You’d lose differentiability though, if that’s one thing you were after.

what I meant was, can I create a 2-mode Program where the Fock cutoff for the first mode is, say, 5, and that for the second mode is 10

Unfortunately, that isn’t possible in StrawberryFields at this time.

I would really appreciate if you could explain what a “stock” operation is too!

I just mean one of the operators that already exists . E.g., BSgate.