The processing of constraint equations and new variable equations requires some abstract linear algebra since a parameter may show up in more than one equation. The equations are collected into groups where each parameter is referenced in only one group. If there are \(n\) parameters in the group, then there must be \(n\) or fewer equations. If there are \(n\) equations, then the constraints uniquely determine the values of all parameters. If there are more than \(n\) equations then the constraints are either overdetermined or a constraint is duplicated in some fashion; either case is treated as an error. If there are \(m\) equations (\(m < n\)) then there are still \(n-m\) remaining degrees of freedom. The remaining degrees of freedom are computed as to be as best orthogonal from the \(m\) equations and these specify the variables that can be refined. Effectively what is done is that new variable equations are generated for the remaining degrees of freedom and when the all the parameters in group are refined, then only the generated new variable equations are varied. Before any refinement is started, the parameter values in constraint equations are adjusted to bring the parameters into compliance with the constraint(s). In the refinement, the shifts are applied only to the new variable equations.
As an example, if we specify an equation:
\(var_1 + var_2 = 1\)
Then there are two variables, one equation, and there remains one degree of freedom. We write this as
\(var_1 - var_2 = var_G\)
and the generated variable, \(var_G\), is the term that is actually varied. Any shift that is calculated for \(var_G\) will be added to \(var_1\) and subtracted from \(var_2\). Prior to refinement the parameters will be adjusted so that \(var_1 = var_1 / (var_1 + var_2)\) and \(var_2 = var_2 / (var_1 + var_2)\) to correct the parameter values if they are not initially compliant with the constraint.
Note that if a variable is used in both a constraint equation and and parameter equivalence, this could cause a conflict in processing. To address this, the parameter equivalences using parameters in constraint equations are converted to constraint equations for processing. Note that constraint equations and new variable equations can share
The math that is used for processing constraint equations is described in the GSAS-II Developer’s Documentation, at this URL: https://gsas-ii.readthedocs.io/en/latest/GSASIImapvars.html∖#constraint-checking-and-grouping-generateconstraints.