Thanks Mikkel for that tip.
Let
me take this opportunity to remind everyone of the difference between
parameters and variables. Parameters are quantities that are needed to
define the physical/structural model. In this sense, Uiso is a
parameter. It is a number that, for each atom, is encoding the
uncertainty in the position of that atom. It is an attribute of the
structural model.
On the other hand,
Variables are things that are varied by the regression engine when it
does its work of fitting the data. These are just numbers that the
regression engine can vary to minimize the objective (agreement).
People
often confuse these two concepts/things and it is understandable
because we often want the parameters themselves to be varied and
therefore the parameters to be the variables. But in fact they are
conceptually different. Sarah wanted to apply a hard constraint for the
allowed range that a parameter was allowed to vary, but to do this we apply the constraint to the variable, not to the parameter.
We
use constraint equations to link parameters to variables. This is done
in the addVar() method for example, which has the pattern
addVar(constraint_expression) where it is implied that the resulting
variable = constraint_expression. So
recipe.addVar(atom1.Biso,
name="atom1_biso_variable",
value=1.,
fixed=True,
)
will, in this case, assign a variable (in the FitRecipe object called "recipe") with the name atom1_biso_variable to the Biso parameter of the atom atom1 in the atom list in the structure object (phew).
We can then put strict bounds on this variable using the boundRange() method, e.g.,
recipe.addVar(atom1.Biso,
name="atom1_biso_variable",
value=1.0,
fixed=True,
).boundRange(0.,5.)