  We use molecular dynamics simulations for a first principles-based effective
Hamiltonian to calculate two important quantities characterizing the
electrocaloric effect in BaTiO$_3$, the adiabatic temperature change $\Delta T$
and the isothermal entropy change $\Delta S$, for different electric field
strengths. We compare direct and indirect methods to obtain $\Delta T$ and
$\Delta S$, and we confirm that both methods indeed lead to identical result
provided that the system does not actually undergo a first order phase
transition. We also show that a large electrocaloric response is obtained for
electric fields beyond the critical field strength for the first order phase
transition. Furthermore, our work fills several gaps regarding the application
of the first principles-based effective Hamiltonian approach, which represents
a very attractive and powerful method for the quantitative prediction of
electrocaloric properties. In particular, we discuss the importance of
maintaining thermal equilibrium during the field ramping when calculating
$\Delta T$ using the direct method within a molecular dynamics approach.
