Site operators in denominators are accepted silently; expand powers in n-site terms
Maintainers usually reply within 3 days
Assessment
This issue has not been assessed yet.
Description
Two follow-ups for site operators inside n-site terms (NSiteOperator::split, src/alps/model/include/alps/model/nsiteoperator.h), and one for the native site-term path.
1. Division by a site operator is accepted silently
Dividing by a site operator is never meaningful (Sz and n have zero eigenvalues), and no model, tutorial or example in the repository does it. Every / in a term on master divides by a number or a parameter (J#/2, n_up(i)-1/2, n(i)*(n(i)-1)/2). But the parser accepts it without an error and uses the operator in its place:
<SITETERM site="i">1/Sz(i)</SITETERM>(spin,local_S=1.5,fulldiag) gives the same spectrum asSz(i).<NSITETERM sites="a b">1/Sz(a)*Sz(b)</NSITETERM>andSz(b)/Sz(a)give the same spectrum asSz(a)*Sz(b).
A mistyped term, for example / for *, therefore runs without a message. Both paths should refuse a site operator in a denominator with an error. Division by numbers and parameters must keep working. <BONDTERM> uses the same evaluator and has not been checked yet.
2. Powers of site operators in n-site terms: expand instead of refusing
Since 5396639f8, split refuses any power of a site operator (Sz(a)^2, (Sz(a)*Sz(b))^2, (Sz(a)+Sz(b))^2, Sz(a)^p). Before that, a power was silently dropped (n(i)^2*n(j) acted as n(i)*n(j)). Site terms accept Sz(i)^2 for diagonal operators and refuse off-diagonal ones ("Cannot apply offdiagonal operator inside function argument or power"). So the same input works as a <SITETERM> and fails as an <NSITETERM>.
Proposal: in split, rewrite a positive integer power X^k as X*X*...*X before splitting, then flatten(). This is exact for diagonal and off-diagonal operators alike. Things to get right, each with a test against the written-out product:
- Order:
(A+B)^2must becomeAA + AB + BA + BB, notA^2 + 2AB + B^2. Operators on one site need not commute, and fermions pick up signs. Repeating the factor and flattening keeps the order. - Coefficients inside the power:
(K*n(a))^2givesK^2. - Exponents:
^pexpands only ifpevaluates to a positive integer. Non-integer and negative powers are still refused.^0becomes 1. - Nothing dropped: a power anywhere in a term (inside parentheses, in a sum, with a parameter exponent) is either expanded or refused, never passed through as a single operator. That was the bug fixed in 5396639f8.
dmrg and ED both build their terms from split, so both get the change.
- Dominant language
- C++
- Stars
- 32
- Forks
- 10
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 52
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ALPSim/ALPS
-
Parallel Ising example: operator precedence makes the heat-bath energy difference wrongPossibly taken @skilledwolf claimed this today. Openarea:tutorials bug scientific-correctness
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ALPSim/ALPS#313 · 1 assignee ·
Maintainers usually reply within 3 days
-
area:parapack bug scientific-correctness
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
area:lattice bug
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
Read parameter files straight into the solver input structsPossibly taken @Ooolab claimed this today. Open
ALPSim/ALPS#317 · 1 assignee ·
Maintainers usually reply within 3 days
-
alps/parapack/mpi.h: message sizes are truncated to int without a check; MPI errors are now fatal (CHANGELOG)Possibly taken @skilledwolf claimed this today. Openarea:parapack compatibility-change enhancement
Difficulty 3/5 1-2 days Newbie friendliness 57/100
ALPSim/ALPS#315 · 1 assignee ·
Maintainers usually reply within 3 days
Similar issues
-
documentation enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
QuantStack/git2cpp#203 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
BaptisteHudyma/Lamp-Da#588 ·
Maintainers usually reply within 1 day
-
bug macOS networking
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
docling-project/docling-parse#448 ·
Maintainers usually reply within 5 days