Import the "Hamiltonian-through-Nonlinearities Engineering" module (it can be installed from PyPI using pip
).
In [1]:
import hamnonlineng as hnle
Set the letters you want to use for annihilation operators (4 modes in our case).
In [2]:
letters = 'abcd'
Write down (or somehow generate) a list of the monomials that you want to be resonant.
In [3]:
resonant = [hnle.Monomial(1,'aabbC'), # First argument is the constant real factor in front of the operator
hnle.Monomial(1,'abddC'), # Second argument is the string representing the operators
hnle.Monomial(1,'Cdddd')]
The convention for typing in or printing out is:
Monomial(1,'Aab')
is $\hat{a}^\dagger\hat{a}\hat{b}+\hat{a}^\dagger\hat{a}\hat{b}^\dagger$Monomial(1,'a')
and Monomial(1,'A')
In [4]:
resonant
Out[4]:
Now generate the terms that you want to be off resonant: start with the sum $\hat{a}+\hat{b}+\hat{c}+\hat{d}+h.c.$.
In [5]:
op_sum = hnle.operator_sum(letters)
op_sum
Out[5]:
Generate the list of 3rd and 5th order terms in the expansion of $\sin(\hat{a}+\hat{b}+\hat{c}+\hat{d}+h.c.)$.
In [6]:
sine_exp = hnle.sin_terms(op_sum, 3) + hnle.sin_terms(op_sum, 5)
sine_exp_list = sine_exp.m
Filter out of the list:
In [7]:
off_resonant = hnle.drop_single_mode(
hnle.drop_definitely_offresonant(
hnle.drop_matching(sine_exp.m, resonant)))
off_resonant = list(off_resonant)
How many terms are left.
In [8]:
len(off_resonant)
Out[8]:
Finally, solve the constraints:
In [9]:
res = hnle.head_and_count(
hnle.solve_constraints_gecode(resonant, off_resonant, letters, maxfreq=20))