Skip to content

Instantly share code, notes, and snippets.

@mpmdean
Created April 26, 2025 18:15
Show Gist options
  • Save mpmdean/af214f9c71609b843d62f47c1f669ffa to your computer and use it in GitHub Desktop.
Save mpmdean/af214f9c71609b843d62f47c1f669ffa to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "407c1ff5-f94e-4eb5-872b-d39afb1db221",
"metadata": {},
"outputs": [],
"source": [
"import edrixs"
]
},
{
"cell_type": "markdown",
"id": "103d69e6-4654-40ad-abde-f7e93b6af740",
"metadata": {},
"source": [
"Check docstring of write_fock_dec_by_N"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c6a68335-0c8e-4a92-8052-575fd9c0f9fd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Get decimal digitals to represent Fock states, sort them by\n",
" ascending order and then write them to file.\n",
"\n",
" Parameters\n",
" ----------\n",
" N: int\n",
" Number of orbitals.\n",
" r: int\n",
" Number of occuancy.\n",
" fname: string\n",
" File name.\n",
"\n",
" Returns\n",
" -------\n",
" ndim: int\n",
" The dimension of the Hilbert space\n",
"\n",
" Examples\n",
" --------\n",
" >>> import edrixs\n",
" >>> edrixs.write_fock_dec_by_N(4, 2, 'fock_i.in')\n",
" file fock_i.in looks like\n",
" 15\n",
" 3\n",
" 5\n",
" 6\n",
" 9\n",
" 10\n",
" 12\n",
" 17\n",
" 18\n",
" 20\n",
" 24\n",
" 33\n",
" 34\n",
" 36\n",
" 40\n",
" 48\n",
"\n",
" where, the first line is the total numer of Fock states,\n",
" and the following lines are the Fock states in decimal form.\n",
" \n"
]
}
],
"source": [
"print(edrixs.write_fock_dec_by_N.__doc__)"
]
},
{
"cell_type": "markdown",
"id": "e82b75e6-653b-4763-8ecf-17654d648050",
"metadata": {},
"source": [
"docstring already looks wrong! shouldn't (4, 2) yield 6 entries?"
]
},
{
"cell_type": "markdown",
"id": "b0b55e9b-08e9-474a-8224-63fab3fa7b07",
"metadata": {},
"source": [
"use write_fock_dec_by_N to check argument of (4, 2)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "20b5e1fb-b16a-45b5-93bd-85726e3ca485",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6 entries\n",
"Int: binary\n",
" 3: 0011\n",
" 5: 0101\n",
" 6: 0110\n",
" 9: 1001\n",
" 10: 1010\n",
" 12: 1100\n"
]
}
],
"source": [
"norb = 4\n",
"edrixs.write_fock_dec_by_N(norb, 2, fname='fock_i.in')\n",
"\n",
"with open(\"fock_i.in\") as f:\n",
" lines = f.readlines()\n",
" print(f\"{int(lines[0])} entries\")\n",
" print(f\"Int: binary\")\n",
" for bstring in lines[1:]:\n",
" b = int(bstring)\n",
" print(f\"{b:{3}}: {b:0{norb}b}\")"
]
},
{
"cell_type": "markdown",
"id": "005b98b1-6af6-4f52-a689-dc3e791a3141",
"metadata": {},
"source": [
"This result look right."
]
},
{
"cell_type": "markdown",
"id": "ad1148a5-098f-4893-95f4-1ba6cdfa08a2",
"metadata": {},
"source": [
"The result in the doc string seems to be relevant to (6, 2)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b1f16a9c-0224-442d-8e40-ec1689923672",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"15 entries\n",
"Int: binary\n",
" 3: 0011\n",
" 5: 0101\n",
" 6: 0110\n",
" 9: 1001\n",
" 10: 1010\n",
" 12: 1100\n",
" 17: 10001\n",
" 18: 10010\n",
" 20: 10100\n",
" 24: 11000\n",
" 33: 100001\n",
" 34: 100010\n",
" 36: 100100\n",
" 40: 101000\n",
" 48: 110000\n"
]
}
],
"source": [
"edrixs.write_fock_dec_by_N(6, 2, fname='fock_i.in')\n",
"\n",
"with open(\"fock_i.in\") as f:\n",
" lines = f.readlines()\n",
" print(f\"{int(lines[0])} entries\")\n",
" print(f\"Int: binary\")\n",
" for bstring in lines[1:]:\n",
" b = int(bstring)\n",
" print(f\"{b:{3}}: {b:0{norb}b}\")"
]
},
{
"cell_type": "markdown",
"id": "45a93b7e-d96c-466f-ab72-585c8552337b",
"metadata": {},
"source": [
"More problematically still. What is going on with (5, 3)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b90fb313-a52e-4aa5-993b-4a9ddf80c2d4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4 entries\n",
"Int: binary\n",
" 7: 00111\n",
" 11: 01011\n",
" 13: 01101\n",
" 14: 01110\n"
]
}
],
"source": [
"norb = 5\n",
"edrixs.write_fock_dec_by_N(norb, 3, fname='fock_i.in')\n",
"\n",
"with open(\"fock_i.in\") as f:\n",
" lines = f.readlines()\n",
" print(f\"{int(lines[0])} entries\")\n",
" print(f\"Int: binary\")\n",
" for bstring in lines[1:]:\n",
" b = int(bstring)\n",
" print(f\"{b:{3}}: {b:0{norb}b}\")"
]
},
{
"cell_type": "markdown",
"id": "33e2357b-444f-458c-a1c1-10544cc6cb99",
"metadata": {},
"source": [
"Missing entries starting with 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "906d4ca9-94e5-4050-9f97-e40576419e25",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment