-
Notifications
You must be signed in to change notification settings - Fork 20
Chemspecies update #130
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
Chemspecies update #130
Conversation
just a suggestion: |
This is now up for review and merge.
I agree with this one and made the change. This is of course up for a debate, so feel free to state your opinions. |
I read through and at least for the use-cases I can envision at the moment I am happy. For me this is ok to merge for now. There is one small item worth thinking about : I find it odd to have a large table of isotope data in a julia source file rather than a JSON or similar. But this is just a matter of preference and I don't feel very strongly about it. |
Fixed a bug where
The reasoning here was that having JSON or similar would add more dependencies. So, having it in julia source allows minimizing dependencies. |
""" | ||
Encodes a chemical species by wrapping an integer that represents the atomic | ||
number, the number of protons, and additional unspecified information as a `UInt32`. | ||
number, the number of protons, and additional name as max 4 characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the drive-by comment, but why are you limiting the name to 4 characters? This is the limit for the obsolete PDB format, but for example the mmcif format that replaced it does not have any length limitation: https://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v40.dic/Items/_chem_comp_atom.atom_id.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to have a bits type you need to have fixed amount of bits. This leads to a limitation on character length, which for now is 4*8bit char. We could of course increase it later on (there are several ways to do this). But the main design goal was to have it as bits type, which e.g., allows moving atom types to GPU etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!
This looks good to me also – should we link this with #115 so it will close when this is merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks for the extension.
str_symbol = String(asymbol) | ||
tmp = 0 | ||
if length(str_symbol) > 1 && isnumeric(str_symbol[end]) | ||
# We only consider cases where number of nucleons is < 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@assert
somewhere on n_neutrons and/or elsewhere to avoid this gets triggered without notice ?
src/utils/chemspecies.jl
Outdated
end | ||
end | ||
asymbol = Symbol(str_symbol) | ||
z = haskey(_sym2z, asymbol) ? _sym2z[asymbol] : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 3-argument get with default
More broadly: is this a good idea, I mean typos and small missmatches lead to a zero here, which could lead to subtle bugs, no? Same with the other lookups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the subtle bugs are possible here.
We could also have it error, if symbol is not recognized and is not :X
. This would probably be the safest option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check for symbols and now symbols that are not recognized throw an ArgumentError.
@@ -221,3 +284,29 @@ of identifying the type of a `species` (e.g. the element for the case of an atom | |||
this may be `:D` while `atomic_number` is still `1`. | |||
""" | |||
atomic_number(sys::AbstractSystem, index) = atomic_number.(species(sys, index)) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few newlines
Everything should now be ok with this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Unless there are objections I'll merge this tomorrow. |
This is update to ChemicalSpecies.
info
field toname
field and make it represent 4 charactersatom_name
to access the new name field if given, else returnatomic_symbol
The idea with
atom_name
is to represent PDB file format defines atom name columns (13-16). Whileelement_symbol
represents element columns (77-78)element_symbol
always gives the symbol of the elementatomic_symbol
adds isotope information if givenatom_name
defaults toatomic_symbol
, but overwrites it withatom_name
if species has that information.This works now
Comparisons
The basic idea is that if no isotope or name information is given, then that ChemicalSpecies works as a general atom with that atomic number.
atom_name
on the other hand is used to distinguish atoms with same type of atoms.So basically, you can create a potential using
ChemicalSpecies(:C)
. Users can then mark their systems with isotopes or atomic names, for some additional information and the potential that uses "the general carbon" works with them.masses
@mfherbst @cortner
edit. changed
atomic_name
toatom_name