Closed auratrifire closed 2 days ago
I think I solved the bug,
I replaced:
# Find the inner product of each of the target state with each of the
# eigenvector; hence overlap has dimension of number of eigenvectors x number of target states
overlap_single = np.absolute(
np.array((Qobj(evecs_dag_mat) * Qobj(single_excitation_states_mat))))
overlap_double = np.absolute(
np.array((Qobj(evecs_dag_mat) * Qobj(double_excitation_states_mat))))
with:
# Find the inner product of each of the target state with each of the
# eigenvector; hence overlap has dimension of number of eigenvectors x number of target states
overlap_single = []
overlap_double = []
for u in evecs_dag_mat:
for v in single_excitation_states_mat:
overlap_single.append(u*v)
for w in double_excitation_states_mat:
overlap_double.append(u*w)
overlap_single = np.reshape(np.absolute(
np.array(overlap_single)), (*evecs_dag_mat.shape, *single_excitation_states_mat.shape))
overlap_double = np.reshape(np.absolute(
np.array(overlap_double)), (*evecs_dag_mat.shape, *double_excitation_states_mat.shape))
Is there a way I can push my changes to the github?
Did you try making a pull request?
From: Cody Fan @.> Date: Tuesday, July 2, 2024 at 7:07 PM To: qiskit-community/qiskit-metal @.> Cc: Subscribed @.***> Subject: Re: [qiskit-community/qiskit-metal] Error in Tutorial 4 Analysis 4.04 New LOM and Fluxonium Example (Issue #993)
Is there a way I can push my changes to the github?
— Reply to this email directly, view it on GitHubhttps://github.com/qiskit-community/qiskit-metal/issues/993#issuecomment-2204640928, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZS5ZTTHLZK6CYH4FPADKLZKMXBHAVCNFSM6AAAAABKGR4OEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBUGY2DAOJSHA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Information
What is the current behavior?
The running the line: hamiltonian_results = composite_sys.hamiltonian_results(hilbertspace, evals_count=30)
results in an error - TypeError: must be real number, not Qobj
Full error below:
Cell In[17], line 1
hamiltonian_results = composite_sys.hamiltonian_results(hilbertspace, evals_count=30)
File c:\users\aurat\qiskit-metal\qiskit_metal\analyses\quantization\lom_core_analysis.py:1522, in CompositeSystem.hamiltonian_results(self, hilbertspace, evals_count, print_info)
File c:\users\aurat\qiskit-metal\qiskit_metal\analyses\hamiltonian\states_energies.py:120, in extract_energies(esys_array, mode_size, zero_evals)
File ~\anaconda3\envs\qubit\lib\site-packages\qutip\core\qobj.py:307, in Qobj.init(self, arg, dims, copy, superrep, isherm, isunitary)
File ~\anaconda3\envs\qubit\lib\site-packages\qutip\core\qobj.py:295, in Qobj._initialize_data(self, arg, dims, copy)
File ~\anaconda3\envs\qubit\lib\site-packages\qutip\core\data\convert.pyx:477, in qutip.core.data.convert._create.call()
File ~\anaconda3\envs\qubit\lib\site-packages\qutip\core\data\dense.pyx:43, in qutip.core.data.dense.Dense.init()
Steps to reproduce the problem
Run the code up until part 6 of tutorial 4.04 of Qiskit Metal.
What is the expected behavior?
Give the results of the analyzed Fluxonium hamiltonian.
Suggested solutions
try except statement.
Seems to be some error interfacing with casting an array as a Qobj when it is a scalar.
the following would maybe work, but the solution may not be very general, and try, except statements usually aren't good code:
try: overlap_single = np.absolute( np.array((Qobj(evecs_dag_mat) Qobj(single_excitation_states_mat)))) overlap_double = np.absolute( np.array((Qobj(evecs_dag_mat) Qobj(double_excitation_states_mat))))
except TypeError: overlap_single = np.absolute( np.array((evecs_dag_mat Qobj(single_excitation_states_mat)))) overlap_double = np.absolute( np.array((evecs_dag_mat Qobj(double_excitation_states_mat))))