ADR suggestion SampleModel
#4
Replies: 9 comments 12 replies
-
|
Since the |
Beta Was this translation helpful? Give feedback.
-
|
I would expect a |
Beta Was this translation helpful? Give feedback.
-
|
Regarding the |
Beta Was this translation helpful? Give feedback.
-
|
Regarding the |
Beta Was this translation helpful? Give feedback.
-
|
There will also be a DoubleGaussian and DoubleLorentzian, with pairs of peaks equidistant from zero, with identical width and detailed balancing |
Beta Was this translation helpful? Give feedback.
-
I'd propose |
Beta Was this translation helpful? Give feedback.
-
|
ModelComponent:
Then maybe we also need a model collection, which will have |
Beta Was this translation helpful? Give feedback.
-
|
ModelComponent:
Making
|
Beta Was this translation helpful? Give feedback.
-
|
GaussianComponent:
I htink it is dangerous to have a badly behaving default. |
Beta Was this translation helpful? Give feedback.
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
The SampleModel is briefly described in #2 , but needs to be fleshed out more. I first repeat what was written in #2
This holds the model, which consists of
components, which can beGaussian,Lorentzian,DHO, etc., or user defined. (Care must be taken to also allow 2d models often used in QENS, such asJumpDiffusion. This will probably be handled by a separate class, which can then generate aSampleModelfor each probed Q).It has methods to create and remove components.
I will discuss the convolution and some issues relating to it in another ADR.
Current Implementation
Only a basic skeleton has been implemented.
Proposed implementation
SampleModelThe
SampleModelwill containcomponentsas discussed below. I think it will inherit fromBaseObj. It will at least have the following methods:add_component: adds aModelComponent. It optionally takes a new name of the component, otherwise the name of the component will be used. It should check to avoid duplicate names.remove_component: removes a component using its nameevaluate: evaluates the full model at givenx, including detailed balancing. Should give a warning if the temperature varies between componentsset_temperature: setstemperatureof all components (for detailed balancing).temperatureis aParameter, which is shared between components.fit_temperatureTrue or False, defaults to False as it`s rare (but not unheard of) to fit the temperature.It is almost always necessary to allow for a small offset in the
xaxis. This offset should be identical for all components. It should have a setter, getter, and a method to fix/free it>offsetfix_offset: True or False. Defaults to FalseModelComponentEach component will inherit from
ModelComponent, which inherits fromBaseObj. It will at least have the following methods:evaluate: Evaluates the component at givenxset_temperature: setstemperatureof this component (useful if people want to play around with the components without making a SampleModel).temperatureis aParameter, which is shared between components. It will by default be fixed.use_detailed_balancingTrue or False. Default True if temperature is non-zero.fix_all: fixes allParametersof this component, excepttemperaturefree_all: frees allParametersof this component, excepttemperature`args:
namea name to refer to the component. There should be checks to disallow duplicate names in aSampleModelGaussianComponentHere is one example of a
ModelComponent. It will take the following arguments and have the following methods:args:
nameamplitude: amplitude of the Gaussian, defaults toNonewidth: sigma of the Gaussiancenter: center of the Gaussianarea: area of the Gaussian, defaults toNone. Exactly one ofamplitudeorareamust be given. Internally, we will work withamplitude, butareais very useful both internally and externally since its conserved during convolutionunit: unit of thewidth,centerandarea`, as a string.The args are given as doubles, and
Parameters will be created from them.methods:
evaluateevaluates the modelarea(both setter and getter):unit(setter and getter): change/get the unitfix_amplitudefix_widthfix_centerLorentzianComponentWill be nearly identical to the
GaussianComponentDeltaFunctionComponentWill be nearly identical to the
GaussianComponent, except its evaluate will beamplitudeif x is 0, and 0 otherwiseBeta Was this translation helpful? Give feedback.
All reactions