Enhancement suggestion for `ElementalComposition` base section
Closed this issue ยท 13 comments
I am trying to use the nomad.datamodel.metainfo.eln.ElementalComposition
base section to define the composition of a material and I have some suggestion to improve its usability :)
- use a periodic table annotation instead of a long list of elements; When you have 10+ elements to provide, navigating the long list repetitively is not the most enjoyable. It is sorted by atomic number, which doesn't help neither.
- add support for converting from atomic % to weight %
For reference, here is an example of the schema that I am using:
definitions:
name: Material
sections:
Material:
base_sections:
- nomad.datamodel.data.EntryData
quantities:
name:
type: str
description: The name of the material.
m_annotations:
eln:
component: StringEditQuantity
name_ASME:
type: str
description: The ASME name of the material.
m_annotations:
eln:
component: StringEditQuantity
batch_number:
type: str
description: The batch number of the material.
m_annotations:
eln:
component: StringEditQuantity
sub_sections:
elemental_composition:
repeats: true
section:
description: |
A list of all the elements found in the material
and their respective atomic fraction within the system.
base_sections:
- nomad.datamodel.metainfo.eln.ElementalComposition
Upvote
converting from atomic % to weight %
There are already some code doing so, buried somewhere for some specific section. It should be easy to make it general.
We could reuse the PTE from the search interface and make it a component for editing.
@hampusnasstrom maybe you want to comment on the atomic_fraction/weight issue.
One comment/suggestion that came up when discussing with colleagues:
- in metallurgy, it is convenient to input the composition of the main element as "balance". This is typically of situation where are many elements (10+) which have a known composition and the rest is the main element of the alloys, i.e. the balance is simply the "100 - sum(all other elements)" and can be calculated on the fly and the user doesn't need to specify it. If it was possible to specific "balance" when inputting the composition (of course, only one element can be "balance"), that would be very convenient!
Thank you for raising this point @ericpre! We are indeed intending to have this automatic conversion from at. % to wt. % but I'm not sure if the ElementalComposition
class alone is enough for this. The ElementalComposition
class is intended to keep track of a single element so this calculation would have to be performed by the parent section which is aware of all the elements. Therefore, our intention is to include this functionality in the Substance
class. This class will already take a molecular formula and automatically generate instances of ElementalComposition
for each element and with their respective molar fraction.
There is an additional problem and that is that we currently do not support various percent units in NOMAD and that is why we haven't yet included wt. % and at. %. However, I could easily add a weight fraction and automate the conversion in the Substance class.
I like the idea with the balance element. We could add a boolean quantity balance_element
or simply use the element without a filled atomic fraction for this.
I had a look at the Substance
class but it seems to be very chemistry oriented (CAS information, molecular_mass, etc.), would it make sense to have a more generic class?
Sorry for the slow reply @ericpre. If you don't want the information in Substance
(it does retrieve relevant information also for single elements) you could use its parent class System
directly. That class only has one property elemental_composition
which is a list of ElementalComposition
instances. It will add the elements (and soon the atomic fractions) to the results section which will help with the search-ability of your data.
I now added the mass fraction to the ElementalComposition
class with an automatic calculation in the System
class (including filling a 'balance' element): https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR/-/merge_requests/1190/diffs?commit_id=9fed4df171b368d1ff63df910c619668860b55d9
Will probably take a bit of time before this is merged and on develop but I'll update here when it is.
I hope this helps! Let me know if you have any more ideas :)
Great, thank you, this sounds good, I will wait for the improvement! :)
Interestingly, I expected the "elemental composition" class to be the "system" class, but I guess this is one of these, where different people/community uses words slightly differently!
@ericpre, after some discussion this is now finally merged into the develop branch of NOMAD and the functionality should be available at nomad-lab.eu/prod/v1/staging/gui.
For your example above I would for now recommend:
definitions:
name: Material
sections:
Material:
base_sections:
- nomad.datamodel.metainfo.eln.System
- nomad.datamodel.data.EntryData
quantities:
name:
type: str
description: The name of the material.
m_annotations:
eln:
component: StringEditQuantity
name_ASME:
type: str
description: The ASME name of the material.
m_annotations:
eln:
component: StringEditQuantity
batch_number:
type: str
description: The batch number of the material.
m_annotations:
eln:
component: StringEditQuantity
The inheritance of nomad.datamodel.metainfo.eln.System
will add the elemental_composition
sub section you had above but will also automatically:
- Calculate single missing atomic/mass fraction,
- Calculate mass fraction from atomic fraction or vice versa,
- Add the elements and the elemental composition to the results section.
We are also working on moving some of the "chemistry" related properties of Substance
into a specialized section as part of a larger restructuring of our base sections and after that it might make sense to inherit directly from Substance
.
Let me know if you have any issues or questions!
@ericpre while we still haven't put a periodic table annotation, we have changed it to one more usable where the drop-down updates when you start typing for an element. I hope this helps.
Thank you for the update!
I tried briefly and it works as intended. ๐ I suspect that I have got the reprocessing confused at some point when unintentionally mixing atomic and mass fraction and I couldn't recover so I had to create a new entry. Would it worth that I try to reproduce it and report the steps here?
To test it, I have used the develop
tag of the docker image. Normally, I used the latest
tag, are they other tag that you would recommend to use?
Now that this functionality is implemented, would it make sense to revisit/tweak the display of the composition, currently, it is:
with having a display of the atomic/weight fraction.
Similarly, for the search, would it be possible to select an element and a composition range in the "elements/ formula" filter?
@ericpre while we still haven't put a periodic table annotation, we have changed it to one more usable where the drop-down updates when you start typing for an element. I hope this helps.
Yes, that works well too!
Thank you for the update!
I tried briefly and it works as intended. ๐ I suspect that I have got the reprocessing confused at some point when unintentionally mixing atomic and mass fraction and I couldn't recover so I had to create a new entry. Would it worth that I try to reproduce it and report the steps here?
To test it, I have used the
develop
tag of the docker image. Normally, I used thelatest
tag, are they other tag that you would recommend to use?Now that this functionality is implemented, would it make sense to revisit/tweak the display of the composition, currently, it is:
with having a display of the atomic/weight fraction.
Similarly, for the search, would it be possible to select an element and a composition range in the "elements/ formula" filter?
I think having an overview card for the composition when the formula is not provided can be a separate issue if that is ok. I would say that you should report your problems when you give it some usage. Also, for a couple of weeks, we support what we call NOMAD plugins: https://nomad-lab.eu/prod/v1/staging/docs/plugins.html
This would allow you to have more powerful schemas and data processing if you would be interested. There is also this video tutorial: https://www.youtube.com/watch?v=e-LmJ06fEso&t=27s