Skip to content

Commit

Permalink
finalize documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkavokine committed May 17, 2024
1 parent 818ed03 commit 295597e
Show file tree
Hide file tree
Showing 29 changed files with 146 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
14 changes: 7 additions & 7 deletions c++/triqs_ctseg/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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]])
Expand All @@ -102,13 +102,13 @@ struct solve_params_t {
/// Whether to measure sign (see [[measure_sign]])
bool measure_sign = true;

/// Whether to measure <nn> (see [[measure_nn]])
/// Whether to measure <n(0)n(0)> (see [[measure_nn]])
bool measure_nn = false;

/// Whether to measure langle n(tau)n(0)rangle (see [[measure_nnt]])
/// Whether to measure <n(tau)n(0)> (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 <s_x(tau)s_x(0)> (see [[measure_sperp_tau]])
bool measure_sperpt = false;

/// Whether to measure state histograms (see [[measure_statehist]])
Expand Down
20 changes: 10 additions & 10 deletions c++/triqs_ctseg/solver_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...................

Expand Down Expand Up @@ -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);
}
Expand All @@ -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<constr_params_t>(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;
Expand Down
16 changes: 11 additions & 5 deletions c++/triqs_ctseg/solver_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<solve_params_t> 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_t> 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;

Expand All @@ -48,7 +54,7 @@ class solver_core {
gf_view<imtime> 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);
};
7 changes: 6 additions & 1 deletion c++/triqs_ctseg/work_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(p.n_tau_k);
for (auto n : range(p.n_tau_k)) { ramp(n) = n * beta / (p.n_tau_k - 1); }
Expand All @@ -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
Expand Down
52 changes: 1 addition & 51 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
# ---------------------------------
Expand All @@ -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()

# ---------------------------------
Expand Down
6 changes: 6 additions & 0 deletions doc/_ref/triqs_ctseg.solver.Solver.constr_params.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
triqs\_ctseg.solver.Solver.constr\_params
=========================================

.. currentmodule:: triqs_ctseg.solver

.. autoattribute:: Solver.constr_params
6 changes: 0 additions & 6 deletions doc/_ref/triqs_ctseg.solver.Solver.hdf5_format.rst

This file was deleted.

5 changes: 3 additions & 2 deletions doc/_ref/triqs_ctseg.solver.Solver.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
triqs\_ctseg.solver.Solver
triqs\_ctseg.solver.Solver
==========================

.. currentmodule:: triqs_ctseg.solver
Expand All @@ -13,7 +13,6 @@ triqs\_ctseg.solver.Solver
:toctree:

~Solver.__init__
~Solver.hdf5_format
~Solver.solve


Expand All @@ -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

6 changes: 6 additions & 0 deletions doc/_ref/triqs_ctseg.solver.Solver.solve_params.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
triqs\_ctseg.solver.Solver.solve\_params
========================================

.. currentmodule:: triqs_ctseg.solver

.. autoattribute:: Solver.solve_params
32 changes: 0 additions & 32 deletions doc/_ref/triqs_ctseg.solver.rst

This file was deleted.

2 changes: 1 addition & 1 deletion doc/_templates/autosummary_module_template.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ fullname | escape | underline}}
{{ fullname | escape | underline }}

.. automodule:: {{ fullname }}

Expand Down
14 changes: 0 additions & 14 deletions doc/_templates/sideb.html

This file was deleted.

12 changes: 6 additions & 6 deletions doc/algorithm_implementation/ctseg.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):

Expand Down
Loading

0 comments on commit 295597e

Please sign in to comment.