diff --git a/quantum_simulation_recipe/plot_config.py b/quantum_simulation_recipe/plot_config.py index eaef9f5..c535011 100644 --- a/quantum_simulation_recipe/plot_config.py +++ b/quantum_simulation_recipe/plot_config.py @@ -39,8 +39,8 @@ def set_fontsize(small=SMALL_SIZE, medium=MEDIUM_SIZE, large=LARGE_SIZE, linewid mpl.rcParams['xtick.major.width'] = linewidth mpl.rcParams['ytick.major.width'] = linewidth mpl.rcParams['ytick.minor.width'] = linewidth - mpl.rcParams['lines.linewidth'] = linewidth - mpl.rcParams['lines.markeredgewidth'] = linewidth + mpl.rcParams['lines.linewidth'] = linewidth+0.5 + mpl.rcParams['lines.markeredgewidth'] = linewidth+0.5 set_fontsize() diff --git a/quantum_simulation_recipe/spin.py b/quantum_simulation_recipe/spin.py index 5469902..122b839 100644 --- a/quantum_simulation_recipe/spin.py +++ b/quantum_simulation_recipe/spin.py @@ -6,6 +6,30 @@ from qiskit.quantum_info import SparsePauliOp import random +class IQP: + def __init__(self, n: int, theta=0, verbose=False): + self.n = n + if theta == 0: + self.pstr = [(''.join(random.choices(['I','Z'], k=n)), 2*np.pi*random.random()) for _ in range(1*n)] + else: + self.pstr = [(''.join(random.choices(['I','Z'], k=n)), theta) for _ in range(1*n)] + + if verbose: print('pstr: ', self.pstr) + self.ham = SparsePauliOp.from_list(self.pstr) + # return SparsePauliOp.from_list(pstr) + + # if H_type == 0: + # J = 2 + # ising_str = 'ZZ' + 'I' * (n-2) + # uni_ising = [(ising_str[i:]+ising_str[:i], J) for i in range(n)] + # del uni_ising[1] + # print(uni_ising) + # H = SparsePauliOp.from_list(uni_ising) + # else: + # # H = get_hamiltonian(L=n, J=1.0, h=0.2, g=0.0, verbose=True) + # H = IQP_H(n, theta, verbose=True) + + class Nearest_Neighbour_1d: def __init__(self, n: int, Jx=0, Jy=0, Jz=0, hx=0, hy=0, hz=0, pbc=False, verbose=False, rand_field=[]): self.n = n @@ -88,6 +112,15 @@ def xyz_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 diff --git a/quantum_simulation_recipe/test.ipynb b/quantum_simulation_recipe/test.ipynb index 4abb677..1b35652 100644 --- a/quantum_simulation_recipe/test.ipynb +++ b/quantum_simulation_recipe/test.ipynb @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "id": "8c03d3e4", "metadata": {}, "outputs": [], @@ -36,6 +36,30 @@ "from bounds import norm, tight_bound, commutator" ] }, + { + "cell_type": "code", + "execution_count": 70, + "id": "2cefc7ad", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SparsePauliOp(['ZZIIZZ', 'IIZIIZ', 'ZZZIIZ', 'IIZZIZ', 'IZZIZZ', 'IIZZIZ'],\n", + " coeffs=[5.807428+0.j, 2.03521 +0.j, 1.718245+0.j, 0.451692+0.j, 4.762469+0.j,\n", + " 1.399856+0.j])" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "iqp = IQP(6)\n", + "iqp.ham" + ] + }, { "cell_type": "code", "execution_count": 3,