Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Add python module documentation. Add documentation compilation workflow
  • Loading branch information
lcrippa committed Oct 13, 2024
1 parent 07c62dd commit 9b76b8f
Show file tree
Hide file tree
Showing 13 changed files with 1,199 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: documentation

on: [push, pull_request, workflow_dispatch]

permissions:
contents: write

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install dependencies
run: |
pip install sphinx sphinx_rtd_theme myst_parser recommonmark
- name: Sphinx build
run: |
sphinx-build doc _build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
3 changes: 3 additions & 0 deletions doc/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wy-nav-content {
max-width: none;
}
80 changes: 80 additions & 0 deletions doc/basicusage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Basic usage
==============

The edipy2 module consists mainly of a class called :code:`global_env`. The global variables and the functions of the EDIpack2 library that are exposed to the user are methods of this class. The class needs to be imported at the beginning of the script, along with other useful modules. Numpy is necessary, while mpi4py is strongly recommended.

.. code-block:: python
import numpy as np
import scipy as sp
from edipy2 import global_env as ed
import mpi4py
from mpi4py import MPI
import os,sys
An example driver is provided in the folder :code:`tests/python` of the EDIpack2 repo. The basic steps to follow to run a single loop of DMFT-ED with edipy2 are the following:

Read the input file

.. code-block:: python
ed.read_input("inputED.conf")
This will read an input file or generate a template one if no such file is found. The template will have the :code:`used.` prefix, which will need to be removed. An `example <https://raw.githubusercontent.com/aamaricci/EDIpack2.0/refs/heads/master/test/python/inputED.conf>`_ of input file with a brief description of the relevant global variables is provided in the EDIpack2 repo.

Set the local Hamiltonian

.. code-block:: python
ed.set_hloc(hloc=Hloc)
If :code:`BATH_TYPE` is :code:`REPLICA` or :code:`GENERAL`, the replica matrix has to be initialized via

.. code-block:: python
ed.set_hreplica(hvec, lambdavec)
ed.set_general(hvec, lambdavec)
where :code:`hvec` and :code:`lambdavec` are arrays of the proper size (see function documentation).

The solver needs to be initialized via

.. code-block:: python
ed.init_solver()
Optionally, such as when real-space DMFT is used, the bath can be already allocated as an array, the dimension of which has to be given by the output of :code:`Nb` = :func:`ed.get_bath_dimension` for single-impurity DMFT and :code:`[Nlat,Nb]` for real-space DMFT, where :code:`Nlat` is the number of inequivalent impurities

The impurity problem is then solved via

.. code-block:: python
ed.solve(bath)
The self-energy needs to be retrieved in order to calculate the local lattice Green's function, via

.. code-block:: python
ed.get_sigma(axis="m")
The local Green's function calculation is left to the user, as well as that of the Weiss field or the Delta function, to be fitted by the new bath.
This latter step happens via

.. code-block:: python
bath = ed.chi2_fitgf(Delta,bath,ispin=0,iorb=0)
(check the function documentation for more details), but alternatively a fitting routine of the user's choice can be employed.
Convergence can be checked via

.. code-block:: python
err,converged=ed.check_convergence(Delta[0,0,0,0,:],ed.dmft_error,1,ed.Nloop)
and, finally, the solution environment can be cleaned up via

.. code-block:: python
ed.finalize_solver()
some or all of the steps above can be inserted in the DMFT convergence loop.
212 changes: 212 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import recommonmark
from recommonmark.transform import AutoStructify
import sphinx_rtd_theme


# -- Project information -----------------------------------------------------

project = u'Edipy2 documentation'
copyright = u'2024, io'
author = u'io'

# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u''


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.autosectionlabel',
'recommonmark',
'sphinx_rtd_theme'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme' #'alabaster'
html_css_files = [
'css/custom.css',
]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'collapse_navigation': True,
'navigation_depth': 4,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'edipy2-docs'


# -- Options for LaTeX output ------------------------------------------------

latex_engine = 'xelatex'

latex_elements = {
'fontpkg': r'''
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
''',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'edipy2.tex', u'edipy2 documentation',
u'io', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'edipy2', u'edipy2 documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'edipy2', u'edipy2 documentation',
author, 'edipy2', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------

# app setup hook
def setup(app):
app.add_config_value('recommonmark_config', {
#'url_resolver': lambda url: github_doc_root + url,
'enable_auto_toc_tree': True,
'auto_toc_maxdepth': 3,
'auto_toc_tree_section': 'Contents',
'enable_math': True,
'enable_inline_math': True,
'enable_eval_rst': True,
}, True)
app.add_transform(AutoStructify)

17 changes: 17 additions & 0 deletions doc/funcs/0_readinput.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Input file manipulation
========================

.. function:: read_input(input_string)

This function reads from the input file of EDIpack2. If the file does not exist, a template file is generated with default parameters.
This is generated with the prefix "used." which will need to be removed for it to be read. "used.${input_string}" will be updated within
the DMFT loop with the current value of the input variables.

:param input_string: The name of the input file to be read, including the extension
:type input_string: str
:return: Nothing
:rtype: None




Loading

0 comments on commit 9b76b8f

Please sign in to comment.