-
Notifications
You must be signed in to change notification settings - Fork 17
[SPH][Setup] Stretch mapping implementation #1372
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
base: main
Are you sure you want to change the base?
Conversation
tdavidcl
left a comment
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.
Very nice to see, great job !
Yona is starting to review this one so i won't interfere. I just had a few comments.
Also from what i see this is only in the spherical case right ? could we generalize it using a lambda to get the position and a lambda with the metric terms (1, 2pi r, 4 pi r^2, ...) such that we can apply it for any axis ?
src/shammodels/sph/include/shammodels/sph/modules/setup/GeneratorLatticeHCP_smap_sphere.hpp
Outdated
Show resolved
Hide resolved
|
Fixes done!
Do you mean something like gen = setup.make_generator_lattice_hcp_smap(dr, center, xmax, rhoprofile, system="spherical", coord="r") # spherical along r
gen = setup.make_generator_lattice_hcp_smap(dr, center, xmax, rhoprofile, system="cart", coord="y") # cartesian along ywith And then for non-isotropic objects, maybe we can allow something like gen = setup.make_generator_lattice_hcp_smap(dr, center, [xmax, ymax, zmax], [rhoprofile_x, rhoprofile_y], system="cart", coord=["x", "y"])
gen = setup.make_generator_lattice_hcp_smap(dr, center, [xmax, ymax, zmax], [rhoprofile_r, rhoprofile_z], system="cylindrical", coord=["r", "z"]) # for a disc ? |
Yeah that could be the we want it to look like in the end. For now i was thinking about the Something like (with r renamed to a to mean that it is anything, x,y,z,r,theta, ...) static Tscal stretchindiv(
Tscal a,
std::function<Tscal(Tscal)> rhoprofile, //rho(a)
std::function<Tscal(Tscal)> S, //surface element (a)
Tscal integral_profile,
Tscal rmin,
Tscal rmax,
Tvec center) {
....
auto rhodS = [&rhoprofile, &S](Tscal a) -> Tscal {
return S(a)*rhoprofile(a);
};If i'm right it is sufficient to generalize it in such a way that can supply anything (even theta/phi streching). Also maybe we can add a Tscal a = a_from_pos(r_a);
....
Tscal new_a = stretchindiv(a, rhoprofile, S, integral_profile, rmin, rmax, center);
...
Tvec new_r_a = a_to_pos(a, r_a); |
|
also for authorship related error in CI you can do |
y-lapeyre
left a comment
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.
Nicely done :)
Could you generalize this setup by turning it into a modifier that takes whatever lattice generator in input and applies the stretch transformation? You can name it something like ModifierApplyStretchMapping for instance. Inspiration can be found in ModifierOffset.hpp / cpp for instance.
|
yeah you can expect the fail with kernel_call since a std::function can not be mapped in the GPU kernel (it is a CPU function pointer which can not exist in the GPU world :sad:) |
|
if you update the branch the mail thing should be fixed |
Okay, that's what I understood, it's a good lesson |
|
I'm currently trying to migrate ModifierApplyStretchMapping into SolverGraph, I think I'll need a little feedback once I manage to compile something haha |
|
honestly as you prefer for this one, the solvergraph is really made for the solver itself so it is quite quirky when it comes to the setups. I haven't really started integrating it in that part of the code so don't worry if it is not used it there |
|
i don't see any solvergraph related thing in the current state of the PR have you committed it or did you meant the setup graph ? |
|
No I haven't committed anything yet. |
|
as you wish I'm ok with both options take whichever you prefer (or take less time). |
|
also i've invited you on the repo to skip the workflow approval, they will start right away |
|
Okay, I'll leave the SolverGraph aside for the moment I think. I'll do it if I have some time at the end of my project. For the doc I can do a call today at 5:30 pm, or Monday if that's too late. |
…th center and radius parameters instead of box boundaries + rename
…d object is coherent with the required geometry
Workflow reportworkflow report corresponding to commit 494dcad Pre-commit check reportSome failures were detected in base source checks checks. ❌ Authorship update requiredThe following files had their author headers updated by the author update script. Please run the script again ( Note: The list below is only partial. Only the first 10 files are shown.
Suggested changesDetailed changes :diff --git a/src/shammath/include/shammath/integrator.hpp b/src/shammath/include/shammath/integrator.hpp
index 9f4adebf..dc7a6bcb 100644
--- a/src/shammath/include/shammath/integrator.hpp
+++ b/src/shammath/include/shammath/integrator.hpp
@@ -11,6 +11,7 @@
/**
* @file integrator.hpp
+ * @author David Fang ([email protected])
* @author Timothée David--Cléris ([email protected])
* @brief
*
|
The goal is to have a way to initialize a distribution of particles that follows a given density profile$\rho(r)$ . We follow the stretch mapping method in Price 2018 (3.2): starting from a lattice (HCP here), each position is modified using a Newton-Raphson method, or a bisection method if necessary. In order to generate an spherical object at the end, the HCP lattice is initially cropped into a sphere and is stretched afterwards.
I've extended the HCP generator:
GeneratorLatticeHCP.hpp->GeneratorLatticeHCP_smap_sphere.hppcrystalLattice.hpp->crystalLattice_smap_sphere.hppUsage:
The given profile has to be a function of$r$ only and needs to be defined at $r=0$ because there's always one particle at the lattice center.
Tested with
3 remaining issues:
hpartis initialized with the expected value during the generation), but then the next computed smoothing length differs close to the origin and the corresponding density no longer matches there 1r2.pdf