Skip to content

Bugfix for bz_integration for edge case where mu and H(kx,ky,kz = 0) - #1023

Open
jcoulter12 wants to merge 2 commits into
unstablefrom
bzint_dim_eval_fix
Open

Bugfix for bz_integration for edge case where mu and H(kx,ky,kz = 0) #1023
jcoulter12 wants to merge 2 commits into
unstablefrom
bzint_dim_eval_fix

Conversation

@jcoulter12

Copy link
Copy Markdown
Contributor

In an edge case where both mu and H(k) at specifically the kx,ky,kz = 0 point, gloc or find_chemical_potential fail as nda::linalg::inv_in_place error. This originated from the deduce_dim_from_expression function, which was filling in placeholders with kx,ky,kz = 0, w=0 to evaluate the lazy expression to be integrated and find it's dimension.
This has been fixed by using the first mesh point on which a function will be evaluated instead of w=0.

Additional minor changes:
-- An unused integrate_ptr function was removed. It was never instantiated and had implementation issues anyway -- it was designed it seems, to output integrated k quantities to a gf container. We can add this later if it seems it's needed.
-- There was a problem in verbose mode with printing the remaining number of unconverged frequency points.
-- Upon suggestion from @dabramovitch, we changed the meaning of k_grid_max. Previously, we ran up to but not including the max grid. This would change the behavior to be more intuitive, running also the maximum specified grid density. As in, if k_grid_max = [10,10,10], and k_grid incremented in units of 1, before the last k_grid run would be 9,9,9. Now it will also run the 10,10,10 one before stopping.

Thanks to @dabramovitch for reporting and helping to locate this issue.

jcoulter12 and others added 2 commits July 30, 2026 10:01
…ide by zero.

- In a case where the gamma point H(k) is zero, mu is zero, the explicit function evaluations
  in bz_integrators' deduce_dim_from_expression encounters a divide by zero.
- Most straightforward fix is to pass one frequency point into the function to avoid using 0.

Co-authored-by: David Abramovitch <dabramovitch@caltech.edu>
…havior.

- Remove completely unused integrate_ptr function, which was outputing integrated quantities stored in a gf object.
  Was never instantiated, can be added back if needed later.
- Minor update to printing during verbose mode, which caused incorrect printing of the remaining number of points.
- Allow calculation to run the max specified kgrid instead of running only up to that grid size.

Co-authored-by: David Abramovitch <dabramovitch@caltech.edu>
@jcoulter12
jcoulter12 requested a review from Wentzell July 30, 2026 14:28
@jcoulter12 jcoulter12 added the Bug label Jul 30, 2026
@jcoulter12
jcoulter12 marked this pull request as ready for review July 30, 2026 15:24
@jcoulter12

Copy link
Copy Markdown
Contributor Author

I realized there may be one more even narrower edge case to handle, maybe delay review until I've looked at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant