1"""! Module of parsers for PSCF output file formats. """
160 with open(filename)
as f:
174 if l[0] !=
'fHelmholtz':
175 raise Exception(
'Not valid Thermo file')
178 line = file.readline()
190 self.
fExt = float(l[1])
191 line = file.readline()
196 if line ==
'polymers:\n':
199 line = file.readline()
203 line = file.readline()
205 if line ==
'solvents:\n':
207 line = file.readline()
208 line = file.readline()
212 line = file.readline()
214 if line ==
'cellParams:\n':
216 line = file.readline()
220 line = file.readline()
236 line = file.readline()
238 line = file.readline()
251 with open(filename,
'w')
as f:
260 v = f
'{self.fHelmholtz:.11e}'
263 v = f
'{self.pressure:.11e}'
270 v = f
'{self.fIdeal:.11e}'
274 v = f
'{self.fInter:.11e}'
276 if self.
fExt !=
None:
278 v = f
'{self.fExt:.11e}'
285 p = f
'{self.polymers[i].phi:.11e}'
286 m = f
'{self.polymers[i].mu:.11e}'
287 s += f
'{i:>5}{p:>20}{m:>20}\n'
294 p = f
'{self.solvents[i].phi:.11e}'
295 m = f
'{self.solvents[i].mu:.11e}'
296 s += f
'{i:>5}{p:>20}{m:>20}\n'
302 v = f
'{self.cellParams[i]:.11e}'
303 s += f
'{i:>5}{v:>20}\n'
325 self.
phi = float(l[1])
326 self.
mu = float(l[2])
328 self.
phi = float(l[0])
329 self.
mu = float(l[1])
406 with open(filename)
as f:
407 firstline = f.readline()
408 fl = firstline.split()
409 if fl[0] !=
'System{':
410 raise Exception(
'Not valid State file')
436 with open(filename)
as f:
495 filename = prefix + str(num) +
'.stt'
496 while os.path.isfile(filename) ==
True:
500 filename = prefix + str(num) +
'.stt'
578 for i
in range(0, len(self.
sweep)):
583 for j
in range(0, n):
585 string =
'a.' + vars[j]
588 except RecursionError:
589 raise Exception(
'Wrong command or values do not exist')
632 for i
in range(0, len(self.
sweep)):
634 for j
in range(0, n):
636 string =
'a.' + vars[j]
639 except RecursionError:
640 raise Exception(
'Wrong command or values do not exist')
646 for i
in range(0, n):
647 index = vars[i].rfind(
'.')
648 name = vars[i][index+1:]
649 nameList.append(name)
653 for i
in range(0, len(summary)):
655 for j
in range(0, len(summary[0])):
656 valType[i].append(type(summary[i][j]))
658 for i
in range(0, len(summary)):
659 for j
in range(0, len(summary[0])):
660 length = len(str(summary[i][j]))
661 if (valType[i][j] == str)
and (length > nl[j]):
663 if (valType[i][j] == float)
and (13 > nl[j]):
665 if (valType[i][j] == int)
and (length > nl[j]):
670 for i
in range(0, len(nameList)):
671 stringFormat =
'{:>' + str(nl[i]) +
's}'
672 if i != len(nameList)-1:
673 summaryString += stringFormat.format(nameList[i]) +
' '
675 summaryString += stringFormat.format(nameList[i]) +
'\n '
677 for i
in range(0, len(summary)):
678 for j
in range(0, len(summary[0])):
679 if valType[i][j] == int:
680 stringFormat =
'{:>' + str(nl[j]) +
'}'
681 summaryString += stringFormat.format(summary[i][j])
682 if valType[i][j] == float:
683 stringFormat =
'{:.7e}'
684 val = stringFormat.format(summary[i][j])
686 if valType[i][j] == str:
687 stringFormat =
'{:>' + str(nl[j]) +
's}'
688 summaryString += stringFormat.format(summary[i][j])
689 if j == len(summary[0])-1:
690 summaryString +=
'\n '
702 return self.
sweep[key]
708 return len(self.
sweep)
Container for phi and mu for a single species in a Thermo object.
def __init__(self, l)
Constructor.
Container for data in state files produced by a sweep.
def write(self, filename)
Write the contents of this object to file in state file format.
def __str__(self)
Return string representation of this object in state file format.
def __init__(self, filename)
Constructor.
Container for data in state files produced by a PSCF sweep.
def __len__(self)
Get the number of states in a sweep.
def __init__(self, prefix)
Constructor.
def __getitem__(self, key)
Get a specific State object, specified by integer index.
def summaryString(self, vars)
Return a summary report as a formatted string suitable for printing.
def summary(self, vars, index=False)
Make a summary report containing values for selected variables.
Parser and container for PSCF thermo file blocks.
def write(self, filename)
Write the contents of this object in thermo file format to a file.
def read(self, file)
Read the passed-in open-file.
def __str__(self)
Return a string representation of this object in thermo file format.
def skipEmptyLine(self, file)
Skip empty lines in the file.
def __init__(self, filename=None)
Constructor.
Container for data of a Composite in a param file.
Module for parsing param files.