nomad-coe / nomad

NOMAD lets you manage and share your materials science data in a way that makes it truly useful to you, your group, and the community.
https://nomad-lab.eu
Apache License 2.0
64 stars 14 forks source link

Enhancement suggestion for `ElementalComposition` base section #47

Closed ericpre closed 1 year ago

ericpre commented 1 year ago

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 :)

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
TLCFEM commented 1 year ago

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.

markus1978 commented 1 year ago

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.

ericpre commented 1 year ago

One comment/suggestion that came up when discussing with colleagues:

hampusnasstrom commented 1 year ago

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.

ericpre commented 1 year ago

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?

hampusnasstrom commented 1 year ago

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 :)

ericpre commented 1 year ago

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!

hampusnasstrom commented 1 year ago

@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:

  1. Calculate single missing atomic/mass fraction,
  2. Calculate mass fraction from atomic fraction or vice versa,
  3. 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!

Pepe-Marquez commented 1 year ago

@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.

ericpre commented 1 year ago

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: image

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 commented 1 year ago

@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!

Pepe-Marquez commented 1 year ago

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: image

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

ericpre commented 1 year ago

Sure, I opened a separate issue in #66.