Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent N_monomer > 3 in AM algorithm, and fix errors in python tools #18

Merged
merged 1 commit into from
Nov 17, 2021

Conversation

benmagruder
Copy link
Contributor

This pull request is primarily to patch a bug in src/iterate_mod.fp.f90. The bug was that the Anderson Mixing algorithm permitted the use of N_monomer > 3, but did not properly calculate the residuals for this system, resulting in quick but wrong conversion to an answer with 0 error from the residuals. This edit simply stops the execution of the code if a user tries to use N_monomer > 3 rather than allowing the answer to be calculated.


I am also including in this pull request a fixed version of the python tools in the directory tools/python/pscf/, because the versions of the tools that exist in the current github directory do not work for me in either python2 or python3. This is an issue I hoped to fix because, if you've added these tools to your PYTHONPATH and they are broken, you can't do anything in python until they're all fixed because python gives you errors for the files in your PYTHONPATH even if you aren't importing/using them.

The amendments included in this pull request fix all of the errors that I have run into when using the python tools, allowing them to be run by users without being fixed beforehand. The issues I ran into were the following:

  • A few of the "tabs" in the python scripts were actually \t tabs rather than spaces like they should be, and python gave me errors that said inconsistent use of tabs and spaces. In each place where this occurred, I replaced the tabs with spaces.
  • The filename io.py is seemingly used for something else somewhere in python, because I ran into a bug once working on an entirely unrelated python project due to overlapping files named io.py. So, I renamed it io_pscf.py.
  • There are a few places where the code says if self.__dict__.has_key(name), and I replaced these with if name in self.__dict__ because the former is specific to python2 but the latter works in both python2 and python3.
  • I deleted some import statements that import packages that are unused in the scripts.
  • Changed true to True and false to False in a few places for proper syntax.

The python tools were initially written for python2.7, but I am able to run them in python3.8 after having made the above changes. However, the changes shouldn't prevent them from still working properly in python2.7 as well, since none of the changes break compatibility with python2.7.


Changes:
modified: src/iterate_mod.fp.f90
modified: tools/python/pscf/fieldfile.py
renamed/modified: tools/python/pscf/io.py -> tools/python/pscf/io_pscf.py
modified: tools/python/pscf/outfile.py
modified: tools/python/pscf/paramfile.py
modified: tools/python/pscf/sweep.py
modified: tools/python/pscf/version.py

 Your branch is up to date with 'upstream/bugfix'.

 Changes to be committed:
	modified:   src/iterate_mod.fp.f90
	modified:   tools/python/pscf/fieldfile.py
	renamed:    tools/python/pscf/io.py -> tools/python/pscf/io_pscf.py
	modified:   tools/python/pscf/outfile.py
	modified:   tools/python/pscf/paramfile.py
	modified:   tools/python/pscf/sweep.py
	modified:   tools/python/pscf/version.py
@dmorse dmorse merged commit b9409d7 into dmorse:bugfix Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants