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

Implement web JSON export #318

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Implement web JSON export #318

wants to merge 18 commits into from

Conversation

ajjackson
Copy link
Collaborator

@ajjackson ajjackson commented Oct 1, 2024

Closes #299

Current status: it basically works but there is some funny business on the x-axis. The phonon website doesn't directly support breaks in the x-axis, so we should clean them up:

  • Merge the neighbouring symbols e.g. ["X", "Y"] becomes ["X|Y"]
  • Remove duplicate q-points at direction changes e.g. ["X", "X"] becomes ["X"]
  • use the line_breaks section to restart the line
  • Remove the empty section of "distance"

Seems to be basically working!

The main limitation is that the seekpath band structures typically
include some non-contiguous sections, and the phonon website doesn't
handle those well. We might need to manipulate the distances a bit.
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Test Results

    22 files  ±0      22 suites  ±0   30m 27s ⏱️ -26s
 1 054 tests ±0   1 048 ✅ ±0   6 💤 ±0  0 ❌ ±0 
10 480 runs  ±0  10 417 ✅ ±0  63 💤 ±0  0 ❌ ±0 

Results for commit 9a1e9e3. ± Comparison against base commit 92a71b8.

♻️ This comment has been updated with latest results.

@ajjackson
Copy link
Collaborator Author

I think the mass-weighting may also need tweaking, the acoustic modes don't quite look right!

This significantly improves appearance, but there are still some oddities.
This is looking better but
- there are still some odd gaps in the band structure, especially at
  (repeated) Gamma points

- Some high-symmetry labels are put in the wrong places; usually these
  correspond to discontinuities
An off-by-one error was creating havoc with the label positions!
@ajjackson
Copy link
Collaborator Author

Mass weighting looks good now. The only remaining oddity is related to line-breaking; we get a gap in the spectrum even though the line break is supposed to happen at coincident points.

e.g.
Screenshot 2024-10-11 at 11 54 58

but in the JSON
Screenshot 2024-10-11 at 11 56 41

and in the distances section
Screenshot 2024-10-11 at 11 58 21

- The last value of line_break range seems to not be included?  By
- setting max index "too high" we get expected behaviour at
  discontinuities.
- Gamma-point LO-TO split still looks wrong, fix that separately?
@ajjackson
Copy link
Collaborator Author

It looks like the last point of each segment is dropped: by "touching" segments we get correct-looking discontinuities except at the LO-TO-split Gamma

Screenshot 2024-10-11 at 17 49 29

232047   ▽ line_breaks: (4) [[…], […], […], […]]
232048     ▽ [0]: (2) [0, 127]
232049         [0]: 0
232050         [1]: 127
232052     ▽ [1]: (2) [127, 275]
232053         [0]: 127
232054         [1]: 275
232056     ▽ [2]: (2) [275, 299]
232057         [0]: 275
232058         [1]: 299
232060     ▽ [3]: (2) [299, 323]
232061         [0]: 299
232062       ▶ [1]: 323

This looks a lot more reasonable overall; was just some inconsistency
in which side of each break was being counted!
@ajjackson
Copy link
Collaborator Author

Screenshot 2024-10-11 at 18 05 26
Results finally look as they should 🎉

Just a bit of cleanup needed to put things in sensible places with good names.

euphonic/qpoint_phonon_modes.py Outdated Show resolved Hide resolved
euphonic/qpoint_phonon_modes.py Outdated Show resolved Hide resolved
euphonic/qpoint_phonon_modes.py Outdated Show resolved Hide resolved
euphonic/qpoint_phonon_modes.py Outdated Show resolved Hide resolved
This is a fair chunk of code with a specific duty, and while it _can_
be used purely with QpointPhononModes as input is better characterised
as a function that uses both modes and a corresponding set of tick
labels. Move to a new "writers" module.

Use the existing CLI --title option to set title when using
euphonic-dispersion to generate JSON

Introduce a named type for XTickLabels; this helps legibility. There
is now some inconsistency between use of generic list/tuple and
classes from Typing: don't worry about it for now, this can be tidied
up afterwards.
Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

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

Like the restructure. Much neater.

Comment on lines 938 to 942
def _get_title(filename: str, title: str = '') -> str:
"""Get a plot title: either user-provided string, or from filename"""
if title:
return title
return pathlib.Path(filename).stem
Copy link
Collaborator

Choose a reason for hiding this comment

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

Warrant using a ternary if?

Would it be better to use None? Is there a reason a user might want to have an empty title?

Copy link
Collaborator Author

@ajjackson ajjackson Oct 14, 2024

Choose a reason for hiding this comment

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

I guess the root of the problem is inconsistency 🙈

  • Currently various plotters take '' to mean "no title" and use it as default so that only one type is allowed
  • Here I want to have a non-empty dynamically-generated default.

I guess the answer is to modify some of the other code to allow None as well, then it can be used as a default here and '' remains available as a way to specify "no seriously I don't want a title"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I would say that's a different issue and if this is the behaviour elsewhere that's fine. May want to make an issue even if it just sits there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The fix required fewer changes than I expected, let's give it a try

It turns out that the band structure will render ok with coincident
q-points, now that the other indexing issues have been resolved :)
This allows empty input '' to be distinguished from default None
@ajjackson
Copy link
Collaborator Author

Not sure what's going on with the test failure; I can reproduce it locally but only within tox. Should get there in the end...

This was causing some "works on my machine" issues with mysterious tox failures
@ajjackson
Copy link
Collaborator Author

... got there in the end.

Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

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

Couple of queries. Looks functionally good.

euphonic/cli/utils.py Show resolved Hide resolved
euphonic/cli/utils.py Outdated Show resolved Hide resolved
euphonic/writers/phonon_website.py Outdated Show resolved Hide resolved
euphonic/writers/phonon_website.py Outdated Show resolved Hide resolved
euphonic/writers/phonon_website.py Outdated Show resolved Hide resolved
euphonic/writers/phonon_website.py Outdated Show resolved Hide resolved
euphonic/writers/phonon_website.py Outdated Show resolved Hide resolved
ajjackson and others added 3 commits October 15, 2024 15:29
Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

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

Once it's passing and you're happy, think this is ready to go!

@ajjackson
Copy link
Collaborator Author

It still needs a couple of proper tests!

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.

Write to phonon website JSON
2 participants