2 Free energy and restoring torque
We begin with a brief summary of principal thermodynamic relations and the relevant thermodynamic potential.
The free energy also called the Helmholtz energy or Helmholtz free energy,
, is a thermodynamic potential defined as:

(62) 
where
is the internal energy and S is the entropy, both of them correspond to state functions. In basis of the first law of thermodynamics, the variation of the internal energy could be expressed as:

(63) 
is the work performed on the system, and is the heat absorbed by it, and using the second law of the thermodynamics we obtain that
.
Then we can express the variation of the free energy in the following way.

(64) 

(65) 

(66) 
The work done on the system can be redefined as a function of the appropriate conjugate work variables
and
, in such way that:

(67) 
If we consider a magnetic system in contact with a thermal bath at a constant temperature, and neglect the possible thermal expansion and magnetostriction effects, the work performed on the system could be described by the following expression:

(68) 
On the other hand, it is known that the work done on the system is equivalent to the restoring force also called internal torque, and we can build the torque of our system as:

(69) 
In constrained Monte Carlo method the system cannot reach full equilibrium. The average of the total internal torque does not vanish
and this is equal to the macroscopic torque
(see detailed proof in Ref. [126]),
where
is the Helmholtz free energy,
now a function of
.
Even though we cannot compute
directly,
we can reconstruct its angular dependence by integration
(if the system behaves reversibly)
and this in turn gives us the anisotropy constants at any temperature.
Rocio Yanes