Skip to content

Commit

Permalink
change hartree_shift to chemical_potential
Browse files Browse the repository at this point in the history
  • Loading branch information
nkavokine committed May 25, 2024
1 parent c10fea3 commit 5ea7ed9
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions c++/triqs_ctseg/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void h5_write(h5::group h5group, std::string subgroup_name, solve_params_t const
h5::group grp = subgroup_name.empty() ? h5group : h5group.create_group(subgroup_name);

h5_write(grp, "h_int", c.h_int);
h5_write(grp, "hartree_shift", c.hartree_shift);
h5_write(grp, "chemical_potential", c.chemical_potential);
h5_write(grp, "n_cycles", c.n_cycles);
h5_write(grp, "length_cycle", c.length_cycle);
h5_write(grp, "n_warmup_cycles", c.n_warmup_cycles);
Expand Down Expand Up @@ -71,7 +71,7 @@ void h5_read(h5::group h5group, std::string subgroup_name, solve_params_t &c) {
h5::group grp = subgroup_name.empty() ? h5group : h5group.open_group(subgroup_name);

h5_read(grp, "h_int", c.h_int);
h5_read(grp, "hartree_shift", c.hartree_shift);
h5_read(grp, "chemical_potential", c.chemical_potential);
h5_read(grp, "n_cycles", c.n_cycles);
h5_read(grp, "length_cycle", c.length_cycle);
h5_read(grp, "n_warmup_cycles", c.n_warmup_cycles);
Expand Down
2 changes: 1 addition & 1 deletion c++/triqs_ctseg/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct solve_params_t {
triqs::operators::many_body_operator h_int;

/// Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`)
nda::vector<double> hartree_shift = nda::vector<double>{};
nda::vector<double> chemical_potential = nda::vector<double>{};

/// Number of QMC cycles
int n_cycles;
Expand Down
6 changes: 3 additions & 3 deletions c++/triqs_ctseg/work_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi

// Color-dependent chemical potential
mu = nda::zeros<double>(n_color);
if (p.hartree_shift.size() > 0) {
ALWAYS_EXPECTS((p.hartree_shift.size() == n_color), "Hartree shift size is not {}", n_color);
mu = p.hartree_shift;
if (p.chemical_potential.size() > 0) {
ALWAYS_EXPECTS((p.chemical_potential.size() == n_color), "Hartree shift size is not {}", n_color);
mu = p.chemical_potential;
}

// .............. Interactions .................
Expand Down
30 changes: 15 additions & 15 deletions doc/guide/step_by_step.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,14 @@ If a rotation is required, then the interactions should also be rotated accordin
Chemical potential
------------------

The orbital-dependent chemical potential is passed to the solver as the solve parameter ``hartree_shift`` (see below),
The orbital-dependent chemical potential is passed to the solver as the solve parameter ``chemical_potential`` (see below),
a list with one value per color. For example, for the single-orbital problem::

hartree_shift = [mu, mu]
chemical_potential = [mu, mu]

.. warning::

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::
.. note::

hartree_shift_ctseg = [mu_list[i] + hartree_shift_cthyb[i] for i in range(n_colors)]
This is different from the Delta interface in CTHYB, which takes ``h0`` (supplied as TRIQS operator) as an input.

Dynamical density-density interaction
-------------------------------------
Expand All @@ -178,8 +172,14 @@ The dynamical density-density interaction :math:`D(\tau)` (see :doc:`CTSEG algor

D_tau = GfImTime(indices = range(n_colors), beta = beta, statistic = "Boson", n_points = n_tau_k)

It is a matrix Green's function, for which no block structure is explicitly enforced. The data in
``D_tau`` can be specified manually (``D_tau.data = ...``) or by using an analytical expression.
It is a matrix Green's function, for which no block structure is explicitly enforced.

.. note::

The ordering of the rows and columns in ``D_tau`` is consistent with the ordering of the blocks in ``Delta_tau``.


The data in ``D_tau`` can be specified manually (``D_tau.data = ...``) or by using an analytical expression.
For example::

from triqs.gf.descriptors import Function
Expand Down Expand Up @@ -226,15 +226,15 @@ The following parameters need to be specified for every run. For example::

solve_params = {
"h_int": h_int,
"hartree_shift": hartree_shift,
"chemical_potential": chemical_potential,
"length_cycle": 50,
"n_warmup_cycles": 20000,
"n_cycles": 200000
}

* ``h_int`` is the local interaction Hamiltonian (see above).

* ``hartree_shift`` is the total orbital-dependent chemical potential (see above).
* ``chemical_potential`` is the total orbital-dependent chemical potential (see above).

* ``length_cycle`` is the length of a Monte Carlo cycle. Observables are sampled every ``length_cycle`` Monte Carlo moves (either accepted or rejected).

Expand Down Expand Up @@ -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 :doc:`CTSEG algorithm <../algorithm_implementation/ctseg>`).
in ``h_int`` and ``chemical_potential`` (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.01)
are generally a sign that something went wrong. However, some of the moves (``split_spin_segment``, ``regroup_spin_segment``)
Expand Down
2 changes: 1 addition & 1 deletion python/triqs_ctseg/parameters_solve_params_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+=======================================+======================================+=========================================+===================================================================================================================+
| h_int | triqs::operators::many_body_operator | -- | Local Hamiltonian |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| hartree_shift | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
| chemical_potential | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| n_cycles | int | -- | Number of QMC cycles |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions python/triqs_ctseg/solver_core_desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
+=======================================+======================================+=========================================+===================================================================================================================+
| h_int | triqs::operators::many_body_operator | -- | Local Hamiltonian |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| hartree_shift | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
| chemical_potential | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| n_cycles | int | -- | Number of QMC cycles |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -233,7 +233,7 @@
initializer = """ """,
doc = r"""Local Hamiltonian""")

c.add_member(c_name = "hartree_shift",
c.add_member(c_name = "chemical_potential",
c_type = "nda::vector<double>",
initializer = """ nda::vector<double>{} """,
doc = r"""Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`)""")
Expand Down
2 changes: 1 addition & 1 deletion test/c++/anderson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(CTSEGJ, Anderson) {

// Solve parameters
param_solve.h_int = U * n("up", 0) * n("down", 0);
param_solve.hartree_shift = {mu, mu};
param_solve.chemical_potential = {mu, mu};
param_solve.n_cycles = n_cycles;
param_solve.n_warmup_cycles = n_warmup_cycles;
param_solve.length_cycle = length_cycle;
Expand Down
2 changes: 1 addition & 1 deletion test/c++/dynamical_U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(CTSEGJ, Dynamical_U) {

// Solve parameters
param_solve.h_int = U * n("up", 0) * n("down", 0);
param_solve.hartree_shift = {mu, mu};
param_solve.chemical_potential = {mu, mu};
param_solve.n_cycles = n_cycles;
param_solve.n_warmup_cycles = n_warmup_cycles;
param_solve.length_cycle = length_cycle;
Expand Down
2 changes: 1 addition & 1 deletion test/c++/jperp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(CTSEGJ, J_perp) {

// Solve parameters
param_solve.h_int = U * n("up", 0) * n("down", 0);
param_solve.hartree_shift = {mu, mu};
param_solve.chemical_potential = {mu, mu};
param_solve.n_cycles = n_cycles;
param_solve.n_warmup_cycles = n_warmup_cycles;
param_solve.length_cycle = length_cycle;
Expand Down
2 changes: 1 addition & 1 deletion test/c++/spin_spin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(CTSEGJ, Spin_Spin) {

// Solve parameters
param_solve.h_int = U * n("up", 0) * n("down", 0);
param_solve.hartree_shift = {mu, mu};
param_solve.chemical_potential = {mu, mu};
param_solve.n_cycles = n_cycles;
param_solve.n_warmup_cycles = n_warmup_cycles;
param_solve.length_cycle = length_cycle;
Expand Down
10 changes: 5 additions & 5 deletions test/python/dimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
gf_struct = [(s, n_orb) for s in block_names] # Green's function structure

########################################################################
# --------------- Construct Delta(tau) and hartree_shift ---------------
# --------------- Construct Delta(tau) and chemical_potential ---------------

# Non-interacting impurity Hamiltonian in matrix representation
h_0_mat = np.diag(eps - mu)
Expand All @@ -54,7 +54,7 @@
for bl, iw in product(block_names, iw_mesh):
G0_iw[bl][iw] = linalg.inv(iw.value * np.eye(2*n_orb) - h_tot_mat)[:n_orb, :n_orb]

# Get Delta(iw) and hartree_shift from G0(iw)
# Get Delta(iw) and chemical_potential from G0(iw)
def get_h0_Delta(G0_iw):
h0_lst, Delta_iw = [], G0_iw.copy()
for bl in G0_iw.indices:
Expand All @@ -65,9 +65,9 @@ def get_h0_Delta(G0_iw):
return h0_lst, Delta_iw

h0_lst, Delta_iw = get_h0_Delta(G0_iw)
hartree_shift = []
chemical_potential = []
for h0 in h0_lst:
hartree_shift += [-l for l in linalg.eig(h0)[0].real]
chemical_potential += [-l for l in linalg.eig(h0)[0].real]

# Fourier-transform to get Delta(tau)
tau_mesh = MeshImTime(beta, 'Fermion', n_tau)
Expand Down Expand Up @@ -96,7 +96,7 @@ def get_h0_Delta(G0_iw):
# --------- Solve parameters ----------
solve_params = {
'h_int': h_int,
'hartree_shift': hartree_shift,
'chemical_potential': chemical_potential,
'n_warmup_cycles': 5000,
'n_cycles': 50000,
'length_cycle': 100,
Expand Down
2 changes: 1 addition & 1 deletion test/python/multiorb.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# Solve parameters
solve_params = {
"h_int": h_int,
"hartree_shift": [mu] * 2 * n_orb,
"chemical_potential": [mu] * 2 * n_orb,
"length_cycle": 50,
"n_warmup_cycles": 1000,
"n_cycles": 10000,
Expand Down
2 changes: 1 addition & 1 deletion test/python/parameters_solve_params_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
+=======================================+======================================+=========================================+===================================================================================================================+
| h_int | triqs::operators::many_body_operator | -- | Local Hamiltonian |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| hartree_shift | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
| chemical_potential | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| n_cycles | int | -- | Number of QMC cycles |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions test/python/solver_core_desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
+=======================================+======================================+=========================================+===================================================================================================================+
| h_int | triqs::operators::many_body_operator | -- | Local Hamiltonian |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| hartree_shift | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
| chemical_potential | nda::vector<double> | nda::vector<double>{} | Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`) |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| n_cycles | int | -- | Number of QMC cycles |
+---------------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -233,7 +233,7 @@
initializer = """ """,
doc = r"""Local Hamiltonian""")

c.add_member(c_name = "hartree_shift",
c.add_member(c_name = "chemical_potential",
c_type = "nda::vector<double>",
initializer = """ nda::vector<double>{} """,
doc = r"""Chemical potential (high frequency limit of :math:`G_0^{-1}(i\omega) - i \omega`)""")
Expand Down
2 changes: 1 addition & 1 deletion test/python/spin_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# Solve parameters
solve_params = {
"h_int": U*n("up", 0)*n("down", 0),
"hartree_shift": [mu, mu],
"chemical_potential": [mu, mu],
"length_cycle": 50,
"n_warmup_cycles": 1000,
"n_cycles": 10000,
Expand Down
2 changes: 1 addition & 1 deletion test/python/two_orbitals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Solve parameters
solve_params = {
"h_int": 0*n("up", 0)*n("down", 0),
"hartree_shift": [mu] * 2 * n_orb,
"chemical_potential": [mu] * 2 * n_orb,
"length_cycle": 50,
"n_warmup_cycles": 1000,
"n_cycles": 10000,
Expand Down

0 comments on commit 5ea7ed9

Please sign in to comment.