derive an average waveform from an FFT spectrum, where all cycles have same shape and period I measured a (real) voltage waveform (red curve below). Then I took its FFT and used the magnitudes of the first 20 harmonics (even and odd) to model the signal (blue trace below), by summing the fundamental and harmonic-related sine wave components as follows:

Vout(t)=A1*sin(wt)+A2*sin(2wt)+A3*sin(3wt)+...+A20*sin(20wt)


I expected a better match between the two curves. What portion of the spectrum am I missing in my model to get a better match?  

The model (blue) has symmetrical rising and falling edges, whereas the measured waveform (red) appears asymmetrical (capacitive charging/discharging; that is, the transitions begin sharply then decay). How does the FFT capture this effect if not in the harmonics?



UPDATE

I modified the above equation to include the phase as follows:

Vout(t)=A1*sin(wt-phi1)+A2*sin(2wt-phi2)+A3*sin(3wt-phi3)+...+A20*sin(20wt-phi20)


where phiN is the phase for each harmonic computed from FFT coefficients between 0 and Nyquist frequencies (e.g. atan(imag/real)).



The model (blue) does show an improvement in addressing asymmetric rise and fall transitions, but I'm still missing something. 

Is there a way to improve the model based on FFT coefficients as I'm trying to do here, without computing the IFFT explicitly? I'm trying to create a waveform where every cycle is exactly the same, with the same period (within machine error), which represents the waveform of an average cycle (repeated many times).
I found the answer here:

https://www.dsprelated.com/thread/3253/simple-and-accurate-phase-estimation-of-harmonics-in-a-signal

Just change atan() to atan2() to account for the correct phase in all quadrants.