Skip to content

Conversation

@tdavidcl
Copy link
Member

@tdavidcl tdavidcl commented Jan 1, 2026

No description provided.

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

@gemini-code-assist
Copy link

Summary of Changes

Hello @tdavidcl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the SPH simulation framework by adding the capability to generate cubic crystal lattices for particle initialization. This new feature is supported by core C++ implementations for lattice generation and is seamlessly integrated into the SPH setup module, with Python bindings provided for user convenience. The changes also include illustrative example scripts that showcase the application of these lattice structures in analyzing SPH pairing instability and overall lattice stability.

Highlights

  • Cubic Lattice Generation: Introduced a new C++ class, LatticeCubic, in shammath for generating cubic crystal lattices, complete with a discontinuous iterator for efficient point generation.
  • SPH Setup Integration: Integrated the new cubic lattice generator into the SPH setup module (SPHSetup), making it accessible for initializing particle positions in SPH simulations.
  • Python API Exposure: Exposed the make_generator_lattice_cubic function to the Python API, allowing users to easily create cubic lattice configurations from Python scripts.
  • New Example Scripts: Added two new Python example scripts (run_cubic_reorganisation.py and run_pairing_instab.py) to demonstrate the setup and stability analysis of both cubic and hexagonal close-packed (HCP) lattices in SPH simulations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for cubic lattices within the SPH simulation framework, complete with a new lattice generator and the necessary Python bindings. Additionally, it adds two example scripts that demonstrate the use of both cubic and HCP lattices for investigating lattice stability and pairing instability. The C++ implementation is well-integrated and logically sound. The Python examples are thorough, but they could be enhanced by adhering more strictly to Python's style conventions, particularly concerning the placement of imports and the elimination of redundant code. I have provided specific suggestions to address these points.


xm, ym, zm = bmin
xM, yM, zM = bmax
vol_b = (xM - xm) * (yM - ym) * (zM - zm)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable vol_b is calculated here but is not used before being recalculated on line 90 with the same values. This line is redundant and can be removed to improve code clarity.

print(f"hpart min={min_hpart} max={max_hpart} delta={max_hpart-min_hpart}")

# Compute all pairwise distances
from scipy.spatial.distance import pdist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Imports should be at the top of the file, as per the PEP 8 style guide. Placing imports inside functions (make_plot, show_image_sequence) is inefficient as the module might be re-imported multiple times, and it makes it harder to see the script's dependencies at a glance. Please move from scipy.spatial.distance import pdist (line 161), import matplotlib.animation as animation (line 233), import glob (line 242), and from PIL import Image (line 246) to the top of the script.

References
  1. Imports should be at the top of the file, as per the PEP 8 style guide. (link)


xm, ym, zm = bmin
xM, yM, zM = bmax
vol_b = (xM - xm) * (yM - ym) * (zM - zm)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable vol_b is calculated here but is not used before being recalculated on line 100 with the same values. This line is redundant and can be removed to improve code clarity.

print(f"hpart min={min_hpart} max={max_hpart} delta={max_hpart-min_hpart}")

# Compute all pairwise distances
from scipy.spatial.distance import pdist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Imports should be at the top of the file, as per the PEP 8 style guide. Placing imports inside functions (make_plot, show_image_sequence) is inefficient as the module might be re-imported multiple times, and it makes it harder to see the script's dependencies at a glance. Please move from scipy.spatial.distance import pdist (line 171), import matplotlib.animation as animation (line 243), import glob (line 252), and from PIL import Image (line 256) to the top of the script.

References
  1. Imports should be at the top of the file, as per the PEP 8 style guide. (link)

Comment on lines +427 to +434
coord_min[0] = box_min[0];
coord_max[0] = box_max[0];

coord_min[1] = box_min[1];
coord_max[1] = box_max[1];

coord_min[2] = box_min[2];
coord_max[2] = box_max[2];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code can be simplified. If Tvec supports assignment, you can replace these lines with coord_min = box_min; and coord_max = box_max; for better readability.

Suggested change
coord_min[0] = box_min[0];
coord_max[0] = box_max[0];
coord_min[1] = box_min[1];
coord_max[1] = box_max[1];
coord_min[2] = box_min[2];
coord_max[2] = box_max[2];
coord_min = box_min;
coord_max = box_max;

Comment on lines +492 to +496
// std::array<i32, 3> current = {
// coord_min[0] + i32(current_idx / (coord_delta[1] * coord_delta[2])),
// coord_min[1] + i32((current_idx / coord_delta[2]) % coord_delta[1]),
// coord_min[2] + i32(current_idx % coord_delta[2]),
// };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out code block appears to be dead code and should be removed to improve readability.

current[1] = remapped_indices[1][current[1]];
current[2] = remapped_indices[2][current[2]];

// logger::raw_ln(current, current_idx, max_coord);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out logging statement should be removed from production code to keep it clean.

static auto init_gen(Tscal dr, std::pair<Tvec, Tvec> box) {

auto [idxs_min, idxs_max] = Lattice::get_box_index_bounds(dr, box.first, box.second);
u32 idx_gen = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable idx_gen is declared and initialized but never used. It should be removed.

u32 len = pos_data.size();
PatchDataField<Tvec> &f
= tmp.get_field<Tvec>(sched.pdl().get_field_idx<Tvec>("xyz"));
// sycl::buffer<Tvec> buf(pos_data.data(), len);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out line of code should be removed to improve code clarity.

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

Workflow report

workflow report corresponding to commit ac03681
Commiter email is timothee.davidcleris@proton.me
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 25
New warnings : 37
Warnings count : 7610 → 7622 (0.2%)

Detailed changes :
+ src/shammath/include/shammath/crystalLattice.hpp:396: warning: Member dim (variable) of class shammath::LatticeCubic is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:401: warning: Member Tscal (typedef) of class shammath::LatticeCubic is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:422: warning: Member get_box_index_bounds(Tscal dr, Tvec box_min, Tvec box_max) (function) of class shammath::LatticeCubic is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:462: warning: Member current_idx (variable) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:463: warning: Member IteratorDiscontinuous(Tscal dr, std::array< i32, dim > coord_min, std::array< i32, dim > coord_max) (function) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:488: warning: Member is_done() (function) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:490: warning: Member next() (function) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:522: warning: Member next_n(u64 nmax) (function) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
+ src/shammath/include/shammath/crystalLattice.hpp:535: warning: Member skip(u64 n) (function) of class shammath::LatticeCubic::IteratorDiscontinuous is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:65: warning: Member make_generator_disc_mc(Tscal part_mass, Tscal disc_mass, Tscal r_in, Tscal r_out, std::function< Tscal(Tscal)> sigma_profile, std::function< Tscal(Tscal)> H_profile, std::function< Tscal(Tscal)> rot_profile, std::function< Tscal(Tscal)> cs_profile, std::mt19937 eng, Tscal init_h_factor) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:65: warning: Member make_generator_lattice_cubic(Tscal dr, std::pair< Tvec, Tvec > box) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:68: warning: Member make_generator_disc_mc(Tscal part_mass, Tscal disc_mass, Tscal r_in, Tscal r_out, std::function< Tscal(Tscal)> sigma_profile, std::function< Tscal(Tscal)> H_profile, std::function< Tscal(Tscal)> rot_profile, std::function< Tscal(Tscal)> cs_profile, std::mt19937 eng, Tscal init_h_factor) (function) of class shammodels::sph::modules::SPHSetup is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:77: warning: Member make_combiner_add(SetupNodePtr parent1, SetupNodePtr parent2) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:80: warning: Member make_combiner_add(SetupNodePtr parent1, SetupNodePtr parent2) (function) of class shammodels::sph::modules::SPHSetup is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:80: warning: Member make_modifier_warp_disc(SetupNodePtr parent, Tscal Rwarp, Tscal Hwarp, Tscal inclination, Tscal posangle) (function) of class shammodels::sph::modules::SPHSetup is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:83: warning: Member make_modifier_custom_warp(SetupNodePtr parent, std::function< Tscal(Tscal)> inc_profile, std::function< Tscal(Tscal)> psi_profile, std::function< Tvec(Tscal)> k_profile) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:83: warning: Member make_modifier_warp_disc(SetupNodePtr parent, Tscal Rwarp, Tscal Hwarp, Tscal inclination, Tscal posangle) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:86: warning: Member make_modifier_custom_warp(SetupNodePtr parent, std::function< Tscal(Tscal)> inc_profile, std::function< Tscal(Tscal)> psi_profile, std::function< Tvec(Tscal)> k_profile) (function) of class shammodels::sph::modules::SPHSetup is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:89: warning: Member make_modifier_add_offset(SetupNodePtr parent, Tvec offset_postion, Tvec offset_velocity) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:92: warning: Member make_modifier_add_offset(SetupNodePtr parent, Tvec offset_postion, Tvec offset_velocity) (function) of class shammodels::sph::modules::SPHSetup is not documented.
- src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:92: warning: Member make_modifier_filter(SetupNodePtr parent, std::function< bool(Tvec)> filter) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/SPHSetup.hpp:95: warning: Member make_modifier_filter(SetupNodePtr parent, std::function< bool(Tvec)> filter) (function) of class shammodels::sph::modules::SPHSetup is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/setup/GeneratorLatticeCubic.hpp:29: warning: Compound shammodels::sph::modules::GeneratorLatticeCubic is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/setup/GeneratorLatticeCubic.hpp:49: warning: Member GeneratorLatticeCubic(ShamrockCtx &context, Tscal dr, std::pair< Tvec, Tvec > box) (function) of class shammodels::sph::modules::GeneratorLatticeCubic is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:187: warning: Compound SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:188: warning: Compound SetupLog::State is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:189: warning: Member count_per_rank (variable) of struct SetupLog::State is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:190: warning: Member msg_list (variable) of struct SetupLog::State is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:191: warning: Member state (variable) of struct SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:193: warning: Member step_counter (variable) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:194: warning: Compound SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:195: warning: Compound SetupLog::State is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:195: warning: Member json_data (variable) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:196: warning: Member count_per_rank (variable) of struct SetupLog::State is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:197: warning: Member log_state() (function) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:197: warning: Member msg_list (variable) of struct SetupLog::State is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:198: warning: Member state (variable) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:200: warning: Member step_counter (variable) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:202: warning: Member json_data (variable) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:204: warning: Member log_state() (function) of struct SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:205: warning: Member dump_state() (function) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:212: warning: Member dump_state() (function) of struct SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:218: warning: Member update_count_per_rank(u64 count) (function) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:225: warning: Member update_count_per_rank(u64 count) (function) of struct SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:228: warning: Member update_msg_list(std::vector< std::tuple< u32, u32, u64 > > &msg_list) (function) of struct SetupLog is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:235: warning: Member update_msg_list(std::vector< std::tuple< u32, u32, u64 > > &msg_list) (function) of struct SetupLog is not documented.
- src/shammodels/sph/src/modules/SPHSetup.cpp:236: warning: Member golden_number (variable) of file SPHSetup.cpp is not documented.
+ src/shammodels/sph/src/modules/SPHSetup.cpp:243: warning: Member golden_number (variable) of file SPHSetup.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1035: warning: Member add_analysisBarycenter_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1040: warning: Member add_analysisBarycenter_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1053: warning: Member add_analysisEnergyKinetic_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1058: warning: Member add_analysisEnergyKinetic_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1069: warning: Member add_analysisEnergyPotential_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1074: warning: Member add_analysisEnergyPotential_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1085: warning: Member add_analysisTotalMomentum_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1090: warning: Member add_analysisTotalMomentum_instance(py::module &m, std::string name_model) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1103: warning: Member analysis_impl(shammodels::sph::Model< Tvec, SPHKernel > &model) -> Analysis (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1108: warning: Member analysis_impl(shammodels::sph::Model< Tvec, SPHKernel > &model) -> Analysis (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1108: warning: Member register_analysis_impl_for_each_kernel(py::module &msph, const char *name_class) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1113: warning: Member register_analysis_impl_for_each_kernel(py::module &msph, const char *name_class) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:1169: warning: Member Register_pymod(pysphmodel) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:1174: warning: Member Register_pymod(pysphmodel) (function) of file pySPHModel.cpp is not documented.

@tdavidcl tdavidcl merged commit ea1c895 into Shamrock-code:main Jan 2, 2026
64 checks passed
@tdavidcl tdavidcl deleted the patch-2026-01-01-09-26 branch January 2, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant