Skip to content

Commit

Permalink
use dcorelib.triqs_compat by default when triqs is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Sep 13, 2024
1 parent 56ec239 commit e837c5f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 41 deletions.
55 changes: 24 additions & 31 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ Prerequisites

#. Python3

#. `TRIQS 3.x <https://triqs.github.io/triqs/>`_ and `TRIQS/DFTTools 3.x <https://triqs.github.io/dft_tools/>`_.
They must be installed prior to installing all other programs.
The current version of DCore supports TRIQS 3.x.
Please make sure that the triqs and triqs_dft_tools modules are loadable in your Python environment.
You may use `MateriAppsInstaller <https://github.com/wistaria/MateriAppsInstaller>`_, a collection of install scripts, to install prerequisites (TRIQS).

#. You will also need at least one impurity solver.

For example, the following programs are supported:
Expand All @@ -25,28 +19,36 @@ Prerequisites
* :doc:`ALPS/CT-HYB<impuritysolvers/alpscore_cthyb/cthyb>`
* :doc:`ALPS/CT-HYB-SEGMENT<impuritysolvers/alpscore_ctseg/ctseg>`
* :doc:`TRIQS/cthyb<impuritysolvers/triqs_cthyb/cthyb>`
* :doc:`Pomerol solver<impuritysolvers/pomerol/pomerol>`

We recommend to use the Hubbard-I solver for tests because this is fast.
See :doc:`impuritysolvers` for a complete list of supported impurity solvers and their user manuals.

#. [OPTIONAL] `TRIQS 3.x <https://triqs.github.io/triqs/>`_ and `TRIQS/DFTTools 3.x <https://triqs.github.io/dft_tools/>`_.

TRIQS can improve the performance of DCore.
The current version of DCore supports TRIQS 3.x.
Please make sure that the triqs and triqs_dft_tools modules are loadable in your Python environment.
You may use `MateriAppsInstaller <https://github.com/wistaria/MateriAppsInstaller>`_, a collection of install scripts, to install prerequisites (TRIQS).
If you installed TRIQS but want not to use it, please set the environment variable "DCORE_TRIQS_COMPAT" to "1" as follows.

.. code-block:: bash
$ export DCORE_TRIQS_COMPAT=1
Installation
------------------

(NOTE: Using a virtual environment such as `venv <https://docs.python.org/3/library/venv.html>`_ is recommended to avoid conflicts with other Python packages.)

You can install the latest version of DCore using ``pip`` command as follows.

::

$ pip3 install dcore -U
$ pip3 install dcore -U

Here, ``-U`` stands for ''Upgrade''. The installed packages are upgraded to the latest version, if you already have packages installed.
Further, if you do not have root privileges, you need to add ``--user`` option as

::

$ pip3 install dcore -U --user

Then, the packages are installed into .local directory in your home directory. Make sure that **$HOME/.local/bin** is included in PATH environment variable.


Installation (only for developers)
Expand Down Expand Up @@ -81,12 +83,6 @@ You can download the source files in two ways.
$ pip3 install .
If you do not have root privileges, please try

.. code-block:: bash
$ pip3 install . --user
If both of them did not work, you could build a binary package and install it as follows

.. code-block:: bash
Expand All @@ -97,17 +93,6 @@ You can download the source files in two ways.
One can run unit tests using the installed DCore by executing the following commands.

Executables such as dcore_pre may be installed into $HOME/.local/bin/dcore if you install DCore with the "--user" option.
Please add this directory to your PATH environment if needed.

You can build documentations as follows.

.. code-block:: bash
$ pip3 install sphinx wild_sphinx_theme matplotlib
$ python3 -m dcore.option_tables doc/reference
$ sphinx-build -b html doc html
Non-MPI tests can be run as follows.

.. code-block:: bash
Expand All @@ -132,3 +117,11 @@ You can download the source files in two ways.
Note that it is not allowed to run MPI programs interactively on some system.
In this case, please run MPI tests as a parallel job with one process.

You can build documentations as follows.

.. code-block:: bash
$ pip3 install sphinx wild_sphinx_theme matplotlib
$ python3 -m dcore.option_tables doc/reference
$ sphinx-build -b html doc html
37 changes: 27 additions & 10 deletions src/dcore/_dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
import os, sys
import importlib.util

TRIQS_FOUND = True

if int(os.environ.get('DCORE_TRIQS_COMPAT', 1)) == 1:
TRIQS_COMPAT = True
triqs_libs = ['triqs', 'triqs_dft_tools']
for l in triqs_libs:
if not importlib.util.find_spec(l):
TRIQS_FOUND = False

if "DCORE_TRIQS_COMPAT" in os.environ:
dtc = os.environ["DCORE_TRIQS_COMPAT"]
if dtc == "1":
TRIQS_COMPAT = True
else:
TRIQS_COMPAT = False

if TRIQS_FOUND and TRIQS_COMPAT:
print("INFO: TRIQS is found but DCORE_TRIQS_COMPAT is set to 1.")
print(" dcorelib.triqs_compat will be used")

if not TRIQS_FOUND and not TRIQS_COMPAT:
print("ERROR: TRIQS is required (DCORE_TRIQS_COMPAT={}) but TRIQS is not found!".format(dtc))
sys.exit(1)
else:
TRIQS_COMPAT = not TRIQS_FOUND


if TRIQS_COMPAT:
from dcorelib.triqs_compat import *
from dcorelib.triqs_compat import h5
from dcorelib.triqs_compat.gf import *
Expand All @@ -16,14 +39,6 @@
from dcorelib.triqs_compat.dft_tools import SumkDFT, SumkDFTTools
from dcorelib.triqs_compat.plot import mpl_interface
else:
TRIQS_COMPAT = False
triqs_libs = ['triqs', 'triqs_dft_tools']
for l in triqs_libs:
if not importlib.util.find_spec(l):
print(f"{l} is not installed!")
print("We can use a TRIQS-compatible library instead by setting environment variable DCORE_TRIQS_COMPAT to 1.")
raise RuntimeError("TRIQS is not found!")

from triqs.gf.gf import *
from triqs.gf import *
from h5 import *
Expand All @@ -37,3 +52,5 @@
from triqs_dft_tools import SumkDFT, SumkDFTTools
else:
from .backend import _triqs_mpi as mpi

print("INFO: TRIQS library is used")

0 comments on commit e837c5f

Please sign in to comment.