@@ -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 ):
0 commit comments