Skip to content

[SPH] add AnalysisSPH module with method to compute barycenter#1116

Merged
tdavidcl merged 5 commits intoShamrock-code:mainfrom
DavidFang03:main
Jul 17, 2025
Merged

[SPH] add AnalysisSPH module with method to compute barycenter#1116
tdavidcl merged 5 commits intoShamrock-code:mainfrom
DavidFang03:main

Conversation

@DavidFang03
Copy link
Copy Markdown
Collaborator

@DavidFang03 DavidFang03 commented Jul 14, 2025

For example to compute the barycenter in the python script:

model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")
model.load_from_dump(f)

analysis = shamrock.analyseSPH(model=model)
barycenter, disc_mass = analysis.get_barycenter()
# [ 1.26118923e-03 -8.13370949e-04  2.48088582e-05] 0.4999949999990419

AnalysisSPH.hpp contains the definition of get_barycenter()
pyAnalyseSPH.cpp for the pybind stuff
EDIT:

model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")
model.load_from_dump(f)

analysis = shamrock.model_sph.analysisBarycenter(model=model)
barycenter, disc_mass = analysis.get_barycenter()
# [ 1.26118923e-03 -8.13370949e-04  2.48088582e-05] 0.4999949999990419

AnalysisBarycenter.hpp contains the definition of get_barycenter()
The pybind stuff has been added to pySPHModel.cpp

@y-lapeyre
Copy link
Copy Markdown
Collaborator

Hi!
Do you plan on adding other stuff to this AnalysisSPH files in the near future ? If not you should consider renaming them something more straightforward like ComputeBarycenter. Also there is no need to create a new file for the binding, you can just plug it in the pySPHModel.cpp file.
Why do you need to compute the barycenter of a simulation? What kind of simulations are you running?

@DavidFang03
Copy link
Copy Markdown
Collaborator Author

Hi!
I'm not planning to add new features immediately, but I thought it would be better to leave the possibility open.
I also wanted to separate these files from pySPHModel.cpp, as it was already quite overcrowded, and to avoid interfering with what has already been done. Tim told me it was fine, but I’ll change it if you prefer.
We’re studying an instability (the reflex instability) where the distance between the barycenter and the star grows exponentially in a basic protoplanetary disk. It has been observed with Fargo and Phantom, and I’m trying to characterize the growth timescale. We expect this timescale to independent with the code, so I am trying with Shamrock.

@y-lapeyre
Copy link
Copy Markdown
Collaborator

Ok ! Then I recommend renaming this to ComputeBarycenter, and then if we have a clearer idea for a broad analysis module we can rename it afterward. It doesn't really matter in my opinion that the binding file is crowded, since the only times people look into it it is to ctrl+f inside, + it is weird to do a new file for just 1 function. If you have time and really find pySPHModel obnoxiously long you can try to split it cleverly.

Nice project :)

Copy link
Copy Markdown
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

Very cool to see this one. I really like the shape of the module, i just have a few comments/tweaks.

Comment thread src/shammodels/sph/include/shammodels/sph/modules/AnalysisSPH.hpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/modules/AnalysisSPH.hpp Outdated
Comment thread src/shammodels/sph/src/modules/pyAnalyseSPH.cpp Outdated
@DavidFang03
Copy link
Copy Markdown
Collaborator Author

Done!

Copy link
Copy Markdown
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

almost there

Comment thread src/shammodels/sph/include/shammodels/sph/Model.hpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp Outdated
Comment thread src/shammodels/sph/src/pySPHModel.cpp Outdated
Copy link
Copy Markdown
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

.

Comment thread src/shammodels/sph/src/pySPHModel.cpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/Model.hpp
@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit 2a0f950
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............................(no files to check)Skipped
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 : 2
New warnings : 16
Warnings count : 6807 → 6821 (0.2%)

Detailed changes :
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:29: warning: Compound shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:31: warning: Member Tscal (typedef) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:32: warning: Member dim (variable) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:34: warning: Member Solver (typedef) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:36: warning: Member model (variable) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:37: warning: Member solver (variable) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:38: warning: Member ctx (variable) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:40: warning: Member AnalysisBarycenter(Model< Tvec, SPHKernel > &model) (function) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:43: warning: Compound shammodels::sph::modules::AnalysisBarycenter::result is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:44: warning: Member barycenter (variable) of struct shammodels::sph::modules::AnalysisBarycenter::result is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:45: warning: Member mass_disc (variable) of struct shammodels::sph::modules::AnalysisBarycenter::result is not documented.
+ src/shammodels/sph/include/shammodels/sph/modules/AnalysisBarycenter.hpp:50: warning: Member get_barycenter() -> result (function) of class shammodels::sph::modules::AnalysisBarycenter is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:35: warning: Member add_instance(py::module &m, std::string name_config, std::string name_model) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:37: warning: Member add_instance(py::module &m, std::string name_config, std::string name_model) (function) of file pySPHModel.cpp is not documented.
- src/shammodels/sph/src/pySPHModel.cpp:765: warning: Member Register_pymod(pysphmodel) (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:768: 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:787: warning: Member analysisBarycenter_impl(shammodels::sph::Model< Tvec, SPHKernel > &model) -> modules::AnalysisBarycenter< Tvec, SPHKernel > (function) of file pySPHModel.cpp is not documented.
+ src/shammodels/sph/src/pySPHModel.cpp:792: warning: Member Register_pymod(pysphmodel) (function) of file pySPHModel.cpp is not documented.

Copy link
Copy Markdown
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

let's merge this one !

@tdavidcl tdavidcl merged commit b1a0e99 into Shamrock-code:main Jul 17, 2025
43 checks passed
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.

3 participants