w2tree
w2tree is a library and command-line tool for accessing and processing w2dynamics data from multiple files in a directory tree. This tree is assumed to have the following properties:
- It must contain
n[#.#]/u#.#/beta#.#
somewhere in its path, with#.#
denoting an integer or decimal and things in brackets being optional. The numbers correspond to the value of the total density (n
), the on-site Coulomb interaction (u
) and the inverse temperature (beta
) respectively. - The two lowest-level directories must be
<type>/##
, where<type>
is the type of w2dynamics measurement that was done and##
is a running, 2-digit integer with leading zeros that identifies different runs of the same type.
Example paths:
/first/path/n1.1/u7.5/beta20/dmft/04/
/second/path/n/u8/beta15/mu4/nn/01/
/third/path/n1/u2/beta10/raman/02/
If your directory tree diverges from this layout, some functions might throw errors or give wrong results. Please check out the code documentation for details. It can be found here for the latest release and here for the master branch.
Contents
Prerequisites
Mandatory:
w2file and w2diag are not available via conda or in the Python Package Index. Check their respective README files for how to install them.
Optional for building the documentation:
- Tomli
- Sphinx
- sphinx-click
- sphinx_rtd_theme >= 1.0
- importlib-metadata for Python < 3.8
Installation
The w2tree package is not listed in the Python Package Index but in
the GitLab Package
Registry.
Therefore, you need to use the -i/--index-url
flag when installing it with pip
:
python -m pip install w2tree -i "https://gitlab.tuwien.ac.at/api/v4/projects/1383/packages/pypi/simple"
The index URL is also provided by the badge "PyPI package registry" at the top of the repository's landing page. Just right-click it and then choose "Copy Link" (or whatever the context menu of you favorite browser calls it).
For development, you can install w2tree from sources. After cloning the repository, cd
into the top-level directory and run
python -m pip install -e .
With the -e/--editable
flag you don't need to reinstall the package every time you edit
the Python code – only when changing the project metadata.
Usage
Part of the w2tree package is a command-line tool of the same name. Executing
w2tree --help
prints a short description and the available subcommands. These subcommands can also be
called with the --help
flag to get more information as well as usage examples.
The library part is found in the module w2tree.utility
. It provides helpful functions
related to, e.g., finding directories or data files in the tree. A few examples are listed
below. For more information, please check out the API documentation for the utility
module.
import w2file
import w2tree.utility
directory = "~/simulation_data/hubbard_model/square_lattice/n1.1/u12/beta10"
print(w2tree.utility.is_in_w2tree(directory))
# Prints "True"
print(w2tree.utility.list_latest_data_directories_in_w2tree_if(
lambda x: True, root_directory=directory))
# The best file is the one in the highest numbered subdirectory with the
# latest timestamp
p2_file = w2tree.utility.find_best_w2_file("p2", directory)
raman_file = w2tree.utility.find_related_file(p2_file.path, "raman")
n, mu, U, beta = w2tree.utility.get_dmft_parameters(raman_file)
Unfortunately the utility
module also contains helper functions for the command-line
interface (CLI). This will hopefully be disentangled in a future version.
Building documentation
To build the code documentation you need to clone the repository and install the optional
dependencies mentioned in Prerequisites. You can do that by installing
the package with the docs
extra:
python -m pip install -e .[docs]
Then you just cd
into the docs
directory and execute
make html
The start page of the documentation is docs/build/html/index.html
.
License
This project is licensed under the MIT License.