-
Notifications
You must be signed in to change notification settings - Fork 220
Fix(hsolver): add early PW basis-size guard to report npw<nbands clearly #7237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,22 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm, | |
| #endif | ||
|
|
||
| const int cur_nbasis = psi.get_current_nbas(); | ||
| const int dim = psi.get_current_ngk(); | ||
| const int nband = psi.get_nbands(); | ||
|
|
||
| // Guard against under-complete PW basis at current k-point. | ||
| // This case is common in highly compressed cells with low ecutwfc, | ||
| // and can otherwise fail later with obscure solver-specific messages. | ||
| if (dim < nband) | ||
|
Comment on lines
+254
to
+257
|
||
| { | ||
|
Comment on lines
+251
to
+258
|
||
| std::cout << "\n ERROR in HSolverPW::hamiltSolvePsiK" << std::endl; | ||
| std::cout << " solver = " << this->method << std::endl; | ||
| std::cout << " ik (1-based) = " << nk_nums + 1 << std::endl; | ||
| std::cout << " npw(dim) = " << dim << std::endl; | ||
|
Comment on lines
+260
to
+262
|
||
| std::cout << " nbands = " << nband << std::endl; | ||
| std::cout << " Suggestion : increase ecutwfc, reduce nbands, or adjust k-mesh." << std::endl; | ||
| ModuleBase::WARNING_QUIT("HSolverPW::hamiltSolvePsiK", "insufficient plane-wave basis dimension for requested nbands"); | ||
|
Comment on lines
+259
to
+265
|
||
| } | ||
|
|
||
| // Shared matrix-blockvector operators used by all iterative solvers. | ||
| auto hpsi_func = [hm, cur_nbasis](T* psi_in, T* hpsi_out, const int ld_psi, const int nvec) { | ||
|
|
@@ -288,8 +304,8 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm, | |
| cg.diag(hpsi_func, | ||
| spsi_func, | ||
| psi.get_nbasis(), | ||
| psi.get_nbands(), | ||
| psi.get_current_ngk(), | ||
| nband, | ||
| dim, | ||
| psi.get_pointer(), | ||
| eigenvalue, | ||
| this->ethr_band, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whitespace-only change to the emitted warning text (adding a leading space before "Notice") is unrelated to the PR’s stated purpose (HSolverPW early basis-size guard). If it’s intentional, it should be called out in the PR description; otherwise consider reverting it to keep the change set focused.