Energy production in ecosystems