Skip to content

Commit

Permalink
fortmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kousuke-nakano committed Feb 15, 2024
1 parent 6b41cd9 commit 94745c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions turbogenius/pyturbo/io_fort10.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,8 +2223,9 @@ def row(self):

@row.setter
def row(self, value_list):
assert len(self.__row) == len(value_list)
self.read()
if len(self.__row) != len(value_list):
raise ValueError
for row, value in zip(self.__row, value_list):
if row.v != value:
row.replace(value=value, in_place=self.in_place)
Expand All @@ -2236,8 +2237,9 @@ def col(self):

@col.setter
def col(self, value_list):
assert len(self.__col) == len(value_list)
self.read()
if len(self.__col) != len(value_list):
raise ValueError
for col, value in zip(self.__col, value_list):
if col.v != value:
col.replace(value=value, in_place=self.in_place)
Expand All @@ -2249,8 +2251,9 @@ def coeff_real(self):

@coeff_real.setter
def coeff_real(self, value_list):
assert len(self.__coeff_real) == len(value_list)
self.read()
if len(self.__coeff_real) != len(value_list):
raise ValueError
for coeff_real, value in zip(self.__coeff_real, value_list):
if coeff_real.v != value:
coeff_real.replace(value=value, in_place=self.in_place)
Expand All @@ -2262,8 +2265,9 @@ def coeff_imag(self):

@coeff_imag.setter
def coeff_imag(self, value_list):
assert len(self.__coeff_imag) == len(value_list)
self.read()
if len(self.__coeff_imag) != len(value_list):
raise ValueError
for coeff_imag, value in zip(self.__coeff_imag, value_list):
if coeff_imag.v != value:
coeff_imag.replace(value=value, in_place=self.in_place)
Expand Down
12 changes: 6 additions & 6 deletions turbogenius/pyturbo/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ def __init__(
vec_b = [0.0, 0.0, 0.0] # bohr
if vec_c is None:
vec_c = [0.0, 0.0, 0.0] # bohr

# cell vectors (the units are bohr)
self.__vec_a = np.array(vec_a, dtype=float)
self.__vec_b = np.array(vec_b, dtype=float)
self.__vec_c = np.array(vec_c, dtype=float)

if vec_a[1] > 1.0e-12 or vec_a[2] > 1.0e-10:
if np.abs(self.__vec_a[1]) > 1.0e-10 or np.abs(self.__vec_a[2]) > 1.0e-10:
logger.error("The lattice vector a is not on the x axis.")
logger.error("TurboRVB assumes that vec_a = [a, 0.0, 0.0]")
logger.error("Please convert lattice vectors and structures.")
raise ValueError

# cell vectors (the units are bohr)
self.__vec_a = np.array(vec_a, dtype=float)
self.__vec_b = np.array(vec_b, dtype=float)
self.__vec_c = np.array(vec_c, dtype=float)

# calc norm
self.__norm_vec_a = LA.norm(self.__vec_a)
self.__norm_vec_b = LA.norm(self.__vec_b)
Expand Down

0 comments on commit 94745c3

Please sign in to comment.