Skip to content

Conversation

berquist
Copy link
Member

Additionally,

  • isotopic masses via periodictable package
  • center of mass
  • moment of inertia tensor
  • principal moments of inertia

Handles #256.

Right now, each method returns multiple arrays, one for each set of units. Another way to do it would be to pass a string with the desired output units ("MHz", "cm-1") and only get back one array. That's probably better.

This also only considers the last set of atomcoords.

@berquist berquist added this to the v1.5.4 milestone Jul 17, 2018
requirements.txt Outdated
@@ -1,5 +1,7 @@
biopython ; python_version == '2.7' or python_version >= '3.4'
numpy
scipy
periodictable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a periodic table thing in util: https://github.com/cclib/cclib/blob/master/cclib/parser/utils.py#L124

Do you think we should replace that with this package, or standardize on our own version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our periodic table is not sufficient, because we need masses, specifically isotopic masses. I am not sure if atommasses, when present, are always isotopic masses. They should be when parsed from a frequency calculation. However I don't believe they're always available.

If there is a better Python package for this sort of data, and a better one for physical constants than scipy, I am open to suggestions.

We can eventually have our periodic table wrap an external package, once we pick an appropriate one, because holding our own atomic masses doesn't sound good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm OK with this choice. periodictable look reasonable.

@berquist
Copy link
Member Author

I am interested in @ghutchis's thoughts about what features are desired and if he knows about other packages, since he originally requested this feature.

@berquist
Copy link
Member Author

For some physical constants, unyt provides a few. One thing I like about it is that it provides the opportunity to handle units in the future. Something I dislike is the provenance of the units is not as clear as SciPy, which specifically says the CODATA version they originate from.

I cannot find a better atomic mass/isotope library than periodictable that is already in Python. There is an excellent one in DALTON, but we cannot use even a Python translation because it is GPL'ed.

@berquist
Copy link
Member Author

periodictable does not work with Python 3.2 due to Unicode strings, but is tested with 3.3.

@berquist
Copy link
Member Author

I just rediscovered mendeleev, which may be even better than periodictable.

@ATenderholt
Copy link
Contributor

@berquist
Copy link
Member Author

  • periodictable requires numpy and pyparsing.
  • mendeleev requires six, python-dateutil, pytz, pandas, colorama, pyfiglet, and sqlalchemy.

I did a quick check and there's a small SQLite3 database (< 400 KB) that comes with the package. periodictable stores all its data in a massive comma-separated string. I have no strong opinion either way.

@ATenderholt
Copy link
Contributor

My vote is against mendeleev because it has so many dependencies completely unrelated to cclib. Since it's MIT licensed, couldn't we just take their database, write custom queries with the builtin sqlite module, and distribute it with cclib?

@berquist
Copy link
Member Author

I would rather choose one package or the other over taking a piece of one, especially since they are both being actively developed. I don't think that there's anything missing from periodictable, so it could replace our own implementation.

@ATenderholt
Copy link
Contributor

Fair point about not taking parts of a package if there are actively developed. I agree with going with periodictable.

@langner
Copy link
Member

langner commented Aug 5, 2018

I think adding a new dependency requires a bit more thought, a slightly more prolonged discussion. Is there a way to use our own stuff for this PR and have this discussion outside of the development cycle?

@berquist
Copy link
Member Author

berquist commented Aug 5, 2018

Just a reminder that the build is failing because of 3.2; bumping to 3.4 solves this and is not really limited to just using periodictable and scipy.

A temporary solution would be to have the mass-dependent parts of this Method work like the bridges, where methods that do not require the external dependency are still usable. So things like the nuclear repulsion energy calculation would still work. It should already be written this way in the PR.

Is there a way to use our own stuff for this PR

It depends on what you mean by this. We don't have masses, either average ones or the isotopic ones we need.

Copy link
Member

@langner langner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder about your thoughts on how far cclib should venture into methods territory. On the one hand, there is some value in providing basic methods based on parsed data. On the other hand, it's good to focus on the core functionality and not dilute cclib's mission.

I'm not sure where to draw this line... any thoughts?

nre += zi*zj/d
return nre

@staticmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't this be a module-level function?

abundance = iso.abundance
return most_abundant_isotope

@staticmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

requirements.txt Outdated
@@ -1,5 +1,7 @@
biopython ; python_version == '2.7' or python_version >= '3.4'
numpy
scipy
periodictable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm OK with this choice. periodictable look reasonable.

@berquist
Copy link
Member Author

The advantage to having all these methods is that they live right next to data type they take as input, and are an example of what you can do with cclib. The hope is that you don't need to always reinvent the wheel when building an analysis on top of ccData objects.

It's nice that using the parser and readers/writers doesn't require using the methods. However, going the other direction, having the readers and writers close by means that you can take just an XYZ file and calculate the nuclear repulsion energy or rotational constants, for example.

An option is to split off all the methods into their own repository. My feeling is that many people don't know about or use the methods as it is, and moving them somewhere else would make that worse.

I think that we should allow any method that doesn't require more than attributes and physical constants, as long as its correctness can be verified.

@berquist berquist force-pushed the rotational-constants branch from 5a34f02 to b1e6265 Compare August 14, 2018 03:18
@langner
Copy link
Member

langner commented Aug 14, 2018

Thanks for the thoughts, my opinion is roughly the same. Added this topic to #555 which should ideally go into docs for developers.


from cclib.method.calculationmethod import Method
from cclib.parser.utils import PeriodicTable


def get_most_abundant_isotope(element):
"""Given a `periodictable` element, return the most abundant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of strictly keeping to the 80 column limit. Having slightly longer lines so that they don't wrap in a n ugly way is fine IMO, as long as the length is reasonable. What do you think? We could also cover this in #555.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm in agreement; I have a habit of running fill-paragraph (or your editor's equivalent, gq?) for docstrings, and the default column width is 70. I can stop doing that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's have a convention to use only one tool if we want to auto-format. We have enough pep8 violations that it would make sense to format in bulk once if we want to go in that direction.

"""Return the masses for the given nuclei, respresented by their
nuclear charges.
"""
import periodictable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we import (softly) at top of module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll make it consistent with the bridges for now.

@langner
Copy link
Member

langner commented Aug 26, 2018

I think this is ready to go, and the Travis failure is for 3.2... @berquist probably need to rebase to get it tested in 3.4 (that was merged a moment ago).

@berquist berquist force-pushed the rotational-constants branch from d1f3086 to 3c1ce8e Compare August 26, 2018 19:28
@langner langner merged commit a39fa1e into cclib:master Sep 1, 2018
@berquist berquist deleted the rotational-constants branch September 1, 2018 20:00
@berquist berquist mentioned this pull request Mar 11, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants