def fun_total_capacity_squared(x, tot_cap):
    """Function defining soft equality constraint on total capacity
    by returning squared deviation from total capacity.

    :param x: State vector.
    :param tot_cap: Total capacity.
    :type x: :py:class:`numpy.array`
    :type tot_cap: float

    :returns: Value of left-hand side of constraint.
    :rtype: float
    """
    return (tot_cap - x.sum()) ** 2
