CT-INT: FourierTransformer and U_matrix default FLAVORS to 2 while the solver falls back to N_ORBITALS

Open
#335 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
backend

Research direction

Read src/apps/dmft/qmc/fouriertransform.C, src/apps/dmft/qmc/U_matrix.h, and the solver’s flavor-count handling to see how defaults reach the legacy consumers. Reproduce the reported case with N_ORBITALS = 4 and no FLAVORS; the issue suggests adding a regression test and running it under the sanitizer build. Done means the consumers use the solver’s resolved flavor count and the regression test passes.

Written by the indexing model from the issue text.

Description

Summary

The CT-INT solver (interaction) and the legacy code it calls disagree on the number of flavors when FLAVORS is not given:

Where Number of flavors without FLAVORS
Solver (ctint_parameters::n_flavors on master, read_ctint_parameters in #288) N_ORBITALS
FourierTransformer::generate_transformer / generate_transformer_U (src/apps/dmft/qmc/fouriertransform.C) 2, via value_or_default("FLAVORS", 2)
U_matrix (src/apps/dmft/qmc/U_matrix.h) 2, via value_or_default("FLAVORS", 2)

The legacy consumers receive an alps::Parameters built by make_deprecated_parameters, which since 9de5b581a copies only the keys the user supplied. A resolved flavor count never reaches them; they see FLAVORS only if it was in the input.

Consequence

With N_ORBITALS = 4 and no FLAVORS:

  • The solver uses 4 flavors. MultiBandDensityHubbardInteractionExpansion::try_add (interaction_expansion2/model.cpp) draws flavor1 and flavor2 from [0, 4) and evaluates U(flavor1, flavor2).
  • U_matrix was built with nf_ = 2. operator() returns val_[flavor_i*nf_ + flavor_j] from a 4-element array, so indices up to 15 are read past the end of the heap allocation.
  • The Fourier transformers are built for 2 flavors, while the Green's functions they transform have 4.

I found this by reading the code and have not run it. Expect a crash, or silently wrong results (garbage interaction values and tail coefficients). It affects standalone interaction runs, and dmft runs whose parameters set N_ORBITALS but not FLAVORS.

This is already on master; #288 does not change it.

Possible fix

Pass the resolved flavor count to the legacy consumers, for example by adding FLAVORS to the Parameters built for U_matrix and the Fourier transformers. Alternatively, make those consumers fall back to N_ORBITALS the way the solver does. A regression test with N_ORBITALS = 4 and no FLAVORS would catch it. Running it under the sanitizer build would show the out-of-bounds read.

Dominant language
C++
Stars
32
Forks
10
Avg merge
4d 3h
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ALPSim/ALPS

All issues in ALPSim/ALPS

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.