Conversation
… is consistent with N_FL
There was a problem hiding this comment.
Pull request overview
Adds a centralized safety/validation layer to ensure Hamiltonian-global variables and core arrays are initialized and correctly set by each Ham_Set, preventing undefined/uninitialized state from propagating into the Monte Carlo core.
Changes:
- Initialize key Hamiltonian globals (
Ndim,N_FL,N_SUN,Ltrot,Thtrot,Projector,Symm) to sentinel/safe defaults inAlloc_Ham. - Validate required Hamiltonian globals and allocations right after
ham%Ham_set()(includingOp_V,Op_T, and projector trial wavefunctions). - Ensure
Thtrotis explicitly initialized in several HamiltonianHam_Setimplementations.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Prog/main.F90 |
Calls Validate_Ham_Variables() immediately after ham%Ham_set(); removes redundant projector WF allocation pre-check now covered by validation. |
Prog/Hamiltonian_main_mod.F90 |
Adds sentinel initialization (Init_Ham_Variables) and post-Ham_Set validation (Validate_Ham_Variables); exports the validator. |
Prog/Hamiltonians/Hamiltonian_Hubbard_smod.F90 |
Explicitly initializes Thtrot = 0 before computing Ltrot. |
Prog/Hamiltonians/Hamiltonian_Kondo_smod.F90 |
Explicitly initializes Thtrot = 0 before computing Ltrot. |
Prog/Hamiltonians/Hamiltonian_Spin_Peierls_smod.F90 |
Explicitly initializes Thtrot = 0 before computing Ltrot. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…te unsued variables in Get_Delta_S0_global_base
|
Thanks, @jonasschwab , for already taking a look at this. We run into this today where we noticed that we ran ALF with N_SUN=0, as it was not set explicitly anywhere. surprisingly, the code ran rather well and the results (mostly) made sense. but the fermion determinate did NOT influence the acceptance/rejection of the Metropolis step. Since we are at enhancing the 'security' of the model definition: Are you aware of other implicit assumptions that we are relying on without checking them explicitly? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot During review on GitHub, copilot provided the following suggestion: |
Agent-Logs-Url: https://github.com/ALF-QMC/ALF/sessions/3f0f3c08-432d-4df4-bd80-a092b67bc03d Co-authored-by: johanneshofmann87 <129625831+johanneshofmann87@users.noreply.github.com>
Done in commit b952e94. The Hermiticity scan and diagonal-detection now share a single O(N²) upper-triangle pass: |
|
@jonasschwab @fassaad I think this update covers some important consistency checks for models implemented by users that I am aware of. Do you know of additional implicit assumptions that we are not enforcing in the code? |
|
One could also add a test if the arrangement of operators is indeed symmetric if |
- Introduced Op_equal function to compare Operator instances. - Added Op_V_is_symmetric function to verify symmetry of operator sequences. - Implemented tests for Op_equal and Op_V_is_symmetric, including cases for both symmetric and asymmetric arrangements. - Updated CMakeLists.txt to include new test files.
johanneshofmann87
left a comment
There was a problem hiding this comment.
One could also add a test if the arrangement of operators is indeed symmetric if
Symmis true.
I implemented such a test in the last commit.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ALF-QMC/ALF/sessions/17c4f4b1-6a95-4987-9d7b-163442ea8aeb Co-authored-by: johanneshofmann87 <129625831+johanneshofmann87@users.noreply.github.com>
|
@copilot update the description of this PR to reflect the actual changes implemented here. |
Updated the PR description to accurately list all changes implemented: sentinel initialization, |
Adds a centralized safety/validation layer to ensure Hamiltonian-global variables and core arrays are initialized and correctly set by each
Ham_Set, preventing undefined/uninitialized state from propagating into the Monte Carlo core.Changes Made
Ndim,N_FL,N_SUN,Ltrot,Thtrot,Projector,Symm) to sentinel/safe defaults inAlloc_Ham.ham%Ham_set()(includingOp_V,Op_T, and projector trial wavefunctions).Thtrotis explicitly initialized in relevantHam_Setimplementations.Op_setto validate operator matrices, merging Hermiticity and diagonal-detection into a single O(N²) upper-triangle pass.Op_equalfunction inOperator_modto compare twoOperatorinstances on their defining properties (used for structural checks).Op_V_is_symmetricfunction inOperator_modthat verifies the product(I+g₁V₁)···(I+gₙVₙ)equals its reverse — satisfied by palindromic arrangement or mutually commuting operators.P(i)inOp_VandOp_Tare within[1, Ndim]inValidate_Ham_Variables, preventing out-of-bounds memory access before any matrix indexing occurs.Op_Voperator sequence is symmetric whenSymm = .true., terminating with a clear error if not.iso_fortran_envimport forerror_unitinOperator_mod.Op_setvalidation (tests 28–32), including Hermiticity failure, type failure, projector index failure, and 1×1 matrix failure.Op_equalandOp_V_is_symmetric(tests 33–35): operator equality comparison, symmetricOp_Vpass, and asymmetricOp_Vfail.