from qiskit_nature.drivers.second_quantization import GaussianForcesDriver
from qiskit_nature.problems.second_quantization import VibrationalStructureProblem
from qiskit_nature.settings import settings

settings.dict_aux_operators = True

driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log")

problem = VibrationalStructureProblem(driver, num_modals=[2, 2, 3, 4], truncation_order=2)

# Note: at this point, `driver.run()` has NOT been called yet. We can trigger this indirectly like so:
second_q_ops = problem.second_q_ops()

hamiltonian = second_q_ops["VibrationalEnergy"]
print("\n".join(str(hamiltonian).splitlines()[:10] + ["..."]))

from qiskit_nature.second_q.drivers import GaussianForcesDriver
from qiskit_nature.second_q.problems import HarmonicBasis

driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log")
basis = HarmonicBasis(num_modals=[2, 2, 3, 4])

# this is now done explicitly and already requires the basis
problem = driver.run(basis=basis)
problem.hamiltonian.truncation_order = 2

hamiltonian = problem.hamiltonian.second_q_op()
print("\n".join(str(hamiltonian).splitlines()[:10] + ["..."]))

from qiskit_nature.drivers.second_quantization import GaussianLogResult
from qiskit_nature.properties.second_quantization.vibrational.bases import HarmonicBasis
from qiskit_nature.settings import settings

settings.dict_aux_operators = True

log_result = GaussianLogResult("aux_files/CO2_freq_B3LYP_631g.log")

hamiltonian = log_result.get_vibrational_energy()
print(hamiltonian)

hamiltonian.basis = HarmonicBasis([2, 2, 3, 4])
op = hamiltonian.second_q_ops()["VibrationalEnergy"]
print("\n".join(str(op).splitlines()[:10] + ["..."]))

from qiskit_nature.second_q.drivers import GaussianLogResult
from qiskit_nature.second_q.formats import watson_to_problem
from qiskit_nature.second_q.problems import HarmonicBasis

log_result = GaussianLogResult("aux_files/CO2_freq_B3LYP_631g.log")

watson = log_result.get_watson_hamiltonian()
print(watson)

basis = HarmonicBasis(num_modals=[2, 2, 3, 4])

problem = watson_to_problem(watson, basis)

hamiltonian = problem.hamiltonian.second_q_op()
print("\n".join(str(hamiltonian).splitlines()[:10] + ["..."]))

from qiskit_nature.drivers.second_quantization import GaussianForcesDriver
from qiskit_nature.problems.second_quantization import VibrationalStructureProblem

driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log")

problem = VibrationalStructureProblem(driver, num_modals=[2, 2, 3, 4], truncation_order=2)

# we trigger driver.run() implicitly like so:
second_q_ops = problem.second_q_ops()

hamiltonian_op = second_q_ops.pop("VibrationalEnergy")
aux_ops = second_q_ops

from qiskit_nature.second_q.drivers import GaussianForcesDriver
from qiskit_nature.second_q.problems import HarmonicBasis

driver = GaussianForcesDriver(logfile="aux_files/CO2_freq_B3LYP_631g.log")
basis = HarmonicBasis(num_modals=[2, 2, 3, 4])

problem = driver.run(basis=basis)
problem.hamiltonian.truncation_order = 2

hamiltonian_op, aux_ops = problem.second_q_ops()

import qiskit.tools.jupyter

%qiskit_version_table
%qiskit_copyright