Ab initio modelling of photoinduced electron dynamics in nanostructures