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 slightly
out of sync since you are using an electrostatic element which solves for charge
and computes current by a numerical derivative over two time steps. Due to this
the current value is half a time step behind the voltage.

To investigate this possibility I modified your current array to be the
average of the values at t and t+1 as follows:

Current(iii) = (Current(iii) + Current(iii+1))/2

I then computed power by multiplying the current array by the voltage
array 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 multiplication
of 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,100
sin_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)





Show Form
No comments yet. Be the first to add a comment!