Has anyone faced this problem - The simulation gets stuck in the "Initialization" phase?

I have a model of a 3ph Inverter on PLECS Standalone, and the issue is that PLECS gets indefinitely stuck in the “Initialization” phase after I give the “Run Simulation” command, after which I then have to close the application from Task Manager. Sometimes the PLECS app just crashes as soon as I give the Run command.

There is nothing wrong with my initialization parameters, I have used the same on other models which run without any problem.

The only difference in this model from other similar variants that I’ve run successfully, is a C-script block which contains about a 1000 lines of code. Assuming that it takes time to process the fairly complex model, I’ve waited up to even an hour, but it never gets past the initialization part. There’s no error message that shows up as well, so I haven’t made much progress in solving the issue so far.

Any feedback is much appreciated!

If the only difference between this model and a working variant is the C-script then the cause of the stuck simulation is most probably - surprise - the C-script.

Good C-scripts are hard to write and harder to debug. If there is, for example, an endless loop in your ‘Start function code’, PLECS will hang on model start and there is no chance to stop the simulation.

Debug your C-script, for example by adding printf in your code to verify that the end of your ‘Start function code’ is reached. This way you may be able to find where your C-script gets stuck.