Adaptive integration for truncated octahedron#710
Adaptive integration for truncated octahedron#710pkienzle wants to merge 33 commits intoticket-535-adaptive-integrationfrom
Conversation
…ions, deleting useless functions
…less functions, renaming functions
I wasn't using the weights because of this line, not sure why i put it ?
…ions, deleting useless functions
…less functions, renaming functions
I wasn't using the weights because of this line, not sure why i put it ?
…i with np.mean and move fibonacci.py to special/ + ruff
…e to match the filename
updated description of model (first line) DOI of Wuttke's reference corrected updated last revision day
Adding nanoprisms model (pure python)
updated figure octa-truncated.png for truncated_octahedron model with the convention t=0 for no truncature.
Modified version with the convention t=0 for no truncature. t and tinv are exchanged everywhere in the code. Please double-check that I didn't messed up somewhere.
|
Today, I started updating the truncated octahedron model in order to have the convention t=0 for no truncature.
After, we will need to:
|
|
Note: in the last commit, Marianne introduced tinv (inverse) that is defined as: tinv = 1 - t, t being the new truncation parameter defined as: 0 < t < 0.5 (0 being the octahedron, 0.5 being the cuboctahedron). I have made some minors updates:
Now I will look at the remaining issues (see TO DOs in the code), especially the instabilities when q tends to 0. From what I've observed, they're are quite significant for now. |
|
I must apologize because I forgot to ask something regarding the final version of the truncated_octahedron model before the code freeze and I'm not sure on how to process. The initial truncated octahedron branch was merged a while ago and the code is not updated as we wish (especially the truncation parameter that is not consistent with the new tetrahedron model). The updated code is in the new branch called adaptative_octahedron, but in this branch, the code also contains a new adapative method that is still being studied. If I understood correctly, we can work on the adaptative method after the code freeze. So how should I update the model ? Thank you in advance for the help. |
|
I have a couple of comments/questions I guess @sara-mokhtari - In general, if this was an update to a model that has been merged, you would normally make a new branch which should contain the 'incorrect" code and then you would alter that code. Is that what you did? or did you create a completely new model? If you did the 2nd than you are not fixing the old code at all. There will be two versions if we merge which would not be ideal in any case.? Assuming your branch is changing the code for the existing truncated octahedron model then yes, you may want to make a new branch and change that model with only the changes that are not part of redoing the integration over orientations (leaving it as before) then making that a PR which can hopefully be merged before the code freeze. Depending on how the changes were committed and how comfortable you are with cherry picking, you could perhaps just cherry pick those commits to your new branch? I would ask however whether there is not a world where the new integration cannot have a working, if not ideal, version ready for the code freeze? To your question about how it should have been done, IMO I would always start with a clean branch if adding some fixes to the existing model. The other PR should just include the new integration code, but of course you need at least one model that will implement the new integration to test it and make sure it is useful. But I would have restricted all changes to the model in that branch to just what is needed to change the method of averaging. Others may suggest other approaches, but in my experience it is easiest to keep the pull requests "clean" with just the code needed for the stated purpose of that PR. |
|
Thank you a lot @butlerpd for your help ! Therefore, I will leave the adapatative-octahedron branch for its main purpose. |
|
From the purely technical point of view, changing the name of the model or of the parameters should not cause a problem right now because this model has never been in a released version. Once a model has been in a release version changing those names becomes difficult. The only other technical issue, specifically with the model name is that it is best of the file name be the same as the name attribute in the file. I believe there was a fix a while back to deal with times when that is not the case, but I'm not sure it has been well-tested? Moreover it should be best practice anyway IMO. From the perspective of being acceptable for merging, the main issue with names is that they should follow the standard convention as much as possible to make it easier for users (and also future developers). I have not thought about the polyhedron models so cannot comment on |
|
Yes thank you @butlerpd, indeed the name of the file was discussed before, and it was chosen to put "truncated_octahedron" and "truncated_tetrahedron" for consistency with other models. The name attribute was also changed in the file, and the other changes were discussed as well ! |
WARNING Applies after #658. Change base to master before merging.
Modified the truncated octahedron function to use simple adaptive integration.
I reordered the axes for speed and accuracy, and adjusted the equations to minimize computation.
Note that the formula is suspicious since the limit as q -> 0 diverges. However setting t=1 (no truncation) and simplifying, the form matches that in 1, Appendix A, which also diverges. This cites 2, but I don't have access to verify the original derivation.
Wei-Ren Chen et al. "Scattering functions of Platonic solids".
In: Journal of Applied Crystallography - J APPL CRYST 44 (June 2011).
DOI: 10.1107/S0021889811011691
Stokes, A. R. & Wilson, A. J. C. (1942). Math. Proc. Camb. Philos.
Soc. 38, 313–322. https://doi.org/10.1017/S0305004100021988