Skip to content

Commit 9415f83

Browse files
committed
Fixed the error message when the fileformat is wrong
in the ForceTensor. Both in the second order and third order.
1 parent a7c9f46 commit 9415f83

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

cellconstructor/ForceTensor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,11 @@ def WriteOnFile(self, fname,file_format='Phonopy'):
678678
----------
679679
fname : string
680680
Path to the file on which you want to save the tensor.
681+
file_format : string
682+
The format of the file (case insensitive). Supported formats are phonopy and D3Q.
681683
"""
682684

683-
if file_format == 'Phonopy':
685+
if file_format.lower() == 'phonopy':
684686

685687
print(" ")
686688
print(" Writing FC2 on "+fname )
@@ -708,7 +710,7 @@ def WriteOnFile(self, fname,file_format='Phonopy'):
708710
f.write("{:>2d} {:>2d} {:>20.10e}\n".format(x+1, y+1, self.tensor[r_block, 3*nat1 + x, 3*nat2 + y]))
709711

710712

711-
elif file_format == 'D3Q':
713+
elif file_format.upper() == 'D3Q':
712714

713715
print(" ")
714716
print(" Writing FC2 on "+fname )
@@ -727,6 +729,9 @@ def WriteOnFile(self, fname,file_format='Phonopy'):
727729
for r_block in range(self.n_R):
728730
f.write("{:>6d} {:>6d} {:>6d} {:16.8e}\n".format(self.x_r_vector2[0, r_block],self.x_r_vector2[1, r_block],self.x_r_vector2[2, r_block], self.tensor[r_block, 3*nat1 + alpha, 3*nat2 + beta]))
729731

732+
else:
733+
raise ValueError("Error, file_format %s not recognized. Please, use D3Q or PHONOPY." % file_format.upper())
734+
730735
def Interpolate(self, q2, asr = False, verbose = False, asr_range = None, q_direct = None, lo_to_splitting = True):
731736
"""
732737
Perform the Fourier interpolation to obtain the force constant matrix at a given q
@@ -1457,7 +1462,7 @@ def WriteOnFile(self,fname,file_format='Phonopy'):
14571462
f.write("{:>6d} {:>6d} {:>6d} {:>6d} {:>6d} {:>6d} {:16.8e}\n".format(self.x_r_vector2[0, r_block],self.x_r_vector2[1, r_block],self.x_r_vector2[2, r_block],self.x_r_vector3[0, r_block],self.x_r_vector3[1, r_block],self.x_r_vector3[2, r_block], self.tensor[r_block, 3*nat1 + alpha, 3*nat2 + beta, 3*nat3 + gamma]))
14581463

14591464
else:
1460-
raise ValueError("File format %s not recognized. Please use either PHONOPY or D3Q.")
1465+
raise ValueError("File format %s not recognized. Please use either PHONOPY or D3Q." % file_format.upper())
14611466

14621467

14631468
def Center(self, nneigh=None, Far=2,tol=1.0e-5):

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('CellConstructor',
22
['c','fortran'],
3-
version: '1.5.2',
3+
version: '1.5.3',
44
license: 'GPL',
55
meson_version: '>= 1.1.0', # <- set min version of meson.
66
default_options : [

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build-backend = "mesonpy"
1111
[project]
1212
# Project metadata, which was previously in the `setup()` call of setup.py.
1313
name = "CellConstructor"
14-
version = "1.5.2" # Make sure this version matches meson.build
14+
version = "1.5.3" # Make sure this version matches meson.build
1515
description = "Python utilities interfaced with ASE for atomic crystal analysis"
1616
authors = [{name = "Lorenzo Monacelli"}]
1717
readme = "README.md"

0 commit comments

Comments
 (0)