From 054dda3f5d696df1e629ccbd11a44e0f63cd0b00 Mon Sep 17 00:00:00 2001 From: Alex Ganose Date: Thu, 29 Dec 2022 17:18:06 +0000 Subject: [PATCH 1/5] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3b0dacb7..79fdb651 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Sumo ==== -.. image:: https://img.shields.io/github/workflow/status/smtg-ucl/sumo/Run%20tests +.. image:: https://img.shields.io/github/actions/workflow/status/smtg-ucl/sumo/tests.yml?branch=master :target: https://github.com/SMTG-UCL/sumo/actions?query=workflow%3A%22Run+tests%22 :alt: Build Status From 3cd46ca349556159c5ef9bad4034026d6a6a4add Mon Sep 17 00:00:00 2001 From: Alex Zanre Date: Mon, 27 Feb 2023 17:17:37 +0000 Subject: [PATCH 2/5] Add check to skip parsing of break lines. --- sumo/io/castep.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sumo/io/castep.py b/sumo/io/castep.py index 708213dc..3bfab75c 100644 --- a/sumo/io/castep.py +++ b/sumo/io/castep.py @@ -486,12 +486,14 @@ def labels_from_cell(cell_file, phonon=False): line = f.readline() # Skip past block start line while blockend.match(line.lower()) is None: - kpt = tuple(map(float, line.split()[:3])) - if len(line.split()) > 3: - label = line.split()[-1] - if label.lower() in ("g", "gamma"): - label = r"\Gamma" - labels[label] = kpt + # Do not parse break lines + if 'break' not in line.lower(): + kpt = tuple(map(float, line.split()[:3])) + if len(line.split()) > 3: + label = line.split()[-1] + if label.lower() in ("g", "gamma"): + label = r"\Gamma" + labels[label] = kpt line = f.readline() if line == "": logging.error("Could not find end of k-point block in cell file.") From 1f283ec36769af2fe8ed6a1144ec089ed17d0b2e Mon Sep 17 00:00:00 2001 From: Alex Zanre Date: Wed, 1 Mar 2023 15:03:51 +0000 Subject: [PATCH 3/5] Add unit test for parsing break in castep k point path. --- tests/data/Pt/Pt.cell | 27 +++++++++++++++++++++++++++ tests/tests_io/test_castep.py | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/data/Pt/Pt.cell diff --git a/tests/data/Pt/Pt.cell b/tests/data/Pt/Pt.cell new file mode 100644 index 00000000..5b6e8662 --- /dev/null +++ b/tests/data/Pt/Pt.cell @@ -0,0 +1,27 @@ +%BLOCK LATTICE_CART +ang # angstrom units + 1.961550000000000 1.961550000000000 0.000000000000000 + 1.961550000000000 0.000000000000000 1.961550000000000 + 0.000000000000000 1.961550000000000 1.961550000000000 +%ENDBLOCK LATTICE_CART + +%BLOCK POSITIONS_FRAC +Pt 0.000000000000000 0.000000000000000 0.000000000000000 +%ENDBLOCK POSITIONS_FRAC + +SYMMETRY_GENERATE + +KPOINT_MP_SPACING: 0.04 +SPECTRAL_KPOINT_PATH_SPACING : 0.04 + +%BLOCK SPECTRAL_KPOINT_PATH +0 0 0 ! \Gamma +0.5 0 0.5 ! X +0.625 0.25 0.625 ! U +BREAK +0.375 0.375 0.75 ! K +0 0 0 ! \Gamma +0.5 0.5 0.5 ! L +0.5 0.25 0.75 ! W +0.5 0 0.5 ! X +%ENDBLOCK SPECTRAL_KPOINT_PATH diff --git a/tests/tests_io/test_castep.py b/tests/tests_io/test_castep.py index b5fdaaaa..64d16d54 100644 --- a/tests/tests_io/test_castep.py +++ b/tests/tests_io/test_castep.py @@ -241,6 +241,26 @@ def test_castep_bands_read_header(self): self.assertEqual(header, ref_header) +class BandStructureTestCasePathBreak(unittest.TestCase): + def setUp(self): + self.pt_cell = resource_filename( + __name__, path_join("..", "data", "Pt", "Pt.cell") + ) + self.ref_labels = { + r"\Gamma": (0.0, 0.0, 0.0), + "X": (0.5, 0.0, 0.5), + "U": (0.625, 0.25, 0.625), + "K": (0.375, 0.375, 0.75), + "L": (0.5, 0.5, 0.5), + "W": (0.5, 0.25, 0.75) + } + + def test_castep_parse_break_in_k_path(self): + labels = labels_from_cell(self.pt_cell) + print(labels) + self.assertEqual(labels, self.ref_labels) + + # To generate reference file:: # # sumo-phonon-bandplot -f zns.phonon --units cm-1 --to-json zns_phonon.json From 575996ed11ef7e45657cdbf570c718d3c4c830c8 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Fri, 3 Mar 2023 10:14:32 +0000 Subject: [PATCH 4/5] Update CHANGELOG.rst Thanks @azanre --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 490b457d..427151c2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Change Log ========== +Unreleased +---------- + +Bugfix: Allow "BREAK" keyword in CASTEP band paths - and ignore it. (@azanre, #201) + v2.3.5 ------ From 0613e47222fec4c3f596dc0e6a282f1b3b6a7439 Mon Sep 17 00:00:00 2001 From: Alex Ganose Date: Wed, 29 Mar 2023 12:30:11 +0100 Subject: [PATCH 5/5] Fix optplot superscript --- sumo/plotting/__init__.py | 2 +- sumo/plotting/optics_plotter.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sumo/plotting/__init__.py b/sumo/plotting/__init__.py index 1a1e27b4..2e9aab9f 100644 --- a/sumo/plotting/__init__.py +++ b/sumo/plotting/__init__.py @@ -169,7 +169,7 @@ def power_tick(val, pos, times_sign=r"\times"): coeff = val / 10**exponent prec = 0 if coeff % 1 == 0 else 1 - return rf"$\mathregular{{{coeff:.{prec}f} {times_sign} 10^{exponent:2d}}}$" + return rf"${coeff:.{prec}f}\mathrm{{{times_sign}}}10^{{{exponent:2d}}}$" def colorline( diff --git a/sumo/plotting/optics_plotter.py b/sumo/plotting/optics_plotter.py index 03096334..5e4d3ac0 100644 --- a/sumo/plotting/optics_plotter.py +++ b/sumo/plotting/optics_plotter.py @@ -243,12 +243,8 @@ def get_plot( if spectrum_key == "absorption": font = findfont(FontProperties(family=["sans-serif"])) - if "Whitney" in font: - times_sign = "x" - else: - times_sign = r"\times" ax.yaxis.set_major_formatter( - FuncFormatter(curry_power_tick(times_sign=times_sign)) + FuncFormatter(curry_power_tick(times_sign=r"\times")) ) ax.yaxis.set_major_locator(MaxNLocator(5))