0
$\begingroup$

I have to compute the molecular vibrational energy of CO2 molecules using VQE, but I am not progressing; Code on the qiskit website does not work. Does anyone have any working code to find vibrational energy of any molecule using qiskit?

code source - qiskit Error-

    from qiskit_nature.second_q.problems import VibrationalStructureProblem
    from qiskit_nature.second_q.mappers import DirectMapper
    
    vibrational_problem = driver.run(basis=basis)
    vibrational_problem.hamiltonian.truncation_order = 2
    main_op, aux_ops = vibrational_problem.second_q_ops()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[9], line 4
      1 from qiskit_nature.second_q.problems import VibrationalStructureProblem
      2 from qiskit_nature.second_q.mappers import DirectMapper
----> 4 vibrational_problem = driver.run(basis=basis)
      5 vibrational_problem.hamiltonian.truncation_order = 2
      6 main_op, aux_ops = vibrational_problem.second_q_ops()

File /opt/homebrew/lib/python3.11/site-packages/qiskit_nature/second_q/drivers/gaussiand/gaussian_forces_driver.py:153, in GaussianForcesDriver.run(self, basis)
    150 else:
    151     glr = GaussianLogDriver(jcf=self._jcf).run()
--> 153 watson = glr.get_watson_hamiltonian(normalize=self._normalize)
    155 problem = watson_to_problem(watson, basis=basis)
    156 return problem

File /opt/homebrew/lib/python3.11/site-packages/qiskit_nature/second_q/drivers/gaussiand/gaussian_log_result.py:287, in GaussianLogResult.get_watson_hamiltonian(self, normalize)
    280     watson = WatsonHamiltonian(
    281         as_coo(quadratic_data, shape=(max_index,) * 2),
    282         as_coo(cubic_data, shape=(max_index,) * 3),
    283         as_coo(quartic_data, shape=(max_index,) * 4),
    284         -as_coo(quadratic_data, shape=(max_index,) * 2),
    285     )
    286 else:
--> 287     quadratic_numpy = np.zeros((max_index,) * 2)
    288     for coord, value in quadratic_data.items():
    289         quadratic_numpy[coord] = value

ValueError: negative dimensions are not allowed
$\endgroup$
2
  • $\begingroup$ Hello, could you share what you have tried so far? We try to help one another on Stack but are not really a task solving community. Update your question with some attempt, what error you get specifically and some Qiskit knowledgeable person can help you out! $\endgroup$
    – 3yakuya
    Jul 13, 2023 at 13:56
  • $\begingroup$ Sorry, my bad. I should have added the qiskit documentation web page(which has code for this task) and the error I got with that code. $\endgroup$ Jul 14, 2023 at 10:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.