Demand charge error?
HOMER calculates the demand charge considering peak demand as shown in this article.
However it considers the peak capacity only related to grid purchases. The peak demand necessary to inject energy into the grid is not taken into account. (In order to attest this issue, one can compare the max value of "Grid Sales" and "Grid Purchases". The value that HOMER uses to calculate the demand charge is only max(Grid Purchases) ).
How to take into account the demand charge for grid injected energy?
Demand charge is usually defined by utilities and it's the same value that you input into HOMER. You get paid for the electricity injected into the grid at the sellback rate. Usually there is not peak demand factor for the sellback rate. If you wish to have different sellback rates, you can either input them as sensitivities or enter more values in the rate definition table under real-time or scheduled rates.