# Why is my macro to compute average power not equalling zero? Theory says that the average power for a capacitor is zero.

 Your macro calculates power based on current and voltage, which are slightlyout of sync since you are using an electrostatic element which solves for chargeand computes current by a numerical derivative over two time steps. Due to thisthe current value is half a time step behind the voltage.To investigate this possibility I modified your current array to be theaverage of the values at t and t+1 as follows:Current(iii) = (Current(iii) + Current(iii+1))/2I then computed power by multiplying the current array by the voltagearray with *VOPER. The mean value of this calculation (calculated by VSCFUN)is quite small as shown below.It is also possible to produce the negative bias in the power with the apdl multiplicationof slightly out of phase sin and cos functions as shown below.fini/clear*afun,deg*dim,sin_cos,table,100,1*vfill,sin_cos(1,0),ramp,0,.01*do,iii,1,100sin_cos(iii,1)=-0.1e-2*cos(iii*360/100-1.8)*2.56*sin(iii*360/100)*enddo*vplot,sin_cos(1,0),sin_cos(1,1)*vscfun,mean_value,mean,sin_cos(1)