pwrs.core.add_userfcn#

pwrs.core.add_userfcn.add_userfcn(mpc, stage, fcn, args=None, allow_multiple=0)[source]#

Add a user callback to a MATPOWER case struct.

Registers a callback function for a named MATPOWER processing stage in mpc['userfcn']. By default it rejects duplicate registrations of the same callback at the same stage.

Parameters:
  • mpc (dict) – MATPOWER case struct.

  • stage (str) – Callback stage name, such as 'ext2int', 'formulation', 'int2ext', 'printpf', or 'savecase'.

  • fcn (callable or str) – Callback function or function name.

  • args (list, optional) – Extra callback arguments stored with the registration record.

  • allow_multiple (int or bool, optional) – Allow duplicate registrations of the same callback when true.

Returns:

Updated MATPOWER case struct with the callback registration added.

Return type:

dict