We present the details of a method to perform molecular-dynamics (MD) simulations without thermostat and with very small temperature fluctuations ±ΔT starting with MD step 1. It involves preparing the supercell at the time t=0 in physically correct microstates using the eigenvectors of the dynamical matrix. Each initial microstate corresponds to a different distribution of kinetic and potential energies for each vibrational mode (the total energy of each microstate is the same). Averaging the MD runs over many initial microstates further reduces ΔT. The electronic states are obtained using first-principles theory (density-functional theory in periodic supercells). Three applications are discussed: the lifetime and decay of vibrational excitations, the isotope dependence of thermal conductivities, and the flow of heat at an interface.