Model elements - Desciptors and Parameters #25
Locked
damskii9992
announced in
ADRs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
General
A model is built upon many various parameters, some of which can be fitted and some of which are static. A model can additionally also be described by booleans and specific strings.
These different model elements behave differently and therefore needs to be treated differently. As such, they are split into two groups, the static parameters, booleans and strings are called "Descriptors", whereas only those model parameters which can be fitted to match the experimental data to the model prediction are called
Parameter
.The Descriptors are then further split into 3 groups based on the type of value that can be assigned to them,
DescriptorNumber
for static numbers,DescriptorStr
for strings andDescriptorBool
for booleans. Functionality shared between all types of Descriptors live in anDescriptorBase
object which all Descriptors inherit from. The inheritance graph of the model objects therefore has the following form:Descriptors
The purpose of a "Descriptor" is to handle model elements that can be considered "static" (can't be fitted to match model to experimental data). The types of descriptors currently implemented have
bool
,string
, ornumber
values, which all share some base functionality contained in a base class.DescriptorBase
All type specific descriptors inherit from this base class. The main properties of the base class are:
name
, name of this object (decorated with undo/redo functionality)display_name
, optional pretty name for the object (decorated with undo/redo functionality)description
, optional summary of what this object is forurl
, optional lookup url for documentation/informationparent
, optional link to the object which this descriptor is attached toDescriptorBool
The
bool
descriptor holds the value of abuiltin bool
type. In addition to the DescriptorBase properties, it has the properties:value
, utilized to hold the value (decorated with undo/redo functionality)DescriptorStr
The
str
descriptor holds the value of abuiltin string
type. In addition to the DescriptorBase properties, it has the properties:value
, utilized to hold the value (decorated with undo/redo functionality)DescriptorNumber
The
number
descriptor is different from the two former descriptors as it is continuous. Furthermore it can be assigned a physical unit and a variance for the value. To provide this functionally the value is kept internally in a [scipp_scalar
] (https://scipp.github.io/generated/functions/scipp.scalar.html). In addition to the DescriptorBase properties, the DescriptorNumber has the following properties:value
, the numerical value of the variable (decorated with undo/redo functionality)unit
, optional physical unit for the numerical value (decorated with undo/redo functionality)variance
, optional variance for the value (decorated with undo/redo functionality)full_value
, the full Scipp scalar holding all the above mentioned properties (decorated with undo/redo functionality)To minimize user mistakes and simplify constraints, the
unit
(and therefore alsofull_value
) cannot be changed after initialization, except between allowed types, such as from "m" to "cm" or "eV" to "J". This unit conversion is done through the convert_unit method.DescriptorNumbers can be created from the
value
and optionally, thevariance
andunit
, as well as directly from a predefined Scipp scalar through theDescriptorNumber.fromScipp(scipp_scalar)
constructor.Parameter
The
Parameter
class inherits fromDescriptorNumber
and serves to hold model parameters that can be fitted. To facilitate this, it contains the additional properties:min
, optional minimum which the value can't go below (decorated with undo/redo functionality)max
, optional maximum which the value can't go above (decorated with undo/redo functionality)fixed
, optional sets if the parameter is allowed to vary while fitting (decorated with undo/redo functionality)enabled
, optional sets if the objects value can be set or if constraints are applied (decorated with undo/redo functionality)callback
, optional callback that serves as a link between the object and a potentialCalculator
Link to the ADR suggestion:
#20
Beta Was this translation helpful? Give feedback.
All reactions