dc link voltage surge

I’m driving a PMSM using a three-phase IGBT inverter with a constant DC supply.
However, in actual motor operation, the voltage across the DC link capacitor fluctuates.
How can I simulate this?

Yes, this is possible but you need to develop a model of your voltage supply. For example instead of directly connecting a voltage source to your inverter, you would have a voltage source connect to some internal impedance representing your supply, output/inverter capacitance, and perhaps cable or busbar inductances, etc. However, developing such a model of your system is something only you and your colleagues are positioned to do.

If you are looking for some inspiration you could look at the demo models “Boosted Motor Drive” or “Power Split Hybrid Vehicle System”. It has a front end DC/DC (if your application has a front end converter that is).

If you have a direct connection to your battery then as Bryan mentions in his response you would need to model the impedance from your battery to the bus capacitor which might include impedance of the internal battery resistance, contactor, and associated cables.