Skip to content

Commit

Permalink
bug: fixed argument order in nanoribbon
Browse files Browse the repository at this point in the history
It was not consistent across the different ribbon
creation routines. Now they are.
  • Loading branch information
zerothi committed Jan 28, 2022
1 parent 818e90f commit fa468bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ we hit release version 1.0.0.
- fixed hpc parameters #403

### Changed
- order of arguments for `nanoribbon` it was not consistent with the others
- removed cell argument in `Geometry.sub`
- removed `Sile.exist`, refer to `Sile.file` which always will be a `pathlib.Path` instance
- `berry_phase` now uses the gauge=R convention, the code became much simpler
Expand Down
8 changes: 4 additions & 4 deletions sisl/geom/nanoribbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@


@set_module("sisl.geom")
def nanoribbon(bond, atoms, width, kind='armchair'):
def nanoribbon(width, bond, atoms, kind='armchair'):
r""" Construction of a nanoribbon unit cell of type armchair or zigzag.
The geometry is oriented along the :math:`x` axis.
Parameters
----------
width : int
number of atoms in the transverse direction
bond : float
bond length between atoms in the honeycomb lattice
atoms : Atom
atom (or atoms) in the honeycomb lattice
width : int
number of atoms in the transverse direction
kind : {'armchair', 'zigzag'}
type of ribbon
Expand Down Expand Up @@ -105,7 +105,7 @@ def graphene_nanoribbon(width, bond=1.42, atoms=None, kind='armchair'):
"""
if atoms is None:
atoms = Atom(Z=6, R=bond * 1.01)
return nanoribbon(bond, atoms, width, kind=kind)
return nanoribbon(width, bond, atoms, kind=kind)


@set_module("sisl.geom")
Expand Down
12 changes: 6 additions & 6 deletions sisl/geom/tests/test_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ def test_bilayer():

def test_nanoribbon():
for w in range(0, 5):
a = nanoribbon(1.42, Atom(6), w, kind='armchair')
a = nanoribbon(1.42, Atom(6), w, kind='zigzag')
a = nanoribbon(1.42, (Atom(5), Atom(7)), w, kind='armchair')
a = nanoribbon(1.42, (Atom(5), Atom(7)), w, kind='zigzag')
a = nanoribbon(w, 1.42, Atom(6), kind='armchair')
a = nanoribbon(w, 1.42, Atom(6), kind='zigzag')
a = nanoribbon(w, 1.42, (Atom(5), Atom(7)), kind='armchair')
a = nanoribbon(w, 1.42, (Atom(5), Atom(7)), kind='zigzag')

with pytest.raises(ValueError):
nanoribbon(1.42, (Atom(5), Atom(7)), 6, kind='undefined')
nanoribbon(6, 1.42, (Atom(5), Atom(7)), kind='undefined')

with pytest.raises(ValueError):
nanoribbon(1.42, (Atom(5), Atom(7)), 'str', kind='undefined')
nanoribbon('str', 1.42, (Atom(5), Atom(7)), kind='undefined')


def test_graphene_nanoribbon():
Expand Down

0 comments on commit fa468bf

Please sign in to comment.