Method for calculating rotational constants#568
Conversation
| biopython ; python_version == '2.7' or python_version >= '3.4' | ||
| numpy | ||
| scipy | ||
| periodictable |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
OK, I'm OK with this choice. periodictable look reasonable.
|
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. |
|
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. |
|
periodictable does not work with Python 3.2 due to Unicode strings, but is tested with 3.3. |
|
I just rediscovered mendeleev, which may be even better than periodictable. |
|
Mendeleev seems nice, but has some pretty heavy dependencies like 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. |
|
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? |
|
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. |
|
Fair point about not taking parts of a package if there are actively developed. I agree with going with periodictable. |
|
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? |
|
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 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.
It depends on what you mean by this. We don't have masses, either average ones or the isotopic ones we need. |
langner
left a comment
There was a problem hiding this comment.
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?
cclib/method/nuclear.py
Outdated
| nre += zi*zj/d | ||
| return nre | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
Why shouldn't this be a module-level function?
cclib/method/nuclear.py
Outdated
| abundance = iso.abundance | ||
| return most_abundant_isotope | ||
|
|
||
| @staticmethod |
| biopython ; python_version == '2.7' or python_version >= '3.4' | ||
| numpy | ||
| scipy | ||
| periodictable |
There was a problem hiding this comment.
OK, I'm OK with this choice. periodictable look reasonable.
|
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 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. |
5a34f02 to
b1e6265
Compare
|
Thanks for the thoughts, my opinion is roughly the same. Added this topic to #555 which should ideally go into docs for developers. |
|
|
||
|
|
||
| def get_most_abundant_isotope(element): | ||
| """Given a `periodictable` element, return the most abundant |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
cclib/method/nuclear.py
Outdated
| """Return the masses for the given nuclei, respresented by their | ||
| nuclear charges. | ||
| """ | ||
| import periodictable |
There was a problem hiding this comment.
Shouldn't we import (softly) at top of module?
There was a problem hiding this comment.
Yes, I'll make it consistent with the bridges for now.
|
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). |
Additionally, * isotopic masses via `periodictable` package * center of mass * moment of inertia tensor * principal moments of inertia
d1f3086 to
3c1ce8e
Compare
Additionally,
periodictablepackageHandles #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.