I am running a simulink/Matlab simulation on power control where i have to connect and disconnect inverters and loads to/from a microgrid at random while the simulation is running. I tried to use the ideal switches but there were some leakage currents (which i believe was because of the finite Snubber resistance). I made snuffer resistance infinite but then at the time of switching, an error occurred and the simulation stopped. Is there anyway to do what i am trying to do? i.e. To achieve connection and disconnection without leakage currents?