diff --git a/.clang-tidy b/.clang-tidy index a6bf7a2..838f74e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,2 @@ Checks: '-*,modernize-*,cppcoreguidelines-*,-modernize-use-trailing-return-type,-modernize-use-nullptr,-cppcoreguidelines-avoid-magic-numbers' -HeaderFilterRegex: 'triqs_ctseg-J' +HeaderFilterRegex: 'triqs_ctseg' diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 411ed86..96d49d2 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -32,7 +32,7 @@ Please provide the application version that you used. You can get this information from copy and pasting the output of ```bash -python -c "from triqs_ctseg-J.version import *; show_version(); show_git_hash();" +python -c "from triqs_ctseg.version import *; show_version(); show_git_hash();" ``` from the command line. Also, please include the OS you are running and its version. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88666bf..ee47a62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,7 +111,7 @@ jobs: make -j1 install VERBOSE=1 cd ../ - - name: Build ctseg-J + - name: Build ctseg env: CC: ${{ matrix.cc }} CXX: ${{ matrix.cxx }} @@ -121,7 +121,7 @@ jobs: mkdir build && cd build && cmake .. make -j2 || make -j1 VERBOSE=1 - - name: Test ctseg-J + - name: Test ctseg env: DYLD_FALLBACK_LIBRARY_PATH: /usr/local/opt/llvm/lib OPENBLAS_NUM_THREADS: "1" diff --git a/Dockerfile b/Dockerfile index 55abe97..fdc9891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # See ../triqs/packaging for other options FROM flatironinstitute/triqs:unstable-ubuntu-clang -ARG APPNAME=ctseg-J +ARG APPNAME=ctseg RUN apt-get install -y libnfft3-dev || yum install -y nfft-devel || dnf install -y 'https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/nfft-3.3.2-1.el7.x86_64.rpm' 'https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/nfft-devel-3.3.2-1.el7.x86_64.rpm' diff --git a/README.md b/README.md index 9ca8087..d5e2128 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![build](https://github.com/TRIQS/ctseg/workflows/build/badge.svg)](https://github.com/TRIQS/ctseg/actions?query=workflow%3Abuild) -## TRIQS segment picture solver with spin-spin interactions (CTSEG-J) +## TRIQS segment picture solver (CTSEG) Copyright (C) 2024, N. Kavokine, H. Lu, N. Wentzell and O. Parcollet. diff --git a/c++/triqs_ctseg/params.hpp b/c++/triqs_ctseg/params.hpp index 158e50d..6f0fa42 100644 --- a/c++/triqs_ctseg/params.hpp +++ b/c++/triqs_ctseg/params.hpp @@ -11,13 +11,13 @@ struct constr_params_t { /// Inverse temperature double beta; - /// Structure of the GF (names, sizes of blocks) + /// Structure of the Green's function (names and sizes of blocks) gf_struct_t gf_struct; - /// Number of time slices for $Delta(\tau)$/$G(\tau)$/$F(\tau)$ + /// Number of time slices for fermionic functions int n_tau = 10001; - /// Number of time slices for $K(\tau)$ + /// Number of time slices for bosonic functions int n_tau_k = 10001; }; @@ -87,7 +87,7 @@ struct solve_params_t { // -------- Measure control -------------- - /// Whether to measure the perturbation order histograms (Order in Delta, and Jperp) + /// Whether to measure the perturbation order histograms (order in Delta and Jperp) bool measure_perturbation_order_histograms = true; /// Whether to measure G(tau) (see [[measure_g_f_tau]]) @@ -102,13 +102,13 @@ struct solve_params_t { /// Whether to measure sign (see [[measure_sign]]) bool measure_sign = true; - /// Whether to measure (see [[measure_nn]]) + /// Whether to measure (see [[measure_nn]]) bool measure_nn = false; - /// Whether to measure langle n(tau)n(0)rangle (see [[measure_nnt]]) + /// Whether to measure (see [[measure_nnt]]) bool measure_nnt = false; - /// Whether to measure langle s_x(tau)s_x(0)rangle (see [[measure_sperp_tau]]) + /// Whether to measure (see [[measure_sperp_tau]]) bool measure_sperpt = false; /// Whether to measure state histograms (see [[measure_statehist]]) diff --git a/c++/triqs_ctseg/solver_core.cpp b/c++/triqs_ctseg/solver_core.cpp index a2ace37..5b5f2c4 100644 --- a/c++/triqs_ctseg/solver_core.cpp +++ b/c++/triqs_ctseg/solver_core.cpp @@ -27,20 +27,20 @@ solver_core::solver_core(constr_params_t const &p) : constr_params(p) { // --------------------------------------------------------------------------- -void solver_core::solve(solve_params_t const &solve_params) { +void solver_core::solve(solve_params_t const &solve_params_input) { - // http://patorjk.com/software/taag/#p=display&f=Calvin%20S&t=TRIQS%20ctint + // http://patorjk.com/software/taag/#p=display&f=Calvin%20S&t=TRIQS%20ctseg if (c.rank() == 0) std::cout << "\n" - "╔╦╗╦═╗╦╔═╗ ╔═╗ ┌─┐┌┬┐┌─┐┌─┐┌─┐ ┬ \n" - " ║ ╠╦╝║║═╬╗╚═╗ │ │ └─┐├┤ │ ┬───│ \n" - " ╩ ╩╚═╩╚═╝╚╚═╝ └─┘ ┴ └─┘└─┘└─┘ └┘ \n"; + "╔╦╗╦═╗╦╔═╗ ╔═╗ ┌─┐┌┬┐┌─┐┌─┐┌─┐\n" + " ║ ╠╦╝║║═╬╗╚═╗ │ │ └─┐├┤ │ ┬\n" + " ╩ ╩╚═╩╚═╝╚╚═╝ └─┘ ┴ └─┘└─┘└─┘\n"; // ................ Parameters ................. - // Store the solve_params - last_solve_params = solve_params; // Merge constr_params and solve_params - params_t p(constr_params, solve_params); + params_t p(constr_params, solve_params_input); + // Store the solve_params + solve_params = solve_params_input; // ................ Work data & Configuration ................... @@ -117,7 +117,7 @@ void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s h5_write_attribute(grp, "TRIQS_GIT_HASH", std::string(STRINGIZE(TRIQS_GIT_HASH))); h5_write_attribute(grp, "CTSEGJ_GIT_HASH", std::string(STRINGIZE(CTSEGJ_GIT_HASH))); h5_write(grp, "constr_params", s.constr_params); - h5_write(grp, "last_solve_params", s.last_solve_params); + h5_write(grp, "solve_params", s.solve_params); h5_write(grp, "inputs", s.inputs); h5_write(grp, "results", s.results); } @@ -127,7 +127,7 @@ solver_core solver_core::h5_read_construct(h5::group h5group, std::string subgro auto grp = h5group.open_group(subgroup_name); auto constr_params = h5_read(grp, "constr_params"); auto s = solver_core{constr_params}; - h5_read(grp, "last_solve_params", s.last_solve_params); + h5_read(grp, "solve_params", s.solve_params); h5_read(grp, "inputs", s.inputs); h5_read(grp, "results", s.results); return s; diff --git a/c++/triqs_ctseg/solver_core.hpp b/c++/triqs_ctseg/solver_core.hpp index bb38be4..763da31 100644 --- a/c++/triqs_ctseg/solver_core.hpp +++ b/c++/triqs_ctseg/solver_core.hpp @@ -19,13 +19,19 @@ class solver_core { mpi::communicator c; public: - /// Solver construction parameters + /**Set of parameters used in the construction of the ``solver_core`` class. + * + *.. include:: ../../python/triqs_ctseg/parameters_constr_params_t.rst + */ constr_params_t constr_params; - /// Solver solve parameters (from last call) - std::optional last_solve_params; + /**Set of parameters used by the last call to ``solve()``. + * + *.. include:: ../../python/triqs_ctseg/parameters_solve_params_t.rst + */ + std::optional solve_params; - /// The set of results + /// The set of results. See :doc:`Measurements <../guide/measurements>`. // Will be passed to measures and initialized by them. results_t results; @@ -48,7 +54,7 @@ class solver_core { gf_view D0_tau() { return inputs.d0t; } // --------------- h5 ------------------------- - CPP2PY_IGNORE static std::string hdf5_format() { return "CTSEG-J_SolverCore"; } + CPP2PY_IGNORE static std::string hdf5_format() { return "CTSEG_SolverCore"; } friend void h5_write(h5::group h5group, std::string subgroup_name, solver_core const &s); CPP2PY_IGNORE static solver_core h5_read_construct(h5::group h5group, std::string subgroup_name); }; diff --git a/c++/triqs_ctseg/work_data.cpp b/c++/triqs_ctseg/work_data.cpp index a17e597..b840e43 100644 --- a/c++/triqs_ctseg/work_data.cpp +++ b/c++/triqs_ctseg/work_data.cpp @@ -54,6 +54,11 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi has_Dt = max_element(abs(inputs.d0t.data())) > 1.e-13; has_jperp = max_element(abs(inputs.jperpt.data())) > 1.e-13; + // Check: no J_perp implementation for more than 2 colors + if (n_color != 2) { + ALWAYS_EXPECTS((not has_jperp), "Error : has_jperp is true and we have {} colors instead of 2", n_color); + } + // For numerical integration of the D0 and Jperp auto ramp = nda::zeros(p.n_tau_k); for (auto n : range(p.n_tau_k)) { ramp(n) = n * beta / (p.n_tau_k - 1); } @@ -73,7 +78,7 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi first_integral(i) = first_integral(i - 1) + (D_data(i) + D_data(i - 1)) / 2; second_integral(i) = second_integral(i - 1) + (first_integral(i) + first_integral(i - 1)) / 2; } - // Noramlize by bin size + // Normalize by bin size first_integral *= beta / (p.n_tau_k - 1); second_integral *= (beta / (p.n_tau_k - 1)) * (beta / (p.n_tau_k - 1)); // Enforce K(0) = K(beta) = 0 diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 767f10e..0d3abc5 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,51 +1,5 @@ # Generate the sphinx config file configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY) - -# ----------------------------------------------------------------------------- -# Create an optional target that allows us to regenerate the C++ doc with c++2rst -# ----------------------------------------------------------------------------- -# add_custom_target(${PROJECT_NAME}_docs_cpp2rst) -# include(${PROJECT_SOURCE_DIR}/share/cmake/extract_flags.cmake) -# extract_flags(${PROJECT_NAME}_c BUILD_INTERFACE) -# separate_arguments(${PROJECT_NAME}_c_CXXFLAGS) -# macro(generate_docs header_file) -# add_custom_command( -# TARGET ${PROJECT_NAME}_docs_cpp2rst -# COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated -# COMMAND -# PYTHONPATH=${CPP2PY_BINARY_DIR}:$ENV{PYTHONPATH} -# PATH=${CPP2PY_BINARY_DIR}/bin:${CPP2PY_ROOT}/bin:$ENV{PATH} -# c++2rst -# ${header_file} -# -N ${PROJECT_NAME} -# --output_directory ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated -# -I${PROJECT_SOURCE_DIR}/c++ -# --cxxflags="${${PROJECT_NAME}_c_CXXFLAGS}" -# ) -# endmacro(generate_docs) - -# generate_docs(${PROJECT_SOURCE_DIR}/c++/${PROJECT_NAME}/solver_core.hpp) -# generate_docs(${PROJECT_SOURCE_DIR}/c++/${PROJECT_NAME}/params.hpp) - -# -------------------------------------------------------- -# Build & Run the C++ doc examples and capture the output -# -------------------------------------------------------- - -# add_custom_target(${PROJECT_NAME}_docs_example_output) -# file(GLOB_RECURSE ExampleList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) -# foreach(example ${ExampleList}) -# get_filename_component(f ${example} NAME_WE) -# get_filename_component(d ${example} DIRECTORY) -# add_executable(${PROJECT_NAME}_doc_${f} EXCLUDE_FROM_ALL ${example}) -# set_property(TARGET ${PROJECT_NAME}_doc_${f} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${d}) -# target_link_libraries(${PROJECT_NAME}_doc_${f} triqs) -# add_custom_command(TARGET ${PROJECT_NAME}_doc_${f} -# COMMAND ${PROJECT_NAME}_doc_${f} > ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${f}.output 2>/dev/null -# WORKING_DIRECTORY ${d} -# ) -# add_dependencies(${PROJECT_NAME}_docs_example_output ${PROJECT_NAME}_doc_${f}) -# endforeach() - # --------------------------------- # Top Sphinx target # --------------------------------- @@ -60,16 +14,12 @@ add_custom_command( COMMAND PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SPHINXBUILD_EXECUTABLE} -j auto -c . -b html ${CMAKE_CURRENT_SOURCE_DIR} html ) -option(Sphinx_Only "When building the documentation, skip the Python Modules and the generation of C++ Api and example outputs" OFF) +option(Sphinx_Only "When building the documentation, skip the Python Modules" OFF) if(NOT Sphinx_Only) - # Autodoc usage requires the python modules to be built first get_property(CPP2PY_MODULES_LIST GLOBAL PROPERTY CPP2PY_MODULES_LIST) if(CPP2PY_MODULES_LIST) add_dependencies(${PROJECT_NAME}_docs_sphinx ${CPP2PY_MODULES_LIST}) endif() - - # Generation of C++ Api and Example Outputs - #add_dependencies(${PROJECT_NAME}_docs_sphinx ${PROJECT_NAME}_docs_cpp2rst ${PROJECT_NAME}_docs_example_output) endif() # --------------------------------- diff --git a/doc/_ref/triqs_ctseg.solver.Solver.constr_params.rst b/doc/_ref/triqs_ctseg.solver.Solver.constr_params.rst new file mode 100644 index 0000000..a8e2aea --- /dev/null +++ b/doc/_ref/triqs_ctseg.solver.Solver.constr_params.rst @@ -0,0 +1,6 @@ +triqs\_ctseg.solver.Solver.constr\_params +========================================= + +.. currentmodule:: triqs_ctseg.solver + +.. autoattribute:: Solver.constr_params \ No newline at end of file diff --git a/doc/_ref/triqs_ctseg.solver.Solver.hdf5_format.rst b/doc/_ref/triqs_ctseg.solver.Solver.hdf5_format.rst deleted file mode 100644 index efa9d4f..0000000 --- a/doc/_ref/triqs_ctseg.solver.Solver.hdf5_format.rst +++ /dev/null @@ -1,6 +0,0 @@ -triqs\_ctseg.solver.Solver.hdf5\_format -======================================= - -.. currentmodule:: triqs_ctseg.solver - -.. automethod:: Solver.hdf5_format \ No newline at end of file diff --git a/doc/_ref/triqs_ctseg.solver.Solver.rst b/doc/_ref/triqs_ctseg.solver.Solver.rst index c177098..d20c91f 100644 --- a/doc/_ref/triqs_ctseg.solver.Solver.rst +++ b/doc/_ref/triqs_ctseg.solver.Solver.rst @@ -1,4 +1,4 @@ -triqs\_ctseg.solver.Solver +triqs\_ctseg.solver.Solver ========================== .. currentmodule:: triqs_ctseg.solver @@ -13,7 +13,6 @@ triqs\_ctseg.solver.Solver :toctree: ~Solver.__init__ - ~Solver.hdf5_format ~Solver.solve @@ -28,5 +27,7 @@ triqs\_ctseg.solver.Solver ~Solver.D0_tau ~Solver.Delta_tau ~Solver.Jperp_tau + ~Solver.constr_params ~Solver.results + ~Solver.solve_params diff --git a/doc/_ref/triqs_ctseg.solver.Solver.solve_params.rst b/doc/_ref/triqs_ctseg.solver.Solver.solve_params.rst new file mode 100644 index 0000000..ff7cff2 --- /dev/null +++ b/doc/_ref/triqs_ctseg.solver.Solver.solve_params.rst @@ -0,0 +1,6 @@ +triqs\_ctseg.solver.Solver.solve\_params +======================================== + +.. currentmodule:: triqs_ctseg.solver + +.. autoattribute:: Solver.solve_params \ No newline at end of file diff --git a/doc/_ref/triqs_ctseg.solver.rst b/doc/_ref/triqs_ctseg.solver.rst deleted file mode 100644 index 10bb4ab..0000000 --- a/doc/_ref/triqs_ctseg.solver.rst +++ /dev/null @@ -1,32 +0,0 @@ -triqs\_ctseg.solver -=================== - -.. automodule:: triqs_ctseg.solver - - - - - - - - - - - -.. rubric:: Classes - -.. autosummary:: - :toctree: - :template: autosummary_class_template.rst - - Solver - - - - - - - - - - diff --git a/doc/_templates/autosummary_module_template.rst b/doc/_templates/autosummary_module_template.rst index 737206f..30f91c2 100644 --- a/doc/_templates/autosummary_module_template.rst +++ b/doc/_templates/autosummary_module_template.rst @@ -1,4 +1,4 @@ -{{ fullname | escape | underline}} +{{ fullname | escape | underline }} .. automodule:: {{ fullname }} diff --git a/doc/_templates/sideb.html b/doc/_templates/sideb.html deleted file mode 100644 index b4cc0b1..0000000 --- a/doc/_templates/sideb.html +++ /dev/null @@ -1,14 +0,0 @@ -

- CEA - Ecole Polytechnique -
- CNRS -ERC - Flatiron Institute -
- Simons Foundation -

-
-

- Visit the project on GitHub -

diff --git a/doc/algorithm_implementation/ctseg.rst b/doc/algorithm_implementation/ctseg.rst index d185ee2..1b564d1 100644 --- a/doc/algorithm_implementation/ctseg.rst +++ b/doc/algorithm_implementation/ctseg.rst @@ -1,13 +1,13 @@ .. _ctseg: -The CTSEG-J algorithm -======================= +The CTSEG double expansion algorithm +==================================== Double expansion **************** -The double-expansion segment-picture continuous-time quantum Monte Carlo algorithm -(CTSEG-J) is based on an expansion of the partition function in powers of the +The segment-picture continuous-time quantum Monte Carlo algorithm +(CTSEG), in its double expansion version, is based on an expansion of the partition function in powers of the hybridization function :math:`\Delta(\tau)` and perprendicular spin-spin interaction :math:`J_{\perp} (\tau)`. Details can be found in [#ctqmc1]_ [#ctqmc2]_. The partition function is :math:`Z = \int [Dc][D\overline{c}]e^{-\mathcal{S}[c,\overline{c}]}`, with the action :math:`\mathcal{S}` given by @@ -46,7 +46,7 @@ where \mathcal{U}_{uv}(\tau - \tau') = \mathcal{U}_{ab}(\tau - \tau') + (-1)^{\sigma \sigma'} \frac{1}{4} \mathcal{J}_a^z(\tau) \delta_{ab}, -:math:`s^{\pm} = s_x \pm i s_y` and :math:`\mathcal{J}^{\perp} \equiv \mathcal{J}^x = \mathcal{J}^y`. The CTSEG-J solver +:math:`s^{\pm} = s_x \pm i s_y` and :math:`\mathcal{J}^{\perp} \equiv \mathcal{J}^x = \mathcal{J}^y`. The CTSEG solver stochastically explores the terms (or configurations) generated by the expansion of :math:`\mathcal{S}` in powers of :math:`\Delta(\tau)` and :math:`\mathcal{J}^{\perp}(\tau)` and samples the observables of interest (e.g. the Green's function) every few configurations. @@ -79,7 +79,7 @@ because it allows for numerically fast updates, while there is no advantage to r operators into a permanent. We will designate by "color" the set of indices carried by an operator in addition to its time (typically, spin and orbital). -Under the applicability conditions of CTSEG-J (the interaction commutes with the density operator) the configuration can be +Under the applicability conditions of CTSEG (the interaction commutes with the density operator) the configuration can be represented as a set of imaginary time segments for each color: within a segment, the color is occupied. Then, the local trace factor supports a simple expression in terms of the overlaps of those segments between different colors (up to a sign, discussed below): diff --git a/doc/algorithm_implementation/implementation_notes.rst b/doc/algorithm_implementation/implementation_notes.rst index 488c0d0..734761b 100644 --- a/doc/algorithm_implementation/implementation_notes.rst +++ b/doc/algorithm_implementation/implementation_notes.rst @@ -5,7 +5,7 @@ Implementation notes *A guide to reading the code.* -CTSEG-J is an application based on the `app4triqs `_ skeleton. The code is written in C++, and a python wrapper +CTSEG is an application based on the `app4triqs `_ skeleton. The code is written in C++, and a python wrapper is generated automatically using ``cpp2py``. The user interacts with the solver in python. Solver core diff --git a/doc/conf.py.in b/doc/conf.py.in index a88edcb..5bb38cc 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -17,7 +17,6 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.githubpages', 'sphinx_autorun', - # 'nbsphinx', 'myst_parser', 'matplotlib.sphinxext.plot_directive'] @@ -44,7 +43,7 @@ source_suffix = '.rst' autosummary_generate = True autosummary_imported_members=False -project = '@PROJECT_NAME@' +project = 'CTSEG - TRIQS segment picture solver' version = '@PROJECT_VERSION@' # this makes the current project version available as var in every rst file @@ -85,7 +84,7 @@ html_theme_options = { html_show_sphinx = False -html_context = {'header_title': 'TRIQS Segment Picture Solver'} +html_context = {'header_title': 'CTSEG'} html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static'] html_sidebars = {'index': ['sideb.html', 'searchbox.html']} diff --git a/doc/documentation.rst b/doc/documentation.rst index 4046901..4a9a2ec 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -23,13 +23,19 @@ User guide guide/measurements -Reference manual ----------------- +Python reference manual +----------------------- .. autosummary:: :toctree: _ref - :template: autosummary_module_template.rst + :template: autosummary_class_template.rst :recursive: - triqs_ctseg.solver + triqs_ctseg.solver.Solver + +Links to all relevant solver parameters: + +* :doc:`Construction parameters <_ref/triqs_ctseg.solver.Solver.__init__>` + +* :doc:`Solve parameters <_ref/triqs_ctseg.solver.Solver.solve>` diff --git a/doc/guide/moves.rst b/doc/guide/moves.rst index 0de13d9..5234e93 100644 --- a/doc/guide/moves.rst +++ b/doc/guide/moves.rst @@ -3,7 +3,7 @@ Monte Carlo moves ================= -In CTSEG-J, a configuration (state of the Markov chain) is a set of time-ordered list of segments (one for every color), and +In CTSEG, a configuration (state of the Markov chain) is a set of time-ordered list of segments (one for every color), and possibly a list of :math:`J_{\perp}` lines (see :doc:`Implementation Notes <../algorithm_implementation/implementation_notes>` for more details). Below is a list of all possible steps (or "moves") of the random walk in configuration space. diff --git a/doc/guide/step_by_step.rst b/doc/guide/step_by_step.rst index babac95..55da84a 100644 --- a/doc/guide/step_by_step.rst +++ b/doc/guide/step_by_step.rst @@ -3,7 +3,7 @@ Step-by-step guide ================== -Below is a step-by-step guide to setting up a CTQMC calcultion with the CTSEG-J solver. +Below is a step-by-step guide to setting up a CTQMC calculation with the CTSEG solver. Step 1 - Choose the construction parameters ******************************************* @@ -12,7 +12,7 @@ We first need to specify the parameters that will define the structure of the so They can be conveniently supplied as a Python dictionary:: constr_params = { - "gf_struct": gf_struct + "gf_struct": gf_struct, "beta": 100, "n_tau": 1001, "n_tau_k": 1001 @@ -31,7 +31,7 @@ Green's function structure The parameter ``gf_struct`` is a list of pairs of the form ``(block_name, block_size)``. The choice of the blocks is not unique, but choosing the smallest possible blocks -ensures the best performance. The impurity problems solved by CTSEG-J are always spin-conserving, +ensures the best performance. The impurity problems solved by CTSEG are always spin-conserving, it is therfore always possible to define at least two blocks ``up`` and ``down``. For example, for a single orbital:: @@ -53,7 +53,7 @@ Step 2 - Construct the solver With the parameters set, we are ready to construct the solver object:: - from triqs_ctseg-j import Solver + from triqs_ctseg import Solver S = Solver(**constr_params) Step 3 - Supply the solver inputs @@ -65,7 +65,7 @@ Here, we will give examples for a single-orbital impurity (``gf_struct = [("up", Interaction Hamiltonian ----------------------- -The static part of the electron-electron interaction is supplied as a TRIQS operator. In the CTSEG-J case, +The static part of the electron-electron interaction is supplied as a TRIQS operator. In the CTSEG case, it is always a density-density interaction. Density operators are represented by ``n(block_name, orbital_number)``. For our single orbital problem:: @@ -95,8 +95,8 @@ The interaction Hamiltonian is passed to the solver as part of the solve paramet Hybridization function ---------------------- -The CTSEG-J solver takes as an input the hybridization function :math:`\Delta(\tau)` that appears in the -impurity action (see :doc:`CTSEG-J algorithm <../algorithm_implementation/ctseg>`). It is initialized as:: +The CTSEG solver takes as an input the hybridization function :math:`\Delta(\tau)` that appears in the +impurity action (see :doc:`CTSEG algorithm <../algorithm_implementation/ctseg>`). It is initialized as:: from triqs.gf import * from triqs.gf.tools import * @@ -163,8 +163,8 @@ a list with one value per color. For example, for the single-orgital problem:: .. warning:: - In CTSEG-J, the meaning of the ``hartree_shift`` parameter is not the same as in CTHYB. In CTHYB, it represents - a shift of the chemical potential with respect to the one already contained in ``G0_iw``. In CTSEG-J, + In CTSEG, the meaning of the ``hartree_shift`` parameter is not the same as in CTHYB. In CTHYB, it represents + a shift of the chemical potential with respect to the one already contained in ``G0_iw``. In CTSEG, ``hartree_shift`` is the full chemical potential with all shifts applied. If the list of chemical potentials is extracted from the CTHYB input ``G0_iw`` as above, then:: @@ -174,7 +174,7 @@ If the list of chemical potentials is extracted from the CTHYB input ``G0_iw`` a Dynamical density-density interaction ------------------------------------- -The dynamical density-density interaction :math:`D(\tau)` (see :doc:`CTSEG-J algorithm <../algorithm_implementation/ctseg>`) is initialized as:: +The dynamical density-density interaction :math:`D(\tau)` (see :doc:`CTSEG algorithm <../algorithm_implementation/ctseg>`) is initialized as:: D_tau = GfImTime(indices = range(n_colors), beta = beta, statistic = "Boson", n_points = n_tau_k) @@ -195,7 +195,7 @@ The dynamical interaction is supplied to the solver via:: Spin-spin interaction --------------------- -The prependicular spin-spin interaction :math:`J_{\perp}(\tau)` (see :doc:`CTSEG-J algorithm <../algorithm_implementation/ctseg>`) is initialized as:: +The prependicular spin-spin interaction :math:`J_{\perp}(\tau)` (see :doc:`CTSEG algorithm <../algorithm_implementation/ctseg>`) is initialized as:: Jperp_tau = GfImTime(indices = [0], beta = beta, statistic = "Boson", n_points = n_tau_k) @@ -203,7 +203,7 @@ It is a :math:`1 \times 1` matrix Green's function. It is supplied to the solver S.Jperp_tau << Jperp_tau -If the impurity action contains a spin-spin interaction term of the form :math:` (1/2) \cdot Q(\tau - \tau') \sum_i s_i(\tau) s_i(\tau')`, +If the impurity action contains a spin-spin interaction term of the form :math:`(1/2) \cdot Q(\tau - \tau') \sum_i s_i(\tau) s_i(\tau')`, it can be split into a density-density and a perpendicular spin-spin term. Indeed, making use of symmetry properties, we may replace in the action .. math:: @@ -251,7 +251,7 @@ Other parameters include: * **Move control**. All the :doc:`Monte Carlo moves ` can be switched on and off. This functionality exists to faciliate testing for developers. The solver chooses the relevant moves depending on its inputs, and regular users should not need move control. -The complete list of parameters is available HERE. +The complete list of parameters is available :doc:`here <../_ref/triqs_ctseg.solver.Solver.solve>`. Step 4 - Run the solver *********************** @@ -263,7 +263,7 @@ The CTQMC run is triggered by:: .. warning:: The solver prints to the command line the interaction matrix ``U`` and chemical potential ``mu`` that are used internally. In the presence of dynamical interactions, these are renormalized values, different from the input parameters contained - in ``h_int`` and ``hartree_shift`` (see HERE). + in ``h_int`` and ``hartree_shift`` (see :doc:`CTSEG algorithm <../algorithm_implementation/ctseg>`). After it is done accumulating, the solver prints the average acceptance rates. Very low acceptance rates for all moves (below 0.1) are generally a sign that something went wrong. However, some of the moves (``split_spin_segment``, ``regroup_spin_segment``) @@ -308,7 +308,7 @@ by saving the solver object:: Running the solver in parallel ****************************** -The CTSEG-J solver supports MPI parallelism. If the solver run is set up in a file ``script.py``, a parallel run +The CTSEG solver supports MPI parallelism. If the solver run is set up in a file ``script.py``, a parallel run is typically achieved with the command:: mpirun -np python script.py diff --git a/doc/install.rst b/doc/install.rst index 70faa5d..adb46f6 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -13,7 +13,7 @@ Compiling CTSEG from source Prerequisites ------------- -#. The :ref:`TRIQS ` library, see :ref:`TRIQS installation instruction `. +#. The :ref:`TRIQS ` library. In the following, we assume that TRIQS is installed in the directory ``path_to_triqs``. Installation steps diff --git a/python/triqs_ctseg/__init__.py b/python/triqs_ctseg/__init__.py index 5a143da..dd7fd2d 100644 --- a/python/triqs_ctseg/__init__.py +++ b/python/triqs_ctseg/__init__.py @@ -1,27 +1,5 @@ -################################################################################ -# -# TRIQS: a Toolbox for Research in Interacting Quantum Systems -# -# Copyright (C) 2014 by P. Seth, I. Krivenko, M. Ferrero, O. Parcollet -# -# TRIQS is free software: you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later -# version. -# -# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# TRIQS. If not, see . -# -################################################################################ - r""" -DOC - +The CTSEG python module. """ from .solver import Solver from .solver_core import SolverCore diff --git a/python/triqs_ctseg/parameters_constr_params_t.rst b/python/triqs_ctseg/parameters_constr_params_t.rst index 77e31ec..d664777 100644 --- a/python/triqs_ctseg/parameters_constr_params_t.rst +++ b/python/triqs_ctseg/parameters_constr_params_t.rst @@ -1,11 +1,11 @@ -+----------------+-------------+---------+--------------------------------------------------------------+ -| Parameter Name | Type | Default | Documentation | -+================+=============+=========+==============================================================+ -| beta | double | -- | Inverse temperature | -+----------------+-------------+---------+--------------------------------------------------------------+ -| gf_struct | gf_struct_t | -- | Structure of the GF (names, sizes of blocks) | -+----------------+-------------+---------+--------------------------------------------------------------+ -| n_tau | int | 10001 | Number of time slices for $Delta(\tau)$/$G(\tau)$/$F(\tau)$ | -+----------------+-------------+---------+--------------------------------------------------------------+ -| n_tau_k | int | 10001 | Number of time slices for $K(\tau)$ | -+----------------+-------------+---------+--------------------------------------------------------------+ \ No newline at end of file ++----------------+-------------+---------+----------------------------------------------------------------+ +| Parameter Name | Type | Default | Documentation | ++================+=============+=========+================================================================+ +| beta | double | -- | Inverse temperature | ++----------------+-------------+---------+----------------------------------------------------------------+ +| gf_struct | gf_struct_t | -- | Structure of the Green's function (names and sizes of blocks) | ++----------------+-------------+---------+----------------------------------------------------------------+ +| n_tau | int | 10001 | Number of time slices for fermionic functions | ++----------------+-------------+---------+----------------------------------------------------------------+ +| n_tau_k | int | 10001 | Number of time slices for bosonic functions | ++----------------+-------------+---------+----------------------------------------------------------------+ \ No newline at end of file diff --git a/python/triqs_ctseg/parameters_solve_params_t.rst b/python/triqs_ctseg/parameters_solve_params_t.rst index 6e60da6..428fda8 100644 --- a/python/triqs_ctseg/parameters_solve_params_t.rst +++ b/python/triqs_ctseg/parameters_solve_params_t.rst @@ -39,7 +39,7 @@ +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | move_swap_spin_lines | bool | true | Whether to perform the move swap spin lines | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_perturbation_order_histograms | bool | true | Whether to measure the perturbation order histograms (Order in Delta, and Jperp) | +| measure_perturbation_order_histograms | bool | true | Whether to measure the perturbation order histograms (order in Delta and Jperp) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_gt | bool | true | Whether to measure G(tau) (see [[measure_g_f_tau]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ @@ -49,11 +49,11 @@ +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_sign | bool | true | Whether to measure sign (see [[measure_sign]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_nn | bool | false | Whether to measure (see [[measure_nn]]) | +| measure_nn | bool | false | Whether to measure (see [[measure_nn]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_nnt | bool | false | Whether to measure langle n(tau)n(0)rangle (see [[measure_nnt]]) | +| measure_nnt | bool | false | Whether to measure (see [[measure_nnt]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_sperpt | bool | false | Whether to measure langle s_x(tau)s_x(0)rangle (see [[measure_sperp_tau]]) | +| measure_sperpt | bool | false | Whether to measure (see [[measure_sperp_tau]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_statehist | bool | false | Whether to measure state histograms (see [[measure_statehist]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ diff --git a/python/triqs_ctseg/solver.py b/python/triqs_ctseg/solver.py index e191648..e84e1e4 100644 --- a/python/triqs_ctseg/solver.py +++ b/python/triqs_ctseg/solver.py @@ -6,19 +6,22 @@ # === The SolverCore Wrapper class Solver(SolverCore): + """ + The solver class. + """ def __init__(self, **kwargs): """ - Initialise the solver. + Initialize the solver. Parameters ---------- - Cf. C++ documentation of SolverCore + .. include:: ../../python/triqs_ctseg/parameters_constr_params_t.rst """ kwargs['gf_struct'] = fix_gf_struct_type(kwargs['gf_struct']) - # Initialise the core solver + # Initialize the solver SolverCore.__init__(self, **kwargs) def solve(self, **kwargs): @@ -27,7 +30,7 @@ def solve(self, **kwargs): Parameters ---------- - Cf. C++ documentation of SolverCore.solve(..) + .. include:: ../../python/triqs_ctseg/parameters_solve_params_t.rst """ # Solve the impurity problem diff --git a/python/triqs_ctseg/solver_core_desc.py b/python/triqs_ctseg/solver_core_desc.py index 3d3cff9..4457901 100644 --- a/python/triqs_ctseg/solver_core_desc.py +++ b/python/triqs_ctseg/solver_core_desc.py @@ -97,33 +97,37 @@ c.add_member(c_name = "constr_params", c_type = "constr_params_t", read_only= True, - doc = r"""Solver construction parameters""") + doc = r"""Set of parameters used in the construction of the ``solver_core`` class. -c.add_member(c_name = "last_solve_params", +.. include:: ../../python/triqs_ctseg/parameters_constr_params_t.rst""") + +c.add_member(c_name = "solve_params", c_type = "std::optional", read_only= True, - doc = r"""Solver solve parameters (from last call)""") + doc = r"""Set of parameters used by the last call to ``solve()``. + +.. include:: ../../python/triqs_ctseg/parameters_solve_params_t.rst""") c.add_member(c_name = "results", c_type = "results_t", read_only= True, - doc = r"""The set of results""") + doc = r"""The set of results. See :doc:`Measurements <../guide/measurements>`.""") c.add_constructor("""(**constr_params_t)""", doc = r"""Initialize the solver -+----------------+-------------+---------+--------------------------------------------------------------+ -| Parameter Name | Type | Default | Documentation | -+================+=============+=========+==============================================================+ -| beta | double | -- | Inverse temperature | -+----------------+-------------+---------+--------------------------------------------------------------+ -| gf_struct | gf_struct_t | -- | Structure of the GF (names, sizes of blocks) | -+----------------+-------------+---------+--------------------------------------------------------------+ -| n_tau | int | 10001 | Number of time slices for $Delta(\tau)$/$G(\tau)$/$F(\tau)$ | -+----------------+-------------+---------+--------------------------------------------------------------+ -| n_tau_k | int | 10001 | Number of time slices for $K(\tau)$ | -+----------------+-------------+---------+--------------------------------------------------------------+ ++----------------+-------------+---------+----------------------------------------------------------------+ +| Parameter Name | Type | Default | Documentation | ++================+=============+=========+================================================================+ +| beta | double | -- | Inverse temperature | ++----------------+-------------+---------+----------------------------------------------------------------+ +| gf_struct | gf_struct_t | -- | Structure of the Green's function (names and sizes of blocks) | ++----------------+-------------+---------+----------------------------------------------------------------+ +| n_tau | int | 10001 | Number of time slices for fermionic functions | ++----------------+-------------+---------+----------------------------------------------------------------+ +| n_tau_k | int | 10001 | Number of time slices for bosonic functions | ++----------------+-------------+---------+----------------------------------------------------------------+ """) c.add_method("""void solve (**solve_params_t)""", @@ -172,7 +176,7 @@ +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | move_swap_spin_lines | bool | true | Whether to perform the move swap spin lines | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_perturbation_order_histograms | bool | true | Whether to measure the perturbation order histograms (Order in Delta, and Jperp) | +| measure_perturbation_order_histograms | bool | true | Whether to measure the perturbation order histograms (order in Delta and Jperp) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_gt | bool | true | Whether to measure G(tau) (see [[measure_g_f_tau]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ @@ -182,11 +186,11 @@ +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_sign | bool | true | Whether to measure sign (see [[measure_sign]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_nn | bool | false | Whether to measure (see [[measure_nn]]) | +| measure_nn | bool | false | Whether to measure (see [[measure_nn]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_nnt | bool | false | Whether to measure langle n(tau)n(0)rangle (see [[measure_nnt]]) | +| measure_nnt | bool | false | Whether to measure (see [[measure_nnt]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ -| measure_sperpt | bool | false | Whether to measure langle s_x(tau)s_x(0)rangle (see [[measure_sperp_tau]]) | +| measure_sperpt | bool | false | Whether to measure (see [[measure_sperp_tau]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | measure_statehist | bool | false | Whether to measure state histograms (see [[measure_statehist]]) | +---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+ @@ -322,7 +326,7 @@ c.add_member(c_name = "measure_perturbation_order_histograms", c_type = "bool", initializer = """ true """, - doc = r"""Whether to measure the perturbation order histograms (Order in Delta, and Jperp)""") + doc = r"""Whether to measure the perturbation order histograms (order in Delta and Jperp)""") c.add_member(c_name = "measure_gt", c_type = "bool", @@ -347,17 +351,17 @@ c.add_member(c_name = "measure_nn", c_type = "bool", initializer = """ false """, - doc = r"""Whether to measure (see [[measure_nn]])""") + doc = r"""Whether to measure (see [[measure_nn]])""") c.add_member(c_name = "measure_nnt", c_type = "bool", initializer = """ false """, - doc = r"""Whether to measure langle n(tau)n(0)rangle (see [[measure_nnt]])""") + doc = r"""Whether to measure (see [[measure_nnt]])""") c.add_member(c_name = "measure_sperpt", c_type = "bool", initializer = """ false """, - doc = r"""Whether to measure langle s_x(tau)s_x(0)rangle (see [[measure_sperp_tau]])""") + doc = r"""Whether to measure (see [[measure_sperp_tau]])""") c.add_member(c_name = "measure_statehist", c_type = "bool", @@ -409,17 +413,17 @@ c.add_member(c_name = "gf_struct", c_type = "gf_struct_t", initializer = """ """, - doc = r"""Structure of the GF (names, sizes of blocks)""") + doc = r"""Structure of the Green's function (names and sizes of blocks)""") c.add_member(c_name = "n_tau", c_type = "int", initializer = """ 10001 """, - doc = r"""Number of time slices for $Delta(\tau)$/$G(\tau)$/$F(\tau)$""") + doc = r"""Number of time slices for fermionic functions""") c.add_member(c_name = "n_tau_k", c_type = "int", initializer = """ 10001 """, - doc = r"""Number of time slices for $K(\tau)$""") + doc = r"""Number of time slices for bosonic functions""") module.add_converter(c)