diff --git a/src/iterate_mod.fp.f90 b/src/iterate_mod.fp.f90 index 0fd4d78..1a4a8cd 100644 --- a/src/iterate_mod.fp.f90 +++ b/src/iterate_mod.fp.f90 @@ -1182,6 +1182,9 @@ subroutine iterate_AM( & + chi(2,3)*rho(1,k+1) + chi(1,3)*rho(2,k+1) )/N_monomer &! - omega(alpha,k+1) end do + else + write(6,*) 'Error: Anderson Mixing is only implemented for N_monomer = 2 or 3' + stop endif end do diff --git a/tools/python/pscf/fieldfile.py b/tools/python/pscf/fieldfile.py index d676289..72d47a1 100644 --- a/tools/python/pscf/fieldfile.py +++ b/tools/python/pscf/fieldfile.py @@ -1,4 +1,4 @@ -from io import IO, IoException +from io_pscf import IO, IoException from version import Version import string import sys @@ -44,11 +44,11 @@ def __init__(self,filename): The file named filename is opened and closed within this function. ''' self.file = open(filename, 'r') - self._io = IO() - file = self.file + self._io = IO() + file = self.file # Read version line - self.version = Version(self.file) + self.version = Version(self.file) self._input_unit_cell() self.group_name = self._input_var('char') @@ -85,7 +85,7 @@ def __init__(self,filename): self.counts.append(int(data[j])) self.file.close() - self.file = None + self.file = None def write(self, file, major=1, minor=0): ''' @@ -105,9 +105,9 @@ def write(self, file, major=1, minor=0): file = temp self.file = file - self.version.major = major - self.version.minor = minor - self.version.write(file) + self.version.major = major + self.version.minor = minor + self.version.write(file) self._output_unit_cell() self._output_var('char', 'group_name') @@ -123,7 +123,7 @@ def write(self, file, major=1, minor=0): file.write('%6d' % self.counts[i]) file.write("\n") - file.close() + file.close() self.file = None def addMonomer(self, value = 0.0): @@ -177,14 +177,14 @@ def _input_vec(self, type, n=None, comment=None, s='R',f='A'): # Output methods (output by name) def _output_var(self, type, name, f='A'): - if self.__dict__.has_key(name): + if name in self.__dict__: data = self.__dict__[name] - self._io.output_var(self.file, type, data, name, f) + self._io.output_var(self.file, type, data, name, f) def _output_vec(self, type, name, n=None, s='R', f='A'): - if self.__dict__.has_key(name): + if name in self.__dict__: data = self.__dict__[name] - self._io.output_vec(self.file, type, data, n, name, s, f) + self._io.output_vec(self.file, type, data, n, name, s, f) def _input_unit_cell(self): ''' Analog of subroutine _input_unit_cell in unit_cell_mod.f ''' diff --git a/tools/python/pscf/io.py b/tools/python/pscf/io_pscf.py similarity index 95% rename from tools/python/pscf/io.py rename to tools/python/pscf/io_pscf.py index 48159b9..7197675 100644 --- a/tools/python/pscf/io.py +++ b/tools/python/pscf/io_pscf.py @@ -16,7 +16,7 @@ def __init__(self): """ Default construct an initially empty object. """ - self.comment = None + self.comment = None def input_comment(self, file, comment=None): """ @@ -45,8 +45,8 @@ def input_var(self,file,type,comment=None,f='A'): -- 'N' -> no comment string """ if f == 'A': - if not self.input_comment(file, comment): - return None + if not self.input_comment(file, comment): + return None data = file.readline().strip() if type == 'int': return int(data) @@ -60,7 +60,7 @@ def input_var(self,file,type,comment=None,f='A'): elif data in ['F','false','FALSE','FALSE']: return 0 else: - raise "Invalid logical variable:", data + raise("Invalid logical variable:", data) else: raise 'Illegal type in input_var' @@ -78,8 +78,8 @@ def input_vec(self,file,type,n=None, comment=None, s='R', f='A'): -- 'C' -> column vector (n lines) """ if f == 'A': - if not self.input_comment(file,comment): - return None + if not self.input_comment(file,comment): + return None if s == 'R': # Row Vector data = file.readline().split() if n: @@ -116,8 +116,8 @@ def input_mat(self, file, type, m, n=None, comment=None, s=None,f='A'): -- 'L' -> symmetric lower triangular (0 diagonals) """ if f == 'A': - if not self.input_comment(file,comment): - return None + if not self.input_comment(file,comment): + return None # Emulate initialization of m x n array if not n: n = m @@ -170,8 +170,8 @@ def format_var(self, type, data): elif type == 'real': return '%20.10E' % data elif type == 'char': - data = "'" + data + "'" - return "%20s" % data + data = "'" + data + "'" + return "%20s" % data elif type == 'logic': if data: data = 'T' @@ -221,8 +221,8 @@ def output_vec(self, file, type, data, n=None, comment=None, s='R', f='A'): s -- 'R' -> row vector (one line) -- 'C' -> column vector (n lines) """ - if not n: - n = len(data) + if not n: + n = len(data) if f == 'A': self.output_comment(file, comment) for i in range(n): @@ -248,7 +248,7 @@ def output_mat(self, file, type, data, m=None, n=None, -- 'S' -> symmetric -- 'L' -> symmetric lower triangular (0 diagonals) """ - if not m: + if not m: m = len(data) if not n: n = m diff --git a/tools/python/pscf/outfile.py b/tools/python/pscf/outfile.py index a02f80e..e7aa496 100644 --- a/tools/python/pscf/outfile.py +++ b/tools/python/pscf/outfile.py @@ -1,8 +1,6 @@ -from io import IO, IoException +from io_pscf import IO from version import Version from paramfile import ParamFile -import string -import sys class OutFile(ParamFile): """ diff --git a/tools/python/pscf/paramfile.py b/tools/python/pscf/paramfile.py index bc9397b..e9697e3 100644 --- a/tools/python/pscf/paramfile.py +++ b/tools/python/pscf/paramfile.py @@ -1,7 +1,6 @@ -from io import IO, IoException +from io_pscf import IO, IoException from version import Version import string -import sys class ParamFile(object): """ diff --git a/tools/python/pscf/sweep.py b/tools/python/pscf/sweep.py index adeb267..6e5a1a1 100644 --- a/tools/python/pscf/sweep.py +++ b/tools/python/pscf/sweep.py @@ -1,5 +1,5 @@ from outfile import OutFile -import sys, os, string +import os, string class Sweep(object): """ diff --git a/tools/python/pscf/version.py b/tools/python/pscf/version.py index 0ade251..1f60bdf 100644 --- a/tools/python/pscf/version.py +++ b/tools/python/pscf/version.py @@ -1,6 +1,3 @@ -from io import IO, IoException -import string - class Version(object): ''' Abstract representation of a file format version tag @@ -16,13 +13,13 @@ def __init__(self,file): ''' # Read first line to determine file format - line = file.readline().strip() + line = file.readline().strip() if line == '': self.major = 0 self.minor = 9 else: - line = line.split() - if line[0] == 'format': + line = line.split() + if line[0] == 'format': self.major = int(line[1]) self.minor = int(line[2]) else: @@ -44,7 +41,7 @@ def eq(self, major, minor): def ge(self, major, minor): if (self.major >= major and self.minor >= minor): - return true + return True else: - return false + return False