It would be interesting if it would be the possibility to switch from an average model to a Spice model for a small time, to have a full view and a fast simulation, by changing the simulation parameters during the simulation when switching from a model to another, and enabling the right model only when switched to itself. in this way whe can have in a single simulation a full wiev of the behaviour of the system. see an example of what i mean
plecs_pspice_test.plecs (79.7 KB)
I understand your motivation for first using an averaged model and then switching to SPICE. However, even switching from an averaged model to a switched model is not straightforward, since the initial states are not the same. Therefore, the switched model cannot directly inherit an already simulated state from the averaged model.
I would also like to mention that averaged models are mainly intended for real-time simulations, as in PLECS, and possibly for long mission profiles. For this reason, I would suggest running a switched model first and then switching to SPICE.
I have created two scripts that I hope will be helpful:
Run Switched/Averaged
This script runs the model once in switched mode and once in average mode. This should help you verify the average mode and compare the differences. Please note that I made a few changes to your initial model:
- I replaced your T-Type implementation with the library component block 3-Level Half Bridge (T-Type). This power module already provides the option to switch between switched and sub-cycle average configurations.
- I replaced the PWM blocks with library blocks for the switched case and placed everything into a configurable subsystem. Depending on the selected configuration, the correct PWM signal or modulation index is generated.
- The model now runs two separate simulations, in contrast to your initial model, where both models were solved in parallel. This allows the simulation to benefit from the much faster execution when average mode is selected.
Switch PLECS/SPICE
This script uses the switched mode and changes to a SPICE implementation at a specified time. To do this, I modified the model described above as follows:
- I broke the library link to the T-Type model and added a third configuration, Switched SPICE.
- In this configuration, I included the MOSFET model from ProofOfConceptSwitchPlecsToSpice.plecs as discussed here: Using Ideal and SPICE Models in the Same PLECS Simulation - #5 by RetoChristen
- I replaced the netlist with a switch model that is able to block the voltage and conduct the current: C3M0021120K. I also adapted the gate circuit so that
Rg = 2.5 Ω and Vgs = -4 V/+15 V , as suggested in the data sheet.
- I fixed the MOSFETs to SPICE mode. PLECS mode can still be helpful for debugging, for example to check whether the switches are placed in the correct direction.
- When you run the model, it starts with ideal switched semiconductors and adds one cycle of SPICE simulation at the end of the simulation run.
I am attaching the model switched_average_test.plecs (66.9 KB), which runs the first script. The second model, switched_spice_average_test.plecs (233.5 KB), runs both scripts.
Please note that the library link is broken in the second model, so this part will not be affected by any future PLECS updates.
I hope this helps.