-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from giovanni-br/PariserParr
Pariser parr
- Loading branch information
Showing
11 changed files
with
725 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# TJUV model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Zero energy: 1.5\n", | ||
"One body integrals in spatial basis: \n", | ||
" [[-0.5 -1. 0. 0. 0. -1. ]\n", | ||
" [-1. -0.5 -1. 0. 0. 0. ]\n", | ||
" [ 0. -1. -0.5 -1. 0. 0. ]\n", | ||
" [ 0. 0. -1. -0.5 -1. 0. ]\n", | ||
" [ 0. 0. 0. -1. -0.5 -1. ]\n", | ||
" [-1. 0. 0. 0. -1. -0.5]]\n", | ||
"Shape of two body integral in spatial basis: (6, 6, 6, 6)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import sys \n", | ||
"sys.path.insert(0, '../')\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"# Now import the modules from the local moha package\n", | ||
"from moha import HamTJUV\n", | ||
"# Example parameters for the TJUV Hamiltonian\n", | ||
"connectivity= np.array([[0, 1, 0, 0, 0, 1],\n", | ||
" [1, 0, 1, 0, 0, 0],\n", | ||
" [0, 1, 0, 1, 0, 0],\n", | ||
" [0, 0, 1, 0, 1, 0],\n", | ||
" [0, 0, 0, 1, 0, 1],\n", | ||
" [1, 0, 0, 0, 1, 0]])\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"alpha = 0.0\n", | ||
"beta = -1.0\n", | ||
"u_onsite = np.array([1, 1, 1, 1, 1, 1])\n", | ||
"gamma = None\n", | ||
"charges = 1\n", | ||
"sym = 8\n", | ||
"J_eq = 1\n", | ||
"J_ax = 1\n", | ||
"\n", | ||
"# Initialize the HamTJUV object\n", | ||
"tjuv_hamiltonian = HamTJUV(connectivity=connectivity,\n", | ||
" alpha=alpha,\n", | ||
" beta=beta,\n", | ||
" u_onsite=u_onsite,\n", | ||
" gamma=gamma,\n", | ||
" charges=charges,\n", | ||
" sym=sym,\n", | ||
" J_eq=J_eq,\n", | ||
" J_ax=J_ax)\n", | ||
"\n", | ||
"# Generate integrals\n", | ||
"e0 = tjuv_hamiltonian.generate_zero_body_integral()\n", | ||
"h1 = tjuv_hamiltonian.generate_one_body_integral(dense=True, basis='spatial basis') \n", | ||
"h2 = tjuv_hamiltonian.generate_two_body_integral(dense=True, basis='spatial basis', sym=8)\n", | ||
"\n", | ||
"print(\"Zero energy: \", e0)\n", | ||
"print(\"One body integrals in spatial basis: \\n\", h1)\n", | ||
"print(\"Shape of two body integral in spatial basis: \", h2.shape)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Numerical energies: [-1. -1. -1. -1.]\n", | ||
"Analytical energies: [-2.0000000e+00 -1.2246468e-16 3.6739404e-16 2.0000000e+00]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"\n", | ||
"def test_tjuv_energy_spectrum():\n", | ||
" # Define parameters for a simple 1D chain\n", | ||
" N = 4\n", | ||
" t = 1.0\n", | ||
" alpha = -t\n", | ||
" beta = 0.0\n", | ||
" u_onsite = np.zeros(N)\n", | ||
" gamma = None\n", | ||
" charges = None\n", | ||
" sym = None\n", | ||
" J_eq = 0.0\n", | ||
" J_ax = 0.0\n", | ||
"\n", | ||
" # Connectivity matrix for a 1D chain with periodic boundary conditions\n", | ||
" connectivity = np.zeros((N, N))\n", | ||
" for i in range(N):\n", | ||
" connectivity[i, (i + 1) % N] = 1\n", | ||
" connectivity[(i + 1) % N, i] = 1\n", | ||
"\n", | ||
" # Initialize the HamTJUV object\n", | ||
" tjuv_hamiltonian = HamTJUV(connectivity=connectivity,\n", | ||
" alpha=alpha,\n", | ||
" beta=beta,\n", | ||
" u_onsite=u_onsite,\n", | ||
" gamma=gamma,\n", | ||
" charges=charges,\n", | ||
" sym=sym,\n", | ||
" J_eq=J_eq,\n", | ||
" J_ax=J_ax)\n", | ||
"\n", | ||
" # Generate the one-body integral (Hamiltonian matrix)\n", | ||
" tjuv_one_body = tjuv_hamiltonian.generate_one_body_integral(basis='spatial basis', dense=True)\n", | ||
"\n", | ||
" # Calculate the eigenvalues (energy spectrum)\n", | ||
" energies, _ = np.linalg.eigh(tjuv_one_body)\n", | ||
"\n", | ||
" # Analytical energy levels for comparison\n", | ||
" k_vals = np.arange(N)\n", | ||
" analytical_energies = -2 * t * np.cos(2 * np.pi * k_vals / N)\n", | ||
"\n", | ||
" # Sort the energies for comparison\n", | ||
" energies_sorted = np.sort(energies)\n", | ||
" analytical_energies_sorted = np.sort(analytical_energies)\n", | ||
"\n", | ||
" # Print the energy spectrum and analytical values\n", | ||
" print(\"Numerical energies:\", energies_sorted)\n", | ||
" print(\"Analytical energies:\", analytical_energies_sorted)\n", | ||
"\n", | ||
"# Outside of the function, call the test function\n", | ||
"test_tjuv_energy_spectrum()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"One body integrals in spin basis: \n", | ||
" [[-0.25 -1. 0. 0. 0. -1. 0. 0. 0. 0. 0. 0. ]\n", | ||
" [-1. -0.25 -1. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]\n", | ||
" [ 0. -1. -0.25 -1. 0. 0. 0. 0. 0. 0. 0. 0. ]\n", | ||
" [ 0. 0. -1. -0.25 -1. 0. 0. 0. 0. 0. 0. 0. ]\n", | ||
" [ 0. 0. 0. -1. -0.25 -1. 0. 0. 0. 0. 0. 0. ]\n", | ||
" [-1. 0. 0. 0. -1. -0.25 0. 0. 0. 0. 0. 0. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. -0.25 -1. 0. 0. 0. -1. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. -1. -0.25 -1. 0. 0. 0. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. 0. -1. -0.25 -1. 0. 0. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. 0. 0. -1. -0.25 -1. 0. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. 0. 0. 0. -1. -0.25 -1. ]\n", | ||
" [ 0. 0. 0. 0. 0. 0. -1. 0. 0. 0. -1. -0.25]]\n", | ||
"Shape of two body integral in spinorbital basis: (12, 12, 12, 12)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"alpha = 0.0\n", | ||
"beta = -1.0\n", | ||
"u_onsite = np.array([1, 1, 1, 1, 1, 1])\n", | ||
"gamma = None\n", | ||
"charges = 1\n", | ||
"sym = 8\n", | ||
"J_eq = 0.5 \n", | ||
"J_ax = 0.5 \n", | ||
"\n", | ||
"# Initialize the HamTJUV object\n", | ||
"tjuv_hamiltonian = HamTJUV(connectivity=connectivity,\n", | ||
" alpha=alpha,\n", | ||
" beta=beta,\n", | ||
" u_onsite=u_onsite,\n", | ||
" gamma=gamma,\n", | ||
" charges=charges,\n", | ||
" sym=sym,\n", | ||
" J_eq=J_eq,\n", | ||
" J_ax=J_ax)\n", | ||
"\n", | ||
"h1_spin = tjuv_hamiltonian.generate_one_body_integral(dense=True, basis='spinorbital basis')\n", | ||
"h2_spin = tjuv_hamiltonian.generate_two_body_integral(dense=True, basis='spinorbital basis', sym=4)\n", | ||
"\n", | ||
"print(\"One body integrals in spin basis: \\n\", h1_spin)\n", | ||
"print(\"Shape of two body integral in spinorbital basis: \", h2_spin.shape)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
r"""Model Hamiltonian module.""" | ||
|
||
|
||
from .hamiltonians import HamPPP, HamHub, HamHuck, \ | ||
HamHeisenberg, HamIsing, HamRG | ||
|
||
from .hamiltonians import ( | ||
HamPPP, | ||
HamHub, | ||
HamHuck, | ||
HamHeisenberg, | ||
HamIsing, | ||
HamRG, | ||
HamTJUV, | ||
) | ||
|
||
__all__ = [ | ||
"HamPPP", | ||
"HamHub", | ||
"HamHuck", | ||
"HamHeisenberg", | ||
"HamIsing", | ||
"HamRG" | ||
"HamRG", | ||
"HamTJUV", | ||
] |
Oops, something went wrong.