diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 7f9b2e04..790598fb 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -106,12 +106,15 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DEST PATTERN "*.py" PATTERN "*.txt" PATTERN "*.bib" + PATTERN "*.inv" PATTERN ".svn" EXCLUDE PATTERN "CVS" EXCLUDE ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/themes/agogo DESTINATION share/triqs/themes) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/themes/triqs DESTINATION share/triqs/themes) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/_static DESTINATION share/triqs/export) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/_templates DESTINATION share/triqs/export) # PDF documentation if (Build_PDF_Documentation) diff --git a/doc/_templates/sideb.html b/doc/_templates/sideb.html index ead3b1e2..89188a07 100644 --- a/doc/_templates/sideb.html +++ b/doc/_templates/sideb.html @@ -6,9 +6,11 @@ ERC

+ diff --git a/doc/_templates/sideb_appli.html b/doc/_templates/sideb_appli.html new file mode 100644 index 00000000..daf7ca2f --- /dev/null +++ b/doc/_templates/sideb_appli.html @@ -0,0 +1,9 @@ +

+ CEA + Ecole Polytechnique +
+ CNRS +ERC +

+ + diff --git a/doc/documentation.rst b/doc/documentation.rst index bf2910ca..87302eee 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -9,24 +9,19 @@ A quick tour .. toctree:: :maxdepth: 1 - overview - tutorials/contents + tutorials/python/introduction + tutorials/c++/contents -C++ libraries -------------- +Reference manual +----------------- + +This is the reference manual for the Python and the C++ libraries. .. toctree:: - :maxdepth: 1 - - reference/c++/contents - -Python modules --------------- - -.. toctree:: - :maxdepth: 1 + :maxdepth: 2 reference/python/contents + reference/c++/contents Version compatibility --------------------- diff --git a/doc/index.rst b/doc/index.rst index 02818fe9..1c7433e5 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -11,31 +11,33 @@ Welcome have changed too. So go look at our :ref:`changelog page ` to find out how to upgrade to 1.0. -TRIQS is a scientific project providing a set of C++ and Python libraries to develop new tools +TRIQS (**T**\oolbox for **R**\esearch on **I**\nteracting **Q**\uantum **S**\ystems) +is a scientific project providing a set of C++ and Python libraries to develop new tools for the study of interacting quantum systems. The goal of this toolkit is to provide condensed matter physicists with -high quality, high level, efficient and simple to use libraries in C++ and Python, -and to promote the use of modern programming techniques and practices in our field. +high level, efficient and simple to use libraries in C++ and Python, +and to promote the use of modern programming techniques in our field. TRIQS is free software (GPL). TRIQS applications ----------------------- -Several :ref:`full-fledged applications ` have been written using -TRIQS and are also maintained by the TRIQS collaboration. They allow for example to +Based on the TRIQS toolkit, several :ref:`full-fledged applications ` +are also maintained by the TRIQS collaboration. They allow for example to solve a generic quantum impurity model or to run a complete LDA+DMFT calculation. -Since 2005, the TRIQS library and applications have allowed to address -questions as diverse as: +Elaborated in a collaboration between IPhT Saclay and Ecole Polytechnique since 2005, +the TRIQS library and applications have allowed to address questions as diverse as: * Momentum-selective aspects on cuprate superconductors (with various cluster DMFT) * Degree of correlation in iron-based superconductors (within an LDA+DMFT approach) * Fermionic Mott transition and exploration of Sarma phase in cold-atoms -C++ & Python + +Python & C++ ----------------------------- The libraries exist at two diff --git a/doc/install.rst b/doc/install.rst index 3400b807..ef177d5d 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -7,7 +7,11 @@ Installation ============ -This page describes the installation of TRIQS itself. The installation of the applications based on TRIQS +TRIQS and its applications are provided *à la carte*: +after you have installed the TRIQS toolkit, you will be able to easily install +various TRIQS-based applications: impurity solvers, realistic DMFT tools, ... + +This page describes the installation of the TRIQS toolkit itself. The installation of the applications is described in their respective documentation. Prerequisite @@ -41,7 +45,7 @@ Installation steps $ cmake -DCMAKE_INSTALL_PREFIX=path_to_install_directory ../src If you omit ``CMAKE_INSTALL_PREFIX``, the default - ``path_to_install_directory`` is a subdirectory ``INSTALL_DIR`` in your build + ``path_to_install_directory`` is the subdirectory *INSTALL_DIR* in your build directory. More configuration options are described in the :ref:`cmake options `. diff --git a/doc/installation/osx_lion.rst b/doc/installation/osx_lion.rst index 2ccddb90..a1f6dd61 100644 --- a/doc/installation/osx_lion.rst +++ b/doc/installation/osx_lion.rst @@ -1,7 +1,8 @@ -.. index:: install_on_osx_lion +.. index:: install_osx_lion + +.. highlight:: bash .. _install_on_osx_lion: -.. highlight:: bash Installing required libraries on Mac OS X ========================================= diff --git a/doc/reference/c++/arrays/cookbook/contents.rst b/doc/reference/c++/arrays/cookbook/contents.rst deleted file mode 100644 index 5c22f5ae..00000000 --- a/doc/reference/c++/arrays/cookbook/contents.rst +++ /dev/null @@ -1,12 +0,0 @@ -Arrays cookbook : learn through simple examples... -********************************************************************************** - -.. highlight:: c - -.. toctree:: - :maxdepth: 2 - :numbered: - - basic - intermediate - diff --git a/doc/reference/c++/arrays/cookbook/intermediate.rst b/doc/reference/c++/arrays/cookbook/intermediate.rst deleted file mode 100644 index f8960dae..00000000 --- a/doc/reference/c++/arrays/cookbook/intermediate.rst +++ /dev/null @@ -1,6 +0,0 @@ - -Intermediate -=============== - -.. highlight:: c - diff --git a/doc/reference/c++/contents.rst b/doc/reference/c++/contents.rst index d1f02e1a..4dc0e177 100644 --- a/doc/reference/c++/contents.rst +++ b/doc/reference/c++/contents.rst @@ -1,5 +1,5 @@ -C++ libraries +C++ ============= .. toctree:: diff --git a/doc/reference/c++/gf/cookbook/contents.rst b/doc/reference/c++/gf/cookbook/contents.rst deleted file mode 100644 index c1bb5c7e..00000000 --- a/doc/reference/c++/gf/cookbook/contents.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _greenfunctions: - -Green's function cookbook -========================== - - -.. toctree:: - :maxdepth: 2 - - real - imaginary diff --git a/doc/reference/c++/gf/cookbook/imaginary.rst b/doc/reference/c++/gf/cookbook/imaginary.rst deleted file mode 100644 index b728899b..00000000 --- a/doc/reference/c++/gf/cookbook/imaginary.rst +++ /dev/null @@ -1,2 +0,0 @@ -Learn more in the full referencen, see :ref:`greenfunctions` - diff --git a/doc/reference/c++/gf/cookbook/real.rst b/doc/reference/c++/gf/cookbook/real.rst deleted file mode 100644 index 953c3aa5..00000000 --- a/doc/reference/c++/gf/cookbook/real.rst +++ /dev/null @@ -1,20 +0,0 @@ - -Create a real frequency Green function --------------------------------------- -.. compileblock:: - - #include - #include - - using triqs::gfs::make_gf; - using triqs::gfs::refreq; - - int main() { - double wmin=0; - double wmax=10; - size_t n_freq=5; - //we want a Green function whose values are 2*2 matrices of complex numbers - auto shape = triqs::arrays::make_shape(2,2); - auto GF=make_gf(wmin, wmax, n_freq, shape); - }; - diff --git a/doc/reference/c++/utilities/exceptions.rst b/doc/reference/c++/utilities/exceptions.rst index e5905cbe..8bf14a8c 100644 --- a/doc/reference/c++/utilities/exceptions.rst +++ b/doc/reference/c++/utilities/exceptions.rst @@ -4,53 +4,54 @@ .. _util_exceptions: Exceptions -============================= +============= TRIQS defines special exceptions, with the following characteristics : -* they derives from std::exceptions and have the interface +* they derives from std::exceptions * their .what() contains : * the file and line where the exception occurred * an additionnal error message (see example below). The error behaves like a std::stringstream, one can accumulate any message * a complete stack strace of the C++ code at the exception point, with demangling of the function name (on gcc and clang). - * the boost python interface catches these exceptions and report all the information , for debugging. - So instead of having "Unknown exception in C++", you have a complete trace of the problem that occurred. .. warning:: For uniformity, it is highly recommended to use these macros when developing for TRIQS. -Example of use :: +Example : - #include - - ... - if (!condition) TRIQS_RUNTIME_ERROR <<" The value of a = "< + + int main() { + if (2!=3) TRIQS_RUNTIME_ERROR <<" The condition is false because "<< 2 << "!=" << 3; + } - This macro is simply :: +The exception can of course be caught : - #define TRIQS_RUNTIME_ERROR throw triqs::runtime_error()<<" Triqs runtime error at "<<__FILE__<< " : "<<__LINE__<<"\n\n Trace is :\n\n"< - - try { - ... - if (!condition) TRIQS_RUNTIME_ERROR <<" The value of a = "< + #include + + void f() { + try { + if (2!=3) TRIQS_RUNTIME_ERROR <<" The condition is false because "<< 2 << "!=" << 3; + } + catch (triqs::runtime_error const & e) { std::cout << "caught error "<< e.what()< - using triqs::arrays::array; - int main(){ - array A(10),B(10); - A()=2;B()=3; - ///..... - } - - HDF5 Archiving ------------------- Archiving an array into an HDF5 file is easy: @@ -185,35 +173,3 @@ Map and fold } -Bound checking ---------------- -By default, there is no bound checking: - -.. compileblock:: - - #include - using triqs::arrays::array; - int main(){ - array A(2,2); A() = 3; - std::cout << A(0,3) << std::endl; - } - -But one can add bound-checking by adding a preprocessor command: - -.. compileblock:: - - #define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK - #include - using triqs::arrays::array; - int main(){ - try { - array A(2,2); A() = 3; - std::cout << A(0,3) << std::endl; - } - //catch (triqs::arrays::key_error & e) { std::cout<< e.what()<< std::endl;} - catch (std::exception & e) { std::cout<< e.what()<< std::endl;} // or like this : triqs::arrays::key_error derives from std::exception - } - - - - diff --git a/doc/tutorials/c++/contents.rst b/doc/tutorials/c++/contents.rst index 62870786..75b3142b 100644 --- a/doc/tutorials/c++/contents.rst +++ b/doc/tutorials/c++/contents.rst @@ -1,8 +1,14 @@ C++ libraries ================================= +.. warning:: + + TO BE WRITTEN + .. toctree:: :maxdepth: 1 - ../../reference/c++/arrays/cookbook/contents - ../../reference/c++/gf/cookbook/contents + + +.. + array_tutorial diff --git a/doc/tutorials/python/aim.py b/doc/tutorials/python/aim.py new file mode 100644 index 00000000..6dac805c --- /dev/null +++ b/doc/tutorials/python/aim.py @@ -0,0 +1,42 @@ +from pytriqs.gf.local import * +from pytriqs.operators import * +from pytriqs.applications.impurity_solvers.cthyb_matrix import Solver + +D, V, U = 1.0, 0.2, 4.0 +e_f, Beta = -U/2.0, 50 + +# The impurity solver +S = Solver(Beta = Beta, # inverse temperature + GFstruct = [ ('up',[1]), ('down',[1]) ], # Structure of the Green's function + H_Local = U * N('up',1) * N('down',1), # Local Hamiltonian + Quantum_Numbers = { # Quantum Numbers + 'Nup' : N('up',1), # (operators commuting with H_Local) + 'Ndown' : N('down',1) }, + N_Cycles = 500000, # Number of QMC cycles + Length_Cycle = 200, # Length of one cycle + N_Warmup_Cycles = 10000, # Warmup cycles + N_Legendre_Coeffs = 50, # Number of Legendre coefficients + Random_Generator_Name = 'mt19937', # Name of the random number generator + Use_Segment_Picture = True, # Use the segment picture + Measured_Operators = { # Operators to be averaged + 'Nimp' : N('up',1)+N('down',1) }, + Global_Moves = [ # Global move in the QMC + (0.05, lambda (a,alpha,dag) : ( {'up':'down','down':'up'}[a],alpha,dag ) ) ], + ) + +# Initialize the non-interacting Green's function S.G0 +for spin, g0 in S.G0 : + g0 <<= inverse( iOmega_n - e_f - V**2 * Wilson(D) ) + +# Run the solver. The result will be in S.G +S.Solve() + +# Save the results in an hdf5 file (only on the master node) +from pytriqs.archive import HDFArchive +import pytriqs.utility.mpi as mpi + +if mpi.is_master_node(): + Results = HDFArchive("solution.h5",'w') + Results["G"] = S.G + Results["Gl"] = S.G_Legendre + Results["Nimp"] = S.Measured_Operators_Results['Nimp'] diff --git a/doc/tutorials/python/aim_plot.py b/doc/tutorials/python/aim_plot.py new file mode 100644 index 00000000..973d83f1 --- /dev/null +++ b/doc/tutorials/python/aim_plot.py @@ -0,0 +1,6 @@ +from pytriqs.gf.local import * +from pytriqs.archive import * +from pytriqs.plot.mpl_interface import oplot + +A = HDFArchive("solution.h5") +oplot(A['G']['up'], '-o', x_window = (0,10)) diff --git a/doc/tutorials/python/introduction.rst b/doc/tutorials/python/introduction.rst index 644431e6..cd49c832 100644 --- a/doc/tutorials/python/introduction.rst +++ b/doc/tutorials/python/introduction.rst @@ -1,33 +1,11 @@ .. index:: introduction .. role:: red -Python modules +Python ================================== -TRIQS (**T**\oolbox for **R**\esearch on **I**\nteracting **Q**\uantum **S**\ystems) -is a free software scientific project -that aims at providing tools for the theoretical study of strongly correlated quantum systems. -It is based on some of the codes originally developed and used at IPhT Saclay and Ecole Polytechnique since 2005 -(see :ref:`credits `). -It is implemented as a `Python `_ library, with Python, C++ and Fortran codes and contains : - -* Various basic objects e.g. : - - * Local Green's functions of various kinds. - * Bravais lattices, tight-binding hoppings, local density of states, superlattices (for cluster methods) - * Some simple *k*-sums over the Brillouin zone. - -* Optional extension modules : - - * Quantum impurity solvers : - - * :ref:`Continuous-time hybridization Quantum Monte Carlo `. - * :ref:`Hubbard I `. - - * :ref:`Wien2TRIQS ` : an interface to the Wien2k electronic structure code for performing LDA+DMFT computations. - -The rest of the introduction is a little demo of examples used elsewhere in the documentation. -The goal is not to explain them here in details but to quickly show some of TRIQS's current capabilities. +This introduction is a little tour of some aspects of TRIQS and some of its applications, +at the Python level. The goal is not to explain here in details but to quickly show some of TRIQS's current capabilities. .. toctree:: :maxdepth: 1 diff --git a/doc/tutorials/python/reading.rst b/doc/tutorials/python/reading.rst index d29513ee..fb9aaa51 100644 --- a/doc/tutorials/python/reading.rst +++ b/doc/tutorials/python/reading.rst @@ -1,5 +1,5 @@ -Recommended reading and references +Learning Python : recommended reading and references ---------------------------------------------------------- * A good set of lectures is the `Scipy lecture notes `_. diff --git a/doc/tutorials/python/single_site_bethe.py b/doc/tutorials/python/single_site_bethe.py new file mode 100644 index 00000000..9b03de87 --- /dev/null +++ b/doc/tutorials/python/single_site_bethe.py @@ -0,0 +1,48 @@ +from pytriqs.gf.local import * +from pytriqs.archive import * +import pytriqs.utility.mpi as mpi + +# Set up a few parameters +Half_Bandwidth = 1.0 +U = 2.5 +Chemical_Potential = U/2.0 +Beta = 100 +N_loops = 5 + +# Construct a CTQMC solver +from pytriqs.applications.impurity_solvers.operators import * # imports the class manipulating C, C_dagger and N = C_dagger C +from pytriqs.applications.impurity_solvers.cthyb_matrix import Solver # imports the solver class +S = Solver(Beta = Beta, # inverse temperature + GFstruct = [ ('up',[1]), ('down',[1]) ], # Structure of the Green function + H_Local = U * N('up',1) * N('down',1), # Local Hamiltonian + Quantum_Numbers = { 'Nup' : N('up',1), 'Ndown' : N('down',1) }, # Quantum Numbers (operators commuting with H_Local) + N_Cycles = 5000, # Number of QMC cycles + Length_Cycle = 200, # Length of a cycle + N_Warmup_Cycles = 1000, # How many warmup cycles + N_Legendre_Coeffs = 30, # Use 30 Legendre coefficients to represent G(tau) + Random_Generator_Name = "mt19937", # Use the Mersenne Twister 19937 random generator + Use_Segment_Picture = True) # Here we can use the segment picture + +# Initalize the Green's function to a semi circular +S.G <<= SemiCircular(Half_Bandwidth) + +# Now do the DMFT loop +for IterationNumber in range(N_loops): + + # Compute S.G0 with the self-consistency condition while imposing paramagnetism + g = 0.5 * ( S.G['up'] + S.G['down'] ) + for name, g0block in S.G0: + g0block <<= inverse( iOmega_n + Chemical_Potential - (Half_Bandwidth/2.0)**2 * g ) + + # Run the solver + S.Solve() + + # Some intermediate saves + if mpi.is_master_node(): + R = HDFArchive("single_site_bethe.h5") + R["G-%s"%IterationNumber] = S.G + del R + + # Here we would usually write some convergence test + # if Converged : break + diff --git a/doc/tutorials/python/tour1.rst b/doc/tutorials/python/tour1.rst index 4f4ad977..744b06d3 100644 --- a/doc/tutorials/python/tour1.rst +++ b/doc/tutorials/python/tour1.rst @@ -21,6 +21,6 @@ Finally, the obtained bath and impurity densities of states are plotted using th :include-source: :scale: 70 -You will find more information on the local Green's function implementation in TRIQS in :ref:`the corresponding chapter of the manual ` +You will find more information on the local Green's function implementation in TRIQS in :doc:`the corresponding chapter of the manual <../../reference/python/green/green>` diff --git a/doc/tutorials/python/tour2.rst b/doc/tutorials/python/tour2.rst index bd183c9a..f0560b0c 100644 --- a/doc/tutorials/python/tour2.rst +++ b/doc/tutorials/python/tour2.rst @@ -9,12 +9,12 @@ neighbour hopping using the ``BravaisLattice`` class of TRIQS, compute its density of states (DOS) and then plot it by using again the ``oplot`` function. -.. literalinclude:: ../lattice/ex1.py +.. literalinclude:: ../../reference/python/lattice/ex1.py :lines: 1-34 -.. image:: ../lattice/ex1.png +.. image:: ../../reference/python/lattice/ex1.png :width: 700 :align: center -More information on the lattice tools implemeted in TRIQS can be :ref:`found here ` +More information on the lattice tools implemeted in TRIQS can be :doc:`found here <../../reference/python/lattice/lattice>` diff --git a/doc/tutorials/python/tour3.rst b/doc/tutorials/python/tour3.rst index ab3a7c62..4306fac5 100644 --- a/doc/tutorials/python/tour3.rst +++ b/doc/tutorials/python/tour3.rst @@ -3,6 +3,8 @@ Tour 3: Solving a quantum impurity model with QMC ---------------------------------------------------------- +`[Requires TRIQS and the application cthyb_matrix]` + Free electrons are nice, but the `I` in TRIQS means `interacting`. So let us solve a simple one-band Anderson impurity model @@ -25,14 +27,14 @@ We solve this model using the hybridization expansion Continuous Time Quantum Mo proposed by `P. Werner et al. `_ To this end we first initialize the ``Solver`` class of the TRIQS CT-Hyb implementaion -``pytriqs.applications.impurity_solvers.ctqmc_hyb``. +``pytriqs.applications.impurity_solvers.cthyb_matrix``. Then, after having constructed the non-interacting Green's function :math:`G^{-1}_{0,\sigma}`, -we launch the CT-Hyb calculations by calling the ``Solve`` method of the ``Solver`` class. +we launch the impurity solver calculations by calling the ``Solve`` method. Finally, the resulting interacting Green's function as well as average impurity occupancy is stored in the :ref:`HDF5 format`. -.. literalinclude:: ../solvers/aim.py +.. literalinclude:: ./aim.py The result can be then read from the ``HDF5`` file and plotted using the ``oplot`` function: @@ -43,5 +45,5 @@ The result can be then read from the ``HDF5`` file and plotted using the ``oplot :align: center -We go through this example in more details in the tutorial :ref:`Anderson impurity model ` +We go through this example in more details in the documentation of the cthyb_matrix application. diff --git a/doc/tutorials/python/tour4.rst b/doc/tutorials/python/tour4.rst index a8d6151b..da3c88c6 100644 --- a/doc/tutorials/python/tour4.rst +++ b/doc/tutorials/python/tour4.rst @@ -2,6 +2,9 @@ Tour 4: Dynamical Mean Field Theory on a Bethe lattice ------------------------------------------------------ + `Requires TRIQS and the application cthyb_matrix` + + In the case of Bethe lattice the dynamical mean-field theory (DMFT) self-consistency condition takes a particularly simple form .. math:: @@ -15,7 +18,7 @@ the previous single-impurity example to the case of a bath with semi-circular de Here is a complete program doing this plain vanilla DMFT on a half-filled one-band Bethe lattice: -.. literalinclude:: ../solvers/dmft/single_site_bethe.py +.. literalinclude:: ./single_site_bethe.py A general introduction to DMFT calculations with TRIQS can be found :ref:`here `