diff --git a/docs/tutorials/index.rst b/docs/tutorials/index.rst index 7f10fddea3..c33da84c58 100644 --- a/docs/tutorials/index.rst +++ b/docs/tutorials/index.rst @@ -7,7 +7,7 @@ sisl is shipped with these tutorials which introduce the basics. All examples are assumed to have this in the header:: import numpy as np - from sisl import * + import sisl as si to enable `numpy`_ and sisl. diff --git a/docs/tutorials/tutorial_es_1.ipynb b/docs/tutorials/tutorial_es_1.ipynb index 54531eca3a..0d9706a046 100644 --- a/docs/tutorials/tutorial_es_1.ipynb +++ b/docs/tutorials/tutorial_es_1.ipynb @@ -7,7 +7,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "from sisl import *\n", + "import sisl as si\n", "from sisl.viz import merge_plots\n", "from sisl.viz.processors.math import normalize\n", "import matplotlib.pyplot as plt\n", @@ -35,7 +35,7 @@ "metadata": {}, "outputs": [], "source": [ - "graphene = geom.graphene().tile(6, 0).tile(6, 1)" + "graphene = si.geom.graphene().tile(6, 0).tile(6, 1)" ] }, { @@ -44,7 +44,7 @@ "source": [ "This does *a lot* of things behind the scenes:\n", "\n", - "1. `geom.graphene`:\n", + "1. `si.geom.graphene`:\n", " - create atomic coordinates of pristine graphene with a default bond-length of $1.42\\,\\mathrm{Å}$.\n", " - create pristine graphene unit cell, by default this will create a supercell\n", " with a size `3x3`, i.e. a nearest neighbour unit-cell.\n", @@ -156,7 +156,7 @@ "metadata": {}, "outputs": [], "source": [ - "H = Hamiltonian(system)\n", + "H = si.Hamiltonian(system)\n", "print(H)" ] }, @@ -291,7 +291,7 @@ "metadata": {}, "outputs": [], "source": [ - "band = BandStructure(\n", + "band = si.BandStructure(\n", " H,\n", " [[0, 0, 0], [0, 0.5, 0], [1 / 3, 2 / 3, 0], [0, 0, 0]],\n", " 400,\n", @@ -349,7 +349,7 @@ "metadata": {}, "outputs": [], "source": [ - "bz = MonkhorstPack(H, [35, 35, 1])\n", + "bz = si.MonkhorstPack(H, [35, 35, 1])\n", "bz_average = (\n", " bz.apply.average\n", "); # specify the Brillouin zone to perform an average of subsequent method calls" @@ -416,7 +416,7 @@ "print(\"Normalization: {}\".format(f.sum() * (r[1] - r[0])))\n", "plt.plot(r, f)\n", "plt.ylim([0, None])\n", - "orb = SphericalOrbital(1, (r, f));" + "orb = si.SphericalOrbital(1, (r, f));" ] }, { @@ -460,7 +460,7 @@ "metadata": {}, "outputs": [], "source": [ - "C = Atom(6, orb)\n", + "C = si.Atom(6, orb)\n", "print(system.atoms)\n", "system.atoms.replace(system.atoms[0], C)\n", "print(system.atoms)" @@ -482,7 +482,7 @@ "outputs": [], "source": [ "es = H.eigenstate(dtype=np.float64).sub([len(H) // 2 + 1])\n", - "grid = Grid(0.075, lattice=H.lattice)\n", + "grid = si.Grid(0.075, lattice=H.lattice)\n", "es.wavefunction(grid)" ] }, @@ -540,7 +540,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.15" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/docs/tutorials/tutorial_es_2.ipynb b/docs/tutorials/tutorial_es_2.ipynb index d31188a6fa..3551df7115 100644 --- a/docs/tutorials/tutorial_es_2.ipynb +++ b/docs/tutorials/tutorial_es_2.ipynb @@ -7,7 +7,8 @@ "outputs": [], "source": [ "import numpy as np\n", - "from sisl import *\n", + "import sisl as si\n", + "from sisl.physics.electron import berry_phase\n", "import matplotlib.pyplot as plt\n", "\n", "%matplotlib inline" @@ -32,8 +33,8 @@ "metadata": {}, "outputs": [], "source": [ - "graphene = geom.graphene()\n", - "H = Hamiltonian(graphene)\n", + "graphene = si.geom.graphene()\n", + "H = si.Hamiltonian(graphene)\n", "H.construct([(0.1, 1.44), (0, -2.7)])" ] }, @@ -70,7 +71,7 @@ "metadata": {}, "outputs": [], "source": [ - "band = BandStructure(\n", + "band = si.BandStructure(\n", " H, [[0, 0.5, 0], [1 / 3, 2 / 3, 0], [0.5, 0.5, 0]], 400, [r\"$M$\", r\"$K$\", r\"$M'$\"]\n", ")" ] @@ -100,7 +101,7 @@ "metadata": {}, "outputs": [], "source": [ - "bz = MonkhorstPack(\n", + "bz = si.MonkhorstPack(\n", " H, [41, 41, 1], displacement=[1 / 3, 2 / 3, 0], size=[0.125, 0.125, 1]\n", ")\n", "bz_average = bz.apply.average # specify the Brillouin zone to perform an average" @@ -139,7 +140,7 @@ "outputs": [], "source": [ "E = np.linspace(-0.5, 0.5, 1000)\n", - "dist = get_distribution(\"gaussian\", 0.03)\n", + "dist = si.get_distribution(\"gaussian\", 0.03)\n", "bz.set_parent(H)\n", "plt.plot(\n", " E,\n", @@ -181,7 +182,7 @@ "normal = [0, 0, 1]\n", "# Origo (in units of reciprocal lattice vectors)\n", "origin = [1 / 3, 2 / 3, 0]\n", - "circle = BrillouinZone.param_circle(H, N, kR, normal, origin)\n", + "circle = si.BrillouinZone.param_circle(H, N, kR, normal, origin)\n", "plt.plot(circle.k[:, 0], circle.k[:, 1])\n", "plt.xlabel(r\"$k_x$ [$b_x$]\")\n", "plt.ylabel(r\"$k_y$ [$b_y$]\")\n", @@ -224,21 +225,13 @@ "outputs": [], "source": [ "circle.set_parent(H)\n", - "print(\"Pristine graphene (0): {:.5f} rad\".format(electron.berry_phase(circle, sub=0)))\n", - "print(\"Pristine graphene (1): {:.5f} rad\".format(electron.berry_phase(circle, sub=1)))\n", - "print(\"Pristine graphene (:): {:.5f} rad\".format(electron.berry_phase(circle)))\n", + "print(\"Pristine graphene (0): {:.5f} rad\".format(berry_phase(circle, sub=0)))\n", + "print(\"Pristine graphene (1): {:.5f} rad\".format(berry_phase(circle, sub=1)))\n", + "print(\"Pristine graphene (:): {:.5f} rad\".format(berry_phase(circle)))\n", "circle.set_parent(H_bp)\n", - "print(\n", - " \"Anti-symmetric graphene (0): {:.5f} rad\".format(\n", - " electron.berry_phase(circle, sub=0)\n", - " )\n", - ")\n", - "print(\n", - " \"Anti-symmetric graphene (1): {:.5f} rad\".format(\n", - " electron.berry_phase(circle, sub=1)\n", - " )\n", - ")\n", - "print(\"Anti-symmetric graphene (:): {:.5f} rad\".format(electron.berry_phase(circle)))" + "print(\"Anti-symmetric graphene (0): {:.5f} rad\".format(berry_phase(circle, sub=0)))\n", + "print(\"Anti-symmetric graphene (1): {:.5f} rad\".format(berry_phase(circle, sub=1)))\n", + "print(\"Anti-symmetric graphene (:): {:.5f} rad\".format(berry_phase(circle)))" ] }, { @@ -258,13 +251,13 @@ "dk = 0.0001\n", "bp = np.empty([4, len(kRs)])\n", "for i, kR in enumerate(kRs):\n", - " circle = BrillouinZone.param_circle(H_bp, dk, kR, normal, origin)\n", - " bp[0, i] = electron.berry_phase(circle, sub=0)\n", - " circle_other = BrillouinZone.param_circle(\n", - " utils.mathematics.fnorm(H_bp.rcell), dk, kR, normal, origin\n", + " circle = si.BrillouinZone.param_circle(H_bp, dk, kR, normal, origin)\n", + " bp[0, i] = berry_phase(circle, sub=0)\n", + " circle_other = si.BrillouinZone.param_circle(\n", + " si.utils.mathematics.fnorm(H_bp.rcell), dk, kR, normal, origin\n", " )\n", " circle.k[:, :] = circle_other.k[:, :]\n", - " bp[1, i] = electron.berry_phase(circle, sub=0)\n", + " bp[1, i] = berry_phase(circle, sub=0)\n", "plt.plot(kRs, bp[0, :] / np.pi, label=r\"1/Ang\")\n", "plt.plot(kRs, bp[1, :] / np.pi, label=r\"$b_i$\")\n", "plt.legend()\n", @@ -296,9 +289,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.9" + "version": "3.11.7" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/docs/tutorials/tutorial_siesta_1.ipynb b/docs/tutorials/tutorial_siesta_1.ipynb index a6ba207f98..3f111d0b60 100644 --- a/docs/tutorials/tutorial_siesta_1.ipynb +++ b/docs/tutorials/tutorial_siesta_1.ipynb @@ -10,7 +10,7 @@ "\n", "os.chdir(\"siesta_1\")\n", "import numpy as np\n", - "from sisl import *\n", + "import sisl as si\n", "from sisl.viz import merge_plots\n", "from sisl.viz.processors.math import normalize\n", "from functools import partial\n", @@ -39,10 +39,10 @@ "metadata": {}, "outputs": [], "source": [ - "h2o = Geometry(\n", + "h2o = si.Geometry(\n", " [[0, 0, 0], [0.8, 0.6, 0], [-0.8, 0.6, 0.0]],\n", - " [Atom(\"O\"), Atom(\"H\"), Atom(\"H\")],\n", - " lattice=Lattice(10, origin=[-5] * 3),\n", + " [si.Atom(\"O\"), si.Atom(\"H\"), si.Atom(\"H\")],\n", + " lattice=si.Lattice(10, origin=[-5] * 3),\n", ")" ] }, @@ -144,7 +144,7 @@ "metadata": {}, "outputs": [], "source": [ - "fdf = get_sile(\"RUN.fdf\")\n", + "fdf = si.get_sile(\"RUN.fdf\")\n", "H = fdf.read_hamiltonian()\n", "# Create a short-hand to handle the geometry\n", "h2o = H.geometry\n", @@ -285,7 +285,7 @@ " )\n", "\n", "\n", - "g = Grid(0.2, lattice=h2o.lattice)\n", + "g = si.Grid(0.2, lattice=h2o.lattice)\n", "es.sub(0).wavefunction(g)\n", "integrate(g)\n", "# g.write('HOMO.cube')\n", @@ -314,7 +314,7 @@ "outputs": [], "source": [ "DM = fdf.read_density_matrix()\n", - "rho = get_sile(\"siesta_1.nc\").read_grid(\"Rho\")" + "rho = si.get_sile(\"siesta_1.nc\").read_grid(\"Rho\")" ] }, { @@ -363,7 +363,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.15" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/docs/tutorials/tutorial_siesta_2.ipynb b/docs/tutorials/tutorial_siesta_2.ipynb index b26b5cea0c..cd0d6a0978 100644 --- a/docs/tutorials/tutorial_siesta_2.ipynb +++ b/docs/tutorials/tutorial_siesta_2.ipynb @@ -10,7 +10,7 @@ "\n", "os.chdir(\"siesta_2\")\n", "import numpy as np\n", - "from sisl import *\n", + "import sisl as si\n", "import matplotlib.pyplot as plt\n", "\n", "%matplotlib inline" @@ -37,7 +37,7 @@ "metadata": {}, "outputs": [], "source": [ - "graphene = geom.graphene(1.44)" + "graphene = si.geom.graphene(1.44)" ] }, { @@ -106,7 +106,7 @@ "metadata": {}, "outputs": [], "source": [ - "fdf = get_sile(\"RUN.fdf\")\n", + "fdf = si.get_sile(\"RUN.fdf\")\n", "H = fdf.read_hamiltonian()\n", "print(H)" ] @@ -128,7 +128,7 @@ "source": [ "E = np.linspace(-6, 4, 500)\n", "for nk in [21, 41, 61, 81]:\n", - " bz = MonkhorstPack(H, [nk, nk, 1])\n", + " bz = si.MonkhorstPack(H, [nk, nk, 1])\n", " plt.plot(\n", " E,\n", " bz.apply.average.eigenvalue(wrap=lambda ev: ev.DOS(E)),\n", @@ -189,7 +189,7 @@ "outputs": [], "source": [ "# Define the band-structure\n", - "bz = BandStructure(\n", + "bz = si.BandStructure(\n", " H,\n", " [[0] * 3, [2.0 / 3, 1.0 / 3, 0], [0.5, 0.5, 0], [1] * 3],\n", " 400,\n", @@ -239,7 +239,7 @@ "es = es.sub(idx_valence)\n", "\n", "# Generate a grid encompassing a 2x2 graphene unit-cell\n", - "g = Grid(0.2, lattice=H.geometry.lattice.tile(2, 0).tile(2, 1))\n", + "g = si.Grid(0.2, lattice=H.geometry.lattice.tile(2, 0).tile(2, 1))\n", "# Calculate the real-space wavefunctions\n", "es.wavefunction(g)\n", "\n", @@ -275,7 +275,7 @@ "es = H.eigenstate([1.0 / 2, 0, 0])\n", "idx_valence = (es.eig > 0).nonzero()[0][0] - 1\n", "es = es.sub(idx_valence)\n", - "g = Grid(0.2, dtype=np.complex128, lattice=H.geometry.lattice.tile(4, 0).tile(4, 1))\n", + "g = si.Grid(0.2, dtype=np.complex128, lattice=H.geometry.lattice.tile(4, 0).tile(4, 1))\n", "es.wavefunction(g)\n", "x, y = np.mgrid[: g.shape[0], : g.shape[1]]\n", "x, y = x * g.dcell[0, 0] + y * g.dcell[1, 0], x * g.dcell[0, 1] + y * g.dcell[1, 1]\n", @@ -312,7 +312,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.15" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/docs/tutorials/tutorial_siesta_2_ahc.ipynb b/docs/tutorials/tutorial_siesta_2_ahc.ipynb index 62b2ed01bc..525ea63bfe 100644 --- a/docs/tutorials/tutorial_siesta_2_ahc.ipynb +++ b/docs/tutorials/tutorial_siesta_2_ahc.ipynb @@ -7,7 +7,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "from sisl import *\n", + "import sisl as si\n", "import matplotlib.pyplot as plt\n", "\n", "%matplotlib inline" @@ -32,7 +32,7 @@ "metadata": {}, "outputs": [], "source": [ - "H = get_sile(\"siesta_2/RUN.fdf\").read_hamiltonian()" + "H = si.get_sile(\"siesta_2/RUN.fdf\").read_hamiltonian()" ] }, {