I am wondering how to calculate WTHD in Plecs?

The THD Block in PLECS uses the mathematical relationship between the RMS voltage and THD to avoid calculating the fundamental component for each signal (see the equation in the component help). I’m not sure such an approach is possible with the WTHD.

The fastest way to implement such a block would be to use the Fourier Transform block from the library to determine the individual components and then apply the WTHD formula. This approach isn’t 100% accurate since the actual WTHD would sum all the components up to infinity, but should work well if the dominant harmonics are known to be within the analysis range of the WTHD block.

See the attached model that calculates the WTHD up to the specified harmonic level.

WTHD_Demo.plecs (22.7 KB)