-
Notifications
You must be signed in to change notification settings - Fork 5
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
molecular weight #2
Comments
Even though it's another dependency, I'd rather depend on The best way to add molecular weight into API is just to define a method, since by default compound string can be anything and may not be valid for periodic table. function molecularweight(compound::Compound)
weight = 0
for (element, k) in elementtuples
weight += k * getweight_fromtable(element)
end
return weight
end There may be a nice way to do further calculations, i.e. check "The chemical composition matrix" at http://logical.ai/chemistry/html/chem-nullspace.html. To get a specific number of moles of some compound, you can use matrix multiplication. Then you just multiply that number by molecular weight, and voila! |
PeriodicTables.jl is basically a big Dict of elements haahah, but depends of unitful, and he molecular weights have units there. |
to add to the method (in case someone needs it)
|
one way to obtain all the molecular weights in a programmatic way:
without depending on PeriodicTables or unitful, the data is the following:
the method of extraction was the following:
to extract the molecular weight, it suffices to make a dict with this data and call it. but im not familiarized enough with the API to do a pull request
The text was updated successfully, but these errors were encountered: