I was wondering if I can get some support with the analysis tools available in PLECS. To be specific I want to plot the loop gain for an Inner Current loop. To start with I found the tutorial material "PFC converter and Controller" from Plexim's website .
In that tutorial, a 2-loop converter is designed and the open-loop response of both the converter and controller are simulated using the analysis tools from PLECS. To make it simple for now I am focused just on the current loop section.
The tutorial provides simulations (.zip file attached )for the open loop control-to-current response (named Iloop_impulse) and the Current loop controller response (named Type2_Icontroller) . From those 2 simulations the plots from Fig.8 in the tutorial can be easily obtained. After that, the tutorial provides some results of the loop-gain for the current loop; however, the loop gain plots (Fig.9) are not obtained by direct simulation in PLECS. Instead those plots are obtained by using a MATLAB file attached in the tutorial by adding the data from the 2 individual responses of the converter and controller. Lets call this approach the "Indirect method" to compute loop-gain.
I wanted to verify that in fact the current loop is working according to the design directly from simulation. For that, I have created a new simulation ("IloopGain_Example" attached) just for the current loop with the current controller to compute the loop-gain using an AC sweep (I used the "Buck Converter with Loop Gain Analysis"  to set the loop gain simulation for my example).
I set a fixed value for the current to generate the desired 400V output voltage from the PFC example (3 A) and the Current Sensor Gain (value of 2 remains the same). I simply closed the loop and put a "Loop Gain Meter".
With an AC sweep I was able to compute the Current Loop-Gain Response (picture attached); The response is very similar to the one obtained by the "Indirect Method" (picture attached), but the directly simulated results have about 10 dB of additional gain.
I want to figure it out from where are those extra 10 dB coming... Since the current loop parameters were not changed at all I would expect to get the same result as in the "Indirect Method".
My questions are the following:
1.- Can those extra 10 dB somehow come from computational error or from the settings of the AC-sweep when computing the loop-gain in simulation? I am asking this because for some reason the tutorial decided not to compute the loop-gain directly with simulation... This makes me think that might be some additional considerations to take for this approach.
2.- The example "Buck Converter with Loop Gain Analysis" has an accurate result which makes me think that may be a very fundamental mistake in my simulation. From the file attached (IloooGain_Example) , can you see anything fundamentally wrong? The simulation only puts together both previous simulations from the PFC tutorial and adds the "Loop Gain Meter". The DC operational point is set to generate a 400V output (that is why I set the value of 3 for the desired current in the loop). Since the PWM carrier amplitude and the current sensor Gain have not been changed, the controller should be expected to work without any change as provided in the PFC tutorial...
Sorry for the long post... and I hope you can give an input on this topic.
 PFC Tutorial files: https://www.plexim.com/support/application-examples/283
 "Buck Converter with loop-gain analysis": https://www.plexim.com/sites/default/files/demo_models_categorized/plecs/buck_converter_with_loop_gain_analysis.pdf