Add new search algorithm#7331
Open
19hello wants to merge 9 commits intodeepmodeling:developfrom
Open
Conversation
added 9 commits
January 16, 2026 17:08
… search_algorithm
There was a problem hiding this comment.
Pull request overview
This PR introduces a new cell neighbor-search implementation (bin-based neighbor list) under source_cell/module_neighbor_search and integrates it into the Lennard-Jones ESolver path, with accompanying build wiring and unit tests. It also adjusts an existing PW float test threshold to account for precision differences.
Changes:
- Added
module_neighbor_search(NeighborSearch + BinManager + NeighborList/PageAllocator) and hooked it into the build (CMake + Makefile.Objects). - Updated
UnitCellto implement a newIAtomProviderinterface; addedUnitCellPlusadapter. - Switched
ESolver_LJneighbor iteration from the legacy grid neighbor search to the new NeighborSearch implementation and added unit tests for the new module.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/01_PW/208_PW_CG_float/threshold | Loosened integration threshold for float PW CG test. |
| source/source_esolver/esolver_lj.h | Included UnitCellPlus and added conversion helper declaration. |
| source/source_esolver/esolver_lj.cpp | Integrated new NeighborSearch into LJ runner (replacing legacy neighbor driver code path). |
| source/source_cell/unitcell.h | Made UnitCell implement IAtomProvider by adding accessor overrides. |
| source/source_cell/module_neighbor_search/unitcell_interface.h | Added IAtomProvider interface for neighbor search inputs. |
| source/source_cell/module_neighbor_search/unitcell_plus.h | Added UnitCellPlus adapter implementing IAtomProvider. |
| source/source_cell/module_neighbor_search/neighbor_atom.h | Added neighbor atom/value types used by the new neighbor search. |
| source/source_cell/module_neighbor_search/neighbor_list.h | Added NeighborList + PageAllocator for adjacency storage. |
| source/source_cell/module_neighbor_search/bin_manager.h | Added binning manager interface. |
| source/source_cell/module_neighbor_search/bin_manager.cpp | Implemented bin construction, binning, and neighbor list building. |
| source/source_cell/module_neighbor_search/neighbor_search.h | Added NeighborSearch API and internal state. |
| source/source_cell/module_neighbor_search/neighbor_search.cpp | Implemented neighbor search initialization, expansion, and domain logic. |
| source/source_cell/module_neighbor_search/CMakeLists.txt | Added object library target and conditional test subdir. |
| source/source_cell/module_neighbor_search/test/CMakeLists.txt | Added test targets for new module. |
| source/source_cell/module_neighbor_search/test/neighbor_search_test.cpp | Added gtest coverage for NeighborSearch. |
| source/source_cell/module_neighbor_search/test/bin_manager_test.cpp | Added gtest coverage for BinManager. |
| source/source_cell/module_neighbor_search/test/neighbor_list_test.cpp | Added gtest coverage for PageAllocator/NeighborList. |
| source/source_cell/module_neighbor_search/test/test_neighbor_search.cpp | Added additional tests file (currently not built). |
| source/source_cell/CMakeLists.txt | Added module_neighbor_search subdirectory to cell build. |
| source/Makefile.Objects | Added neighbor_search objects to Makefile build graph. |
| CMakeLists.txt | Linked neighbor_search into main executable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+44
to
+49
| void NeighborSearch::init(const IAtomProvider& ucell, double sr, int mpi_rank) | ||
| { | ||
| search_radius = sr / ucell.get_lat0(); | ||
| Check_Expand_Condition(ucell); | ||
| setMemberVariables(ucell); | ||
| InputAtoms atoms = ucell_to_input_atoms(ucell); |
Comment on lines
+51
to
+54
| int mpi_size = 1; | ||
| int nx, ny, nz; | ||
| decompose(mpi_size, nx, ny, nz); | ||
|
|
Comment on lines
+56
to
+57
| y = (mpi_rank % (nx * ny)) / ny; | ||
| x = mpi_rank % (nx * ny) % ny; |
Comment on lines
+67
to
+71
| if(wide_x==0) | ||
| { | ||
| if(all_atoms[i].position_x==atoms.x_low) | ||
| { | ||
| in_x = x; |
| } | ||
| } | ||
|
|
||
| neighbor_list.initialize(inside_atoms.size(), 100000000); |
| classname = "ESolver_LJ"; | ||
| } | ||
|
|
||
| UnitCellPlus change_from_ucell_to_ucell_plus(UnitCell& ucell); |
| ../bin_manager.cpp | ||
| ) | ||
|
|
||
| AddTest( |
Comment on lines
+151
to
+155
| void NeighborSearch::Check_Expand_Condition(const IAtomProvider& ucell) | ||
| { | ||
| double a23_1 = ucell.get_latvec().e22 * ucell.get_latvec().e33 - ucell.get_latvec().e23 * ucell.get_latvec().e32; | ||
| double a23_2 = ucell.get_latvec().e21 * ucell.get_latvec().e33 - ucell.get_latvec().e23 * ucell.get_latvec().e31; | ||
| double a23_3 = ucell.get_latvec().e21 * ucell.get_latvec().e32 - ucell.get_latvec().e22 * ucell.get_latvec().e31; |
Comment on lines
+273
to
+281
| // with mpi_size fixed to 1 in init, nx=ny=nz=1; for rank 0 expect x=y=0,z=0 | ||
| EXPECT_EQ(ns0.x, 0); | ||
| EXPECT_EQ(ns0.y, 0); | ||
| EXPECT_EQ(ns0.z, 0); | ||
|
|
||
| NeighborSearch ns1; | ||
| ns1.init(ucell, 0.5, 1); | ||
| // rank 1: z = mpi_rank /(nx*ny) = 1, x and y remain 0 when ny==1 | ||
| EXPECT_EQ(ns1.z, 1); |
Comment on lines
+34
to
+41
| ModuleBase::Vector3<double> get_tauu(int i, int j) const override { | ||
| int count=0; | ||
| for(int k=0;k<i;k++) | ||
| { | ||
| count += na[k]; | ||
| } | ||
| count+=j; | ||
| return tau[count]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
Any changes of core modules? (ignore if not applicable)