Skip to content

Commit

Permalink
finish qn tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
liwt31 committed Jul 26, 2024
1 parent 49a95b7 commit b80d923
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ please refer to the :doc:`applications`.
.. toctree::
tutorials/define_model.ipynb
tutorials/mps_mpo.ipynb
tutorials/compress_mps.ipynb
tutorials/quantum_number.ipynb
tutorials/compress_mps.ipynb
tutorials/ttn_basic.ipynb

..
Expand Down
2 changes: 1 addition & 1 deletion doc/source/tutorials/define_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"- The DOF at wich the operation is operated on, such as \"spin 0\", \"exiton 1\". In mathematical expression this is usually the subscript for an operator, i.e., $\\hat X_0$ or $\\hat a^\\dagger_1$\n",
"- The factor or coefficient for the operator.\n",
"\n",
"There is an additional useful attributes that is sometimes quite useful: the quantum number.\n",
"There is an additional useful attributes that is sometimes quite useful: the quantum number. The idea of quantum number will be described in detail in another tutorial.\n",
"\n",
"`Op` are constructed from the above 4 attributes. The first 2 are necessary and the last 2 are optional."
]
Expand Down
127 changes: 116 additions & 11 deletions doc/source/tutorials/quantum_number.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"id": "38d22aea-d558-4050-ba09-5ee910022a6e",
"metadata": {},
"outputs": [],
Expand All @@ -84,7 +84,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"id": "4069da65-755f-4fce-8a83-48a498dfabda",
"metadata": {},
"outputs": [],
Expand All @@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"id": "9d3b7ff7-ac29-4a33-8ed8-98dca88d1c37",
"metadata": {},
"outputs": [],
Expand All @@ -114,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"id": "e9358f1f-f98e-4581-b6e0-54308966f74f",
"metadata": {},
"outputs": [],
Expand All @@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"id": "f86cea1c-916f-47c0-bced-a8dc7c2f7055",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -309,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 16,
"id": "eb7f7ba4-5228-41bc-bf6d-ee41211e5f81",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -419,14 +419,119 @@
"id": "2dd4d74c-386a-4244-8422-5d022842d07f",
"metadata": {},
"source": [
"## Advanced usage (To be updated)\n",
"## Notes\n",
"\n",
"- Setting quantum number is not necessary. When quantum number is not conserved or in other cases when quantum number is not desired, we can skip this by set all to 0.\n",
"Setting quantum number is not necessary. When quantum number is not conserved or for some reason quantum number conservation is not desired, set all quantum numbers to 0.\n",
"\n",
"- If quantum numbers are set incorrectly.\n",
"\n",
"- U(1) quantum number and more than one quantum number"
"Renormalizer supports the conservation of multiple quantum numbers. For example, in *ab initio* electronic structure calculations, both the number of alpha spin electrons and the number of beta spin electrons are conserved.\n",
"In such cases, quantum numbers should be set to a numpy array of integers."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "9d3c8a36-25e8-46e6-91cd-4d520238f0df",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "9f5fa2cf-e6e5-430a-9dc2-176237d82e5a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Op('a^\\\\dagger', ['up'], 1.0, [[1, 0]])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# spin up creation operator\n",
"Op(r\"a^\\dagger\", \"up\", qn=np.array([1, 0]))"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "9166c78b-15d3-4c64-a42d-5a3c37ecc4aa",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Op('a', ['up'], 1.0, [[-1, 0]])"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# spin up annihilation operator\n",
"Op(r\"a\", \"up\", qn=np.array([-1, 0]))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "f789d3b7-46e2-4a23-b9a0-e72ed323c0e3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Op('a^\\\\dagger', ['down'], 1.0, [[0, 1]])"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# spin down creation operator\n",
"Op(r\"a^\\dagger\", \"down\", qn=np.array([0, 1]))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "4f023161-daa1-42f2-84ba-4d4528dd4461",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Op('a^\\\\dagger', ['down'], 1.0, [[0, -1]])"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# spin down annihilation operator\n",
"Op(r\"a^\\dagger\", \"down\", qn=np.array([0, -1]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78557796-060c-42ce-94ab-6981c862c870",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit b80d923

Please sign in to comment.