Skip to content

Commit

Permalink
Update readElkfiles.py
Browse files Browse the repository at this point in the history
During the Elk conversion process, two files, SYMCRYS.OUT and LATTICE.OUT, need to be read. However, after the Elk calculation is completed, there are some blank lines in these files, which leads to recognition failure of readElkfiles.py.  By using line.strip(), non-blank lines can be directly read.
  • Loading branch information
XiaoJiang-Phy authored and the-hampel committed Sep 9, 2024
1 parent f3a0d61 commit dcb47d6
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions python/triqs_dft_tools/converters/elktools/readElkfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,21 @@ def read_elk_file2(self, filename, to_replace):
if not(os.path.exists(filename)):
raise IOError("File %s does not exist." % filename)
for line in open(filename, 'r'):
for old, new in to_replace.items():
line = line.replace(old, new)
# removes the substring after '(' character - if it exists
if "(" in line:
line = self.split_string2(line,'(')
# removes the substring after '+' character - if it exists
if "+" in line:
line = self.split_string2(line,'+')
# removes the substring after '|' character - if it exists
if "|" in line:
line = self.split_string2(line,'|')
#only include lines which have multiple characters
if(len(line)>1):
yield line.split()
if line.strip():
for old, new in to_replace.items():
line = line.replace(old, new)
# removes the substring after '(' character - if it exists
if "(" in line:
line = self.split_string2(line,'(')
# removes the substring after '+' character - if it exists
if "+" in line:
line = self.split_string2(line,'+')
# removes the substring after '|' character - if it exists
if "|" in line:
line = self.split_string2(line,'|')
#only include lines which have multiple characters
if(len(line)>1):
yield line.split()

def split_string(self,line):
"""
Expand Down

0 comments on commit dcb47d6

Please sign in to comment.