tmpchem / computational_chemistry

Files used in TMP Chem videos on computational chemistry
209 stars 91 forks source link

Fixed update methods in topology.py to take molecule, and fixed calls… #4

Closed jialincheoh closed 6 years ago

jialincheoh commented 6 years ago

… to pass in molecule.

This fixes errors of the following type, discovered when trying to run mc.py

python3 mc.py ../../input/mc/he20.mc 
0/20000 confs as of 12:36:14
Traceback (most recent call last):
  File "mc.py", line 27, in <module>
    sim.Run()
  File "/Users/jialincheoh/computational_chemistry/scripts/molecular_mechanics/mmlib/simulate.py", line 410, in Run
    self._DispCoords(self.rand_disp)
  File "/Users/jialincheoh/computational_chemistry/scripts/molecular_mechanics/mmlib/simulate.py", line 453, in _DispCoords
    self.mol.UpdateInternals()
  File "/Users/jialincheoh/computational_chemistry/scripts/molecular_mechanics/mmlib/molecule.py", line 618, in UpdateInternals
    topology.UpdateTorsions(self.torsions)
  File "/Users/jialincheoh/computational_chemistry/scripts/molecular_mechanics/mmlib/topology.py", line 252, in UpdateTorsions
    for torsion in mol.torsions:
NameError: name 'mol' is not defined
tmpchem commented 6 years ago

Hi Jia,

I'm currently in the middle of a large update to refactor modules to make unit testing much easier and create a thorough test suite to protect future updates from regression errors. One of the central themes of this update is to remove function calls which pass in entire molecule object.

In this particular instance, I believe the appropriate path is to continue the update to fix these mc.py errors rather than moving back to the former style of method calls. This is an error of laziness on my part, as I've been primarily focusing on the function of the mm.py script during these updates, to the detriment of the other main files.

Stay tuned, as I'll try to push a fix for this in the next 2 days which allows continued function of other main files. Hopefully opportunities for failures of this type are decreasing, as only a few modules remain which have methods with the entire molecule as an input.

tmpchem commented 6 years ago

Today's update resolves this issue, allowing mc.py to be executed without error.