I’d like to create a dictionary or a list called Fock_states
to which I can append different vectors. The different vectors will be specified by their index j
which specifies what frequency value the Fock state corresponds to from a range of frequencies ω = np.array([ω_0, ω_1, ω_2])
where ω_j take on some specified values and their Fock number n
which specifies how many photons are in that frequency mode. So for instance, one of the basis vectors I want to define is Fock_state_12 = np.array([2,0,0])
which is the Fock state which encodes “2 photons in frequency mode ω_0”. In general, I want to have callable objects Fock state_nj
which encode “n photons in frequency mode ω_j” and be able to call them by their indices. At first I tried something like this:
Fock_states = []
ω = np.array([0, 2.5, 5])
ψ = np.zeros(len(ω))
def update_ψ(J,N):
ψ[J] += N
n_max = 10
for j in range(0, len(ω)):
for n in range(1, n_max+1):
update_ψ(j,n)
Fock_states.append(ψ)
But this obviously doesn’t reset ψ so as to create a new vector for every run of the loop and instead just continuously updates the same vector and returns Fock_states = [[55,55,55,55], [55,55,55,55],...,[55,55,55,55]]
I thought the fix would be as simple as adding a new line:
Fock_states = []
ω = np.array([0, 2.5, 5])
ψ = np.zeros(len(ω))
def update_ψ(J,N):
ψ[J] += N
n_max = 10
for j in range(0, len(ω)):
for n in range(1, n_max+1):
update_ψ(j,n)
Fock_states.append(ψ)
update_ψ(j,-n)
But that returns an array of lists filled with 0’s.
Any help would be appreciated!
Cody Payne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.