diff --git a/quantum_simulation_recipe/09d749e2-95b2-40d4-9eb5-444ebea855d8.hdf5 b/quantum_simulation_recipe/09d749e2-95b2-40d4-9eb5-444ebea855d8.hdf5 new file mode 100644 index 0000000..f170554 Binary files /dev/null and b/quantum_simulation_recipe/09d749e2-95b2-40d4-9eb5-444ebea855d8.hdf5 differ diff --git a/quantum_simulation_recipe/data/hydrogen_2_1.0.hdf5 b/quantum_simulation_recipe/data/hydrogen_2_1.0.hdf5 new file mode 100644 index 0000000..f170554 Binary files /dev/null and b/quantum_simulation_recipe/data/hydrogen_2_1.0.hdf5 differ diff --git a/quantum_simulation_recipe/fermion_ham.py b/quantum_simulation_recipe/fermion.py similarity index 98% rename from quantum_simulation_recipe/fermion_ham.py rename to quantum_simulation_recipe/fermion.py index 51dbd42..8bcc31a 100644 --- a/quantum_simulation_recipe/fermion_ham.py +++ b/quantum_simulation_recipe/fermion.py @@ -97,7 +97,7 @@ def op2mat(ops, n_qubits, to_array=False): return list_sparse_mat -class h2o_hamiltonian: +class H2O: def __init__(self, verbose=False): # Set molecule parameters self.use_ActiveSpace = True @@ -212,8 +212,8 @@ def pauli_commutator(pauli_str1, pauli_str2): return product, 2*(factor%2) * phase -class hydrogen_chain_hamiltonian: - def __init__(self, chain_length, bond_length, verbose=False): +class Hydrogen_Chain: + def __init__(self, chain_length: int, bond_length: float, verbose=False): # def hydrogen_chain_hamiltonian(chain_length, bond_length): self.chain_length = chain_length @@ -295,7 +295,7 @@ def __init__(self, chain_length, bond_length, verbose=False): # return hydrogen_hamiltonian_list -def LiH_hamiltonian(): +def LiH(): basis = 'sto-3g' multiplicity = 1 # Set Hamiltonian parameters. diff --git a/quantum_simulation_recipe/spin.py b/quantum_simulation_recipe/spin.py new file mode 100644 index 0000000..84fd711 --- /dev/null +++ b/quantum_simulation_recipe/spin.py @@ -0,0 +1,122 @@ +############################ +# define spin Hamiltonians +############################ + +import numpy as np +from qiskit.quantum_info import SparsePauliOp +import random + +class Nearest_Neighbour_1d: + def __init__(self, n: int, Jx=1, Jy=1, Jz=1, hx=0.2, hy=0, hz=0, pbc=False, verbose=False, rand_field=[]): + self.n = n + self.xx_tuples = [('XX', [i, i + 1], Jx) for i in range(0, n-1)] + self.yy_tuples = [('YY', [i, i + 1], Jy) for i in range(0, n-1)] + self.zz_tuples = [('ZZ', [i, i + 1], Jz) for i in range(0, n-1)] + + if len(rand_field) == 0: + self.rand_field = [0]*n + elif len(rand_field) >= n: + self.rand_field = rand_field[:n] + else: + raise ValueError(f'Length of random field should be at least {n}!') + + self.x_tuples = [('X', [i], (self.rand_field[i]+1)*hx) for i in range(0, n)] + self.y_tuples = [('Y', [i], (self.rand_field[i]+1)*hy) for i in range(0, n)] + self.z_tuples = [('Z', [i], (self.rand_field[i]+1)*hz) for i in range(0, n)] + + if pbc: + self.xx_tuples.append(('XX', [n-1, 0], Jx)) + self.yy_tuples.append(('YY', [n-1, 0], Jy)) + self.zz_tuples.append(('ZZ', [n-1, 0], Jz)) + + self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples, *self.y_tuples, *self.z_tuples], num_qubits=n).simplify() + self.xyz_group() + self.par_group() + if verbose: + print('The Hamiltonian: \n', self.ham) + print('The xyz grouping: \n', self.ham_xyz) + print('The parity grouping: \n', self.ham_par) + + def xyz_group(self): + self.x_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.x_tuples], num_qubits=self.n).simplify() + self.y_terms = SparsePauliOp.from_sparse_list([*self.yy_tuples, *self.y_tuples], num_qubits=self.n).simplify() + self.z_terms = SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], num_qubits=self.n).simplify() + self.ham_xyz = [self.x_terms, self.y_terms, self.z_terms] + self.ham_xyz = [item for item in self.ham_xyz if not np.all(abs(item.coeffs) == 0)] + + def par_group(self): + self.even_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples[::2], *self.yy_tuples[::2], *self.zz_tuples[::2], *self.x_tuples[::2], *self.y_tuples[::2], *self.z_tuples[::2]], num_qubits=self.n).simplify() + self.odd_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples[1::2], *self.yy_tuples[1::2], *self.zz_tuples[1::2], *self.x_tuples[1::2], *self.y_tuples[1::2], *self.z_tuples[1::2]], num_qubits=self.n).simplify() + self.ham_par = [self.even_terms, self.odd_terms] + + # def lc_group(self, right, left, step): + # self.ham_lc = [] + + +class Power_Law: + def __init__(self, n: int, alpha=4, Jx=1, Jy=1, Jz=1, hx=0.0, hy=0.0, hz=0.2, pbc=False, verbose=False): + self.n, self.alpha = n, alpha + self.xx_tuples = [('XX', [i, j], Jx*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] + self.yy_tuples = [('YY', [i, j], Jy*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] + self.zz_tuples = [('ZZ', [i, j], Jz*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] + self.x_tuples = [('X', [i], hx) for i in range(0, n)] + self.y_tuples = [('Y', [i], hy) for i in range(0, n)] + self.z_tuples = [('Z', [i], hz) for i in range(0, n)] + if pbc: + # self.xx_tuples.append(('XX', [n-1, 0], Jx)) + # self.yy_tuples.append(('YY', [n-1, 0], Jy)) + # self.zz_tuples.append(('ZZ', [n-1, 0], Jz)) + raise ValueError(f'PBC is not defined!') + + self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples, *self.y_tuples, *self.z_tuples], num_qubits=n).simplify() + if verbose: print('The Hamiltonian: \n', self.ham) + self.xyz_group() + + def xyz_group(self): + self.x_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.x_tuples], self.n).simplify() + self.y_terms = SparsePauliOp.from_sparse_list([*self.yy_tuples, *self.y_tuples], self.n).simplify() + self.z_terms = SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], self.n).simplify() + self.ham_xyz = [self.x_terms, self.y_terms, self.z_terms] + self.ham_xyz = [item for item in self.ham_xyz if not np.all(abs(item.coeffs) == 0)] + + # def parity_group(self): + # print('todo') + # return self.ham.to_matrix().todense() + +# class TF_Ising_1d: +# def __init__(self, n: int, J=1, h=0.2, g=0.0, pbc=False, verbose=False): +# self.n = n +# self.zz_tuples = [('ZZ', [i, i + 1], -J) for i in range(0, n-1)] +# self.x_tuples = [('X', [i], -h) for i in range(0, n)] +# self.z_tuples = [('Z', [i], -g) for i in range(0, n)] +# if pbc: self.zz_tuples.append(('ZZ', [n-1, 0], -J)) + +# self.ham = SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.x_tuples, *self.z_tuples], num_qubits=n).simplify() +# if verbose: print('The Hamiltonian: \n', self.ham) +# self.parity_group() +# self.xyz_group() + +# def parity_group(self): +# # return self.ham.to_matrix().todense() +# self.ham_parity = [SparsePauliOp.from_sparse_list([*self.zz_tuples[::2], *self.x_tuples[::2], *self.z_tuples[::2]], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.zz_tuples[1::2], *self.x_tuples[1::2], *self.z_tuples[1::2]], num_qubits=self.n).simplify()] + +# def xyz_group(self): +# self.ham_xyz = [SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.x_tuples], num_qubits=self.n)] + +# class Heisenberg_1d: +# def __init__(self, n: int, Jx=1, Jy=1, Jz=1, h=0.2, pbc=False, verbose=False): +# self.xx_tuples = [('XX', [i, i + 1], -Jx) for i in range(0, n-1)] +# self.yy_tuples = [('YY', [i, i + 1], -Jy) for i in range(0, n-1)] +# self.zz_tuples = [('ZZ', [i, i + 1], -Jz) for i in range(0, n-1)] +# self.x_tuples = [('X', [i], -h) for i in range(0, n)] +# if pbc: +# self.xx_tuples.append(('XX', [n-1, 0], -Jx)) +# self.yy_tuples.append(('YY', [n-1, 0], -Jy)) +# self.zz_tuples.append(('ZZ', [n-1, 0], -Jz)) + +# self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples], num_qubits=n) +# if verbose: print('The Hamiltonian: \n', self.ham) + +# def parity_group(self): +# print('todo') +# return self.ham.to_matrix().todense() diff --git a/quantum_simulation_recipe/spin_ham.py b/quantum_simulation_recipe/spin_ham.py deleted file mode 100644 index 4d8be97..0000000 --- a/quantum_simulation_recipe/spin_ham.py +++ /dev/null @@ -1,130 +0,0 @@ -############################ -# define spin Hamiltonians -############################ - -import numpy as np -from qiskit.quantum_info import SparsePauliOp -import random - -class Nearest_Neighbour_1d: - def __init__(self, n: int, Jx=1, Jy=1, Jz=1, hx=0.2, hy=0, hz=0, pbc=False, verbose=False, rand_field=[]): - self.n = n - self.xx_tuples = [('XX', [i, i + 1], Jx) for i in range(0, n-1)] - self.yy_tuples = [('YY', [i, i + 1], Jy) for i in range(0, n-1)] - self.zz_tuples = [('ZZ', [i, i + 1], Jz) for i in range(0, n-1)] - - if len(rand_field) != 0: - self.rand_field = rand_field[:n] - # if len(rand_field) < n: - # self.rand_field = rand_field + [random.gauss(0, 0.1) for _ in range(n-len(rand_field))] - # else: - # self.rand_field = rand_field[:n] - # # self.rand_field = rand_field + [0.2*(random.random()-0.5) for _ in range(n-len(rand_field))] - if hx != 0: - self.x_tuples = [('X', [i], (self.rand_field[i]+1)*hx) for i in range(0, n)] - else: - self.x_tuples = [('X', [i], hx) for i in range(0, n)] - if hy != 0: - self.y_tuples = [('Y', [i], (self.rand_field[i]+1)*hy) for i in range(0, n)] - else: - self.y_tuples = [('Y', [i], hy) for i in range(0, n)] - if hz != 0: - self.z_tuples = [('Z', [i], (self.rand_field[i]+1)*hz) for i in range(0, n)] - else: - self.z_tuples = [('Z', [i], hz) for i in range(0, n)] - else: - self.x_tuples = [('X', [i], hx) for i in range(0, n)] - self.y_tuples = [('Y', [i], hy) for i in range(0, n)] - self.z_tuples = [('Z', [i], hz) for i in range(0, n)] - - if pbc: - self.xx_tuples.append(('XX', [n-1, 0], Jx)) - self.yy_tuples.append(('YY', [n-1, 0], Jy)) - self.zz_tuples.append(('ZZ', [n-1, 0], Jz)) - - self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples, *self.y_tuples, *self.z_tuples], num_qubits=n).simplify() - self.xyz_group() - self.par_group() - if verbose: - print('The Hamiltonian: \n', self.ham) - print('The xyz grouping: \n', self.ham_xyz) - print('The parity grouping: \n', self.ham_par) - - def xyz_group(self): - self.x_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.x_tuples], num_qubits=self.n).simplify() - self.y_terms = SparsePauliOp.from_sparse_list([*self.yy_tuples, *self.y_tuples], num_qubits=self.n).simplify() - self.z_terms = SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], num_qubits=self.n).simplify() - self.ham_xyz = [self.x_terms, self.y_terms, self.z_terms] - - def par_group(self): - self.even_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples[::2], *self.yy_tuples[::2], *self.zz_tuples[::2], *self.x_tuples[::2], *self.y_tuples[::2], *self.z_tuples[::2]], num_qubits=self.n).simplify() - self.odd_terms = SparsePauliOp.from_sparse_list([*self.xx_tuples[1::2], *self.yy_tuples[1::2], *self.zz_tuples[1::2], *self.x_tuples[1::2], *self.y_tuples[1::2], *self.z_tuples[1::2]], num_qubits=self.n).simplify() - self.ham_par = [self.even_terms, self.odd_terms] - - def lc_group(self, right, left, step): - self.ham_lc = [] - - -class Power_law: - def __init__(self, n: int, alpha=4, Jx=1, Jy=1, Jz=1, hx=0.0, hy=0.0, hz=0.2, pbc=False, verbose=False): - self.n, self.alpha = n, alpha - self.xx_tuples = [('XX', [i, j], Jx*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] - self.yy_tuples = [('YY', [i, j], Jy*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] - self.zz_tuples = [('ZZ', [i, j], Jz*abs(i-j)**(-alpha)) for i in range(0, n-1) for j in range(i+1, n)] - self.x_tuples = [('X', [i], hx) for i in range(0, n)] - self.y_tuples = [('Y', [i], hy) for i in range(0, n)] - self.z_tuples = [('Z', [i], hz) for i in range(0, n)] - if pbc: - # self.xx_tuples.append(('XX', [n-1, 0], Jx)) - # self.yy_tuples.append(('YY', [n-1, 0], Jy)) - # self.zz_tuples.append(('ZZ', [n-1, 0], Jz)) - raise ValueError(f'PBC is not defined!') - - self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples, *self.y_tuples, *self.z_tuples], num_qubits=n).simplify() - if verbose: print('The Hamiltonian: \n', self.ham) - self.xyz_group() - - def xyz_group(self): - self.ham_xyz = [SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.x_tuples], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.yy_tuples, *self.y_tuples], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], num_qubits=self.n).simplify()] - - def parity_group(self): - print('todo') - return self.ham.to_matrix().todense() - -class TF_Ising_1d: - def __init__(self, n: int, J=1, h=0.2, g=0.0, pbc=False, verbose=False): - self.n = n - self.zz_tuples = [('ZZ', [i, i + 1], -J) for i in range(0, n-1)] - self.x_tuples = [('X', [i], -h) for i in range(0, n)] - self.z_tuples = [('Z', [i], -g) for i in range(0, n)] - if pbc: self.zz_tuples.append(('ZZ', [n-1, 0], -J)) - - self.ham = SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.x_tuples, *self.z_tuples], num_qubits=n).simplify() - if verbose: print('The Hamiltonian: \n', self.ham) - self.parity_group() - self.xyz_group() - - def parity_group(self): - # return self.ham.to_matrix().todense() - self.ham_parity = [SparsePauliOp.from_sparse_list([*self.zz_tuples[::2], *self.x_tuples[::2], *self.z_tuples[::2]], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.zz_tuples[1::2], *self.x_tuples[1::2], *self.z_tuples[1::2]], num_qubits=self.n).simplify()] - - def xyz_group(self): - self.ham_xyz = [SparsePauliOp.from_sparse_list([*self.zz_tuples, *self.z_tuples], num_qubits=self.n).simplify(), SparsePauliOp.from_sparse_list([*self.x_tuples], num_qubits=self.n)] - -class Heisenberg_1d: - def __init__(self, n: int, Jx=1, Jy=1, Jz=1, h=0.2, pbc=False, verbose=False): - self.xx_tuples = [('XX', [i, i + 1], -Jx) for i in range(0, n-1)] - self.yy_tuples = [('YY', [i, i + 1], -Jy) for i in range(0, n-1)] - self.zz_tuples = [('ZZ', [i, i + 1], -Jz) for i in range(0, n-1)] - self.x_tuples = [('X', [i], -h) for i in range(0, n)] - if pbc: - self.xx_tuples.append(('XX', [n-1, 0], -Jx)) - self.yy_tuples.append(('YY', [n-1, 0], -Jy)) - self.zz_tuples.append(('ZZ', [n-1, 0], -Jz)) - - self.ham = SparsePauliOp.from_sparse_list([*self.xx_tuples, *self.yy_tuples, *self.zz_tuples, *self.x_tuples], num_qubits=n) - if verbose: print('The Hamiltonian: \n', self.ham) - - def parity_group(self): - print('todo') - return self.ham.to_matrix().todense() diff --git a/quantum_simulation_recipe/test.ipynb b/quantum_simulation_recipe/test.ipynb new file mode 100644 index 0000000..fcea94f --- /dev/null +++ b/quantum_simulation_recipe/test.ipynb @@ -0,0 +1,354 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e385a43f", + "metadata": {}, + "source": [ + "# Test" + ] + }, + { + "cell_type": "markdown", + "id": "b318c92e", + "metadata": {}, + "source": [ + "## Hamiltonians" + ] + }, + { + "cell_type": "markdown", + "id": "2209bd76", + "metadata": {}, + "source": [ + "### Spin lattice model" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "8c03d3e4", + "metadata": {}, + "outputs": [], + "source": [ + "from spin import *\n", + "from fermion import *" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "6ae552ff", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[SparsePauliOp(['IIXX', 'XXII', 'IIYY', 'YYII', 'IIZZ', 'ZZII', 'IIIZ', 'IZII'],\n", + " coeffs=[1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 0.2+0.j, 0.2+0.j]),\n", + " SparsePauliOp(['IXXI', 'XIIX', 'IYYI', 'YIIY', 'IZZI', 'ZIIZ', 'IIZI', 'ZIII'],\n", + " coeffs=[1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 0.2+0.j, 0.2+0.j])]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## Test 1D Nearest Neighbour (Heisenberg) Hamiltonian with PBC\n", + "n = 4\n", + "nnh = Nearest_Neighbour_1d(4, Jx=1, Jy=1, Jz=1, hx=0, hy=0, hz=0.2, pbc=True)\n", + "nnh.ham\n", + "nnh.ham_par\n", + "# nnh.ham_xyz" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "c9ffdc57", + "metadata": {}, + "outputs": [], + "source": [ + "## to matrix\n", + "h_list = [h.to_matrix() for h in nnh.ham_par]\n", + "# h_list" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "id": "37fd7d0d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[SparsePauliOp(['IIIX', 'IIXI', 'IXII', 'XIII'],\n", + " coeffs=[0.20865101+0.j, 0.18081363+0.j, 0.22731382+0.j, 0.19945575+0.j]),\n", + " SparsePauliOp(['IIZZ', 'IZZI', 'ZZII', 'ZIIZ'],\n", + " coeffs=[1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])]" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## TF Ising with disorder field\n", + "n = 4\n", + "disorder = np.random.uniform(-0.2, 0.2, n)\n", + "tfi = Nearest_Neighbour_1d(4, Jx=0, Jy=0, Jz=1, hx=0.2, hy=0, hz=0, pbc=True, rand_field=disorder)\n", + "tfi.ham\n", + "tfi.ham_xyz" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "697472fc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[SparsePauliOp(['IXX', 'XIX', 'XXI'],\n", + " coeffs=[1. +0.j, 0.0625+0.j, 1. +0.j]),\n", + " SparsePauliOp(['IZZ', 'ZIZ', 'ZZI', 'IIZ', 'IZI', 'ZII'],\n", + " coeffs=[1. +0.j, 0.0625+0.j, 1. +0.j, 0.2 +0.j, 0.2 +0.j, 0.2 +0.j])]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## Test 1D Power-law decaying Hamiltonian\n", + "plh = Power_Law(3, alpha=4, Jx=1, Jy=0, Jz=1, hx=0, hy=0, hz=0.2)\n", + "plh.ham_xyz" + ] + }, + { + "cell_type": "markdown", + "id": "d7fe9c22", + "metadata": {}, + "source": [ + "### Molecules" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "5534a0bd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "# pstr: 15, ['IIII', 'ZIII', 'IZII', 'IIZI', 'IIIZ', 'ZZII', 'YXXY', 'YYXX', 'XXYY', 'XYYX', 'ZIZI', 'ZIIZ', 'IZZI', 'IZIZ', 'IIZZ']\n", + "# groups: 2\n", + "[[{'IIII': (-0.3276081896748102+0j)}, {'ZIII': (0.13716572937099497+0j)}, {'IZII': (0.13716572937099497+0j)}, {'IIZI': (-0.13036292057109025+0j)}, {'IIIZ': (-0.13036292057109025+0j)}, {'ZZII': (0.15660062488237947+0j)}], [{'YXXY': (0.049197645871367546+0j)}, {'YYXX': (-0.049197645871367546+0j)}, {'XXYY': (-0.049197645871367546+0j)}, {'XYYX': (0.049197645871367546+0j)}, {'ZIZI': (0.10622904490856078+0j)}, {'ZIIZ': (0.15542669077992832+0j)}, {'IZZI': (0.15542669077992832+0j)}, {'IZIZ': (0.10622904490856078+0j)}, {'IIZZ': (0.16326768673564335+0j)}]]\n" + ] + } + ], + "source": [ + "h2 = Hydrogen_Chain(2, 1.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "011d3ad9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.52917721092 [] +\n", + "-1.110844179883727 [0^ 0] +\n", + "0.31320124976475894 [0^ 0^ 0 0] +\n", + "0.09839529174273509 [0^ 0^ 2 2] +\n", + "0.31320124976475894 [0^ 1^ 1 0] +\n", + "0.09839529174273509 [0^ 1^ 3 2] +\n", + "0.09839529174273509 [0^ 2^ 0 2] +\n", + "0.31085338155985653 [0^ 2^ 2 0] +\n", + "0.09839529174273509 [0^ 3^ 1 2] +\n", + "0.31085338155985653 [0^ 3^ 3 0] +\n", + "0.31320124976475894 [1^ 0^ 0 1] +\n", + "0.09839529174273509 [1^ 0^ 2 3] +\n", + "-1.110844179883727 [1^ 1] +\n", + "0.31320124976475894 [1^ 1^ 1 1] +\n", + "0.09839529174273509 [1^ 1^ 3 3] +\n", + "0.09839529174273509 [1^ 2^ 0 3] +\n", + "0.31085338155985653 [1^ 2^ 2 1] +\n", + "0.09839529174273509 [1^ 3^ 1 3] +\n", + "0.31085338155985653 [1^ 3^ 3 1] +\n", + "0.3108533815598567 [2^ 0^ 0 2] +\n", + "0.09839529174273509 [2^ 0^ 2 0] +\n", + "0.3108533815598567 [2^ 1^ 1 2] +\n", + "0.09839529174273509 [2^ 1^ 3 0] +\n", + "-0.5891210037060843 [2^ 2] +\n", + "0.09839529174273509 [2^ 2^ 0 0] +\n", + "0.3265353734712867 [2^ 2^ 2 2] +\n", + "0.09839529174273509 [2^ 3^ 1 0] +\n", + "0.3265353734712867 [2^ 3^ 3 2] +\n", + "0.3108533815598567 [3^ 0^ 0 3] +\n", + "0.09839529174273509 [3^ 0^ 2 1] +\n", + "0.3108533815598567 [3^ 1^ 1 3] +\n", + "0.09839529174273509 [3^ 1^ 3 1] +\n", + "0.09839529174273509 [3^ 2^ 0 1] +\n", + "0.3265353734712867 [3^ 2^ 2 3] +\n", + "-0.5891210037060843 [3^ 3] +\n", + "0.09839529174273509 [3^ 3^ 1 1] +\n", + "0.3265353734712867 [3^ 3^ 3 3]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "h2.fermion_hamiltonian" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "90678d99", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "() 0.52917721092\n", + "((0, 1), (0, 0)) -1.110844179883727\n", + "((1, 1), (1, 0)) -1.110844179883727\n", + "((2, 1), (2, 0)) -0.5891210037060843\n", + "((3, 1), (3, 0)) -0.5891210037060843\n", + "((0, 1), (0, 1), (0, 0), (0, 0)) 0.31320124976475894\n", + "((0, 1), (0, 1), (2, 0), (2, 0)) 0.09839529174273509\n", + "((0, 1), (1, 1), (1, 0), (0, 0)) 0.31320124976475894\n", + "((0, 1), (1, 1), (3, 0), (2, 0)) 0.09839529174273509\n", + "((0, 1), (2, 1), (0, 0), (2, 0)) 0.09839529174273509\n", + "((0, 1), (2, 1), (2, 0), (0, 0)) 0.31085338155985653\n", + "((0, 1), (3, 1), (1, 0), (2, 0)) 0.09839529174273509\n", + "((0, 1), (3, 1), (3, 0), (0, 0)) 0.31085338155985653\n", + "((1, 1), (0, 1), (0, 0), (1, 0)) 0.31320124976475894\n", + "((1, 1), (0, 1), (2, 0), (3, 0)) 0.09839529174273509\n", + "((1, 1), (1, 1), (1, 0), (1, 0)) 0.31320124976475894\n", + "((1, 1), (1, 1), (3, 0), (3, 0)) 0.09839529174273509\n", + "((1, 1), (2, 1), (0, 0), (3, 0)) 0.09839529174273509\n", + "((1, 1), (2, 1), (2, 0), (1, 0)) 0.31085338155985653\n", + "((1, 1), (3, 1), (1, 0), (3, 0)) 0.09839529174273509\n", + "((1, 1), (3, 1), (3, 0), (1, 0)) 0.31085338155985653\n", + "((2, 1), (0, 1), (0, 0), (2, 0)) 0.3108533815598567\n", + "((2, 1), (0, 1), (2, 0), (0, 0)) 0.09839529174273509\n", + "((2, 1), (1, 1), (1, 0), (2, 0)) 0.3108533815598567\n", + "((2, 1), (1, 1), (3, 0), (0, 0)) 0.09839529174273509\n", + "((2, 1), (2, 1), (0, 0), (0, 0)) 0.09839529174273509\n", + "((2, 1), (2, 1), (2, 0), (2, 0)) 0.3265353734712867\n", + "((2, 1), (3, 1), (1, 0), (0, 0)) 0.09839529174273509\n", + "((2, 1), (3, 1), (3, 0), (2, 0)) 0.3265353734712867\n", + "((3, 1), (0, 1), (0, 0), (3, 0)) 0.3108533815598567\n", + "((3, 1), (0, 1), (2, 0), (1, 0)) 0.09839529174273509\n", + "((3, 1), (1, 1), (1, 0), (3, 0)) 0.3108533815598567\n", + "((3, 1), (1, 1), (3, 0), (1, 0)) 0.09839529174273509\n", + "((3, 1), (2, 1), (0, 0), (1, 0)) 0.09839529174273509\n", + "((3, 1), (2, 1), (2, 0), (3, 0)) 0.3265353734712867\n", + "((3, 1), (3, 1), (1, 0), (1, 0)) 0.09839529174273509\n", + "((3, 1), (3, 1), (3, 0), (3, 0)) 0.3265353734712867" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "h2.molecular_hamiltonian" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "87d9256d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(-0.3276081896748102+0j) [] +\n", + "(-0.049197645871367546+0j) [X0 X1 Y2 Y3] +\n", + "(0.049197645871367546+0j) [X0 Y1 Y2 X3] +\n", + "(0.049197645871367546+0j) [Y0 X1 X2 Y3] +\n", + "(-0.049197645871367546+0j) [Y0 Y1 X2 X3] +\n", + "(0.13716572937099497+0j) [Z0] +\n", + "(0.15660062488237947+0j) [Z0 Z1] +\n", + "(0.10622904490856078+0j) [Z0 Z2] +\n", + "(0.15542669077992832+0j) [Z0 Z3] +\n", + "(0.13716572937099497+0j) [Z1] +\n", + "(0.15542669077992832+0j) [Z1 Z2] +\n", + "(0.10622904490856078+0j) [Z1 Z3] +\n", + "(-0.13036292057109025+0j) [Z2] +\n", + "(0.16326768673564335+0j) [Z2 Z3] +\n", + "(-0.13036292057109025+0j) [Z3]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "h2.jw" + ] + }, + { + "cell_type": "markdown", + "id": "f981124d", + "metadata": {}, + "source": [ + "## Misc" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ceb9923", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.8.8 ('base')", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + }, + "vscode": { + "interpreter": { + "hash": "4e8ef2f9fcac0817bca9a7ca376f64f20b4df5ea3bf7af756a50bda7d3557ea6" + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/setup.py b/setup.py index 23f99b7..41fd1bc 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ setuptools.setup( name="quantum-simulation-recipe", - version='0.1.1', + version='0.1.2', # version=package_version, # author="Jue XU", author_email="xujue@connect.hku.hk",