API

Types and functions documentation in ePowerSim.

Module Index

Detailed API

ePowerSim.Ax_A_A_gov_t0_cbMethod

Algebraic variables of gov gov_t0_cb

        τm_tilade  #ω_ref      phat_in   p_in

τm_tilade -1 0 0 0

#ω_ref 0 -1 0 0

phat_in 0 1/(R*ωs) (-1) 0

p_in 0 0 1 (-1)

source
ePowerSim.Ax_A_S_avr_t0_cbMethod

Coupling between algebraic variables and state variables of avr avr_t0_cb

     vm     vr1    vr2   vf_tilade

v_ref 0 0 0 0

vr1_hat 0 1 0 0

vf 0 0 0 1

source
ePowerSim.Ax_A_S_avr_t1_cbMethod

Coupling between algebraic variables and state variables of avr avr_t1_cb

     vm     vr1    vr2   vf_tilade  

      0      0      0      0

v_ref

vf 0 0 0 1

source
ePowerSim.Ax_A_S_gov_t0_cbMethod

Coupling between algebraic variables and state variables of gov gov_t0_cb

        xg1                   xg2     xg3

τm_tilade (T4/T5)* (T3/Tc) T4/T5 1

ω_ref 0 0 0

phat_in 0 0 0

p_in 0 0 0

source
ePowerSim.Ax_A_S_gov_t1_cbMethod

Coupling between algebraic variables and state variables of gov gov_t1_cb

        xg1                   xg2     xg3

τm_tilade (T4/T5)* (T3/Tc) T4/T5 1

ω_ref 0 0 0

phat_in 0 0 0

source
ePowerSim.Ax_A_Sgen_avr_t0_cbMethod

Coupling between algebraic variables of avr avr_t0_cb, and state equations of generator

        δ      u_gen_ω     e_d_dash   e_q_dash

v_ref 0 0 0 0

vr1_hat 0 0 0 0

vf 0 0 0 0

source
ePowerSim.Ax_A_Sgen_avr_t1_cbMethod

Coupling between algebraic variables of avr avr_t1_cb, and state equations of generator

        δ      u_gen_ω     e_d_dash   e_q_dash

v_ref 0 0 0 0

vf 0 0 0 0

source
ePowerSim.Ax_A_Sgen_gov_ieee_tgov1_cbMethod

Coupling between algebraic variables of gov gov_ieee_tgov1, and state equations of generator

         δ   u_gen_ω       e_d_dash e_q_dash

τmtilade 0 (-Dt/ωref0) 0 0

ω_ref 0 0 0 0

source
ePowerSim.Ax_A_Sgen_gov_t0_cbMethod

Coupling between algebraic variables of gov gov_t0_cb, and state equations of generator

        δ      u_gen_ω     e_d_dash   e_q_dash

τm_tilade 0 0 0 0

ω_ref 0 0 0 0

phat_in 0 -1/(R*ω) 0 0

p_in 0 0 0 0

source
ePowerSim.Ax_A_Sgen_gov_t1_cbMethod

Coupling between algebraic variables of gov gov_t1_cb, and state equations of generator

        δ      u_gen_ω     e_d_dash   e_q_dash

τm_tilade 0 0 0 0

#ω_ref 0 0 0 0

phat_in 0 -1/(R*ωs) 0 0

source
ePowerSim.Ax_A_Sgen_gov_t1_cb_sauerMethod

Coupling between algebraic variables of gov gov_t1_cb_sauer, and state equations of generator

        δ      u_gen_ω     e_d_dash   e_q_dash

ω_ref 0 0 0 0

τm_tilade 0 0 0 0

source
ePowerSim.Ax_S_A__gov_t0_cbMethod

Coupling between state variables and algebraic variables of gov gov_t0_cb

 τm_tilade     ω_ref    phat_in   p_in

xg1 0 0 1/Ts 0

xg2 0 0 0 0

xg3 0 0 0 0

source
ePowerSim.Ax_S_A_avr_t0_cbMethod

Coupling between state variables and algebraic variables of avr avr_t0_cb!

         v_ref           vr1_hat     vf

vm 0 0 0

vr1 0 0 0

vr2 0 0 0

vf_tilade 0 1/Te 0

source
ePowerSim.Ax_S_A_gov_t1_cbMethod

Coupling between state variables and algebraic variables of gov gov_t1_cb

 τm_tilade     #ω_ref    phat_in

xg1 0 0 1

xg2 0 0 0

xg3 0 0 0

source
ePowerSim.Bx_A_avr_t0_cbMethod

Coupling between algebraic variables of avr avr_t0_cb, and network

        id      iq            pg         vh

v_ref 0 0 0 0

vr1_hat 0 0 0 0

vf 0 0 0 0

source
ePowerSim.Bx_A_gov_ieee_tgov1_cbMethod

Coupling between algebraic variables of gov gov_ieee_tgov1, and network injections id, iq, ph, vh,

          id  iq  ph  vh

τm_tilade 0 0 0 0

ω_ref 0 0 0 0

source
ePowerSim.Bx_A_gov_t0_cbMethod

Coupling between algebraic variables of gov gov_t0_cb, and network injections id, iq, ph, vh,

          id  iq  ph  vh

τm_tilade 0 0 0 0

#ω_ref 0 0 0 0

phat_in 0 0 0 0

p_in 0 0 0 0

source
ePowerSim.Bx_A_gov_t1_cbMethod

Coupling between algebraic variables of gov gov_t1_cb, and network injections id, iq, ph, vh,

          id  iq  ph  vh

τm_tilade 0 0 0 0

#ω_ref 0 0 0 0

phat_in 0 0 0 0

source
ePowerSim.Cx_A_avr_t0_cbMethod

Coupling between algebraic variables of avr avr_t0_cb, and set points

         ωs    ω_ref0       v_ref0   p_order0

v_ref 0 0 1 0

vr1_hat 0 0 0 0

vf 0 0 0 0

source
ePowerSim.Cx_A_avr_t1_cbMethod

Coupling between algebraic variables of avr avr_t1_cb, and set points

         ωs    ω_ref0       v_ref0   p_order0

v_ref 0 0 1 0

vf 0 0 0 0

source
ePowerSim.Cx_A_gov_ieee_tgov1_cbMethod

Coupling between algebraic variables of gov gov_ieee_tgov1, and set points ωs, ωref0, vref0, p_order0

        ωs  ω_ref0  v_ref0  p_order0

τm_tilade 0 Dt/(ωs) 0 0

ω_ref 0 1 0 0

source
ePowerSim.Cx_A_gov_t0_cbMethod

Coupling between algebraic variables of gov gov_t0_cb, and set points ωs, ωref0, vref0, p_order0

        ωs   #ω_ref0      v_ref0  p_order0

τm_tilade 0 0 0 0

#ω_ref 0 1 0 0

phat_in 0 1/(R*ωs) 0 1

p_in 0 0 0 0

source
ePowerSim.Cx_A_gov_t1_cbMethod

Coupling between algebraic variables of gov gov_ieee_tgov1, and set points ωs, ωref0, vref0, p_order0

        ωs  ω_ref0  v_ref0  p_order0

τm_tilade 0 0 0 0

#ω_ref 0 1 0 0

phat_in 0 1/(R*ωs) 0 1

source
ePowerSim.Cx_A_gov_t1_cb_sauerMethod

Coupling between algebraic variables of gov gov_t1_cb_sauer, and set points

        ωs     ω_ref0    v_ref0  p_order0

#ω_ref 0 1 0 0

τm_tilade 0 0 0 0

source
ePowerSim.DAE_BoolVectorMethod
DAE_BoolVector(
    state_size, algebraic_size )

Returns the boolean vector for a differential algebraic equations

source
ePowerSim.V_C2RMethod
V_C2R(V)

Returns a tuple of a vector of voltage magnitudes and a vector of voltage angles for a given vector of complex voltage.

source
ePowerSim.V_R2CMethod
V_R2C(V)

Returns a vector of complex voltage for a given concatenated flattened vector of voltage magnitudes and voltage angles.

source
ePowerSim.Z_dqMethod
Z_dq(ra, X_d_dash, X_q_dash)

Returns Z_dq matrix transform for a generator.

source
ePowerSim.anonymus_funcFunction
anonymus_func(x)

Returns a place holder for an anonymus function that produce nothing.

It is needed in struct that do not have some functions implemented.

source
ePowerSim.conj_x_from_xr_xiMethod
conj_x_from_xr_xi(ur_ui)

Returns the complex conjugate for a list containing real part and imaginary part of a complex voltage.

source
ePowerSim.convert_dataframe_selected_cols_typesMethod
convert_dataframe_selected_cols_types(
    df, cols_types, cols_names )

Converts a selected columns to specific types in a dataframe.

The function was created because of the challenges of getting is_slack column as a Bool in dyn_plant.csv

source
ePowerSim.create_avr_parameters_libMethod

create_avr_parameters_lib

Crerates a json file that contains parameters of dynamic models of avr. Values of some parameters of some avr are already defined in the function. This can be extended by adding parameters values and symbolic name of the avr type.

It creates a dictionary that associates the symbolic name of a avr type with its dyanamic parameters. The dictionary is subsequently written to a json file for persistence.

source
ePowerSim.create_dynamic_components_parameters_libs_jsonMethod

create_dynamic_components_parameters_libs_json

Creates a json file that contains parameters of dynamic models of generators, automatic-voltage regulator, governors, powers sytems stabiliers in some appropriate folders under components_libs_dir.

Assistant functions:

get_sub_components_libs_dir: get_sub_components_libs_files

create_generators_dynamic_parameters_lib create_gov_parameters_lib create_avr_parameters_lib create_pss_parameters_lib

source
ePowerSim.create_generators_dynamic_parameters_libMethod

create_generators_dynamic_parameters_lib

Crerates a json file that contains parameters of dynamic models of generators. Values of some parameters of some generators are already defined in the function. This can be extended by adding parameters values and symbolic name of the generator type.

It creates a dictionary that associates the symbolic name of a generator type with its dyanamic parameters. The dictionary is subsequently written to a json file for persistence.

source
ePowerSim.create_gov_parameters_libMethod

create_gov_parameters_lib

Crerates a json file that contains parameters of dynamic models of governors. Values of some parameters of some governors are already defined in the function. This can be extended by adding parameters values and symbolic name of the governor type.

It creates a dictionary that associates the symbolic name of a governor type with its dyanamic parameters. The dictionary is subsequently written to a json file for persistence.

source
ePowerSim.create_idxsMethod
create_idxs(offs, dims)

Create indexes for stacked array of dimensions dims using the offsets offs

source
ePowerSim.create_pss_parameters_libMethod

create_pss_parameters_lib(

Crerates a json file that contains parameters of dynamic models of pss. Values of some parameters of some pss are already defined in the function. This can be extended by adding parameters values and symbolic name of the pss type.

It creates a dictionary that associates the symbolic name of a pss type with its dyanamic parameters. The dictionary is subsequently written to a json file for persistence.

source
ePowerSim.create_u_idxsMethod
create_u_idxs(offs)

Create indexes of ur and ui for stacked array of dimensions dims using the offsets offs

source
ePowerSim.create_x_dst_idxsMethod
create_x_dst_idxs(offs)

Create indexes of dst-end (h) flow in an edge, xkr and xki for stacked array of dimensions dims using the offsets offs

source
ePowerSim.create_x_src_idxsMethod
create_i_src_idxs(offs)

Create indexes of src-end (h) flow in an edge, xhr and xhi for stacked array of dimensions dims using the offsets offs

source
ePowerSim.exciter_saturation_functionMethod
exciter_saturation_function(
    ( efd_1, S_E_1 ), ( efd_2, S_E_2 ) )

Returns an exciter saturation parameters A_x, and B_x.

Power system modeling, computation and control.

page:243

source
ePowerSim.extract_matpower_case_nameMethod

extract_matpower_case_name

Returns the case name of a MATPOWER file.

The first line of every matpower file contains function name for the file, e.g. "function mpc = case5".

source
ePowerSim.find_V_idx_in_sparse_matrix_IJVMethod
 find_V_idx_in_sparse_matrix_IJV(
     row_idx,
     col_idx,
     sparse_row_idxs,
     sparse_col_idxs )

Returns an index in V of a sparse matrix, where sparse_row_idxs[idx] = row_idx && sparse_col_idxs[idx] = col_idx.

source
ePowerSim.generate_labels_by_nodes_idxs_and_varsMethod
generate_labels_by_nodes_idxs_and_vars(
    nodes_idxs,
    nodes_vars_syms;
    label_prefix = "bus" )

Return labels for nodes variables.

Example

tgensnodes_idx = [1, 2, 3]

tstatevarssymsinternal_mode = [:δ, :ω]

generatelabelsbynodesidxsandvars( tgensnodesidx, tstatevarssymsinternalmode)

source
ePowerSim.get_YbusMethod
get_Ybus(
    edge_data_from_json,
    shunt_data_from_json;
    basekV = 1.0,
    baseMVA = 1.0,
    line_data_in_pu = true )

Returns network sparse admittance matrix.

source
ePowerSim.get_Ybus_and_related_matricesMethod
get_Ybus_and_related_matrices(
    edge_data_from_json,
    shunt_data_from_json;
    basekV = 1.0,
    baseMVA = 1.0,
    line_data_in_pu = true )

Returns constituent objects for building Ybus.

source
ePowerSim.get_YnetMethod
get_Ynet(
    edge_data_from_json,
    shunt_data_from_json;
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0,
    line_data_in_pu = true)

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_and_related_vectorsMethod
get_Ynet_and_related_vectors(
    edge_data_from_json,
    shunt_data_from_json;
    basekV = 1.0,
    baseMVA = 1.0,
    line_data_in_pu = true )

Returns constituent objects for building Ynet.

source
ePowerSim.get_Ynet_sp_shMethod
get_Ynet(
    edge_data_from_json,
    shunt_data_from_json;
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0,
    line_data_in_pu = true)

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_dataMethod
get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_data(
    edges_r, edges_x, edges_b,
    edges_ratio, edges_angle,
    Gs, Bs;
    edges_fbus,
    edges_tbus,
    edges_type,    
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA=1.0,
    basekV=1.0,
    line_data_in_pu = true)

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_dataMethod
get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_data(
    ;edges_fbus, edges_tbus,
    edges_type,
    edges_r, edges_x, edges_b,
    edges_ratio, edges_angle,
    Gs, Bs,
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA=1.0,
    basekV=1.0,
    line_data_in_pu = true)

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_genericMethod
get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_generic(
    branches_fbus,
    branches_tbus,
    r,
    x,
    b,
    ratio,
    angle,
    edge_type,    
    Gs,
    Bs;
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0 )

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_genericMethod
get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_generic(
    branches_fbus,
    branches_tbus,
    r, x, b,
    ratio, angle,
    edge_type,
    buses_idx,
    Gs, Bs;
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0 )

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_genericMethod
get_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_generic(
    branches_fbus,
    branches_tbus,
    r,
    x,
    b,
    ratio,
    angle,        
    Gs,
    Bs;
    edges_type,
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0 )

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_Yπ_netMethod
get_Yπ_net(
    edge_data_from_json,
    shunt_data_from_json;
    # all_nodes_idx,
    # n2s_all_nodes_idx,
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0,
    line_data_in_pu = true,
    orientated_bool = false )

Returns nodes incident edges elementary admittance matrices .

swapdiagonal_elements is used to ensure a proper orientation of elementary based on an edge orientation (i,j) i.e (from, to). Since an edge is connected to two nodes; node i and node k, a primary node checks if the first index in (i,j) is the same as its index. if from idx is the same as the index of the primary node, is accepted, otherwise, values in the diagonal of are swapped. This is important for branches element whose elementaray admittance matrix are not symetrix

A primary node is the first node in each row of nodes_idx_with_adjacent_nodes_idx

source
ePowerSim.get_Yπ_net_and_related_vectorsMethod
get_Yπ_net_and_related_vectors(
    edge_data_from_json,
    shunt_data_from_json;
    all_nodes_idx,
    n2s_all_nodes_idx,
    basekV = 1.0,
    baseMVA = 1.0,
    baseShunt = 1.0,
    line_data_in_pu = true,
    orientated_bool = true )

Returns constituent objects for building Yπ_net.

source
ePowerSim.get_a_flattend_vars_or_paras_and_IdxMethod
get_a_flattend_vars_or_paras_and_Idx(
    vec_of_vec_var )

Returns indices in a flattened vectors for a vector of vectors.

d = [ [1,2], [3,4], [5,6]]

e = [[10,11,12], [13,14,15], [16,17,18]]

testdata2 = [d, e]

dimsvarsorparastypes = length.([first(d), first(e) ] )

teste = getpervarsorparastopernode( testdata2 )

testt = getpernodeparatopervarsorparas( teste, dimsvarsorparastypes )

source
ePowerSim.get_a_gen_dyn_idqMethod
get_a_gen_dyn_idq(
    vh, θh,
    δ_ω_ed_eq,
    ra_Xd_dash_Xq_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_a_gen_dyn_idqMethod
get_a_gen_dyn_idq(
    vh, θh,
    δ, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_a_gen_dyn_idqMethod
get_a_gen_dyn_idq(
    vh, θh,
    δ, ω, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_a_gen_dyn_idqMethod
get_a_gen_dyn_idq(
    vh_θh,
    δ_ω_ed_eq,
    ra_X_d_dash_X_q_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_a_model_integrated_intra_dyn_current_balance_pf_ΔI_idq_mismatchMethod

IgilocloadrealB = ( idi * sin(δi) + iqi * cos(δ_i) )

IgilocloadimagB = ( iqi * sin(δi) - idi * cos(δ_i) )

IgilocloadrealA = ( Ploci * cos(θi) + Qloci * sin(θi) ) / vhi

IgilocloadimagA = ( Ploci * sin(θi) - Qloci * cos(θi)) / vhi

IgilocloadrealC = sum( vhk * Yik * cos( θk + α_ik ) )

IgilocloadrealC = -sum( vhk * Yik * sin( θk + α_ik ) )

source
ePowerSim.get_a_n2s_dictMethod
get_a_n2s_dict(a_type_idxs )

Returns "indices to ordinal" dictionaries of indices of a list.

Example

atypeidx = Union{Symbol,String,Int64}[1,2,"dayo", :yusuff]

n2satype = getan2sdict(atype_idx )

source
ePowerSim.get_a_n2s_net_groupMethod
get_a_n2s_net_group(
    a_net_group_idxs;
    loc_load_exist = false,
    transmission_group = false )

Returns streamlined idxs conversion dictionary

n2s_gens_idx =
    get_a_n2s_net_group(gens_nodes_idx)

n2s_transmission_idxs =
    get_a_n2s_net_group(transmission_nodes_idx;
    transmission_group = true)

n2s_gens_with_loc_load_idxs =
    get_a_n2s_net_group(gens_with_loc_load_idx;
    loc_load_exist = true)
source
ePowerSim.get_a_namedtuple_dict_types_dyn_or_output_funcMethod
get_a_namedtuple_dict_types_dyn_or_output_func(
    types_func,
    dae_or_ode_type)

It return a singleton namedtuple. The property of the namedtuple is the type of modelling, which could either be :ode or :dae, while the property value is a dictionary of component models and their specific associated functions.

source
ePowerSim.get_a_node_state_algb_vars_indices_in_symsMethod
get_a_node_state_algb_vars_indices_in_syms(
    ; node_syms_labels = node_syms_labels,
    bus_name = bus_name, vars = [:ω, :δ])

Returns indices of state_algebraic variables of a node in the node syms list.

It is meant to extract the indices in sol.

source
ePowerSim.get_a_node_state_algb_vars_indices_in_systemMethod
get_a_node_state_algb_vars_indices_in_system(
    ; network_vars_labels = network_vars_labels,
    bus_name = bus_name,
    vars = [:ω, :δ])

Returns indices of state_algebraic variables of a node in the systems.

It is meant to extract the indices in sol.

source
ePowerSim.get_a_node_states_indices_in_systemMethod
get_a_node_states_indices_in_system(
    ; network_vars_labels = network_vars_labels,
    bus_name = bus_name,
    vars = [:δ, :ed_dash, :eq_dash])

Returns indices of a list of state variables vars of a plant in the network state.

source
ePowerSim.get_a_node_states_vars_syms_in_systemMethod
get_a_node_states_vars_syms_in_system(
    ; network_vars_labels = network_vars_labels,
    bus_name = bus_name,
    vars = [:δ, :ed_dash, :eq_dash])

Returns labels of a list of state variables vars of a plant in the network state labels.

source
ePowerSim.get_a_node_∑_ynj_x_vj_by_YbusMethod

Columns are used because Julia access matrix via cols. It does not make any diffence, because Ybus is symetric.

Ybus_nth_col = Ybus[:,nth] == Ybus_nth_row = Ybus[nth,:]

Ybus_nth_col' * (vh .* exp.( im * θh ))

getanodeynjxvjbyYbus( vh, θh, Ybus[:,1] )

source
ePowerSim.get_a_status_steady_state_dataMethod
get_a_status_steady_state_data(
    system_status;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for simulation.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow. pf_alg: power flow solver abstol: the absolute error tolerance reltol: the relative error tolerance on_fault_time: the on fault time clear_fault_time: the clear fault time list_fault_point_from_node_a::Vector{Float64}=[0.3]: the list containing a ratio of the fault point from the source (from) orientation of lines list_fault_resistance::Vector{Float64} = [0.001]: the list containing fault resistances of each fault in the network. list_no_line_circuit::Vector{Float64} = [4]: the list containing the number of circuits per faulted lines list_edges_to_have_fault::Vector{Int64} = [2]: the list containing indices of lines that should have a fault. clear_fault_selection_list::Vector{Int64} = [1]: the list containing indices of faulted lines to be cleared in list_edges_to_have_fault. ode_alg: the ode solver. daealg: the dae solver. dt: the solve interval. `withfaults::Bool=false`: a legacy boolean variable.

  • system_status: can take the form of the following
    • :pre_fault_state
    • :fault_state
    • :post_fault_state
source
ePowerSim.get_absract_type_dict_subsubtypesMethod
get_absract_type_dict_subsubtypes(
    absract_type )

Returns a dictionary of symbol to subsubtypes of an abstract types, e,g. AbstractPowerSystemComponent. This is used to translate a symbol of a type to type

Example

get_absract_type_dict_subsubtypes(
    absract_type )

dictsymboltypes = getabsracttypedictsubsubtypes( AbstractPowerSystemComponent )

dict_symbol_types[:pss_t2_cb] will return pss_t2_cb

source
ePowerSim.get_abstract_type_dict_subtypesMethod
get_abstract_type_dict_subtypes(
    absract_type )

Returns a dictionary of concrete subtypes of absract_type.

The set of abstract types currently defined in the package are:

SdAvr, SdBranchElement, SdGen, SdGenPlant, SdGov, SdNonGen, SdNonGenPlant, SdPss.

They are subtypes of

AbstractPowerSystemComponent

source
ePowerSim.get_algebraic_vars_labelsMethod
get_algebraic_vars_labels(
    dyn_pf_fun_kwd_net_idxs;
    label_prefix = "bus" )

Return plants algebraic variable symbols or lables for all generator plants in a flattened vector.

Arguments

  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • label_prefix::String="bus": the label that should be used as a prefix.
source
ePowerSim.get_case_data_by_csvMethod
get_case_data_by_csv(
    case_name;
    <keyword arguments> )

Returns selected static parameters and dynamic types of components from network model csv files.

source
ePowerSim.get_components_properties_by_jsonMethod
get_components_properties_by_json(
    plant_generators_data_from_json;
    <keyword arguments>)

Returns a vector of properties of components selected by the variables sequence_order and selection.

Arguments

  • sequence_order::Tuple{Symbol}=(:components_data, :gen): the selection order of components data.
  • selections::Tuple{Symbol}=(:P, :Q): the tuple of parameters data to be selected.
source
ePowerSim.get_csv2texMethod
get_csv2tex(
    csv_file;
    wt_new_header_bool      = false,
    wt_selected_colums_bool = false,
    new_header              = nothing,
    delim              = ',',
    normalizenames     = true,
    selected_colums    = [] )

Converts a csv data to tex table.

source
ePowerSim.get_dict_net_streamlined_idx_by_nodes_type_idxsMethod
get_dict_net_streamlined_idx_by_nodes_type_idxs(
    net_nodes_type_idxs)

Returns "indices to ordinal" dictionaries of indices of various type of nodes in a network.

These are:

n2s_slack_gens_idx, n2s_non_slack_gens_idx, n2s_gens_idx, n2s_non_gens_idx, n2s_load_idx, n2s_gens_with_loc_load_idxs, n2s_transmission_idxs, n2s_all_nodes_idx, n2s_nodes_with_demands_idx

It aligns indices of node types with the indices of parameters of node types.

Consider a 14 nodes network, where 6 nodes are generator nodes, 1 node is a transmission node, and 7 nodes are load nodes.

The indices of generator nodes in the network are gennodesidx = [1,2,3,6,8]. The size of gen_nodes_idx is 5.

Lets define an array for reactive power, Qg = [-0.169, 0.42, 0.234, 0.122, 0.174]

How do we access the reactive power of the fifth generator, whose index in the network is 8? It is evident that Qg[8] will throw an error.

A way out is to use a dictionary

n2stypeidx = OrderedDict( idx => ord for (idx, ord) in zip(gennodesidx, collect(1:length(gennodesidx)) ))

i.e n2stypeidx = Dict(1=>1, 2=>2, 3=3, 6=>4, 8=5)

The reactive power of the fifth generator can be subsequently accessed as :

Qg[ n2stypeidx[ 8 ] ]

Note n2stypeidx[ 8 ] will produced 5.

The beauty of this is that, indices of nodes are not resticted to numbers. Strings, symbols can be used as indices.

If gennodesidx had been,

gennodesidx = ["node-gauteng","node-limpopo","node-wc","node-ec", "node-nw"]

n2stypeidx = OrderedDict( idx => ord for (idx, ord) in zip(gennodesidx, collect(1:length(gennodesidx)) ))

Qg[ n2stypeidx[ "node-nw" ] ] will produce, the reactive power of the fifth generator,

A generic function could be defined

function getn2sany( anetgroup_idxs)

return OrderedDict{Union{Symbol,String,Int64},Int64}(
        net_idx =>idx
        for (net_idx, idx) in zip(
            a_net_group_idxs,
            collect(1:length(
                a_net_group_idxs )) ) )

end

source
ePowerSim.get_dict_types_dyn_or_output_funcMethod
get_dict_types_dyn_or_output_func(
    types_func)

It converts a list of functions into a dictionaly of functions. A key in the dictionary is a type of a model of component, and the value is a specific function that is applicable to the component.

source
ePowerSim.get_dyn_red_vh_θh_idqMethod
get_dyn_red_vh_θh_idq(
    uh,
    δ_ω_ed_dash_eq_dash_view;
    <keywords arguments> )

Arguments

  • gens_vh
  • raXddashXqdash_view
  • redvhθh_idx
  • n2sgensidx
  • n2snongens_idx
  • gensnodesidx
  • nodes_size

Returns [ red_vh_θh; gens_idq_flat ].

source
ePowerSim.get_dynamic_comps_init_out_dyn_callback_funcsMethod
get_dynamic_comps_init_out_dyn_callback_funcs(
    gens_govs_avrs_types)

Returns namedtuples of dynamic components functions comps_callback_paras_funs, comps_init_funs, comps_output_funs, ode_comps_dyn_funs, dae_comps_dyn_funs, comps_dyn_funs.

Arguments

  • `gens_govs_avrs_states_syms: the namedtuple of states variables symbols of generators, governors and automatic voltage regulators.
source
ePowerSim.get_dynamic_id_iq_pg_vh_by_ur_uiMethod
get_dynamic_id_iq_pg_vh_by_ur_ui(
    u_r, u_i, δ,
    ed_dash,
    eq_dash,
    ra,
    X_d_dash,
    X_q_dash )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_id_iq_pg_vh_by_ur_uiMethod
get_dynamic_id_iq_pg_vh_by_ur_ui(
    u_r, u_i, δ, ω, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_id_iq_pg_vh_by_vhθhMethod
get_dynamic_id_iq_pg_vh_by_vhθh(
    vh, θh, δ, ed_dash, eq_dash, ra,
    X_d_dash, X_q_dash )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_id_iq_pg_vh_by_vhθhMethod
get_dynamic_id_iq_pg_vh_by_vhθh(
    vh, θh, δ, ω, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_idq_ur_uiMethod
get_dynamic_idq_ur_ui(
    u_r, u_i, δ_ω_ed_eq, ra_X_d_dash_X_q_dash)

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_dynamic_idq_ur_uiMethod
get_dynamic_idq_ur_ui(
    u_r, u_i, δ, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash)

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_dynamic_idq_vhθhMethod
get_dynamic_idq_vhθh(
    vh,
    θh,
    δ,
    ed_dash,
    eq_dash,
    ra,
    X_d_dash,
    X_q_dash )

Returns a generator direct current id and quadrature current iq.

source
ePowerSim.get_dynamic_idq_vhθhMethod
get_dynamic_idq_vhθh(
    vh,
    θh,
    δ,
    ω,
    ed_dash,
    eq_dash,
    ra,
    X_d_dash,
    X_q_dash )

Returns a generator direct current id and quadrature current iq.

source
ePowerSim.get_dynamic_idq_θ_π_ur_uiMethod
get_dynamic_idq_θ_π_ur_ui(
    u_r, u_i, δ_ω_ed_eq,
    ra_X_d_dash_X_q_dash)

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_dynamic_pg_from_id_iqMethod
get_dynamic_pg_from_id_iq(
   id, iq, δ, ed_dash, eq_dash,  ra,
   X_d_dash, X_q_dash)

Returns a generator active power for a given id, iq, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_pg_from_id_iqMethod
get_dynamic_pg_from_id_iq(
    id, iq, δ, ω, ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash)

Returns a generator active power for a given id, iq, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_dynamic_τe_from_id_iqMethod
get_dynamic_τe_from_id_iq(
   id, iq, δ, ed_dash, eq_dash,  ra,
   X_d_dash, X_q_dash)

Returns a generator torque for a given id, iq, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_edges_Ybr_by_genericMethod
get_edges_Ybr_by_generic(
    r, x, b,
    ratio, angle,
    edge_type,
    Gs, Bs;
    baseMVA = 1.0,
    basekV = 1.0 )

Returns a list of per unit π admittance matrices for branches.

source
ePowerSim.get_gen_node_static_data_tup_by_mpcMethod
get_gen_node_static_data_tup_by_mpc(
    idx,
    vmax,vmin,
    Pg,Qg,
    Vg,
    Qmax, Qmin,
    Pmax, Pmin;
    mpc_baseMVA = 1.0 )

Returns a generator's index and static parameters as a tuple of index and namedtuple of static parameters.

source
ePowerSim.get_gencost_data_by_mpcMethod
get_gencost_data_by_mpc(
    mpc_gencost;
    mpc_baseMVA =
        1.0)

Returns a dict Dict{:cost_type,:startup,:shutdown,:n,:c_n_1,:c_1,:c_0 } for generators operation cost.

source
ePowerSim.get_generic_Pg_Png_Qng_IdxMethod
get_generic_Pg_Png_Qng_Idx(
    dyn_pf_fun_kwd_net_idxs)

Returns indices of generator nodes active power generation Pg, generator nodes reactive power generation Qg, non-generator nodes active power demand Png, non-generator nodes reactive power demand Qng in a flattened Pg_Png_Qng vector.

source
ePowerSim.get_generic_Pg_Qg_Png_Qng_Pll_Qll_IdxMethod
get_generic_Pg_Qg_Png_Qng_Pll_Qll_Idx(
    dyn_pf_fun_kwd_net_idxs)

Returns indices of generator nodes active power generation Pg, generator nodes reactive power generation Qg, non-generator nodes active power demand Png, non-generator nodes reactive power demand Qng, generator nodes local active power demand Pll, generator nodes local reactive power demand Qll in a flattened Pg_Qg_Png_Qng_Pll_Qll vector.

source
ePowerSim.get_generic_Png_Qng_Pll_Qll_IdxMethod
get_generic_Png_Qng_Pll_Qll_Idx(
    dyn_pf_fun_kwd_net_idxs)

Returns indices of non-generator nodes active power demand Png, non-generator nodes reactive power demand Qng, generator nodes local active power demand Pll, generator nodes local reactive power demand Qll in a flattened Png_Qng_Pll_Qll vector.

source
ePowerSim.get_generic_flat_vh_flat_θh_id_iq_IdxMethod
get_generic_flat_vh_flat_θh_id_iq_Idx(
    gens_nodes_idx,
    all_nodes_idx)

Returns a flattend vector of indices of nodes voltages magnitude vh, nodes voltages angle θh, generators direct-axis currents id, generators quadrature axix currents iq.

source
ePowerSim.get_generic_line_loss_outage_wt_or_no_ref_adjsMethod
get_generic_line_loss_outage_wt_or_no_ref_adjs(
    outage_type,
    ntuple_status_steady_state_data,
    line_outage_time,
    generation_adjustment_time;
    <keywords arguments> )

Returns dynamic solution of a network with line outage.

Arguments

  • outage_type

    • :line_outage_wt_pref_adjs
    • :line_outage_wt_vpref_adjs
    • :line_outage
  • ntuple_status_steady_state_data

  • line_outage_time

  • generation_adjustment_time

  • sim_timespan = (0.0, 20)

  • pf_alg = NewtonRaphson()

  • dae_alg = IDA()

  • ode_alg = Rodas4()

  • abstol = 1e-12

  • reltol = 1e-12

  • nt_system_dynamics_fun_type = (;system_dynamics_fun_type = :dae_line_loss_pre_fault_post_pf_funcs, system_dynamics_fun = line_loss_generic_dynamics_wt_pre_fault_post_by_dae_pf_funcs!)

nt_system_dynamics_fun_type is a namedtuple of dynamic function type symbol and a dynamic function.

The list of function types are given below:

dae funs symbols denoted by system_dynamics_fun_type

  • :daegenericprefaultpostpffuncs
  • :daeYnetprefaultpostpffuncs
  • :daelinelossprefaultpostpf_funcs
  • :daelineoutageprefaultpostpf_funcs
  • :daeYnetprepostpf_funcs

functions denoted by systemdynamicsfun

  • genericdynamicswtprefaultpostbydaepf_funcs!
  • Ynetgenericdynamicswtprefaultpostbydaepffuncs!
  • linelossgenericdynamicswtprefaultpostbydaepf_funcs!
  • line_outage_generic_dynamics_wt_pre_post_fault_by_dae_pf_funcs!
  • Ynet_generic_dynamics_wt_pre_post_fault_by_dae_pf_funcs!

mm ode funs symbols denoted by system_dynamics_fun_type

  • :mmgenericprefaultpostpffuncs
  • :mmYnetprefaultpostpffuncs
  • :mmlinelossprefaultpostpf_funcs
  • :mmlineoutageprefaultpostpf_funcs
  • :mmYnetprepostpf_funcs

functions denoted by systemdynamicsfun

  • mm_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_Ynet_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_line_loss_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_line_outage_generic_dynamics_wt_pre_post_fault_by_ode_pf_funcs!
  • mm_Ynet_generic_dynamics_wt_pre_post_fault_by_ode_pf_funcs!
source
ePowerSim.get_generic_line_loss_outage_wt_or_no_ref_adjsMethod
get_generic_line_loss_outage_wt_or_no_ref_adjs(
    outage_type,

    on_fault_time,
    clear_fault_time,

    line_outage_time,
    generation_adjustment_time,

    net_data_by_components_file;
    <keywords arguments> )

Returns dynamic solution of a network with line outage.

Arguments

  • outage_type

    • :line_outage_wt_pref_adjs
    • :line_outage_wt_vpref_adjs
    • :line_outage
  • on_fault_time

  • clear_fault_time

  • net_data_by_components_file

  • components_libs_dir

  • data_dir

  • line_outage_time

  • generation_adjustment_time

  • sim_timespan = (0.0, 20)

  • pf_alg = NewtonRaphson()

  • dae_alg = IDA()

  • ode_alg = Rodas4()

  • abstol = 1e-12

  • reltol = 1e-12

  • nt_system_dynamics_fun_type = (;system_dynamics_fun_type = :dae_line_loss_pre_fault_post_pf_funcs, system_dynamics_fun = line_loss_generic_dynamics_wt_pre_fault_post_by_dae_pf_funcs!)

nt_system_dynamics_fun_type is a namedtuple of dynamic function type symbol and a dynamic function.

The list of function types are given below:

dae funs symbols denoted by system_dynamics_fun_type

  • :daegenericprefaultpostpffuncs
  • :daeYnetprefaultpostpffuncs
  • :daelinelossprefaultpostpf_funcs
  • :daelineoutageprefaultpostpf_funcs
  • :daeYnetprepostpf_funcs

functions denoted by systemdynamicsfun

  • genericdynamicswtprefaultpostbydaepf_funcs!
  • Ynetgenericdynamicswtprefaultpostbydaepffuncs!
  • linelossgenericdynamicswtprefaultpostbydaepf_funcs!
  • line_outage_generic_dynamics_wt_pre_post_fault_by_dae_pf_funcs!
  • Ynet_generic_dynamics_wt_pre_post_fault_by_dae_pf_funcs!

mm ode funs symbols denoted by system_dynamics_fun_type

  • :mmgenericprefaultpostpffuncs
  • :mmYnetprefaultpostpffuncs
  • :mmlinelossprefaultpostpf_funcs
  • :mmlineoutageprefaultpostpf_funcs
  • :mmYnetprepostpf_funcs

functions denoted by systemdynamicsfun

  • mm_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_Ynet_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_line_loss_generic_dynamics_wt_pre_fault_post_by_ode_pf_funcs!
  • mm_line_outage_generic_dynamics_wt_pre_post_fault_by_ode_pf_funcs!
  • mm_Ynet_generic_dynamics_wt_pre_post_fault_by_ode_pf_funcs!
source
ePowerSim.get_generic_namedtuple_per_plant_para_wt_kwd_paraMethod
get_generic_namedtuple_per_plant_para_wt_kwd_para(
    ωref0_vref0_porder0_id_iq_vh;
    kwd_para = plants_kwd_para )

Returns namedtuples of parameters per plant. It is used in generating a namedtuple consisting of data struture needed to simulate a generator plant. A generator plant can consist of a generator, gov, avr, etc.

Arguments

  • ωref0_vref0_porder0_id_iq_vh: the flattend vector consisting concatenation of ωref0, vref0, porder0, id, iq, and vh
  • plantskwdpara:
source
ePowerSim.get_generic_network_vars_labelsMethod
get_generic_network_vars_labels(
    plants_states_syms,
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs
    ;label_prefix = "bus",
    plants_states_by_per_comp = false,
    plants_states_by_per_plant = false
    )

Returns namedtuples of state_labels, algebraic_vars_labels, network_vars_labels.

Arguments

  • plants_states_syms: the plants states variables symbols per plant for all generator plants.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_generic_nodes_namesMethod
get_generic_nodes_names(
    dyn_pf_fun_kwd_net_idxs,
    n2s_all_nodes_idx)

Returns namedtuples of nodes types names all_nodes_names, gens_nodes_names, non_gens_nodes_names.

Arguments

  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_generic_scale_Pg_Png_Qng_IdxMethod
get_generic_scale_Pg_Png_Qng(
    dyn_pf_fun_kwd_net_idxs)

Returns indices of scale variable scale, generator nodes active power generation Pg, non-generator nodes active power demand Png, non-generator nodes reactive power demand Qng in a flattened scale_Pg_Qg_Png_Qng vector.

source
ePowerSim.get_generic_scale_Pg_Qg_Png_Qng_Pll_Qll_IdxMethod
get_generic_scale_Pg_Qg_Png_Qng_Pll_Qll_Idx(
    dyn_pf_fun_kwd_net_idxs)

Returns indices of scale variable scale, generator nodes active power generation Pg, generator nodes reactive power generation Qg, non-generator nodes active power demand Png, non-generator nodes reactive power demand Qng, generator nodes local active power demand Pll, generator nodes local reactive power demand Qll in a flattened scale_Pg_Qg_Png_Qng_Pll_Qll vector.

source
ePowerSim.get_generic_state_symMethod
get_generic_state_sym(
    gens_govs_avrs_states_syms,
    gens_nodes_idx;
    label_prefix = "bus")

Return plants states variables symbols or lables for all generator plants in a flattened vector.

A generator plant consist of a generator, automatic voltage regulator, governor etc.

source
ePowerSim.get_generic_system_simulation_parametersMethod
get_generic_system_simulation_parameters(
    net_data_by_components_file;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for simulation.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver ode_alg: ode solverdae_alg`: dae solver

source
ePowerSim.get_generic_vh_vhf_IdxMethod
get_generic_vh_vhf_Idx(
    all_nodes_idx;
    no_lines_fault = 1)

Returns a flattend vector of indices of nodes voltages magnitude vh, and fault node voltages magnitude vhf.

source
ePowerSim.get_generic_vh_vhf_θh_θhf_id_iq_IdxMethod
get_generic_vh_vhf_θh_θhf_id_iq_Idx(
    gens_nodes_idx,
    all_nodes_idx;
    no_lines_fault = 1)

Returns a flattend vector of indices of nodes voltages magnitude vh, nodes voltages angle θh, generators direct-axis currents id, generators quadrature axix currents iq, fault node voltages magnitude vhf, fault nodes voltage angle θhf.

source
ePowerSim.get_generic_vh_θh_id_iq_vhf_θhf_IdxMethod
get_generic_vh_θh_id_iq_vhf_θhf_Idx(
    gens_nodes_idx,
    all_nodes_idx;
    no_lines_fault = 1)

Returns a flattend vector of indices of nodes voltages magnitude vh, nodes voltages angle θh, generators direct-axis currents id, generators quadrature axix currents iq, fault node voltages magnitude vhf, fault nodes voltage angle θhf.

source
ePowerSim.get_generic_θh_θhf_IdxMethod
get_generic_θh_θhf_Idx(
    all_nodes_idx;
    no_lines_fault = 1)

Returns a flattend vector of indices of nodes voltages angle θh, fault nodes voltage angle θhf.

source
ePowerSim.get_gens_dynamic_id_iq_pg_vh_by_ur_uiMethod
get_gens_dynamic_id_iq_pg_vh_by_ur_ui(
    gens_ur_ui_post_pf,
    gen_nodes_δ_ω_ed_dash_eq_dash_views,
    gen_nodes_ra_Xd_dash_Xq_dash_view )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_gens_dynamic_id_iq_pg_vh_by_vhθhMethod
get_gens_dynamic_id_iq_pg_vh_by_vhθh(
    gens_vh_θh_post_pf,
    gen_nodes_δ_ω_ed_dash_eq_dash_views,
    gen_nodes_ra_Xd_dash_Xq_dash_view )

Returns a list of id, iq, pg and vh for a given vh, θh, δ, ed_dash, eq_dash, ra, X_d_dash, X_q_dash.

source
ePowerSim.get_gens_govs_avrs_states_syms_by_jsonMethod
 get_gens_govs_avrs_states_syms_by_json(
        net_data_by_components_file;
        components_libs_dir =
            components_libs_dir )

Retrives states variables symbols gens_govs_avrs_states_syms, gens_govs_avrs_types for different types of gens, govs, and avrs from the library of state symbols.

Arguments

  • net_data_by_components_file::String: the path to network json file.
  • components_libs_dir::String: the path to components library folder.

This information is stored in :

  • componentslibsdir: - states-syms - gens - govs - avrs
source
ePowerSim.get_gens_govs_avrs_types_by_jsonMethod
get_gens_govs_avrs_types_by_json(
    plant_generators_data_from_json)

It selects :gen, :gov, :avr as a tuple from :components_type property of a plant.

:components_type property of a plant contains other properties such as :loc_load.

source
ePowerSim.get_gens_state_vars_idx_in_stateMethod
get_gens_state_vars_idx_in_state(
    network_vars_labels,
    # all_nodes_idx,
    dyn_pf_fun_kwd_net_idxs,
    n2s_all_nodes_idx;
    selected_gens_state_vars_syms =
        (:δ, :ed_dash, :eq_dash) )

Returns state variables indices in the state for a selected set of variables in selected_gens_state_vars_syms.

Arguments

  • network_vars_labels: the system variables labels.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • selected_gens_state_vars_syms::Tuple{Symbol}=(:δ, :ed_dash, :eq_dash): the selected state variables.
source
ePowerSim.get_idxs_in_flattened_by_nodes_idx_wt_vars_symsMethod
get_idxs_in_flattened_by_nodes_idx_wt_vars_syms(
    list_state_vars_syms,
    gens_nodes_idx )

Returns Idxs of variables per node based on a list of variables.

Example

tgensnodes_idx = [1, 2, 3]

tliststatevarssyms = [:δ, :ω, :eqdash, :Efd]

getidxsinflattenedbynodesidxwtvarssyms( tliststatevarssyms, tgensnodesidx )

Vector{UnitRange{Int64}}:

1:4 5:8 9:12

source
ePowerSim.get_labels_by_nodes_idxs_and_vec_vec_symsMethod
get_labels_by_nodes_idxs_and_vec_vec_syms(
    nodes_idxs,
    plants_states_syms;
    label_prefix = "bus" )

Returns labels for state variables for a list of nodes in nodes_idxs.

Arguments

  • nodes_idxs: the list of nodes indices.
  • plants_states_syms: the state variables symbols per plant for all plants.
source
ePowerSim.get_list_vars_to_plot_by_symsMethod

This function returns a vector of strings from a list of list of symbols of variables to be plotted.

listselectedsymslist = [[:ω, :δ, :eddash, :eqdash], [:xg1, :xg2, :xg3, :τmtilade], [:vm, :vr1, :vr2, :vftilade], [:phatin, :v_ref]]

listofplotnames = getvarstoplotbysyms( listoflistsselectedsyms)

source
ePowerSim.get_mass_matrix_and_bool_dae_varsMethod
get_mass_matrix_and_bool_dae_vars(
    state_labels,
    algebraic_vars_labels)

Returnsfor a system and generator mass matrices and dae boolean variables model_mass_matrix, model_bool_dae_vars, ode_gens_mass_matrix, ode_gens_bool_dae_vars.

source
ePowerSim.get_model_nodes_types_namesMethod
get_model_nodes_types_names(
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs )

Returns nodes labels for generator buses, non-generator buses and all buses.

Arguments

  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_model_symsMethod
get_model_syms(
    state_labels,
    dyn_pf_fun_kwd_net_idxs;
    label_prefix = "bus")

Return a system model symbols or labels for state and algebraic variables in a flattened vector.

Arguments

  • state_labels: the system state variables labels.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • label_prefix::String="bus": the label that should be used as a prefix.
source
ePowerSim.get_n2s_anyMethod
get_n2s_any(
    a_net_group_idxs;
    nothing_bool= false)

Returns "indices to ordinal" dictionaries of indices of any type of nodes in a network.

source
ePowerSim.get_nested_nt_from_nt_wt_dictMethod
get_nested_nt_from_nt_wt_dict(
    a_nested_nt )

Converts a dict in a namedtuple to a namedtuple.

Example


tt = (plant_type = "plant_cb_v6",
      components_type = Dict{Symbol, Any}(
          :gen => "SM_2axis_cb_v6",
          :avr => "avr_t1_cb_sauer",
          :gov => "gov_t1_cb_sauer"),
      idx = 1)

get_a_plant_data_json_to_nt(
    json_a_plant;
    in_components_type_sym = true)

get_nested_nt_from_nt_wt_dict( tt )
source
ePowerSim.get_net_data_by_components_from_json_fileMethod
get_net_data_by_components_from_json_file(
    net_data_by_components_file;
    in_components_type_sym = false )

Returns namedtuples of dynamic network data plant_generators_data_from_json, plant_loads_data_from_json, plant_transmission_data_from_json, edge_data_from_json, shunt_data_from_json, baseMVA_data_from_json, gencost_data_from_json.

Arguments

  • net_data_by_components_file::String: the path to network json file.
  • in_components_type_sym::Bool=false: the variable that determines how plants data are stored in json network file.
source
ePowerSim.get_net_nodes_type_idxs_by_jsonMethod
get_net_nodes_type_idxs_by_json(
    plant_generators_data_from_json,
    plant_loads_data_from_json,
    plant_transmission_data_from_json )

Returns list of indices of various type of nodes in a network.

These are:

`slackbusidx, gensidx, slackgensnodesidx, nonslackgensnodesidx, gensnodesidx,

genswithlocloadidx, gensnodeswithlocloads_idx,

locloadexist, loadnodesidx, transmissionnodesidx, nongensnodesidx, allnodesidx, nonslackgensandnongensidx, nodeswithdemandsidx`

source
ePowerSim.get_network_vars_labelsMethod
get_network_vars_labels(
    gens_govs_avrs_states_syms,
    dyn_pf_fun_kwd_net_idxs;
    label_prefix = "bus",
    plants_states_by_per_comp = false,
    plants_states_by_per_plant = true )

Return a system network states and algebraic variables label in a flatted.

Arguments

  • gens_govs_avrs_states_syms: the namedtuple of states variables symbols of generator, governors and automatic voltage regulator.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • label_prefix::String="bus": the label that should be used as a prefix.
source
ePowerSim.get_node_dst_edgesMethod
get_node_dst_edges((node_number::Int64, Cnb)

Returns a node destination edges, they are edges whose the node is a destination node.

source
ePowerSim.get_nodes_state_algb_vars_indices_in_systemMethod
get_nodes_state_algb_vars_indices_in_system(
    ; network_vars_labels =
        network_vars_labels,
    nodes_name = ["bus1", "bus2"],
    vars = [:ω, :δ])

Returns indices of state_algebraic variables of specified nodes in the systems.

It is meant to extract the indices in sol.

source
ePowerSim.get_non_null_listMethod
get_non_null_list(list_of_lists)
    return [ a_list for a_list in
                list_of_lists
                if a_list != []]

Returns non empty lists.

ll_1 = [[9,2], [4,5,7,3], [3,6,8,4]]

getnonnulllist(ll1)

ll_2 = [[9,2], [], [3,6,8,4]]

getnonnulllist(ll2)

source
ePowerSim.get_non_null_list_and_IdxMethod
get_non_null_list_and_Idx(
    list_of_lists)

Returns non empty lists and their indices.

ll_1 = [[9,2], [4,5,7,3], [3,6,8,4]]

getnonnulllistandIdx(ll1)

ll_2 = [[9,2], [], [3,6,8,4]]

getnonnulllistandIdx(ll2)

source
ePowerSim.get_nt_vec_wt_vec_vec_per_parasMethod
get_nt_vec_wt_vec_vec_per_paras(
    vec_vec_per_node;
    nt_syms = (:nothing, ),
    vec_datatype = Float64 )

Convert vec_namedtuple to nt_vector, vector of namedtuples to namedtuples of vector per parameters.

source
ePowerSim.get_ntuple_status_steady_state_dataMethod
get_ntuple_status_steady_state_data(
    ;<keyword arguments>)

Returns namedtuples of data for network status in list_network_status. The network status in the list are :pre_fault_state, :fault_state, :post_fault_state.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

pf_alg: power flow solver abstol: the absolute error tolerance reltol: the relative error tolerance on_fault_time: the on fault time clear_fault_time: the clear fault time list_fault_point_from_node_a::Vector{Float64}=[0.3]: the list containing a ratio of the fault point from the source (from) orientation of lines list_fault_resistance::Vector{Float64} = [0.001]: the list containing fault resistances of each fault in the network. list_no_line_circuit::Vector{Float64} = [4]: the list containing the number of circuits per faulted lines list_edges_to_have_fault::Vector{Int64} = [2]: the list containing indices of lines that should have a fault. clear_fault_selection_list::Vector{Int64} = [1]: the list containing indices of faulted lines to be cleared in list_edges_to_have_fault. with_faults::Bool=false: a legacy boolean variable. timespan: the simulation time. list_network_status: the list of network status.

source
ePowerSim.get_ode_flat_para_Idxs_in_IdxsMethod
get_ode_flat_para_Idxs_in_Idxs(
    gens_vh_θh,
    gens_nodes_ωs_ωref0_vref0_porder0,
    gens_dynamic_id_iq_pg_vh )

Returns namedtuples of gens_nodes_vh_θh_idx_in_Idx, gens_nodes_ωs_ωref0_vref0_porder0_idx_in_Idx, gens_nodes_id_iq_pg_vh_idx_in_Idx.

source
ePowerSim.get_ode_gens_generic_paraMethod
 get_ode_gens_generic_para(
     plant_generators_data_from_json;
     sequence_order =
         gens_generic_sequence_order,
     selections =
         ode_gens_generic_selections)

Returns a namedtuple of selected parameters of devices from plant_generators_data_from_json.

Arguments

  • sequence_order::Tuple{Symbol}: the selection order of components data.
  • selections::Tuple{Symbol}: the tuple of parameters data to be selected.

It is used in get_ode_gens_generic_para, get_generic_gens_avr_gov_para

source
ePowerSim.get_only_adjacent_nodes_idxMethod
get_only_adjacent_nodes_idx(
    nodes_idx_with_adjacent_nodes_idx)

Returns only adjacent nodes indicies from nodesidxwithadjacentnodes_idx.

It does not consider the first entry in each row of nodesidxwithadjacentnodes_idx.

source
ePowerSim.get_opf_streamedlined_simulation_parametersMethod
get_opf_streamedlined_simulation_parameters(
    net_data_by_components_file;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for optimal power flow analyses.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver

source
ePowerSim.get_per_node_flat_idxsMethod
get_per_node_flat_idxs(
    list_vars_or_paras )

Returns for a vector of vectors list_vars_or_paras a per sub vector indices as per_node_vars_or_paras_Idx.

source
ePowerSim.get_per_node_flat_para_and_idxsMethod
get_per_node_flat_para_and_idxs(
    list_vars_or_paras )

Returns for a vector of vectors list_vars_or_paras a flattened vector, per sub vector indices as flattend_per_node_vars_or_paras, and per_node_vars_or_paras_Idx respectively.

source
ePowerSim.get_per_node_para_to_per_vars_or_parasMethod
get_per_node_para_to_per_vars_or_paras(
    list_per_node_vars_or_paras,
    dims_vars_or_paras_types )

Converts vars or paras given in per node format to per vars or paras format.

The dimension of each of the per vars or paras should be supplied in a list dims_vars_or_paras_types

source
ePowerSim.get_per_node_per_vars_or_paras_flat_idxsMethod
get_per_node_per_vars_or_paras_flat_idxs(
    list_vars_or_paras )

Returns for a vector of vectors list_vars_or_paras per sub vector indices and sub vector indices in the flattened vector as per_node_per_vars_or_paras_Idxs and per_node_vars_or_paras_Idx respectively.

source
ePowerSim.get_per_node_per_vars_or_paras_flat_para_and_idxsMethod
get_per_node_per_vars_or_paras_flat_para_and_idxs(
    list_vars_or_paras )

Returns for a vector of vectors list_vars_or_paras a flattened vector, per sub vector indices and sub vector indices in the flattened vector as flattend_per_node_vars_or_paras, per_node_vars_or_paras_Idx, per_node_per_vars_or_paras_Idxs respectively.

source
ePowerSim.get_per_vars_or_paras_flat_para_and_idxsMethod
get_per_vars_or_paras_flat_para_and_idxs(
    list_vars_or_paras )

Returns for a vector of vectors a flattened vector and and per sub vector indices as flattend_per_vars_or_paras, and per_vars_or_paras_Idx respectively.

source
ePowerSim.get_pf_dyn_idqMethod
get_pf_dyn_idq(
    vh, θh,
    δ_ω_ed_eq,
    ra_Xd_dash_Xq_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_pf_dyn_idqMethod
get_pf_dyn_idq(
    vh, θh, δ, ω,
    ed_dash, eq_dash,
    ra, X_d_dash, X_q_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_pf_dyn_idqMethod
get_pf_dyn_idq(
    vh_θh,
    δ_ω_ed_eq,
    ra_X_d_dash_X_q_dash )

Returns a generator direct current id and quadrature current iq in network reference frame.

source
ePowerSim.get_pf_streamedlined_simulation_parametersMethod
get_pf_streamedlined_simulation_parameters(
    net_data_by_components_file;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for power flow analyses.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver

source
ePowerSim.get_pf_transformed_idxsMethod
get_pf_transformed_idxs(
    ;slack_gens_nodes_idx,
    non_slack_gens_nodes_idx,
    gens_nodes_idx,
    non_gens_nodes_idx,
    gens_with_loc_load_idx,
    all_nodes_idx,

    n2s_slack_gens_idx,
    n2s_non_slack_gens_idx,
    n2s_gens_idx,
    n2s_non_gens_idx,
    n2s_gens_with_loc_load_idxs,
    n2s_all_nodes_idx )

Returns transformed indices of nodes types.

source
ePowerSim.get_pf_vh_θh_idx_and_idx2IdxMethod
get_pf_vh_θh_idx_and_idx2Idx(
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs)

Returns indices of vh, θh, and indices transformation dictionaries.

Arguments

  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_plants_states_symsMethod
get_plants_states_syms(
    gens_govs_avrs_states_syms)

Return plants states variables symbols per plant for all generator plants in a vector of vectors.

A generator plant consist of a generator, automatic voltage regulator, governor etc.

source
ePowerSim.get_plants_states_syms_and_labelsMethod
get_plants_states_syms_and_labels(
    gens_govs_avrs_states_syms,
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs)

Return a system namedtuple of state_vars_idx, vec_comp_states_Idx, plants_states_syms, generic_state_sym, state_labels, algebraic_vars_labels, and network_vars_labels.

Arguments

  • gens_govs_avrs_states_syms: the namedtuple of states variables symbols of generator, governors and automatic voltage regulator.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_plants_states_syms_wt_labels_wt_namesMethod
get_plants_states_syms_wt_labels_wt_names(
    gens_govs_avrs_states_syms,
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs)

Return a system namedtuple of state_vars_idx, vec_comp_states_Idx, plants_states_syms, generic_state_sym, state_labels, algebraic_vars_labels, network_vars_labels, model_syms, nodes_names, gens_nodes_names, non_gens_nodes_names, SM_gens_nodes_names, and SC_gens_nodes_names.

Arguments

  • gens_govs_avrs_states_syms: the namedtuple of states variables symbols of generator, governors and automatic voltage regulator.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_renewable_energy_net_optimisation_parametersMethod
get_renewable_energy_net_optimisation_parameters(
    case_file,

    wind_gens_cost_scale,    
    solar_gens_cost_scale,

    wind_gens_capacity_scale,    
    solar_gens_capacity_scale,

    active_power_demand_deviation_scale,
    reactive_power_demand_deviation_scale)

Return renewable energy network optimisation parameters for optimal power flow, unit commitment or economic dispatch

source
ePowerSim.get_selected_comp_properties_by_lensMethod

get_selected_comp_properties_by_lens

This is an utility function that return a subset of properties determined by selections as a vector of namedtuple.

It first assets that the selection is a subset of properties of lensed_comp_data.

lensed_comp_data is the result of application of lensfunc to compdata.

source
ePowerSim.get_selected_comps_ode_para_by_jsonMethod

get_selected_comps_ode_para_by_json can be used for any component for a plant.

It is more generic compared to:

get_gens_ra_and_reactances_by_json,

get_gens_ode_para_by_json,

get_avrs_ode_para_by_json_generic,

get_avrs_ode_para_by_json,

get_selected_avrs_ode_para_by_json, and

get_govs_ode_para_by_json

source
ePowerSim.get_selected_comps_properties_by_lensMethod

get_selected_comps_properties_by_lens

This is an utility function that return a subset of properties determined by selections as a vector of namedtuple.

selectedgensparas = getselectedcompspropertiesbylens( getgendynparasinnet, plantgenerators; selections = genstaticparaselections )

selectedgensparas = [ (P = 72.3, Q = 27.03, vh = 1.04, vmax = 1.1, vmin = 0.9, Qmax = 300, Qmin = -300, Pmax = 250, Pmin = 10, Sn = 390.51248379533274), (P = 72.3, Q = 27.03, vh = 1.04, vmax = 1.1, vmin = 0.9, Qmax = 300, Qmin = -300, Pmax = 250, Pmin = 10, Sn = 390.51248379533274), (P = 72.3, Q = 27.03, vh = 1.04, vmax = 1.1, vmin = 0.9, Qmax = 300, Qmin = -300, Pmax = 250, Pmin = 10, Sn = 390.51248379533274)]

It is like using a map on

get_selected_comp_properties_by_lens

selectedgensparas = getselectedcomppropertiesbylens.( getgendynparasinnet, plantgenerators; selections = genstaticparaselections )

selectedgensparas = map((y) -> getselectedcomppropertiesbylens( getgendynparasinnet, y; selections = genstaticparaselections), plantgenerators )

source
ePowerSim.get_selected_edges_data_by_jsonMethod
get_selected_edges_data_by_json(
    edge_data_from_json;
    sequence_order =
        (:components_data, ) ,
    selections =
        (:r, :x, :b, :ratio,
         :angle) )

Returns a vector of properties of edges selected by the variables sequence_order and selection.

source
ePowerSim.get_selected_vec_nt_as_nt_vec_by_lensMethod

get_selected_comp_as_nt_vec_by_lens

This is an utility function that return a subset of properties determined by selections as a namedtuple of vectors.

It first assets that the selection is a subset of properties of lensed_comp_data.

lensed_comp_data is the result of application of lensfunc to compdata.

getselectedcompasntvecby_lens(

getgendynparasin_net,

plant_generators;

selections =

genstaticpara_selections,

vec_datatype = Float64 )

selectedcompasntvec = (P = [72.3, 72.3, 72.3], Q = [27.03, 27.03, 27.03], vh = [1.04, 1.04, 1.04], vmax = [1.1, 1.1, 1.1], vmin = [0.9, 0.9, 0.9], Qmax = [300.0, 300.0, 300.0], Qmin = [-300.0, -300.0, -300.0], Pmax = [250.0, 250.0, 250.0], Pmin = [10.0, 10.0, 10.0], Sn = [390.512, 390.512, 390.512])

source
ePowerSim.get_selected_vec_nt_to_vec_vecMethod
get_selected_vec_nt_to_vec_vec(
    vec_namedtuple,
    nothing;
    selections = (:nothing, ),
    vec_datatype = Float64 )

Convert vec_namedtuple to nt_vector, vector of namedtuples to namedtuples of vector.

source
ePowerSim.get_sense_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_dataMethod
get_sense_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_edges_data(
    ;edges_fbus, edges_tbus,
    edges_type,
    edges_r, edges_x, edges_b,
    edges_ratio, edges_angle,
    Gs, Bs,
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA=1.0,
    basekV=1.0,
    line_data_in_pu = true)

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_sense_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_genericMethod
get_sense_Ynet_wt_nodes_idx_wt_adjacent_nodes_by_generic(
    branches_fbus,
    branches_tbus,
    r,
    x,
    b,
    ratio,
    angle,        
    Gs,
    Bs;
    edges_type,
    all_nodes_idx,
    n2s_all_nodes_idx,
    baseMVA = 1.0,
    basekV = 1.0,
    baseShunt = 1.0 )

Returns a namedtuple of network admitance vectors and network nodes neigbouhood vectors.

source
ePowerSim.get_shunt_data_by_mpcMethod
get_shunt_data_by_mpc(
    mpc_bus;
    mpc_baseMVA =
        1.0)

Returns a dict Dict{:shunt_idx,:shunt_Gs,:shunt_Bs } for network lines shunt parameters.

source
ePowerSim.get_slack_gens_vh_θh_gens_vh_non_slack_gens_vhMethod
get_slack_gens_vh_θh_gens_vh_non_slack_gens_vh(
    vh,
    θh,
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs)

Returns slack_gens_vh, slack_gens_θh, gens_vh, and non_slack_gens_vh.

Arguments

  • vh: the network nodes voltage magnitudes.
  • θh: the network nodes voltage angles.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_state_algebraic_vars_Idx_in_stateMethod
get_state_algebraic_vars_Idx_in_state(
    generic_state_labels,
    gens_nodes_idx,
    all_nodes_idx)

Returns state variables, and algebraic variables indices in the state.

Arguments

  • generic_state_labels: the states variables labels.
source
ePowerSim.get_state_algebraic_vars_wt_fault_Idx_in_stateMethod
get_state_algebraic_vars_wt_fault_Idx_in_state(
    generic_state_labels,
    gens_nodes_idx,
    all_nodes_idx;
    no_lines_fault = 1)

Returns state variables, and algebraic variables with fault nodes algebraic variables indices in the state.

Arguments

  • generic_state_labels: the states variables labels.
source
ePowerSim.get_state_and_algebraic_vars_Idx_in_stateMethod
get_state_and_algebraic_vars_Idx_in_state(
    state_labels,
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs;
    no_lines_fault = 1 )

Return indices of state and algebraic variables for a normal system and faulted system states in a flattened vector.

state_vars_and_i_dq_Idx_in_state, state_vars_and_i_dq_wt_fault_Idx_in_state, state_algebraic_vars_Idx_in_state, and state_algebraic_vars_wt_fault_Idx_in_state.

Arguments

  • state_labels: the system state variables labels.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
  • no_lines_fault::Int64 = 1: the number of lines faults.
source
ePowerSim.get_state_labelsMethod
get_state_labels(
    gens_govs_avrs_states_syms,
    gens_nodes_idx;
    label_prefix = "bus",
    plants_states_by_per_comp = false,
    plants_states_by_per_plant = true )

Return plants states variables symbols or lables for all generator plants in a flattened vector.

A generator plant consist of a generator, automatic voltage regulator, governor etc.

source
ePowerSim.get_state_vars_and_i_dq_Idx_in_stateMethod
get_state_vars_and_i_dq_Idx_in_state(
    generic_state_labels,
    gens_nodes_idx,
    all_nodes_idx )

Returns state variables, nodes voltage magnitudes, nodes voltage angles, generators direct axix current id, and generators quadrature axis current indices in the state.

Arguments

  • network_vars_labels: the system variables labels.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • selected_gens_state_vars_syms::Tuple{Symbol}=(:δ, :ed_dash, :eq_dash):
source
ePowerSim.get_state_vars_and_i_dq_wt_fault_Idx_in_stateMethod
get_state_vars_and_i_dq_wt_fault_Idx_in_state(
    generic_state_labels,
    gens_nodes_idx,
    all_nodes_idx;
    no_lines_fault = 1)

Returns state variables, nodes voltage magnitudes, nodes voltage angles, generators direct axix current id, and generators quadrature axis current, fault node voltage magnitudes, fault node voltage angles, indices in the state.

Arguments

  • generic_state_labels: the states variables labels.
source
ePowerSim.get_state_vars_idxMethod
get_state_vars_idx(
    gens_govs_avrs_states_syms)

Return indices of states variables in the system in a flatted.

Arguments

  • gens_govs_avrs_states_syms: the namedtuple of states variables symbols of generator, governors and automatic voltage regulator.
source
ePowerSim.get_states_Idx_syms_wt_functionsMethod
get_states_Idx_syms_wt_functions(
    net_data_by_components_file,    
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs;
    components_libs_dir =
        nothing,
    no_lines_fault = 1 )

Returns dynamic functions of components, states variables indices, algebraic variables indices, states variables labels, algebraic variables labels and most parameters indices.

Arguments

  • net_data_by_components_file: the network data file.
  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
  • components_libs_dir: the components library folder.
source
ePowerSim.get_static_Idx_and_symsMethod
get_static_Idx_and_syms(
    dyn_pf_fun_kwd_net_idxs,
    dyn_pf_fun_kwd_n2s_idxs;
    no_lines_fault = 1)

Returns states variables indices, algebraic variables indices, states variables labels, algebraic variables labels and most parameters indices.

Arguments

  • dyn_pf_fun_kwd_net_idxs: the namedtuple of node's type indices.
  • dyn_pf_fun_kwd_n2s_idxs: the namedtuple of node's type indices translation dictionaries.
source
ePowerSim.get_status_steady_state_parametersMethod
get_status_steady_state_parameters(
    net_data_by_components_file;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for simulation.

Arguments

  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver

abstol: the absolute error tolerance reltol: the relative error tolerance

on_fault_time: the on fault time clear_fault_time: the clear fault time

list_fault_point_from_node_a::Vector{Float64}=[0.3]: the list containing a ratio of the fault point from the source (from) orientation of lines list_fault_resistance::Vector{Float64} = [0.001]: the list containing fault resistances of each fault in the network. list_no_line_circuit::Vector{Float64} = [4]: the list containing the number of circuits per faulted lines.

list_edges_to_have_fault::Vector{Int64} = [2]: the list containing indices of lines that should have a fault. clear_fault_selection_list::Vector{Int64} = [1]: the list containing indices of faulted lines to be cleared in list_edges_to_have_fault.

with_faults::Bool=false: a legacy boolean variable.

source
ePowerSim.get_subsubtypeMethod
get_subsubtype(AbstractPowerSystemComponent)

It returns the subtypes of subtypes of abstract types of AbstractPowerSystemComponent. These are the subtypes of SdGen, SdNonGen, SdGov, SdAvr, SdPss, SdNonGenPlant, SdGenPlant and SdBranchElement. It is used to get list_components_types which is a list of components defined in this package.

source
ePowerSim.get_system_net_data_wt_static_parametersMethod
get_system_net_data_wt_static_parameters(
    case_name;
    <keyword arguments>)

It is used to simplify static model parameters or data of a system that are needed for static analyses.

Arguments

-case_name: the case name

  • script_dir::String="": working folder
  • data_dir::String="": data folder where all cases are stored
  • json_net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

pf_alg: power flow solver

source
ePowerSim.get_system_net_static_dataMethod
get_system_net_static_data(
    case_name;
    <keyword arguments>)

It is used to simplify static model parameters or data of a system that are needed for static analyses.

Arguments

-case_name: the case name

  • script_dir::String="": working folder
  • data_dir::String="": data folder where all cases are stored
  • json_net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver no_lines_fault: the number of faults

source
ePowerSim.get_system_simulation_parametersMethod
get_system_simulation_parameters(
    net_data_by_components_file,
    nothing;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for simulation.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver

abstol: the absolute error tolerance reltol: the relative error tolerance

source
ePowerSim.get_system_simulation_parametersMethod
get_system_simulation_parameters(
    net_data_by_components_file;
    <keyword arguments>)

It is used to simplify generation of parameters or data of a system that are needed for simulation.

Arguments

  • net_data_by_components_file: the network data file
  • components_libs_dir: the components library folder
  • basekV: the base voltage
  • use_pu_in_PQ: the boolean variable that determines if PQ should be in pu.
  • line_data_in_pu: the boolean variable that informs if line data are in pu,

use_init_u0: the boolean variable that determines if initial state u0 should be used in a power flow. use_nlsolve: the boolean variable that determines if nlsolve should be used in power flow.

pf_alg: power flow solver

abstol: the absolute error tolerance reltol: the relative error tolerance

source
ePowerSim.get_ur_ui_Idx_in_stateMethod
get_ur_ui_Idx_in_state(
    dims, comps_ur_ui_Idx; counter=0 )

Returns indices of ur, ui for a flattend system states.

The input are dims of components state and indices of ur and ui in each component state

Test:

\[\]

compsstatessyms = [[:ur,:ui], [:δ, :ω, :ur, :ui], [:δ,:ur,:ω,:ui]]

comps_states = [[9,2], [4,5,7,3], [3,6,8,4]]

compsflattenedstates = [comps_states...;]

dims = length.(comps_states)

compsuruiIdx = [[1,2], [3,4], [2,4]]

uruiIdxinstate = geturuiIdxinstate(dims, compsurui_Idx; counter=0 )

uruiinstate = [compsflattenedstates[inx] for inx in uruiIdxin_state ]

compsuview = [view(compsflattenedstates, uruiIdxinstate[Ind]) for Ind in collect(1:length( uruiIdxinstate ))]

source
ePowerSim.get_vars_idxs_in_range_IdxsMethod
get_vars_idxs_in_range_Idxs(
    vec_unit_range,
    list_vars_syms )

Returns vectors of idxs as tuples

gensnodesidx = [1,2,3] gensstatevarssyms = [:δ, :ω, :eqdash, :E_fd]

gensstatesIdx = getidxsinflattenedbynodesidxwtvarssyms( gensstatevarssyms, gensnodesidx )

sum( length.( gensstatesIdx ) )

idxinstate, ωidxinstate, eqdashidxinstate, Efdidxinstate ) = getvarsidxsinrangeIdxs( gensstatesIdx, gensstatevarssyms )

source
ePowerSim.idx_containingMethod
idx_containing(
    network_vars_labels,
    expr;
    syms = true)

Returns the list of indices of variables containing a given expr in network variable labels.

source
ePowerSim.init_im_plants_system_matrices_views!Method

This function initialises system matrices views Ax_view, Bx_view, Cx_view which are in vectors vec_Ax_views, vec_Bx_views, vec_Cx_views.

These views are created by create_gens_nodes_im_aggregate_system_matrices_Idx_and_views.

The intialisation is expected to be reflected in aggregate system matrices Ax_matrix, Bx_matrix, Cx_matrix

source
ePowerSim.init_plants_system_matrices_views!Method

This function initialises system matrices views Ax_view, Bx_view, Cx_view which are in vectors vec_Ax_views, vec_Bx_views, vec_Cx_views.

These views are created by create_gens_nodes_aggregate_system_matrices_Idx_and_views.

The intialisation is expected to be reflected in aggregate system matrices Ax_matrix, Bx_matrix, Cx_matrix

source
ePowerSim.init_plants_system_stability_matrices_views!Method

This function initialises system stability matrices views stab_Ax_view, stab_Bx_view, stab_Cx_view which are in vectors vec_stab_Ax_views, vec_stab_Bx_views, vec_stab_Cx_views.

These views are created by create_gens_nodes_aggregate_system_stability_matrices_Idx_and_views.

The intialisation is expected to be reflected in aggregate system matrices stab_Ax_matrix, stab_Bx_matrix, stab_Cx_matrix

source
ePowerSim.invZ_dqMethod
invZ_dq(ra, X_d_dash, X_q_dash)

Returns inverse Z_dq matrix transform for a generator.

source
ePowerSim.make_csv_from_solsMethod

This function saves solution of cases in csv files

listsol = [solIEEE5BusplantSMcbidqcntrlandPQConstI, solIEEE5BusplantSMcbv6cntrlandPQConstI, solIEEE5BusplantSMcbidqcntrlandPQConstP, solIEEE5BusplantSMcbv6cntrlandPQConst_P]

listprefix = ["IEEE5BusplantSMcbidqcntrlandPQConstI", "IEEE5BusplantSMcbv6cntrlandPQConstI", "IEEE5BusplantSMcbidqcntrlandPQConstP", "IEEE5BusplantSMcbv6cntrlandPQConst_P"]

makecsvfromsols(csvfolder, listsol, listprefix; suffix = :csv)

source
ePowerSim.make_plots_with_namesMethod

This function makes plots for selected symbols for a list of solutions:

networkvarslabels = getnetworkvarslabels(NetworkData(caseIEEE5BusdynamicplantSMcbidqPQConstI()...))

listsol = [solIEEE5BusplantSMcbidqcntrlandPQConstI, solIEEE5BusplantSMcbv6cntrlandPQConstI, solIEEE5BusplantSMcbidqcntrlandPQConstP, solIEEE5BusplantSMcbv6cntrlandPQConst_P]

listprefix = String.(nameof.(listcases))

or

listprefix = ["IEEE5BusplantSMcbidqcntrlandPQConstI", "IEEE5BusplantSMcbv6cntrlandPQConstI", "IEEE5BusplantSMcbidqcntrlandPQConstP", "IEEE5BusplantSMcbv6cntrlandPQConst_P"]

listselectedsymslist = [[:ω, :δ, :eddash, :eqdash], [:xg1, :xg2, :xg3, :τmtilade], [:vm, :vr1, :vr2, :vftilade], [:phatin, :v_ref]]

makeplotswithnames(figfolder, listsol, listprefix, listselectedsymslist, networkvars_labels; tspan = (0.0, 50.0), suffix = :pdf)

source
ePowerSim.namedtuple_nested_selectionMethod
namedtuple_nested_selection(
    nested_namedtuple;
    sequence_order = (:nothing,),
    selections = (:nothing,) )

Returns a set of selection at the same level in a nested namedtuple.

Example


    some_plant_generators_data_from_json =
        [(idx = 1,
          plant_type = "plant_wt_loc_load_v6",
          components_type =
              (gen = "SM_2axis_wt_loc_load_cb_v6",
               avr = "avr_t1_cb",
               gov = "gov_ieee_tgov1_cb"),
          components_data = (
              gen = (T_d_dash = 7.4, D = 0, X_d = 0.8979,
                     vh = 1.06, X_q = 0.646,
                     ωs = 376.99111843077515,
                     T_d_2dash = 0.03, Qmin = 0,
                     Sn = 332.5503871596002,
                     X_d_dash = 0.2995, T_q_dash = 0.3,
                     Ωb = 376.99111843077515,
                     Bus = "bus1", X_q_dash = 0.646,
                     ra = 0, X_q_2dash = 0.4,
                     Q = -16.9, Pmax = 332.4,
                     Pmin = 0, xℓ = 0.2396,
                     P = 232.4, vmax = 1.06,
                     H = 5.148, Qmax = 10,
                     vmin = 0.94, T_q_2dash = 0.033,
                     X_d_2dash = 0.23), )),
         (idx = 2,
          plant_type = "plant_wt_loc_load_v6",
          components_type =
              (loc_load = "loc_Load_t1",
               gen = "SM_2axis_wt_loc_load_cb_v6",
               avr = "avr_t1_cb",
               gov = "gov_ieee_tgov1_cb"),
          components_data = (
              loc_load = (Bus = "bus2",
                          loc_P = 21.7,
                          loc_Q = 12.7),
              gen = (T_d_dash = 6.1, D = 0, X_d = 1.05,
                     vh = 1.045, X_q = 0.98,
                     ωs = 376.99111843077515,
                     T_d_2dash = 0.04, Qmin = -40,
                     Sn = 148.66068747318505,
                     X_d_dash = 0.185, T_q_dash = 0.3,
                     Ωb = 376.99111843077515,
                     Bus = "bus2", X_q_dash = 0.36,
                     ra = 0.0031, X_q_2dash = 0.13,
                     Q = 42.4, Pmax = 140, Pmin = 0,
                     xℓ = 0, P = 40, vmax = 1.06,
                     H = 6.54, Qmax = 50, vmin = 0.94,
                     T_q_2dash=0.099,X_d_2dash=0.13),))]


    sequence_order = (:components_data, :gen)
    
    selections = (:P, :Q)
    
    namedtuple_nested_selection(
        some_plant_generators_data_from_json;
        sequence_order = sequence_order,
        selections = selections )

2-element Vector{Any}:
 (P = 232.4, Q = -16.9)
 (P = 40, Q = 42.4)
source
ePowerSim.parse_matpower_data_as_csvMethod

parse_matpower_data_as_csv

Returns a dictionary

Dict( "name" => matrix_name, "columns_header" => columns_header, "matrix_body" => matrix_body_lines, "line_count" => line_count )

for a matpower file section.

source
ePowerSim.pertubation_by_itegratorMethod
pertubation_by_itegrator(
    var_normal_value,
    pertubation_factor,
    pertubation_tstop,
    var_idx,
    system_integrator;
    parameter_df =
        nothing,
    change_in_parameter_dict =
        nothing,
    target_parameter_sym =
        nothing )

These functions are used in generating results for load pertubation, co-simulation, etc.

get_sol_auxilliary_results, pertubation_by_itegrator

a_parameter_pertubation!, a_parameter_pertubation_and_step!

save_pertubation_stage_plot, save_co_sim_stage_plot,

get_P_or_Q_idx_in_generic_model_dynamics_para

get_make_df_header_generic_model_dynamics_para

source
ePowerSim.recursive_dict_to_namedtupleMethod
recursive_dict_to_namedtuple(
    mapping)

Converts recursively a nested dictionary to a nested namedtuple.

Example


dict_values =
    Dict{Symbol, Any}(
        :V_R_max => 5.2,
        :Tf => 0.35,
        :Be => 1.555,
        :Tr => 0.001,
        :Ta => 0.2,
        :Ka => 20,
        :Te => 0.314,
        :Kf => 0.063,
        :V_R_min => -4.16,
        :Ke => 1,
        :gov => Dict{Symbol, Any}(
            :p_max => 2.2,
            :R => 0.02,
            :p_min => 0.1,
            :Ts => 0.2,
            :Tc => 0.4,
            :avr => Dict{Symbol, Any}(
            :Tr => 0.001,
            :Ta => 0.2,
            :Ka => 20,
            :Te => 0.314) ))

recursive_dict_to_namedtuple(dict_values)
source
ePowerSim.recursive_nested_namedtuple_wt_dictMethod
recursive_nested_namedtuple_wt_dict(
    nested_namedtuple)

Converts recursively a nested dictionary to a nested namedtuple.

Example



nt_values =
    (
        V_R_max = 5.2,
        Tf = 0.35,
        Be = 1.555,
        Tr = 0.001,
        Ta = 0.2,
        Ka = 20,
        Te = 0.314,
        Kf = 0.063,
        V_R_min = -4.16,
        Ke = 1,
        gov = Dict{Symbol, Any}(
            :p_max => 2.2,
            :R => 0.02,
            :p_min => 0.1,
            :Ts => 0.2,
            :Tc => 0.4,
            :avr => Dict{Symbol, Any}(
            :Tr => 0.001,
            :Ta => 0.2,
            :Ka => 20,
                :Te => 0.314) ))

recursive_nested_namedtuple_wt_dict(
    nt_values)
source
ePowerSim.save_matpower_data_as_csvMethod

save_matpower_data_as_csv

Saves a matpower section as a csv file. The inputs to this function is a dictionary which is an output of parse_matpower_data_as_csv

Dict( "name" => matrix_name, "columns_header" => columns_header, "matrix_body" => matrix_body_lines, "line_count" => line_count )

and a directory to store the csv file. The name of the csv file is taken from matrix_name in the dictionary.

source
ePowerSim.simulate_casesMethod

simulate_cases(sd_dyn_sim_func, list_cases; static_case = case_IEEE_5_Bus_static )

This function simulates several cases in of dynamic power models in listcases. The dynamic function for simulation is `sddynsimfunc` .

The static_case is used to obtain power flow for intialisation of the states of the dynamic model.

It returns solution for each of the cases in a list.

listcases = [caseIEEE5BusdynamicplantSMcbidqPQConstI, caseIEEE5BusdynamicplantSMcbv6PQConstI, caseIEEE5BusdynamicplantSMcbidqPQConstP, caseIEEE5BusdynamicplantSMcbv6PQConst_P]

listsol = simulatecases(sddynamicssimulationexternalft, listcases; staticcase = caseIEEE5Bus_static )

source
ePowerSim.swap_yπ_diagonal_elementsMethod
get_nt_components_data( components_data)

Swap the diagonal element of a 2 x 2 matrix.

It is used in get_Yπ_net to get an appropriate orientation for elementary admittance matrix .

source
ePowerSim.syms_containingMethod
syms_containing(
    network_vars_labels,
    expr;
    syms = true)

Returns the list of symbols of variables containing a given expr in network variable labels.

source
ePowerSim.thermal_cost_functionMethod

This was taken from JuMP tutoria:

thermal_cost_function(g)

A user-defined thermal cost function in pure-Julia! You can include nonlinearities, and even things like control flow.

Warning

It's still up to you to make sure that the function has a meaningful derivative.

source
ePowerSim.u_from_ur_uiMethod
u_from_ur_ui(ur_ui)

Returns the complex voltage for a list containing real part and imaginary part of a complex voltage.

source
ePowerSim.u_to_ΘVMethod
u_to_ΘV(u)

Returns a flatted concatenated nodes voltage angles and nodes voltage magnitudes for a list of nodes complex voltages.

source
ePowerSim.update_padded_vec_of_vec_from_comp_axis!Method
update_padded_vec_of_vec_from_comp_axis!(
    padded_vec_of_vec,
    P_comp, Q_comp,
    idxs )

Updates padded_vec_of_vec, by P_comp, Q_comp based on idxs.

Example

nodes_size = 9

paddedvecofvec = [[0.0, 0.0] for idx in 1:nodessize ]

Pcomp = [1.2, 3.0, 4.0] Qcomp = [2.2, 3.1, 1.0]

idxs = [2,5,9]

source
ePowerSim.update_vec_of_vec_from_comp_axis!Method
update_vec_of_vec_from_comp_axis!(
    vec_of_vec, P_comp, Q_comp )

Updates vec_of_vec, by P_comp, Q_comp.

Example

a = [[0.0, 0.0], [1.0, 0.0], [0.1,0.2]] tp = [1.2, 3.0, 4.0] tq = [2.2, 3.1, 1.0]

updatevecofvecfromcompaxis!( a , tp , tq )

source
ePowerSim.update_vec_of_vec_from_vec_vec!Method
update_vec_of_vec_from_vec_vec!(
    vec_of_vec, PQ_vec_vec, idxs )

Updates vec_of_vec, by PQ_vec_vec based on idxs.

Example

a = [[0.0, 0.0], [0.0, 0.0], [0.0,0.0], [0.0,0.0], [0.0,0.0], [0.0,0.0] ]

t_p = [[1.2, 3.0], [4.0, 6.0]]

idxs = [2, 4, 6]

source
ePowerSim.ur_ui_to_uMethod
ur_ui_to_u(ur_ui)

Returns the complex voltage for a list containing real part and imaginary part of a complex voltage.

source
ePowerSim.ur_ui_to_ΘVMethod
ur_ui_to_ΘV(ur_ui)

Returns a flatted concatenated nodes voltage angles and nodes voltage magnitudes for a list of list of nodes voltages real and imaginary parts.

source
ePowerSim.x_from_xr_xiMethod
x_from_xr_xi(ur_ui)

Returns the complex value for a list containing real part and imaginary part of a complex value.

source
ePowerSim.xr_xi_to_xMethod
xr_xi_to_x(ur_ui)

Returns the complex value for a list containing real part and imaginary part of a complex value.

source
ePowerSim.z2yMethod
z2y(; r =1.0, x = 1.00, G = 0.0, B = 0.0)

Returns a transmission admittance y for a given r, x, G and B.

source