# スピン多重度
multiplicity = 1
# 全電荷
charge = 0
# 原子核配置
distance = 0.977
geometry = [["H", [0, 0, 0]], ["H", [0, 0, distance]]]

!pip install qulacs pyscf openfermion openfermionpyscf

from openfermion.transforms import get_fermion_operator, jordan_wigner
from openfermion.hamiltonians import MolecularData
from openfermionpyscf import run_pyscf
from pyscf import fci

# 分子軌道を表現するための基底関数(Slator Type Orbital - 3 gaussian)
basis = "sto-3g"

# 計算結果の保存場所
description = "tmp"
molecule = MolecularData(geometry, basis, multiplicity, charge, description)
molecule = run_pyscf(molecule, run_scf=1, run_fci=1)

n_qubit = molecule.n_qubits
n_electron = molecule.n_electrons
# get_molecular_hamiltonianで第二量子化形式のハミルトニアンを計算
fermionic_hamiltonian = get_fermion_operator(
    molecule.get_molecular_hamiltonian())
# Jordan-Wigner変換によりハミルトニアンをパウリ行列のテンソル積形式に変換
jw_hamiltonian = jordan_wigner(fermionic_hamiltonian)

print(jw_hamiltonian)

from qiskit.chemistry.drivers import PySCFDriver, UnitsType, Molecule
from qiskit.chemistry.transformations import FermionicTransformation,FermionicTransformationType, FermionicQubitMappingType

basis = "sto3g"

molecule = Molecule(geometry=geometry, charge=charge, multiplicity=multiplicity)
driver = PySCFDriver(molecule = molecule, unit=UnitsType.ANGSTROM, basis=basis)
transformation = FermionicTransformation(
    transformation=FermionicTransformationType.FULL,
    qubit_mapping=FermionicQubitMappingType.JORDAN_WIGNER,
    two_qubit_reduction=False,
    freeze_core=False)
qubit_op, _ = transformation.transform(driver)
print(qubit_op)

