Autogenerated documentation¶
pfpy.pf module¶
-
class
pfpy.pf.ComRes(pfobject, load=True)¶ Bases:
pfpy.pf.BasePFObject-
define_outputs(outputs, elmres, filepath)¶
-
read_results()¶
-
-
class
pfpy.pf.ElmFile(pfobject)¶ Bases:
pfpy.pf.BasePFObject-
create_file(signal, filepath)¶ Writes a signal to a file that can be read by ElmFile in PowerFactory
-
-
class
pfpy.pf.ElmRes(pfobject, load=True)¶ Bases:
pfpy.pf.BasePFObject-
LOADED= 'LOADED'¶
-
Load()¶
-
NOTLOADED= 'NOTLOADED'¶
-
Release()¶
-
clear_variables()¶ Unloads the ElmRes file, deletes of the variable definitions, and intializes writing.
-
n_cols¶
-
n_rows¶
-
outputs¶ Returns the pandas data frame containing the simulation results.
Returns: Pandas DataFrame containing the simulation results. The columns are monitored variables’ names and the index is the simulation time. Return type: DataFrame
-
static
save_results(result, filepath)¶ Saves the pandas DataFrame of results as a JSON file.
Parameters: - result (DataFrame) – A DataFrame with simulation results.
- output_file (str) – A filepath at which the results are saved.
-
state¶
-
variables¶
-
-
pfpy.pf.GetActiveNetworks()¶
-
class
pfpy.pf.IntMat(pfobject)¶ Bases:
pfpy.pf.BasePFObject-
signal¶
-
-
class
pfpy.pf.Network(pfobject, *args, **kwargs)¶ Bases:
pfpy.pf.SubscribablePFObject-
activate()¶
-
deactivate()¶
-
-
class
pfpy.pf.Project(project_name, project_folder=None)¶ Bases:
pfpy.pf.BasePFObject-
activate(project_path)¶
-
-
class
pfpy.pf.StudyCase(pfobject, *args, **kwargs)¶ Bases:
pfpy.pf.SubscribablePFObject-
activate()¶
-
create_comres(comres_name)¶
-
create_elmres(elmres_name)¶ Creates an ElmRes object. If there is an existing ElmRes object with the same name, it is overwritten by default.
Parameters: elmres_name (str) – The name of the ElmRes object which is created.
-
deactivate()¶
-
modal_analysis(path)¶
-
simulate(start_time, step_size, end_time, sim_type='rms')¶ Initializes and runs a dynamic simulation.
Parameters: - sim_type (str {'rms', 'emt'}) – Simulation type which can be either RMS or EMT simulation.
- start_time (float) – Starting time of the simulation.
- step_size (float) – Simulation step time.
- end_time (float) – End time of the simulation.
-
-
class
pfpy.pf.StudyCaseContainer¶ Bases:
dict-
active_study_case¶
-
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
-
class
pfpy.pf.SubscribablePFObject(pfobject, **kwargs)¶ Bases:
pfpy.pf.BasePFObject-
observers_add(observers)¶
-
observers_notify(event)¶
-
observers_remove(observers)¶
-
-
pfpy.pf.change_parameters(params)¶ Sets the parameters of PF elements.
Parameters: params (dict) – A dictionary of parameters of the following form {‘element name 1’:{‘parameter name 1’:value, …}, … }
-
pfpy.pf.generate_object_dict(obj_list, obj_class)¶
-
pfpy.pf.get_parameters(params)¶ Fetches the parameters of a model’s elements.
Parameters: params (dict) – A dictionary of parameters of the following form {‘element name 1’:[‘parameter name 1’, …], … }
-
pfpy.pf.parse_name(name)¶ Parses a name of a PowerFactory element and returns its name and class
-
pfpy.pf.print_tree(root)¶
-
pfpy.pf.set_params(params)¶ Sets the parameters of a model’s elements.
Parameters: params (dict) – A dictionary of parameters of the following form {‘element name 1’:{‘parameter name 1’:value, …}, … }
-
pfpy.pf.start_powerfactory()¶
pfpy.models module¶
-
class
pfpy.models.PowerFactoryModel(project_name, project_folder=None, **kwargs)¶ Bases:
object-
a_mat¶
-
get_states()¶ Returns two dictionaries containing states and their indices used by PowerFactory. They are generated from modal computation results so they need to be generated first.
Parameters: modalpath (str) – A path to the folder where PowerFactory modal results are stored. Returns: - states (dict [str, list]) – States is a dictionary where states are grouped by a network element.
- states_idx (dict [str, int]) – A dictionary where every state as a key has a corresponding index in PowerFactory as a value.
-
inputs¶
-
linearize(inputs_c, inputs_bd, outputs, ref_state='')¶ Returns the A, B, C and D matrices of a numerically linearized system, i.e. the matrices of the following system.
\[\dot{x} = Ax + Bu\]\[y = Cx + Du\]Compute a column of B assuming steady state after a disturbance: .. math: 0 = dot{x} = Ax + B_iu_i Rightarrow B_i = -Axu^{-1} .. math: D_i = (y-Cx)u^{-1}
Parameters: - inputs_c (list) – A list containing dictionaries that specify all the input waveforms for computation of the matrix C.
- inputs_bd (list) – A list containing dictionaries that specify all the input waveforms for computation of matrices B and D.
- outputs (dict[str, list]) – Dictionary of outputs where key is the name of an object in PowerFactory and the value is a list of the correspodning signals taken as an output of the system.
- outputs_idx (dict[str, int]) – Dictionary where a key is of the following form -
'ObjectName.ObjectType\SignalName - modalpath (str, optional) – A path to a folder where PowerFactory will store the modal analysis results.
- ref_state (str) – This can be used to eliminate a reference state which causes
the A matrix to be nonsingular. The state has to be
specified using the following form
'ObjectName.ObjectType\SignalName
Notes
First, the system is perturbed from the steady state, and the unforced system response is recorded (both the system states and the outputs). The matrix C is found by solving the following least-squares problem
\[C = yX^T[XX^T]^{-1}\]Once this is solved, a step change is introduced to each of the inputs separately, and the values at the end of the simulation time are assumed to be at the steady state. The colums of the matrices B and D are then computed as
\[ \begin{align}\begin{aligned}0 = \dot{x} = Ax + B_iu_i \Rightarrow B_i &= -Axu_i^{-1}\\D_i &= (y-Cx)u_i^{-1}\end{aligned}\end{align} \]
-
linearize2(inputs, outputs, ref_state='')¶
-
outputs¶
-
read_amat()¶ Returns the matrix A read from the file Amat.mtl which is the output form PowerFactory modal analysis.
Returns: Returns the A matrix of the linearized system. Return type: ndarray
-
static
set_params(*args)¶ #### NOT FINISHED Maps a list of parameters into a dictionary.
This is done so that it is possible to set the parameters of the equivalent method using
pf.set_params().Parameters: - param (list) – A list of equivalent model’s parameters.
- param_map (dict) – A dictionary to map the parameter list. It is of the
following form
{0:('element name 0', 'parameter name 0'),1:...}
Returns: The dictionary of parameters of the following form:
{'element name 0':{'parameter name 0':value, ... }', ...}Return type: dict
-
setup()¶
-
simulate(t_start, t_stop, dt, output=True)¶
-
states¶
-
-
pfpy.models.d2c(a, b, c, d, Ts, method='bi')¶
-
pfpy.models.generate_inputs(inputs, replace=False)¶