Modelling Matter and Energy in an Ecosystem