Skip to content
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

Fixes to BrillouinSpglibExt as suggested in #26 #27

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

mfherbst
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2023

Codecov Report

Merging #27 (7832df1) into master (1aa1e32) will decrease coverage by 0.30%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
- Coverage   85.95%   85.65%   -0.30%     
==========================================
  Files          14       14              
  Lines         968      969       +1     
==========================================
- Hits          832      830       -2     
- Misses        136      139       +3     
Files Coverage Δ
ext/BrillouinSpglibExt.jl 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@thchr
Copy link
Owner

thchr commented Oct 13, 2023

Thanks! This should probably also bump the version of Spglib in Project.toml:

Spglib = "0.6"

@mfherbst
Copy link
Contributor Author

For sure ! Thanks @thchr

@mfherbst
Copy link
Contributor Author

These failures look like they are due to changes in the ordering of matrices (rows versus columns etc.) @singularitti any idea which of your changes could cause this ?

@singularitti
Copy link
Contributor

I probably transposed some matrices to align with Spglib's mathematical convention. I will have a look at these errors.

@mfherbst
Copy link
Contributor Author

Got it. It actually was that @singularitti plus a small inconsistency in the code.

@singularitti
Copy link
Contributor

singularitti commented Oct 16, 2023

Alright, I've reviewed your code and compared it to my convention. It appears that Michael's fix is indeed correct.

In Spglib's convention, when you transform the reference axes, you apply the transformation matrix by multiplying it on the right, denoted as P:

Transformation

However, when you rotate the axes during idealization to get dataset.std_lattice, you multiply the rotation matrix R on the left:

Rotation

I realized that in versions prior to v0.8, I was using the inconsistent convention, which resulted in the rotation matrix being the transpose of the current convention. Interestingly, this happened to align with your convention.

I'm also checking if dataset.transformation_matrix might be affected by this change. @mfherbst, did you use dataset.transformation_matrix in your code?

Apart from that, I have conducted extensive tests since v0.8, and it seems that the current convention is indeed the correct one.

I have a couple of suggestions:

  1. Consider changing points(kp)[lab] = rotation' * kv to points(kp)[lab] = transpose(rotation) * kv. Using transpose makes it more explicit and easier to understand.

  2. Instead of eachcol, you can use pRs = SVector{3}(Spglib.basisvectors(dset.std_lattice)) and pRs_original = SVector{3}(Spglib.basisvectors(cell.lattice). These are part of the official API I provided, which can enhance code readability and maintainability.

Feel free to let me know your thoughts or if you have any further questions!

@thchr
Copy link
Owner

thchr commented Oct 16, 2023

This seems to work now, at least on the latest Julia version. I don't quite understand the errors on Julia master, but I suppose that could well be a master-issue rather than an issue related to this PR.

Let me know when you are happy with the PR @mfherbst and I'll merge.

@thchr
Copy link
Owner

thchr commented Oct 16, 2023

And thanks for double checking everything @singularitti: really nice to have it settled and carefully checked.

@mfherbst
Copy link
Contributor Author

mfherbst commented Oct 18, 2023

Thanks for the comments @singularitti. I changed the code according to your second suggestion. I don't think the first is worth the additional characters 😄: In Julia the tick is quite wide-spread to transpose a matrix and the comment should make clear why.

@mfherbst
Copy link
Contributor Author

Good to go from my end now @thchr !

@thchr
Copy link
Owner

thchr commented Oct 18, 2023

Brilliant; many thanks!

@thchr thchr merged commit e9821cb into thchr:master Oct 18, 2023
6 of 7 checks passed
@mfherbst mfherbst deleted the patch-1 branch October 18, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants