FAIRmat-NFDI / nomad-material-processing

A NOMAD plugin containing base sections for material processing.
https://fairmat-nfdi.github.io/nomad-material-processing/
Apache License 2.0
9 stars 2 forks source link

42 add solution and solution preparation classes #43

Closed ka-sarthak closed 1 month ago

ka-sarthak commented 2 months ago
hampusnasstrom commented 2 months ago

In general Andrea and I thinks this looks good. It will be a bit more Entity heavy than the last implementation but that could also be fine. The main thing we discussed was how the Solution class was structured. Was there a reason for having a separate section for the concentrations rather than filling them directly in the Solute class?

ka-sarthak commented 2 months ago

@hampusnasstrom @aalbino2 thanks for looking into it!

Was there a reason for having a separate section for the concentrations rather than filling them directly in the Solute class?

It was inspired by the classes from the last implementation where the component_concentration is a part of the properties of the solution. Since the concentration of each component depends on the final volume of the solution, I find it reasonable to make concentrations as a sub-section of the solution.

What do you think?

ka-sarthak commented 2 months ago

Main points from the Task Force meeting on 22.07.2024:

ka-sarthak commented 2 months ago

If multiple components in the solution are the same pure substance, they should be combined into one. This can happen especially when multiple existing solutions sharing a common solvent are used to create a new solution. Here, we want the new solution to not have multiple components representing the same solvent, but instead one combined component.

To combine the components, the Solution.normalize uses component.pure_substance.iupac. If this is shared by two components, they will be combined into one: masses and volumes will be accumulated.

ka-sarthak commented 2 months ago

solvents, solutes, and elemental_composition sub-sections are meant for viewing and not for editing. Ideally, they should be made non-editable subsections. I tried doing this with SectionProperties and Filter, but it did not work. Leaving it as a TODO comment for later.

ka-sarthak commented 2 months ago

When determining the molar concentration, the moles are calculated based on the mass and the molecular mass of the component. In the case of liquids, their density and volume are used to compute the mass. Once the moles are available, they are multiplied with purity_fraction if available.

The question of whether the purity figure is vol/vol or weight/vol or weight/weight not relevant. Right? @aalbino2 @hampusnasstrom

ka-sarthak commented 2 months ago

BaseSolutionComponent was needed to put together SolutionComponent, which is a solid or liquid pure substance, and SolutionComponentReference, which connects to a pre-existing solution. With the new factoring, however, this parent section is not required.

The AddSolution step in the SolutionPreparation.steps uses a SolutionReference, and takes the solution_components from the referred solution and copies it into the current solution. Therefore, in the solution class, there is no need to save the reference as a solution component.

ka-sarthak commented 2 months ago

The SolidSolutionComponent class provides nothing additional to its parent: SolutionComponent. Removing it.

ka-sarthak commented 2 months ago
ka-sarthak commented 1 month ago

SolutionPreparation class populates the solution sub-section instead of creating a new Solution entry. This change is made to avoid using m_to_dict method used create_archive function, which is not resolving the references correctly. Once the method is fixed, the intended behavior of SolutionPreparation will be re-instigated.

ka-sarthak commented 1 month ago

SolutionPreparation entry now creates a Solution entry and attaches a reference to it in the solution sub-section. The missing part was to supply the context of the current entry archive to the newly generated archive. This led correct references.

ka-sarthak commented 1 month ago

@hampusnasstrom I made most of the changes you suggested. Please review again :)

ka-sarthak commented 1 month ago

@hampusnasstrom Thanks for a great review! Merging it now.