iMac 27' powering off without reason
Voltage fluctuations are normal.  I am assuming you are in the UK or Europe.  If so, your voltage should be between 220V and 240V so everything is within range.  Besides, the UPS is designed to "smooth out" these voltage fluctuations so your power is clean coming into your Mac.

What is key to finding out what your issue is what the shutdown code is in your system log.  

In Terminal, type the following command and paste the output to your question

syslog | grep shutdown

You should get something like "Previous shutdown cause: X"

Based on your error message as "Previous shutdown cause: 0" means there was a power loss.



You said that you have a UPS; it's very easy to test whether it is working or not:  just unplug it from the wall while your Mac is powered.  If it continues to run, your UPS is good.  For the record, I doubt it's your UPS because you would know if you were having power outages, but it's always good to test.

Once you have confirmed your UPS, take a look at this post:  iMac randomly shuts down  I believe it will answer your question as to why your iMac is powering off; basically your iMac's power supply failing.