Message Boards Message Boards

TBpack: tight-binding calculations package

enter image description here

TBpack is a package for tight-binding calculations in Wolfram Language.

Hands-on Trial

Try our Cloud based demo -- TBpackDemo. TBpackDemo contains all fully functional core functions, excluding visualization and data currating functions.

Get TBpackDemo immediately in your notebook from Wolfram Cloud by evaluating in Mathematica 10.0+:

CloudGet["https://www.wolframcloud.com/obj/vasil.saroka/TBpack/Demo/TBpackDemo.wl"]

TBpackDemo does not have documentation built-in into Wolfram Documentation Center, only user information messages can be invoked for the core functions. The available functions are Hamiltonian, ElectronicStructure, ElectronicBands1D. To get informaiton on the usage of Hamiltonian core function, try

   ?Hamiltonian

For a flawless start, you can use our Cloud based demo examples shown at the last part of this post.

Installation guide

  • The recommended option for TBpack paclet management in Mathematica 11.3+ is to use the resource function:

To install the latest version of the TBpack from this GitHub repo, evaluate

    ResourceFunction["InstallTBpack"][]

To find all installed versions on your PC and to uninstall chosen (all) version (s), evaluate

    ResourceFunction["InstallTBpack"][Method->"Uninstall"]
  • The automated management of TBpack paclet in Mathematica 10.0+:

To install the latest version of the TBpack from this GitHub repo, evaluate

    CloudGet["https://www.wolframcloud.com/obj/vasil.saroka/TBpack/Services/InstallTBpack"];
    InstallTBpack[]

To find all installed versions on your PC and to uninstall chosen (all) version (s), evaluate

    CloudGet["https://www.wolframcloud.com/obj/vasil.saroka/TBpack/Services/InstallTBpack"];
    InstallTBpack[Method->"Uninstall"]
  • The automated installation option for Mathematica 10.0+:

Copy-paste the below function into a Mathematica notebook cell. Evaluate the cell to make the definition of this function known to Mathematica. In the next cell type and evaluate InstallTBpack[].

    InstallTBpack[] := Block[{jsonreleases, info, url, message,tempfile,fpath},
    jsonreleases = Import["https://api.github.com/repos/vasilsaroka/TBpack/releases","JSON"];
    If[jsonreleases === $Failed, Return[$Failed]];
    info = "Downloading TBpack " <> First@Lookup[jsonreleases, "tag_name"];
    If[
       $Notebooks,
       PrintTemporary@Row[{info,ProgressIndicator[Appearance -> "Percolate"]},Frame -> True,RoundingRadius -> 9], 
       Print[info <> "..."]
    ];
    url = First@Lookup[First[Lookup[jsonreleases, "assets"]],"browser_download_url"];
    message = "TBpack is succefully installed.";
    If[
             $VersionNumber >= 12.1,
             Check[PacletInstall[url, ForceVersionInstall -> True],Return[$Failed]];
             Print[message],
             If[
          $VersionNumber >= 11.0,
tempfile = FileNameJoin[{$TemporaryDirectory,FileNameTake[url]}];
Check[fpath = URLDownload[url, tempfile],Return[$Failed]];
If[
FileExistsQ[fpath],
Check[PacletManager\`PacletInstall[fpath,"IgnoreVersion" -> True],Return[$Failed]];
DeleteFile[fpath];
Print[message],
$Failed
          ],
          If[
$VersionNumber >= 10.0,
tempfile = FileNameJoin[{$TemporaryDirectory,FileNameTake[url]}];
Check[fpath = URLSave[url,tempfile],Return[$Failed]];
If[
FileExistsQ[fpath],
Check[PacletManager\`PacletInstall[fpath,"IgnoreVersion" -> True],Return[$Failed]];
DeleteFile[fpath];
Print[message],
$Failed
],
$Failed
](* end If *)
](* end If *)
](* end If  *)
](* end Block *) 
  • An alternative manual installation option for Mathematica 10.0+ is the following. Download the latest release, distributed as a .paclet file, and install it using the PacletInstall function in Mathematica:

    Needs["PacletManager`"]
    PacletInstall["path2paclet"]
    

Insert path2paclet via Mathematica's Insert ? File Path... menu command.

  • In Mathematica 12.1+ PacletInstall["url"] can be used for the installation straight away:

    PacletInstall["https://github.com/vasilsaroka/TBpack/releases/download/v<version>/TBpack-<version>.paclet"]  
    

where <version> stands for any existing version of the application. For example,

    PacletInstall["https://github.com/vasilsaroka/TBpack/releases/download/v0.2.0/TBpack-0.2.0.paclet"]

Demo

  • Evaluate <<TBpack` to load the application into the Mathematica session.
  • Test TBpack using AtomicStructure[Nanotube[10, 10]].
  • Test MaTeX using MaTeX["x^2"].
  • Test CustomTicks using

    Plot[Sin[x], {x, 0, 3}, Ticks -> {LinTicks[-1, 3, 1, 5], LinTicks[0, 1, 1, 5]}]
    
  • Test MaTeX and CustomTicks altogether using

    Plot[Sin[x], {x, -1, 3}, 
        Axes -> {MaTeX["x"],MaTeX["\sin(x)"]},
        AxesStyle -> BlackFrame, 
        Ticks -> {
         LinTicks[-1, 3, 1, 5, MinorTickLength -> 0.015, MajorTickLength -> 0.025], 
         LinTicks[-1, 1, 1, 5, MinorTickLength -> 0.015, MajorTickLength -> 0.025]
          }
        ]

Packages MaTeX by Szabolcs Horvát and CustomTicks by Mark A. Caprio are integral parts of TBpack.

  • Open the documentation center and search for "Hamiltonian" to get started.

Note: Compilation to C code is used in TBpack to speed up optical absorption spectra calculations. See how to make Mathematica working with C compiler on Windows. If compiler is not available Mathematica will run uncompiled function.

Supporting the project

We believe everyone deserves access to knowledge that is grounded in science and integrity. That is why we keep our code open for all users, regardless of where they live or what they can afford to pay. This means more people can be better educated and inspired to make an impact on the global wellbeing. We have no shareholders or billionaire owner, meaning only your donations power our work and ensure it can remain open for all. Every contribution, however big or small, makes a real difference for TBpack future. If you find it useful, consider supporting the project.

POSTED BY: Vasil Saroka
3 Replies

Hi Jay,

Thanks a lot for reporting this bug. The link should be "paclet:TBpack/tutorial/ConfiguringMaTeX", it will be fixed in the next release. For now you can access configuring tutorial by searching it in documentation center as "ConfigureingMaTeX": enter image description here then enter image description here and finally enter image description here

In general, the error was caused by fact that MaTeX was not able to automatically locate gostscript. It is either not installed or installed in a non-standard folder so you need to provide a path to the gostscript program in that folder manually. Make sure also that you have gostscript version 9.15 or higher. It can be downloaded and installed from https://ghostscript.com/

Thanks again for this report.

Best wishes, Vasil

POSTED BY: Vasil Saroka

Hi Vasil,

Neat package. Thank you for sharing it. I get following message when Needs["TBpack`"] runs the first time and when MaTeX[] is used.

The path to Ghostscript is not configured.
Please configure Ghostscript using ConfigureMaTeX["Ghostscript" -> "path to gs executable\[Ellipsis]"]
Click here for documentation on configuring MaTeX.

When I click the link, I get a beep and the message

"paclet:MaTeX/tutorial/ConfiguringMaTeX" could not be found.

How do I configure Ghostscript?

POSTED BY: Jay Morreale

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial columns Staff Picks http://wolfr.am/StaffPicks and Publication Materials https://wolfr.am/PubMat and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract