I double checked and added again. Getting the same error.
As I said, Python is sensitive to indentation - and the indentation in
your script is all over the place. Compare with the original script in
the wiki at http://salilab.org/modeller/wiki/Mutate%20model
#molecular dynamics
def refine(atmsel):
For example, both of these two lines should be left-aligned (no space at
the start).