I want to use my Pentium 4 desktop for running some heavy simulations. These simulations take from two to eight hours.
Is it safe to run the CPU at 100% for such a long time?
Yes it is safe.
It is not efficient though. Pentium IV's were notorious for consuming a lot of power and generating a lot of heat. Using anything but a P4 will likely improve performance, reduce electricity needed and will generate less noise from the cooling.
(As comparison a equally old Intel pentium mobile 740 run at 1.73 GHz is just as fast as a P4 at 3GHz. And that is a laptop chip with laptop power consumption. A modern chip will finish the job way faster and use less power. If you are going to run a lot of these simulations then consider using more modern hardware).
But safe? Yes it is safe. The CPU is build to run up to 100%. The cooling it came with should be able to handle the heat. And should the cooling fail or work badly if it is full of dust bunnies then the CPU will slow down on its own. (For a P4 this means skipping cycles, so it will be a lot slower, but it will continue to calculate.).