Skip to content

Commit

Permalink
Added unit option to the Fcsxml class
Browse files Browse the repository at this point in the history
By default, the unit of the given lattice vectors is
assumed to be Angstrom and converted to the Bohr unit.
  • Loading branch information
ttadano committed Feb 24, 2023
1 parent fe46095 commit bdc19d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/alm/fcsxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import numpy as np
import spglib
from ase.units import Bohr

atom_names = (
"X",
Expand Down Expand Up @@ -133,13 +134,14 @@
class Fcsxml(object):
"""Writer of harmonic and anharmonic interatomic force constants for alamode."""

def __init__(self, lavec, xcoord, numbers, symprec=1.0e-3):
def __init__(self, lavec, xcoord, numbers, symprec=1.0e-3, unit='angstrom'):
"""Initialize the object with the input crystal structure.
Parameters
----------
lavec : array_like
Basis vectors. a, b, c are given as column vectors.
Basis vectors in units specified by 'unit'
a, b, c are given as column vectors.
shape=(3, 3), dtype='double'
xcoord : array_like
Fractional coordinates of atomic points.
Expand All @@ -152,7 +154,11 @@ def __init__(self, lavec, xcoord, numbers, symprec=1.0e-3):
Will be passed to spglib.
"""
self._lavec = np.array(lavec).transpose()
if unit == 'angstrom':
self._lavec = np.array(lavec).transpose() / Bohr
else:
self._lavec = np.array(lavec).transpose()

self._xf = np.array(xcoord)
self._atomic_kinds = np.array(numbers)
self._symprec = symprec
Expand Down

0 comments on commit bdc19d8

Please sign in to comment.