Skip to content

Commit

Permalink
Release new version
Browse files Browse the repository at this point in the history
  • Loading branch information
utf committed Mar 29, 2023
2 parents 3132d2f + 6786d04 commit 8f4f76e
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 14 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Change Log
v2.3.6
------

Fix superscript in ``sumo-optplot``

Bugfixes:

- Allow "BREAK" keyword in CASTEP band paths - and ignore it. (@azanre, #201)
- Fix superscript in ``sumo-optplot`` (@utf, #203)

v2.3.5
------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions sumo/io/castep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion sumo/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 1 addition & 5 deletions sumo/plotting/optics_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
27 changes: 27 additions & 0 deletions tests/data/Pt/Pt.cell
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions tests/tests_io/test_castep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f4f76e

Please sign in to comment.