# fweight

The target function for the optimization algorithms in *potfit* is defined as:

$$Z_F(\boldsymbol\xi) = \sum_{k=1}^{3N}u_k(F_k(\boldsymbol\xi)-F_k^0)^2 + \sum_{l=1}^{M}w_E(E_l(\boldsymbol\xi)-E_l^0)^2+\ldots$$

where $F_k(\boldsymbol\xi)$ are the forces calculated from the potential and $F_k^0$ the reference value. The same notation is used for the energies $E$.

The weights for the energies ($w_E$) and stresses can be given in the parameter file with the `eng_weight`

and `stress_weight`

parameters. The weight for the forces
($u_k$) is normally chosen to be 1.

This can be a problem for very small reference values. By enabling the `fweight`

compile option, each force component $F_k$ is weighted by the factor

$$u_k=\frac{1}{(\boldsymbol F_k^0+\epsilon)^2},$$

where $\boldsymbol F_k^0$ is the magnitude of the force vector for atom $k$.

This increases the relative contributions of numerically small forces to the error sum.

The compile time parameter FORCE_EPS (in `defines.h`

) prevents the overweighting of very tiny forces. The default for this value is 0.1.