Skip to content

Model language implementation#83

Merged
aglavic merged 46 commits into
reflectivity:mainfrom
aglavic:model_language
Feb 20, 2023
Merged

Model language implementation#83
aglavic merged 46 commits into
reflectivity:mainfrom
aglavic:model_language

Conversation

@aglavic
Copy link
Copy Markdown
Collaborator

@aglavic aglavic commented Mar 30, 2022

Implement the ORSO header classes for the draft simple model language.
The classes include the logic for resolving names and layers to be used easily by other programs.

The examples folder includes YAML from the website examples, a script that plots reflectivity and SLD from a given sample model, a conversion script showcasing the export of GenX models to the sample model and an estimator for measurement uncertainties based on a sample model string.

Some usage of the examples:

aglavic added 30 commits March 2, 2022 16:22
- material: {sld: -3.73401535e-07}
thickness: 1.4
roughness: 3.0
represents: refnx.reflect.LipidLeaflet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setup looks interesting. However, what happens if/when the parameterisation of a given function/class changes? Or more generally if there are changes between different versions of an analysis package?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, maybe such a description would need to include the software version, e.g. in the model "origin" attribute.

As alternative it is always possible we define our own "LipidLeaflet" model class that defines the slab-generation. It was just my understanding, that there is not really a consensus in the soft-matter community on how these are parameterized.
So this was a proposal how to deal with that in a generic way.

Comment thread examples/simple_model_example_1.yml
thickness: 11.0
roughness: 3.0
material:
sld: {real: 4.864311704082625e-06, imag: -4.533346598101179e-07}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth multiplying these values by 1e6? So one would have real: 4.86, with implied units of 1e-6 A**-2

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is already possible by defining the correct default units through the "globals" attribute of the model, we will need to find consensus on what the default for non-provided "globals" should be.
Right now I used these:

@orsodataclass
class ModelParameters(Header):
    roughness: Optional[Value] = Value(0.3, "nm")
    length_unit: Optional[str] = "nm"
    mass_density_unit: Optional[str] = "g/cm^3"
    number_density_unit: Optional[str] = "1/nm^3"
    sld_unit: Optional[str] = "1/angstrom^2"
    magnetic_moment_unit: Optional[str] = "muB"

@jfkcooper
Copy link
Copy Markdown
Contributor

Am I being slow, or is there a unit difference in the thicknesses between the examples 1/3 and 4? The total thicknesses don't seem to add up for me without 1/3 being in nm and 4 being in A?

@aglavic
Copy link
Copy Markdown
Collaborator Author

aglavic commented Apr 7, 2022

@jfkcooper
What you are seeing is the newly added automatic unit conversion in combination with the globals-length_unit arguments. So example 1 is the default, which is nm, and 3+4 should be in angstrom.

But I noticed now a bug in the example 3, where the attribute is called length_units instead of length_unit, will correct that.

@aglavic aglavic marked this pull request as ready for review February 20, 2023 15:00
@aglavic
Copy link
Copy Markdown
Collaborator Author

aglavic commented Feb 20, 2023

According to @jochenstahn it was decided to merge these developments. Will create another PR for the revision that will include the documentation and proper review.

@aglavic aglavic merged commit 5694e65 into reflectivity:main Feb 20, 2023
@aglavic aglavic deleted the model_language branch February 20, 2023 15:03
@aglavic aglavic mentioned this pull request Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants