diff --git a/README.md b/README.md index 69e05aa9..ce9a6ab7 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,27 @@ Simulation Toolkit for Electrical Power Systems Maintainer: Changgang Li Please go to http://steps.drli.group:380 for documentation. +How to build: +1) Select which LA solver is to be used +Open STEPS.cbp and go to header/basic/sparse_matrix_define.h. Comment the solver you don't want to use. +For example, if you want to keep only c_sparse, comment out umfpack and klu. +Then go to source/basic/sparse_matrix_klu.cpp and umfpack.cpp, disable 'compile' and 'link' options of the two files. +2) Go compile the LS solver. +For example, open csparse.cbp, and compile CSparse. The target should be 'static library' +3) Go compile the CppTest. +Open cpptest.cbp, and compile CppTest. The target should be 'static library' +4) Build STEPS +In the linker settings, you should include the above two static libraries libCSparse.a and libCpptest.a. +Then compile the STEPS. +5) If you want to build a 64bit version, use 64 bit MinGW and select the X64 version compiler. + +If you want to compile a complete version, follow the steps: +1) Compile BLAS as static library +2) Compile UMFPACK as static library +3) Compile CSparse as static library +4) Compile CppTest as static library +5) Compile STEPS as dynamic library or exectuable file. Include libUMFPACK.a, libBLAS.a, libCSparse.a, and libCpptest.a. Put libBLAS.a after libUMFPACK.a. + +When compiling in Windows, remove -no-pie and -lgfortran options and remove libKLU.a, libBLAS.a, libUMFPACK.a + + diff --git a/code/STEPS.cbp b/code/STEPS.cbp index 54c968be..1e61cd0d 100644 --- a/code/STEPS.cbp +++ b/code/STEPS.cbp @@ -17,6 +17,7 @@ + @@ -30,6 +31,7 @@ + @@ -419,10 +421,12 @@ + + diff --git a/code/STEPS.depend b/code/STEPS.depend index e32ff13f..3d20e5d6 100644 --- a/code/STEPS.depend +++ b/code/STEPS.depend @@ -385,10 +385,8 @@ "header/basic/inphno.h" -1553928358 c:\users\lichg\steps\code\header\basic\sparse_matrix_define.h +1563791982 c:\users\lichg\steps\code\header\basic\sparse_matrix_define.h "header/basic/sparse_matrix_csparse.h" - "header/basic/sparse_matrix_umfpack.h" - "header/basic/sparse_matrix_klu.h" 1553928358 c:\users\lichg\steps\code\header\basic\sparse_matrix_csparse.h "cs.h" @@ -479,7 +477,7 @@ "header/device/hvdc.h" -1561874701 c:\users\lichg\steps\code\header\data_imexporter\data_imexporter.h +1563870847 c:\users\lichg\steps\code\header\data_imexporter\data_imexporter.h "header/power_system_database.h" "header/basic/base.h" @@ -503,7 +501,7 @@ "header/basic/utility.h" "header/steps_namespace.h" -1561874546 source:c:\users\lichg\steps\code\source\apis\steps_api_data_import_export.cpp +1563873761 source:c:\users\lichg\steps\code\source\apis\steps_api_data_import_export.cpp "header/apis/steps_api.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -2068,8 +2066,9 @@ -1561861274 source:c:\users\lichg\steps\code\source\data_imexporter\data_imexporter.cpp +1563872516 source:c:\users\lichg\steps\code\source\data_imexporter\data_imexporter.cpp "header/data_imexporter/data_imexporter.h" + "header/STEPS.h" "header/basic/utility.h" @@ -2154,7 +2153,7 @@ "header/data_imexporter/psse_imexporter.h" "header/STEPS.h" -1563243177 source:c:\users\lichg\steps\code\source\data_imexporter\psse_powerflow_imexporter.cpp +1563873156 source:c:\users\lichg\steps\code\source\data_imexporter\psse_powerflow_imexporter.cpp "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/steps_imexporter.h" "header/basic/utility.h" @@ -4202,7 +4201,7 @@ "header/model/wtg_models/wt_electrical_model/wind_turbine_power_speed_lookup_table.h" "header/basic/utility.h" -1561097477 source:c:\users\lichg\steps\code\source\model\wtg_models\wt_electrical_model\wt3e0.cpp +1563799901 source:c:\users\lichg\steps\code\source\model\wtg_models\wt_electrical_model\wt3e0.cpp "header/model/wtg_models/wt_electrical_model/wt3e0.h" "header/device/wt_generator.h" "header/power_system_database.h" @@ -4841,7 +4840,7 @@ "header/toolkit/dynamic_simulator/dynamic_simulator.h" -1563678595 source:c:\users\lichg\steps\code\source\toolkit\powerflow_solver\powerflow_solver.cpp +1563709170 source:c:\users\lichg\steps\code\source\toolkit\powerflow_solver\powerflow_solver.cpp "header/toolkit/powerflow_solver/powerflow_solver.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -5292,7 +5291,7 @@ "header/toolkit/powerflow_solver/powerflow_solver.h" "header/toolkit/dynamic_simulator/dynamic_simulator.h" -1561086121 source:c:\users\lichg\steps\code\source\apis\steps_api_utilities.cpp +1563873638 source:c:\users\lichg\steps\code\source\apis\steps_api_utilities.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" diff --git a/code/cpptest.cbp b/code/cpptest.cbp index e2a885c0..a28ba9a4 100644 --- a/code/cpptest.cbp +++ b/code/cpptest.cbp @@ -19,10 +19,14 @@ + + + + diff --git a/code/csparse.cbp b/code/csparse.cbp index 8b3b4cc3..623396f9 100644 --- a/code/csparse.cbp +++ b/code/csparse.cbp @@ -17,6 +17,7 @@ + @@ -24,6 +25,9 @@ + + + diff --git a/code/csparse.depend b/code/csparse.depend index bbdfcbdb..11c3cf83 100644 --- a/code/csparse.depend +++ b/code/csparse.depend @@ -160,3 +160,164 @@ 1544403720 source:/home/changgang/steps/code/thirdparty/SuiteSparse/CSparse/Source/cs_utsolve.c "cs.h" +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_add.c + "cs.h" + +1553928359 c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\include\cs.h + + + + + + "mex.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_amd.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_chol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_cholsol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_compress.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_counts.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_cumsum.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_dfs.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_dmperm.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_droptol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_dropzeros.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_dupl.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_entry.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_ereach.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_etree.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_fkeep.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_gaxpy.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_happly.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_house.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_ipvec.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_leaf.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_load.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_lsolve.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_ltsolve.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_lu.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_lusol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_malloc.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_maxtrans.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_multiply.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_norm.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_permute.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_pinv.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_post.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_print.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_pvec.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_qr.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_qrsol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_randperm.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_reach.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_scatter.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_scc.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_schol.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_spsolve.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_sqr.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_symperm.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_tdfs.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_transpose.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_updown.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_usolve.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_util.c + "cs.h" + +1553928359 source:c:\users\lichg\steps\code\thirdparty\suitesparse\csparse\source\cs_utsolve.c + "cs.h" + diff --git a/code/header/basic/sparse_matrix_define.h b/code/header/basic/sparse_matrix_define.h index c1d966ce..ba6887ea 100644 --- a/code/header/basic/sparse_matrix_define.h +++ b/code/header/basic/sparse_matrix_define.h @@ -1,6 +1,6 @@ #include "header/basic/sparse_matrix_csparse.h" -#include "header/basic/sparse_matrix_umfpack.h" -#include "header/basic/sparse_matrix_klu.h" +//#include "header/basic/sparse_matrix_umfpack.h" +//#include "header/basic/sparse_matrix_klu.h" #define STEPS_SPARSE_MATRIX SPARSE_MATRIX_CSPARSE //#define STEPS_SPARSE_MATRIX SPARSE_MATRIX_UMFPACK diff --git a/code/header/data_imexporter/data_imexporter.h b/code/header/data_imexporter/data_imexporter.h index 3150c0cd..0175a338 100644 --- a/code/header/data_imexporter/data_imexporter.h +++ b/code/header/data_imexporter/data_imexporter.h @@ -20,6 +20,8 @@ class DATA_IMEXPORTER : public BASE bool get_export_zero_impedance_line_logic() const; bool get_export_out_of_service_bus_logic() const; + void export_shadowed_bus_pair(string file) const; + virtual void load_powerflow_data(string pf_source) = 0; virtual void load_dynamic_data(string dy_source) = 0; virtual void load_sequence_data(string sq_source) = 0; diff --git a/code/source/apis/steps_api_data_import_export.cpp b/code/source/apis/steps_api_data_import_export.cpp index dd586322..84b3bebc 100644 --- a/code/source/apis/steps_api_data_import_export.cpp +++ b/code/source/apis/steps_api_data_import_export.cpp @@ -34,7 +34,7 @@ void api_save_powerflow_data_to_file(char* file, char* file_type, bool export_ze PSSE_IMEXPORTER exporter; exporter.set_toolkit(toolkit); exporter.set_export_out_of_service_bus_logic(export_out_of_service_bus); - exporter.export_powerflow_data(file); + exporter.export_powerflow_data(file, export_zero_impedance_line); } else { @@ -43,7 +43,7 @@ void api_save_powerflow_data_to_file(char* file, char* file_type, bool export_ze BPA_IMEXPORTER exporter; exporter.set_toolkit(toolkit); exporter.set_export_out_of_service_bus_logic(export_out_of_service_bus); - exporter.export_powerflow_data(file); + exporter.export_powerflow_data(file, export_zero_impedance_line); } } } diff --git a/code/source/apis/steps_api_utilities.cpp b/code/source/apis/steps_api_utilities.cpp index 429626b5..30d795cd 100644 --- a/code/source/apis/steps_api_utilities.cpp +++ b/code/source/apis/steps_api_utilities.cpp @@ -46,6 +46,8 @@ double api_get_toolkit_float_data(char* parameter_name, size_t toolkit_index) string PARAMETER_NAME = string2upper(parameter_name); if(PARAMETER_NAME=="SBASE") return psdb.get_system_base_power_in_MVA(); + if(PARAMETER_NAME=="ZERO IMPEDANCE THRESHOLD IN PU") + return psdb.get_zero_impedance_threshold_in_pu(); show_parameter_not_supported_with_api(PARAMETER_NAME, __FUNCTION__); return 0.0; @@ -59,6 +61,8 @@ void api_set_toolkit_float_data(char* parameter_name, double value, size_t toolk string PARAMETER_NAME = string2upper(parameter_name); if(PARAMETER_NAME=="SBASE") return psdb.set_system_base_power_in_MVA(value); + if(PARAMETER_NAME=="ZERO IMPEDANCE THRESHOLD IN PU") + return psdb.set_zero_impedance_threshold_in_pu(value); show_parameter_not_supported_with_api(PARAMETER_NAME, __FUNCTION__); } diff --git a/code/source/data_imexporter/data_imexporter.cpp b/code/source/data_imexporter/data_imexporter.cpp index 4d5d4466..fa039a3d 100644 --- a/code/source/data_imexporter/data_imexporter.cpp +++ b/code/source/data_imexporter/data_imexporter.cpp @@ -1,6 +1,9 @@ #include "header/data_imexporter/data_imexporter.h" +#include "header/STEPS.h" #include #include "header/basic/utility.h" + + DATA_IMEXPORTER::DATA_IMEXPORTER() { set_base_frequency_in_Hz(50.0); @@ -44,6 +47,63 @@ bool DATA_IMEXPORTER::get_export_out_of_service_bus_logic() const return export_out_of_service_bus; } +void DATA_IMEXPORTER::export_shadowed_bus_pair(string file) const +{ + ostringstream osstream; + STEPS& toolkit = get_toolkit(__PRETTY_FUNCTION__); + POWER_SYSTEM_DATABASE& psdb = toolkit.get_power_system_database(); + + ofstream ofs(file); + if(!ofs) + { + osstream<<"Warning. Shadowed bus pair file "< > bus_pairs; + + bus_pairs.clear(); + + vector buses = psdb.get_all_buses(); + size_t n = buses.size(); + for(size_t i=0; i!=n; ++i) + { + BUS* bus = buses[i]; + size_t bus_number = bus->get_bus_number(); + size_t equiv_bus_number = bus->get_equivalent_bus_number(); + if(equiv_bus_number!=0 and bus_number!=equiv_bus_number) + { + map >::iterator iter = bus_pairs.begin(); + iter = bus_pairs.find(equiv_bus_number); + if(iter!=bus_pairs.end()) + { + (iter->second).push_back(bus_number); + } + else + { + vector new_pair; + new_pair.push_back(bus_number); + bus_pairs.insert(pair >(equiv_bus_number, new_pair)); + } + } + } + for(map >::const_iterator iter = bus_pairs.begin(); iter!=bus_pairs.end(); ++iter) + { + size_t equiv_bus_number = iter->first; + vector bus_pair = iter->second; + size_t n = bus_pair.size(); + if(n==0) + continue; + ostringstream oss; + oss<get_bus_number(); + for(size_t j=0; j!=n; ++j) + { + BUS* tbus = buses[j]; + if(tbus->get_equivalent_bus_number()==bus_number) + { + BUS_TYPE btype = tbus->get_bus_type(); + if(btype == SLACK_TYPE) + { + type = 3; + break; + } + else + { + if((btype == PV_TYPE or + btype == PV_TO_PQ_TYPE_1 or btype == PV_TO_PQ_TYPE_2 or + btype == PV_TO_PQ_TYPE_3 or btype == PV_TO_PQ_TYPE_4) and type==1) + type = 2; + } + } + } + } snprintf(buffer, 1000, "%8lu, \"%-16s\", %8.2f, %2d, %4lu, %4lu, %4lu, %10.6f, %10.6f, %6.4f, %6.4f, %6.4f, %6.4f, %4.1f", bus->get_bus_number(), (bus->get_bus_name()).c_str(), bus->get_base_voltage_in_kV(), type, diff --git a/code/source/model/wtg_models/wt_electrical_model/wt3e0.cpp b/code/source/model/wtg_models/wt_electrical_model/wt3e0.cpp index 71fe538c..9e6edd61 100644 --- a/code/source/model/wtg_models/wt_electrical_model/wt3e0.cpp +++ b/code/source/model/wtg_models/wt_electrical_model/wt3e0.cpp @@ -1380,7 +1380,10 @@ void WT3E0::prepare_model_internal_variable_table() add_model_inernal_variable_name_and_index_pair("STATE@TORQUE REGULATOR", i); i++; add_model_inernal_variable_name_and_index_pair("STATE@VIRTUAL INERTIA CONTROL", i); i++; add_model_inernal_variable_name_and_index_pair("STATE@PRIMARY FREQUENCY CONTROL", i); i++; - add_model_inernal_variable_name_and_index_pair("STATE@SECONDARY FREQUENCY CONTROL", i); i++; + add_model_inernal_variable_name_and_index_pair("STATE@SECONDARY FREQUENCY CONTROL", i); i++; + add_model_inernal_variable_name_and_index_pair("VIRTUAL INERTIA CONTROL COMMAND", i); i++; + add_model_inernal_variable_name_and_index_pair("PRIMARY FREQUENCY CONTROL COMMAND", i); i++; + add_model_inernal_variable_name_and_index_pair("SECONDARY FREQUENCY CONTROL COMMAND", i); i++; } double WT3E0::get_model_internal_variable_with_name(string var_name) @@ -1392,6 +1395,9 @@ double WT3E0::get_model_internal_variable_with_name(string var_name) if(var_name == "STATE@VIRTUAL INERTIA CONTROL") return virtual_inertia_emulator.get_state(); if(var_name == "STATE@PRIMARY FREQUENCY CONTROL") return frequency_droop_controller.get_state(); if(var_name == "STATE@SECONDARY FREQUENCY CONTROL") return frequency_integral_controller.get_state(); + if(var_name == "VIRTUAL INERTIA CONTROL COMMAND") return virtual_inertia_emulator.get_output(); + if(var_name == "PRIMARY FREQUENCY CONTROL COMMAND") return frequency_droop_controller.get_output(); + if(var_name == "SECONDARY FREQUENCY CONTROL COMMAND") return frequency_integral_controller.get_output(); return 0.0; } diff --git a/python/pysteps0.5/ReadMe.txt b/python/pysteps0.5/ReadMe.txt new file mode 100644 index 00000000..313a9e52 --- /dev/null +++ b/python/pysteps0.5/ReadMe.txt @@ -0,0 +1,8 @@ +1, Copy folder pysteps/ to PYTHONPATH/Lib/site-packages/ +2, If you are using 32 bit Python, rename file pysteps/libsteps/libSTEPS32.dll to libSTEPS.dll +3, If you are using 64 bit Python, rename file pysteps/libsteps/libSTEPS64.dll to libSTEPS.dll +4, If the VC runtime is missing, download and install Microsoft Visual C++ 2017 Redistributable of 32 or 64 bit version. +5, To import the pysteps, use + import pysteps + or + from pysteps import STEPS \ No newline at end of file diff --git a/python/pysteps0.5/__init__.py b/python/pysteps0.5/__init__.py new file mode 100644 index 00000000..9da1c917 --- /dev/null +++ b/python/pysteps0.5/__init__.py @@ -0,0 +1,2 @@ +from .pysteps import STEPS +__all__ = ['STEPS'] diff --git a/python/pysteps0.5/demo_pysteps2_powerflow.py b/python/pysteps0.5/demo_pysteps2_powerflow.py new file mode 100644 index 00000000..af190851 --- /dev/null +++ b/python/pysteps0.5/demo_pysteps2_powerflow.py @@ -0,0 +1,188 @@ +#coding = utf-8 +''' +Here is a demo of showing how to slove powerflow with pysteps2. + +Changgang Li, 2018/09/07 +''' + +from pysteps2 import STEPS # import the class 'STEPS' + +simulator = STEPS() # create a STEPS simulator instance + + +powerflow_data_file = 'IEEE9.raw' # file name of powerflow data. Use absolute path if necessary +powerflow_data_type = 'PSS/E' # powerflow data type. Currently, use 'PSS/E' only + +simulator.load_powerflow_data(powerflow_data_file, powerflow_data_type) # load powerflow data into the simulator + +data_type = 'D' # if you want to set or get doubule data, set data_type as 'F' or 'D'. +data_name = 'MAX ACTIVE POWER IMBALANCE IN MW' # the data name in the powerflow solver of the simulator +# the data_type and data_name should be consistent. make sure the data_type is correct. +# If the data is double, use 'F' or 'D'. If the data is integer, use 'I'. If the data is boolean, use 'B'. If the data is string, use 'S' +''' +(1) when data_type is 'D' or 'F' you can set/get the following data + 'MAX ACTIVE POWER IMBALANCE IN MW': maximum allowed active power mismatch at each bus, in MW. This is the powerflow convergence threshold of P equations. + 'MAX REACTIVE POWER IMBALANCE IN MVAR': maximum allowed reactive power mismatch at each bus, in MVar. This is the powerflow convergence threshold of Q equations. + 'ITERATION ACCELERATOR': acceleration factor for iteration. by default it is 1.0. if >1.0, then the powerflow solver is accelerated. if <1.0, the powerflow solver is decellerated. + + (2) when data_type is 'I', you can set/get the following data + 'MAX ITERATION': maximum iteration count allowed for solving powerflow. If set as 1, you can get the solution step by step. + + (3)when data_type is 'B', you can set/get the following data + 'FLAT START LOGIC': if true, powerflow will be solved with unity voltage profile (1.0pu, 0.0deg), if false, poewrflow will be solved from the current voltage profile. +''' + +# here goes get and set maximum active power imbalance in MW +data_type = 'D' +data_name = 'MAX ACTIVE POWER IMBALANCE IN MW' +P_error_MW = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 0.001 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set maximum reactive power imbalance in MVAR +data_type = 'D' +data_name = 'MAX REACTIVE POWER IMBALANCE IN MVAR' +Q_error_MVar = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 0.001 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set maximum iteration +data_type = 'I' +data_name = 'MAX ITERATION' +Iter_max = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 50 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set flat start logic +data_type = 'B' +data_name = 'FLAT START LOGIC' +flat_flag = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# now assuming that maximum active and reactive power imbalance are already set. +# show how to solve powerflow + +# solve powerflow with flat start logic disabled +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') # use 'NR' for Newton-Raphson solution, use 'PQ' for PQ decoupled solution + +# solve powerflow with flat start logic enabled +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('PQ') + +# if you want to solve powerflow step by step to get the solution process, +# you can set MAX ITERATION as 1, and Flat start logic as false +data_type = 'I' +data_name = 'MAX ITERATION' +value = 1 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') # first slove it with flat start enable + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) # from now on, disable flat start + +while not simulator.is_powerflow_converged(): # use is_powerflow_converged() to check if powerflow is converged + simulator.solve_powerflow('NR') + simulator.save_jacobian_matrix('jacobian.txt') # if you are solving with NR method, you can get jacobian matrix of each iteration in the file + +# once powerflow is converged, you can export powerflow result to file +powerflow_result_file = 'pf_result.txt' +simulator.save_powerflow_result(powerflow_result_file) # you can check the file's contents + +# you can get power loss of a solved powerflow case +ploss_MW = simulator.get_powerflow_loss() # in MW +print('Loss is:', ploss_MW) + +# if you want to get the voltage of each bus, you can try the following codes +buses = simulator.get_all_buses() +for bus in buses: + bus_name = simulator.get_bus_data(bus, 'S', 'Name') + voltage = simulator.get_bus_data(bus, 'D', 'Voltage in PU') + angle = simulator.get_bus_data(bus, 'D', 'Angle in deg') + print(bus, bus_name, voltage, angle) + +# if you want to get the generation of each generator, you can try the following codes +generators = simulator.get_generators_at_bus(0) # 0 indicate all generators will be returned +for generator in generators: + P = simulator.get_generator_data(generator, 'D', 'PGEN_MW') + Q = simulator.get_generator_data(generator, 'D', 'QGEN_MVAR') + print(generator, P, Q) + +# if you want to get the load of each load, you can try the following codes +loads = simulator.get_loads_at_bus(0) # 0 indicate all loads will be returned +for load in loads: + P = simulator.get_load_data(load, 'D', 'P_MW') + Q = simulator.get_load_data(load, 'D', 'Q_MVAR') + print(load, P, Q) + +# if you want to get the power of each line, you can try the following codes +lines = simulator.get_lines_at_bus(0) # 0 indicate all lines will be returned +for line in lines: + bus_send = simulator.get_line_data(line, 'I', 'BUS_SEND') # get the bus number of sending side + bus_recv = simulator.get_line_data(line, 'I', 'BUS_RECV') # get the bus number of receiving side + Psend = simulator.get_line_data(line, 'D', 'PSEND_MW') # active power at sending side + Qsend = simulator.get_line_data(line, 'D', 'QSEND_MVAR') # reactive power at sending side + Precv = simulator.get_line_data(line, 'D', 'PRECV_MW') # active power at receiving side + Qrecv = simulator.get_line_data(line, 'D', 'QRECV_MVAR') # reactive power at receiving side + print(line, bus_send, (Psend, Qsend), bus_recv, (Precv, Qrecv)) + +# if you want to get the power of each transformer, you can try the following codes +transformers = simulator.get_transformers_at_bus(0) # 0 indicate all transformers will be returned +for transformer in transformers: + bus_pri = simulator.get_transformer_data(transformer, 'I', 'Primary', 'BUS') # get the bus number of primary side + bus_sec = simulator.get_transformer_data(transformer, 'I', 'Secondary', 'BUS') # get the bus number of secondary side + + P_pri = simulator.get_transformer_data(transformer, 'D', 'Primary', 'P_MW') # active power at primary side + Q_pri = simulator.get_transformer_data(transformer, 'D', 'Primary', 'Q_MVAR') # reactive power at primary side + P_sec = simulator.get_transformer_data(transformer, 'D', 'Secondary', 'P_MW') # active power at secondary side + Q_sec = simulator.get_transformer_data(transformer, 'D', 'Secondary', 'Q_MVAR') # reactive power at secondary side + print(transformer, bus_pri, (P_pri, Q_pri), bus_sec, (P_sec, Q_sec)) + + + +# if you want to change generation of each generaor, trye the following codes +generator = (2,'1') # generator bus, and generator ID, check generator line of raw file +simulator.set_generator_data(generator, 'D', 'PGEN_MW', 50.0) # remember, only P of generator at bus of type 2 can be changed + +data_type = 'I' +data_name = 'MAX ITERATION' +value = 10 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') + + + + + + + + + + diff --git a/python/pysteps0.5/libsteps/__init__.py b/python/pysteps0.5/libsteps/__init__.py new file mode 100644 index 00000000..574b1589 --- /dev/null +++ b/python/pysteps0.5/libsteps/__init__.py @@ -0,0 +1 @@ +__all__ = ['pylibsteps'] diff --git a/python/pysteps0.5/libsteps/dll_or_so_file_should_be_put_here b/python/pysteps0.5/libsteps/dll_or_so_file_should_be_put_here new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/python/pysteps0.5/libsteps/dll_or_so_file_should_be_put_here @@ -0,0 +1 @@ + diff --git a/python/pysteps0.5/libsteps/pylibsteps.py b/python/pysteps0.5/libsteps/pylibsteps.py new file mode 100644 index 00000000..d463c095 --- /dev/null +++ b/python/pysteps0.5/libsteps/pylibsteps.py @@ -0,0 +1,654 @@ +from ctypes import * +import platform +import os + +libsteps_version = "0.5.0" +libsteps_date = "2019/05/15" + +def get_base_library(): + dirname, filename = os.path.split(os.path.abspath(__file__)) + dirname = dirname.replace('\\','/') + if not dirname.endswith('/'): + dirname = dirname + '/' + + libsteps_name = 'libSTEPS' + libsteps_extension = '.so' + if platform.system()=="Linux" or platform.system()=="Unix": + libsteps_extension = '.so' + elif platform.system()=="Windows": + libsteps_extension = '.dll' + + library = dirname+libsteps_name+libsteps_extension + if not os.path.exists(library): + library = dirname+libsteps_name+libsteps_extension + if not os.path.exists(library): + library = None + + return library + +def load_library(): + library = get_base_library() + if library is not None: + libsteps = cdll.LoadLibrary(library) + else: + return None + + libsteps.api_set_default_toolkit_log_file.restype = None + libsteps.api_set_default_toolkit_log_file.argtype = (c_char_p, ) + + libsteps.api_generate_new_toolkit.restype = c_uint + libsteps.api_generate_new_toolkit.argtypes = None + + libsteps.api_delete_toolkit.restype = None + libsteps.api_delete_toolkit.argtypes = (c_uint, ) + + libsteps.api_initialize_toolkit.restype = None + libsteps.api_initialize_toolkit.argtypes = (c_uint, ) + + libsteps.api_clear_toolkit.restype = None + libsteps.api_clear_toolkit.argtypes = (c_uint, ) + + libsteps.api_get_toolkit_float_data.restype = c_double + libsteps.api_get_toolkit_float_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_float_data.restype = None + libsteps.api_set_toolkit_float_data.argtypes = (c_char_p, c_double, c_uint) + + libsteps.api_get_toolkit_string_data.restype = c_char_p + libsteps.api_get_toolkit_string_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_string_data.restype = None + libsteps.api_set_toolkit_string_data.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_toolkit_bool_data.restype = c_bool + libsteps.api_get_toolkit_bool_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_bool_data.restype = None + libsteps.api_set_toolkit_bool_data.argtypes = (c_char_p, c_bool, c_uint) + + libsteps.api_load_powerflow_data_from_file.restype = None + libsteps.api_load_powerflow_data_from_file.argtypes = (c_char_p, c_char_p, c_uint) + libsteps.api_load_dynamic_data_from_file.restype = None + libsteps.api_load_dynamic_data_from_file.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_save_powerflow_data_to_file.restype = None + libsteps.api_save_powerflow_data_to_file.argtypes = (c_char_p, c_char_p, c_bool, c_bool, c_uint) + libsteps.api_save_dynamic_data_to_file.restype = None + libsteps.api_save_dynamic_data_to_file.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_check_database.restype = None + libsteps.api_check_database.argtypes = (c_uint, ) + + libsteps.api_check_dynamic_data.restype = None + libsteps.api_check_dynamic_data.argtypes = (c_uint, ) + + libsteps.api_check_network_connectivity.restype = None + libsteps.api_check_network_connectivity.argtypes = (c_bool, c_uint) + + libsteps.api_get_allowed_maximum_bus_number.restype = c_uint + libsteps.api_get_allowed_maximum_bus_number.argtypes = (c_uint, ) + + libsteps.api_set_allowed_maximum_bus_number.restype = None + libsteps.api_set_allowed_maximum_bus_number.argtypes = (c_uint, c_uint) + + libsteps.api_get_device_capacity.restype = c_uint + libsteps.api_get_device_capacity.argtypes = (c_char_p, c_uint) + libsteps.api_get_area_capacity.restype = c_uint + libsteps.api_get_area_capacity.argtypes = (c_uint, ) + libsteps.api_get_zone_capacity.restype = c_uint + libsteps.api_get_zone_capacity.argtypes = (c_uint, ) + libsteps.api_get_owner_capacity.restype = c_uint + libsteps.api_get_owner_capacity.argtypes = (c_uint, ) + + libsteps.api_set_device_capacity.restype = None + libsteps.api_set_device_capacity.argtypes = (c_char_p, c_uint, c_uint) + libsteps.api_set_area_capacity.restype = None + libsteps.api_set_area_capacity.argtypes = (c_uint, c_uint) + libsteps.api_set_zone_capacity.restype = None + libsteps.api_set_zone_capacity.argtypes = (c_uint, c_uint) + libsteps.api_set_owner_capacity.restype = None + libsteps.api_set_owner_capacity.argtypes = (c_uint, c_uint) + + libsteps.api_get_device_count.restype = c_uint + libsteps.api_get_device_count.argtypes = (c_char_p, c_uint) + libsteps.api_get_area_count.restype = c_uint + libsteps.api_get_area_count.argtypes = (c_uint, ) + libsteps.api_get_zone_count.restype = c_uint + libsteps.api_get_zone_count.argtypes = (c_uint, ) + libsteps.api_get_owner_count.restype = c_uint + libsteps.api_get_owner_count.argtypes = (c_uint, ) + libsteps.api_get_in_service_bus_count.restype = c_uint + libsteps.api_get_in_service_bus_count.argtypes = (c_uint, ) + libsteps.api_update_overshadowed_buses.restype = None + libsteps.api_update_overshadowed_buses.argtypes = (c_uint, ) + libsteps.api_set_all_buses_un_overshadowed.restype = None + libsteps.api_set_all_buses_un_overshadowed.argtypes = (c_uint, ) + libsteps.api_get_overshadowed_bus_count.restype = c_uint + libsteps.api_get_overshadowed_bus_count.argtypes = (c_uint, ) + + libsteps.api_is_bus_exist.restype = c_bool + libsteps.api_is_bus_exist.argtypes = (c_uint, c_uint) + libsteps.api_is_generator_exist.restype = c_bool + libsteps.api_is_generator_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_wt_generator_exist.restype = c_bool + libsteps.api_is_wt_generator_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_pv_unit_exist.restype = c_bool + libsteps.api_is_pv_unit_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_energy_storage_exist.restype = c_bool + libsteps.api_is_energy_storage_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_load_exist.restype = c_bool + libsteps.api_is_load_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_fixed_shunt_exist.restype = c_bool + libsteps.api_is_fixed_shunt_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_line_exist.restype = c_bool + libsteps.api_is_line_exist.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_transformer_exist.restype = c_bool + libsteps.api_is_transformer_exist.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_hvdc_exist.restype = c_bool + libsteps.api_is_hvdc_exist.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_equivalent_device_exist.restype = c_bool + libsteps.api_is_equivalent_device_exist.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_show_device_data.restype = None + libsteps.api_show_device_data.argtypes = (c_char_p, c_uint) + + libsteps.api_bus_number2bus_name.restype = c_char_p + libsteps.api_bus_number2bus_name.argtypes = (c_uint, c_uint) + libsteps.api_bus_name2bus_number.restype = c_uint + libsteps.api_bus_name2bus_number.argtypes = (c_char_p, c_uint) + + libsteps.api_initialize_bus_search.restype = None + libsteps.api_initialize_bus_search.argtypes = (c_double, c_double, c_double, c_double, c_uint, c_uint, c_uint, c_uint) + libsteps.api_initialize_all_bus_search.restype = None + libsteps.api_initialize_all_bus_search.argtypes = (c_uint, ) + + libsteps.api_get_current_bus_number.restype = c_uint + libsteps.api_get_current_bus_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_bus.restype = None + libsteps.api_goto_next_bus.argtypes = (c_uint, ) + + libsteps.api_initialize_device_search.restype = None + libsteps.api_initialize_device_search.argtypes = (c_char_p, c_uint, c_uint) + + libsteps.api_get_current_device_bus_number.restype = c_uint + libsteps.api_get_current_device_bus_number.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_current_device_identifier.restype = c_char_p + libsteps.api_get_current_device_identifier.argtypes = (c_char_p, c_uint) + + libsteps.api_goto_next_device.restype = None + libsteps.api_goto_next_device.argtypes = (c_char_p, c_uint) + + libsteps.api_initialize_area_search.restype = None + libsteps.api_initialize_area_search.argtypes = (c_uint, ) + + libsteps.api_get_current_area_number.restype = c_uint + libsteps.api_get_current_area_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_area.restype = None + libsteps.api_goto_next_area.argtypes = (c_uint, ) + + libsteps.api_initialize_zone_search.restype = None + libsteps.api_initialize_zone_search.argtypes = (c_uint, ) + + libsteps.api_get_current_zone_number.restype = c_uint + libsteps.api_get_current_zone_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_zone.restype = None + libsteps.api_goto_next_zone.argtypes = (c_uint, ) + + libsteps.api_initialize_owner_search.restype = None + libsteps.api_initialize_owner_search.argtypes = (c_uint, ) + + libsteps.api_get_current_owner_number.restype = c_uint + libsteps.api_get_current_owner_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_owner.restype = None + libsteps.api_goto_next_owner.argtypes = (c_uint, ) + + libsteps.api_add_bus.restype = None + libsteps.api_add_bus.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_add_generator.restype = None + libsteps.api_add_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_wt_generator.restype = None + libsteps.api_add_wt_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_pv_unit.restype = None + libsteps.api_add_pv_unit.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_energy_storage.restype = None + libsteps.api_add_energy_storage.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_load.restype = None + libsteps.api_add_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_fixed_shunt.restype = None + libsteps.api_add_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_line.restype = None + libsteps.api_add_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_hvdc.restype = None + libsteps.api_add_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_transformer.restype = None + libsteps.api_add_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_equivalent_device.restype = None + libsteps.api_add_equivalent_device.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_area.restype = None + libsteps.api_add_area.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_zone.restype = None + libsteps.api_add_zone.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_owner.restype = None + libsteps.api_add_owner.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_remove_bus.restype = None + libsteps.api_remove_bus.argtypes = (c_uint, c_uint) + libsteps.api_remove_generator.restype = None + libsteps.api_remove_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_wt_generator.restype = None + libsteps.api_remove_wt_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_pv_unit.restype = None + libsteps.api_remove_pv_unit.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_energy_storage.restype = None + libsteps.api_remove_energy_storage.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_load.restype = None + libsteps.api_remove_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_fixed_shunt.restype = None + libsteps.api_remove_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_line.restype = None + libsteps.api_remove_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_hvdc.restype = None + libsteps.api_remove_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_transformer.restype = None + libsteps.api_remove_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_equivalent_device.restype = None + libsteps.api_remove_equivalent_device.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_area.restype = None + libsteps.api_remove_area.argtypes = (c_uint, c_uint) + libsteps.api_remove_zone.restype = None + libsteps.api_remove_zone.argtypes = (c_uint, c_uint) + libsteps.api_remove_owner.restype = None + libsteps.api_remove_owner.argtypes = (c_uint, c_uint) + + + + + libsteps.api_get_bus_integer_data.restype = (c_int) + libsteps.api_get_bus_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_bus_float_data.restype = (c_double) + libsteps.api_get_bus_float_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_bus_string_data.restype = (c_char_p) + libsteps.api_get_bus_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_bus_integer_data.restype = None + libsteps.api_set_bus_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_bus_float_data.restype = None + libsteps.api_set_bus_float_data.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_set_bus_string_data.restype = None + libsteps.api_set_bus_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_load_integer_data.restype = (c_int) + libsteps.api_get_load_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_float_data.restype = (c_double) + libsteps.api_get_load_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_string_data.restype = (c_char_p) + libsteps.api_get_load_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_boolean_data.restype = (c_bool) + libsteps.api_get_load_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_integer_data.restype = None + libsteps.api_set_load_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_load_float_data.restype = None + libsteps.api_set_load_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_load_string_data.restype = None + libsteps.api_set_load_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_boolean_data.restype = None + libsteps.api_set_load_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_source_integer_data.restype = (c_int) + libsteps.api_get_source_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_float_data.restype = (c_double) + libsteps.api_get_source_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_string_data.restype = (c_char_p) + libsteps.api_get_source_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_boolean_data.restype = (c_bool) + libsteps.api_get_source_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_source_integer_data.restype = None + libsteps.api_set_source_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_source_float_data.restype = None + libsteps.api_set_source_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_source_string_data.restype = None + libsteps.api_set_source_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_source_boolean_data.restype = None + libsteps.api_set_source_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_fixed_shunt_integer_data.restype = (c_int) + libsteps.api_get_fixed_shunt_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_float_data.restype = (c_double) + libsteps.api_get_fixed_shunt_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_string_data.restype = (c_char_p) + libsteps.api_get_fixed_shunt_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_boolean_data.restype = (c_bool) + libsteps.api_get_fixed_shunt_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_fixed_shunt_integer_data.restype = None + libsteps.api_set_fixed_shunt_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_fixed_shunt_float_data.restype = None + libsteps.api_set_fixed_shunt_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_fixed_shunt_string_data.restype = None + libsteps.api_set_fixed_shunt_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_fixed_shunt_boolean_data.restype = None + libsteps.api_set_fixed_shunt_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_line_integer_data.restype = (c_int) + libsteps.api_get_line_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_float_data.restype = (c_double) + libsteps.api_get_line_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_string_data.restype = (c_char_p) + libsteps.api_get_line_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_boolean_data.restype = (c_bool) + libsteps.api_get_line_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_integer_data.restype = None + libsteps.api_set_line_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_line_float_data.restype = None + libsteps.api_set_line_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_line_string_data.restype = None + libsteps.api_set_line_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_boolean_data.restype = None + libsteps.api_set_line_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_transformer_integer_data.restype = (c_int) + libsteps.api_get_transformer_integer_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_float_data.restype = (c_double) + libsteps.api_get_transformer_float_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_string_data.restype = (c_char_p) + libsteps.api_get_transformer_string_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_boolean_data.restype = (c_bool) + libsteps.api_get_transformer_boolean_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_transformer_integer_data.restype = None + libsteps.api_set_transformer_integer_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_transformer_float_data.restype = None + libsteps.api_set_transformer_float_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_transformer_string_data.restype = None + libsteps.api_set_transformer_string_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_transformer_boolean_data.restype = None + libsteps.api_set_transformer_boolean_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_hvdc_integer_data.restype = (c_int) + libsteps.api_get_hvdc_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_float_data.restype = (c_double) + libsteps.api_get_hvdc_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_string_data.restype = (c_char_p) + libsteps.api_get_hvdc_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_boolean_data.restype = (c_bool) + libsteps.api_get_hvdc_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_integer_data.restype = None + libsteps.api_set_hvdc_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_hvdc_float_data.restype = None + libsteps.api_set_hvdc_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_hvdc_string_data.restype = None + libsteps.api_set_hvdc_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_boolean_data.restype = None + libsteps.api_set_hvdc_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_area_integer_data.restype = (c_int) + libsteps.api_get_area_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_area_float_data.restype = (c_double) + libsteps.api_get_area_float_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_area_string_data.restype = (c_char_p) + libsteps.api_get_area_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_area_integer_data.restype = None + libsteps.api_set_area_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_area_float_data.restype = None + libsteps.api_set_area_float_data.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_set_area_string_data.restype = None + libsteps.api_set_area_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_zone_integer_data.restype = (c_int) + libsteps.api_get_zone_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_zone_string_data.restype = (c_char_p) + libsteps.api_get_zone_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_zone_integer_data.restype = None + libsteps.api_set_zone_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_zone_string_data.restype = None + libsteps.api_set_zone_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_owner_integer_data.restype = (c_int) + libsteps.api_get_owner_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_owner_string_data.restype = (c_char_p) + libsteps.api_get_owner_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_owner_integer_data.restype = None + libsteps.api_set_owner_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_owner_string_data.restype = None + libsteps.api_set_owner_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_set_dynamic_model.restype = None + libsteps.api_set_dynamic_model.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_generator_related_model_name.restype = c_char_p + libsteps.api_get_generator_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_generator_related_model_float_parameter.restype = c_double + libsteps.api_get_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_generator_related_model_float_parameter.restype = None + libsteps.api_set_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_wt_generator_related_model_name.restype = c_char_p + libsteps.api_get_wt_generator_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_wt_generator_related_model_float_parameter.restype = c_double + libsteps.api_get_wt_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_wt_generator_related_model_float_parameter.restype = None + libsteps.api_set_wt_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_pv_unit_related_model_name.restype = c_char_p + libsteps.api_get_pv_unit_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_pv_unit_related_model_float_parameter.restype = c_double + libsteps.api_get_pv_unit_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_pv_unit_related_model_float_parameter.restype = None + libsteps.api_set_pv_unit_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_load_related_model_name.restype = c_char_p + libsteps.api_get_load_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_related_model_float_parameter.restype = c_double + libsteps.api_get_load_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_related_model_float_parameter.restype = None + libsteps.api_set_load_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_line_related_model_name.restype = c_char_p + libsteps.api_get_line_related_model_name.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_related_model_float_parameter.restype = c_double + libsteps.api_get_line_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_related_model_float_parameter.restype = None + libsteps.api_set_line_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_hvdc_related_model_name.restype = c_char_p + libsteps.api_get_hvdc_related_model_name.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_related_model_float_parameter.restype = c_double + libsteps.api_get_hvdc_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_related_model_float_parameter.restype = None + libsteps.api_set_hvdc_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + + libsteps.api_get_powerflow_solver_integer_parameter.restype = (c_uint) + libsteps.api_get_powerflow_solver_integer_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_powerflow_solver_float_parameter.restype = (c_double) + libsteps.api_get_powerflow_solver_float_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_powerflow_solver_boolean_parameter.restype = (c_bool) + libsteps.api_get_powerflow_solver_boolean_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_set_powerflow_solver_integer_parameter.restype = None + libsteps.api_set_powerflow_solver_integer_parameter.argtypes = (c_char_p, c_int, c_uint) + libsteps.api_set_powerflow_solver_float_parameter.restype = None + libsteps.api_set_powerflow_solver_float_parameter.argtypes = (c_char_p, c_double, c_uint) + libsteps.api_set_powerflow_solver_boolean_parameter.restype = None + libsteps.api_set_powerflow_solver_boolean_parameter.argtypes = (c_char_p, c_bool, c_uint) + + libsteps.api_solve_powerflow.restype = None + libsteps.api_solve_powerflow.argtypes = (c_char_p, c_uint) + libsteps.api_is_powerflow_converged.restype = (c_bool) + libsteps.api_is_powerflow_converged.argtypes = (c_uint, ) + libsteps.api_show_powerflow_result.restype = None + libsteps.api_show_powerflow_result.argtypes = (c_uint, ) + libsteps.api_save_powerflow_result.restype = None + libsteps.api_save_powerflow_result.argtypes = (c_char_p, c_uint) + libsteps.api_save_extended_powerflow_result.restype = None + libsteps.api_save_extended_powerflow_result.argtypes = (c_char_p, c_uint) + libsteps.api_save_jacobian_matrix.restype = None + libsteps.api_save_jacobian_matrix.argtypes = (c_char_p, c_uint) + + libsteps.api_build_network_matrix.restype = None + libsteps.api_build_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_decoupled_network_matrix.restype = None + libsteps.api_build_decoupled_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_dc_network_matrix.restype = None + libsteps.api_build_dc_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_dynamic_network_matrix.restype = None + libsteps.api_build_dynamic_network_matrix.argtypes = (c_uint, ) + libsteps.api_save_network_matrix.restype = None + libsteps.api_save_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_decoupled_network_matrix.restype = None + libsteps.api_save_decoupled_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_dc_network_matrix.restype = None + libsteps.api_save_dc_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_dynamic_network_matrix.restype = None + libsteps.api_save_dynamic_network_matrix.argtypes = (c_char_p, c_uint) + + libsteps.api_get_dynamic_simulator_integer_parameter.restype = (c_uint) + libsteps.api_get_dynamic_simulator_integer_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_float_parameter.restype = (c_double) + libsteps.api_get_dynamic_simulator_float_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_string_parameter.restype = (c_char_p) + libsteps.api_get_dynamic_simulator_string_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_boolean_parameter.restype = (c_bool) + libsteps.api_get_dynamic_simulator_boolean_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_set_dynamic_simulator_integer_parameter.restype = None + libsteps.api_set_dynamic_simulator_integer_parameter.argtypes = (c_char_p, c_int, c_uint) + libsteps.api_set_dynamic_simulator_float_parameter.restype = None + libsteps.api_set_dynamic_simulator_float_parameter.argtypes = (c_char_p, c_double, c_uint) + libsteps.api_set_dynamic_simulator_string_parameter.restype = None + libsteps.api_set_dynamic_simulator_string_parameter.argtypes = (c_char_p, c_char_p, c_uint) + libsteps.api_set_dynamic_simulator_boolean_parameter.restype = None + libsteps.api_set_dynamic_simulator_boolean_parameter.argtypes = (c_char_p, c_bool, c_uint) + libsteps.api_get_dynamic_simulator_output_file.restype = (c_char_p) + libsteps.api_get_dynamic_simulator_output_file.argtypes = (c_uint, ) + libsteps.api_set_dynamic_simulator_output_file.restype = None + libsteps.api_set_dynamic_simulator_output_file.argtypes = (c_char_p, c_uint) + + libsteps.api_get_dynamic_simulation_time_step.restype = (c_double) + libsteps.api_get_dynamic_simulation_time_step.argtypes = (c_uint, ) + libsteps.api_set_dynamic_simulation_time_step.restype = None + libsteps.api_set_dynamic_simulation_time_step.argtypes = (c_double, c_uint) + libsteps.api_get_dynamic_simulation_time.restype = (c_double) + libsteps.api_get_dynamic_simulation_time.argtypes = (c_uint, ) + + libsteps.api_prepare_meters.restype = None + libsteps.api_prepare_meters.argtypes = (c_uint, ) + libsteps.api_prepare_bus_related_meters.restype = None + libsteps.api_prepare_bus_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_generator_related_meters.restype = None + libsteps.api_prepare_generator_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_wt_generator_related_meters.restype = None + libsteps.api_prepare_wt_generator_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_pv_unit_related_meters.restype = None + libsteps.api_prepare_pv_unit_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_energy_storage_related_meters.restype = None + libsteps.api_prepare_energy_storage_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_load_related_meters.restype = None + libsteps.api_prepare_load_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_line_related_meters.restype = None + libsteps.api_prepare_line_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_hvdc_related_meters.restype = None + libsteps.api_prepare_hvdc_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_equivalent_device_related_meters.restype = None + libsteps.api_prepare_equivalent_device_related_meters.argtypes = (c_uint, ) + + + libsteps.api_prepare_bus_related_meter.restype = None + libsteps.api_prepare_bus_related_meter.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_prepare_generator_related_meter.restype = None + libsteps.api_prepare_generator_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_wt_generator_related_meter.restype = None + libsteps.api_prepare_wt_generator_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_pv_unit_related_meter.restype = None + libsteps.api_prepare_pv_unit_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_energy_storage_related_meter.restype = None + libsteps.api_prepare_energy_storage_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_load_related_meter.restype = None + libsteps.api_prepare_load_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_line_related_meter.restype = None + libsteps.api_prepare_line_related_meter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_hvdc_related_meter.restype = None + libsteps.api_prepare_hvdc_related_meter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_equivalent_device_related_meter.restype = None + libsteps.api_prepare_equivalent_device_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + + libsteps.api_start_dynamic_simulation.restype = None + libsteps.api_start_dynamic_simulation.argtypes = (c_uint, ) + libsteps.api_stop_dynamic_simulation.restype = None + libsteps.api_stop_dynamic_simulation.argtypes = (c_uint, ) + libsteps.api_run_simulation_to_time.restype = None + libsteps.api_run_simulation_to_time.argtypes = (c_double, c_uint) + libsteps.api_run_a_step.restype = None + libsteps.api_run_a_step.argtypes = (c_uint, ) + + libsteps.api_set_bus_fault.restype = None + libsteps.api_set_bus_fault.argtypes = (c_uint, c_char_p, c_double, c_double, c_uint) + libsteps.api_clear_bus_fault.restype = None + libsteps.api_clear_bus_fault.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_trip_bus.restype = None + libsteps.api_trip_bus.argtypes = (c_uint, c_uint) + + libsteps.api_set_line_fault.restype = None + libsteps.api_set_line_fault.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_double, c_double, c_uint) + libsteps.api_clear_line_fault.restype = None + libsteps.api_clear_line_fault.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_trip_line.restype = None + libsteps.api_trip_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_trip_line_breaker.restype = None + libsteps.api_trip_line_breaker.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_line.restype = None + libsteps.api_close_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_line_breaker.restype = None + libsteps.api_close_line_breaker.argtypes = (c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_trip_transformer.restype = None + libsteps.api_trip_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_trip_transformer_breaker.restype = None + libsteps.api_trip_transformer_breaker.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_transformer.restype = None + libsteps.api_close_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_transformer_breaker.restype = None + libsteps.api_close_transformer_breaker.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_trip_generator.restype = None + libsteps.api_trip_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_shed_generator.restype = None + libsteps.api_shed_generator.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_trip_load.restype = None + libsteps.api_trip_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_close_load.restype = None + libsteps.api_close_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_scale_load.restype = None + libsteps.api_scale_load.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_scale_all_loads.restype = None + libsteps.api_scale_all_loads.argtypes = (c_double, c_uint) + + libsteps.api_trip_fixed_shunt.restype = None + libsteps.api_trip_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_close_fixed_shunt.restype = None + libsteps.api_close_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_manually_bypass_hvdc.restype = None + libsteps.api_manually_bypass_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_unbypass_hvdc.restype = None + libsteps.api_manually_unbypass_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_block_hvdc.restype = None + libsteps.api_manually_block_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_unblock_hvdc.restype = None + libsteps.api_manually_unblock_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_get_generator_voltage_reference_in_pu.restype = (c_double) + libsteps.api_get_generator_voltage_reference_in_pu.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_generator_voltage_reference_in_pu.restype = None + libsteps.api_set_generator_voltage_reference_in_pu.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_get_generator_power_reference_in_MW.restype = (c_double) + libsteps.api_get_generator_power_reference_in_MW.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_generator_power_reference_in_MW.restype = None + libsteps.api_set_generator_power_reference_in_MW.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_search_cct.restype = (c_double) + libsteps.api_search_cct.argtypes = (c_char_p, c_char_p, c_uint, c_uint, c_char_p, c_uint, c_uint, c_uint) + + return libsteps diff --git a/python/pysteps0.5/pysteps.py b/python/pysteps0.5/pysteps.py new file mode 100644 index 00000000..495b8e21 --- /dev/null +++ b/python/pysteps0.5/pysteps.py @@ -0,0 +1,1969 @@ +pysteps_version = "0.6.0" +pysteps_date = "2019/05/15" +pysteps_author = (("Changgang Li", "lichangang@sdu.edu.cn"),("Yue Wu","sduyuewu2018@163.com")) + +from .libsteps import pylibsteps +from ctypes import c_char_p +import platform +global STEPS_LIB + +class STEPS(): + def __init__(self, is_default=False, log_file=""): + global STEPS_LIB + + if 'STEPS_LIB' not in globals(): + STEPS_LIB = pylibsteps.load_library() + + if is_default==True: + #STEPS_LIB.api_set_default_toolkit_log_file(log_file) + self.toolkit_index = 1000000000 + else: + log_file = self.__get_c_char_p_of_string(log_file) + self.toolkit_index = STEPS_LIB.api_generate_new_toolkit(log_file) + + def __del__(self): + global STEPS_LIB + if 'STEPS_LIB' in globals(): + STEPS_LIB.api_delete_toolkit(self.toolkit_index) + + def __extract_single_bus_device_id(self, did): + bus = did[0] + ickt = did[1] + return bus, ickt + + def __extract_double_bus_device_id(self, did): + ibus = did[0] + jbus = did[1] + ickt = did[2] + return ibus, jbus, ickt + + def __extract_triple_bus_device_id(self, did): + ibus = did[0] + jbus = did[1] + kbus = 0 + ickt = did[-1] + if len(did)>3: + kbus = did[2] + return ibus, jbus, kbus, ickt + + def __get_c_char_p_of_string(self, data): + python_version = platform.python_version_tuple() + python_version = python_version[0] + if python_version is '3': + return c_char_p(bytes(data, 'utf-8')) + elif python_version is '2': + return c_char_p(bytes(data)) + else: + return None + + def __get_string_from_c_char_p(self, data): + python_version = platform.python_version_tuple() + python_version = python_version[0] + if python_version is '3': + return str(data, encoding='utf-8') + elif python_version is '2': + return str(data) + else: + return None + + def clear_toolkit(self): + global STEPS_LIB + STEPS_LIB.api_clear_toolkit(self.toolkit_index) + return + + def terminate_toolkit(self): + global STEPS_LIB + STEPS_LIB = None + #STEPS_LIB.api_terminate_toolkit(self.toolkit_index) + return + + def get_toolkit_float_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_get_toolkit_float_data(dataname, self.toolkit_index) + + def set_toolkit_float_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_set_toolkit_float_data(dataname, value, self.toolkit_index) + + def get_system_base_power_in_MVA(self): + global STEPS_LIB + return self.get_toolkit_float_data("SBASE") + + def set_system_base_power_in_MVA(self, sbase): + global STEPS_LIB + return self.set_toolkit_float_data("SBASE", sbase) + + def get_toolkit_string_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return self.__get_source_data(STEPS_LIB.api_get_toolkit_string_data(dataname, self.toolkit_index)) + + def set_toolkit_string_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + value = self.__get_c_char_p_of_string(value) + return self.__get_source_data(STEPS_LIB.api_set_toolkit_string_data(dataname, value, self.toolkit_index)) + + def get_case_information(self): + global STEPS_LIB + return self.__get_source_data(self.get_toolkit_string_data("CASE INFORMATION")) + + def get_case_additional_information(self): + global STEPS_LIB + return self.__get_source_data(self.get_toolkit_string_data("CASE ADDITIONAL INFORMATION")) + + def set_case_information(self, value): + global STEPS_LIB + return self.set_toolkit_string_data("CASE INFORMATION", value) + + def set_case_additional_information(self, value): + global STEPS_LIB + return self.set_toolkit_string_data("CASE ADDITIONAL INFORMATION", value) + + def get_toolkit_bool_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_get_toolkit_bool_data(dataname, self.toolkit_index) + + def set_toolkit_bool_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_set_toolkit_bool_data(dataname, value, self.toolkit_index) + + def get_toolkit_detailed_log_logic(self): + global STEPS_LIB + return self.get_toolkit_bool_data("DETAILED LOG LOGIC") + + def set_toolkit_detailed_log_logic(self, logic): + global STEPS_LIB + return self.set_toolkit_bool_data("DETAILED LOG LOGIC", logic) + + + def get_allowed_maximum_bus_number(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_allowed_maximum_bus_number(self.toolkit_index)) + + def set_allowed_maximum_bus_number(self, max_bus_number): + global STEPS_LIB + STEPS_LIB.api_set_allowed_maximum_bus_number(max_bus_number, self.toolkit_index) + + def load_powerflow_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_load_powerflow_data_from_file(file, ftype, self.toolkit_index) + + def save_powerflow_data(self, file, ftype, export_zero_line=True, export_out_of_service_bus=True): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_save_powerflow_data_to_file(file, ftype, export_zero_line, export_out_of_service_bus, self.toolkit_index) + + def load_dynamic_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_load_dynamic_data_from_file(file, ftype, self.toolkit_index) + + def save_dynamic_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_save_dynamic_data_to_file(file, ftype, self.toolkit_index) + + def check_database(self): + global STEPS_LIB + STEPS_LIB.api_check_database(self.toolkit_index) + + def check_dynamic_data(self): + global STEPS_LIB + STEPS_LIB.api_check_dynamic_data(self.toolkit_index) + + def check_network_connectivity(self, remove_void_islands=False): + global STEPS_LIB + STEPS_LIB.api_check_network_connectivity(remove_void_islands, self.toolkit_index) + + def get_bus_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_generator_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_wt_generator_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("WT Generator") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_pv_unit_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_load_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_fixed_shunt_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_line_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_transformer_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_hvdc_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_equivalent_device_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_energy_storage_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_area_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_area_capacity(self.toolkit_index)) + def get_zone_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_zone_capacity(self.toolkit_index)) + def get_owner_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_owner_capacity(self.toolkit_index)) + + def set_bus_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return STEPS_LIB.api_set_device_capacity("BUS", capacity, self.toolkit_index) + def set_generator_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_wt_generator_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Wt Generator") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_pv_unit_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_load_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_fixed_shunt_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_line_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_transformer_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_hvdc_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_equivalent_device_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_energy_storage_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_area_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_area_capacity(capacity, self.toolkit_index) + def set_zone_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_zone_capacity(capacity, self.toolkit_index) + def set_owner_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_owner_capacity(capacity, self.toolkit_index) + + + def add_bus(self, busnumber, busname, basevoltage): + global STEPS_LIB + busname = self.__get_c_char_p_of_string(busname) + STEPS_LIB.api_add_bus(busnumber, busname, basevoltage, self.toolkit_index) + return + + def add_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_generator(bus, ickt, self.toolkit_index) + return + + def add_wt_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_wt_generator(bus, ickt, self.toolkit_index) + + def add_pv_unit(self, unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(unit) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_pv_unit(bus, ickt, self.toolkit_index) + return + + def add_load(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_load(bus, ickt, self.toolkit_index) + return + + def add_fixed_shunt(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_fixed_shunt(bus, ickt, self.toolkit_index) + return + + def add_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_line(ibus, jbus, ickt, self.toolkit_index) + return + + def add_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def add_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def add_equivalent_device(self, device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(device) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_equivalent_device(bus, ickt, self.toolkit_index) + return + + def add_energy_storage(self, storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(storage) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_energy_storage(bus, ickt, self.toolkit_index) + return + + def add_area(self, areanumber, areaname): + global STEPS_LIB + areaname = self.__get_c_char_p_of_string(areaname) + STEPS_LIB.api_add_area(areanumber, areaname, self.toolkit_index) + return + + def add_zone(self, zonenumber, zonename): + global STEPS_LIB + zonename = self.__get_c_char_p_of_string(zonename) + STEPS_LIB.api_add_zone(zonenumber, zonename, self.toolkit_index) + return + + def add_owner(self, ownernumber, ownername): + global STEPS_LIB + ownername = self.__get_c_char_p_of_string(ownername) + STEPS_LIB.api_add_owner(ownernumber, ownername, self.toolkit_index) + return + + def remove_bus(self, busnumber): + global STEPS_LIB + STEPS_LIB.api_remove_bus(busnumber, self.toolkit_index) + return + + def remove_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_generator(bus, ickt, self.toolkit_index) + return + + def remove_wt_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_wt_generator(bus, ickt, self.toolkit_index) + return + + def remove_pv_unit(self, unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(unit) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_pv_unit(bus, ickt, self.toolkit_index) + return + + def remove_load(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_load(bus, ickt, self.toolkit_index) + return + + def remove_fixed_shunt(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_fixed_shunt(bus, ickt, self.toolkit_index) + return + + def remove_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_line(ibus, jbus, ickt, self.toolkit_index) + return + + def remove_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def remove_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def remove_equivalent_device(self, device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(device) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_equivalent_device(bus, ickt, self.toolkit_index) + return + + def remove_energy_storage(self, storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(storage) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_energy_storage(bus, ickt, self.toolkit_index) + return + + def remove_area(self, areanumber): + global STEPS_LIB + STEPS_LIB.api_remove_area(areanumber, self.toolkit_index) + return + + def remove_zone(self, zonenumber): + global STEPS_LIB + STEPS_LIB.api_remove_zone(zonenumber, self.toolkit_index) + return + + def remove_owner(self, ownernumber): + global STEPS_LIB + STEPS_LIB.api_remove_owner(ownernumber, self.toolkit_index) + return + + def get_bus_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_generator_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_wt_generator_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("WT Generator") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_pv_unit_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_load_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_fixed_shunt_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_line_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_transformer_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_hvdc_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_equivalent_device_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_energy_storage_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_area_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_area_count(self.toolkit_index) + def get_zone_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_zone_count(self.toolkit_index) + def get_owner_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_owner_count(self.toolkit_index) + def get_in_service_bus_count(self): + global STEPS_LIB + STEPS_LIB.api_get_in_service_bus_count(self.toolkit_index) + return + def update_overshadowed_buses(self): + global STEPS_LIB + return STEPS_LIB.api_update_overshadowed_buses(self.toolkit_index) + def set_all_buses_un_overshadowed(self): + global STEPS_LIB + STEPS_LIB.api_set_all_buses_un_overshadowed(self.toolkit_index) + return + def get_overshadowed_bus_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_overshadowed_bus_count(self.toolkit_index) + + def is_bus_exist(self, bus): + global STEPS_LIB + return STEPS_LIB.api_is_bus_exist(bus, self.toolkit_index) + + def is_generator_exist(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_generator_exist(bus, ickt, self.toolkit_index) + + def is_wt_generator_exist(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_wt_generator_exist(bus, ickt, self.toolkit_index) + + def is_pv_unit_exist(self, pv_unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_pv_unit_exist(bus, ickt, self.toolkit_index) + + def is_load_exist(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_load_exist(bus, ickt, self.toolkit_index) + + def is_fixed_shunt_exist(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_fixed_shunt_exist(bus, ickt, self.toolkit_index) + + def is_line_exist(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_line_exist(ibus, jbus, ickt, self.toolkit_index) + + def is_transformer_exist(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_transformer_exist(ibus, jbus, kbus, ickt, self.toolkit_index) + + def is_hvdc_exist(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_hvdc_exist(ibus, jbus, ickt, self.toolkit_index) + + def is_equivalent_device_exist(self, equivalent_device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_equivalent_device_exist(bus, ickt, self.toolkit_index) + + def is_energy_storage_exist(self, energy_storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(energy_storage) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_energy_storage_exist(bus, ickt, self.toolkit_index) + + def bus_name2number(self, name): + global STEPS_LIB + name = self.__get_c_char_p_of_string(name) + return int(STEPS_LIB.api_bus_name2bus_number(name, self.toolkit_index)) + + def bus_number2name(self, bus): + global STEPS_LIB + return self.__get_string_from_c_char_p(STEPS_LIB.api_bus_number2bus_name(bus, self.toolkit_index)) + + def get_all_buses(self): + global STEPS_LIB + STEPS_LIB.api_initialize_all_bus_search(self.toolkit_index) + buses = [] + while True: + bus = STEPS_LIB.api_get_current_bus_number(self.toolkit_index) + if bus==0: + break + buses.append(int(bus)) + STEPS_LIB.api_goto_next_bus(self.toolkit_index) + return tuple(buses) + + def get_buses_with_constraints(self, constraints): + global STEPS_LIB + buses = [] + if len(constraints)<7: + return buses + vbase_min = constraints[0] + vbase_max = constraints[1] + v_min = constraints[2] + v_max = constraints[3] + area = constraints[4] + zone = constraints[5] + owner = constraints[6] + + STEPS_LIB.api_initialize_bus_search(vbase_min, vbase_max, v_min, v_max, area, zone, owner, self.toolkit_index) + while True: + bus = STEPS_LIB.api_get_current_bus_number(self.toolkit_index) + if bus==0: + break + buses.append(int(bus)) + STEPS_LIB.api_goto_next_bus(self.toolkit_index) + return tuple(buses) + + def get_generators_at_bus(self, bus): + global STEPS_LIB + device = "GENERATOR" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + generators = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + generators.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(generators) + + def get_wt_generators_at_bus(self, bus): + global STEPS_LIB + device = "WT GENERATOR" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + wt_generators = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + wt_generators.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(wt_generators) + + def get_pv_units_at_bus(self, bus): + global STEPS_LIB + device = "PV UNIT" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + pv_units = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + pv_units.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(pv_units) + + def get_loads_at_bus(self, bus): + global STEPS_LIB + device = "LOAD" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + loads = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + loads.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(loads) + + def get_fixed_shunts_at_bus(self, bus): + global STEPS_LIB + device = "FIXED SHUNT" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + fixed_shunts = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + fixed_shunts.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(fixed_shunts) + + def get_equivalent_devices_at_bus(self, bus): + global STEPS_LIB + device = "EQUIVALENT DEVICE" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + equivalent_devices = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + equivalent_devices.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(equivalent_devices) + + def get_energy_storages_at_bus(self, bus): + global STEPS_LIB + device = "ENERGY STORAGE" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + energy_storages = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + energy_storages.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(energy_storages) + + def get_lines_at_bus(self, bus): + global STEPS_LIB + device = "LINE" + device = self.__get_c_char_p_of_string(device) + send_side = self.__get_c_char_p_of_string("SEND") + recv_side = self.__get_c_char_p_of_string("RECEIVE") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + lines = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, send_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, recv_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + lines.append((int(ibus), int(jbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(lines) + + def get_transformers_at_bus(self, bus): + global STEPS_LIB + device = "TRANSFORMER" + device = self.__get_c_char_p_of_string(device) + pri_side = self.__get_c_char_p_of_string("PRIMARY") + sec_side = self.__get_c_char_p_of_string("SECONDARY") + ter_side = self.__get_c_char_p_of_string("TERTIARY") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + transformers = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, pri_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, sec_side, self.toolkit_index) + kbus = STEPS_LIB.api_get_current_device_bus_number(device, ter_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + transformers.append((int(ibus), int(jbus), int(kbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(transformers) + + def get_hvdcs_at_bus(self, bus): + global STEPS_LIB + device = "HVDC" + device = self.__get_c_char_p_of_string(device) + rec_side = self.__get_c_char_p_of_string("RECTIFIER") + inv_side = self.__get_c_char_p_of_string("INVERTER") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + hvdcs = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, rec_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, inv_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + hvdcs.append((int(ibus), int(jbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(hvdcs) + + def get_areas(self): + global STEPS_LIB + STEPS_LIB.api_initialize_area_search(self.toolkit_index) + areas = [] + while True: + area = STEPS_LIB.api_get_current_area_number(self.toolkit_index) + if area==0: + break + areas.append(int(area)) + STEPS_LIB.api_goto_next_area(self.toolkit_index) + return tuple(areas) + + def get_zones(self): + global STEPS_LIB + STEPS_LIB.api_initialize_zone_search(self.toolkit_index) + zones = [] + while True: + zone = STEPS_LIB.api_get_current_zone_number(self.toolkit_index) + if zone==0: + break + zones.append(int(zone)) + STEPS_LIB.api_goto_next_zone(self.toolkit_index) + return tuple(zones) + + def get_owners(self): + global STEPS_LIB + STEPS_LIB.api_initialize_owner_search(self.toolkit_index) + owners = [] + while True: + owner = STEPS_LIB.api_get_current_owner_number(self.toolkit_index) + if owner==0: + break + owners.append(int(owner)) + STEPS_LIB.api_goto_next_owner(self.toolkit_index) + return tuple(owners) + + def get_bus_data(self, bus, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_bus_integer_data(bus, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_bus_float_data(bus, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_bus_boolean_data(bus, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_bus_string_data(bus, par_name, self.toolkit_index)) + return None + + def __get_source_data(self, source, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(source) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_source_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_source_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_source_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_source_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_generator_data(self, generator, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(generator, par_type, par_name) + + def get_wt_generator_data(self, wt_generator, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(wt_generator, par_type, par_name) + + def get_pv_unit_data(self, pv_unit, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(pv_unit, par_type, par_name) + + def get_energy_storage_data(self, energy_storage, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(energy_storage, par_type, par_name) + + def get_load_data(self, load, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_load_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_load_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_load_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_load_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_fixed_shunt_data(self, fixed_shunt, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(fixed_shunt) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_fixed_shunt_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_fixed_shunt_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_fixed_shunt_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_fixed_shunt_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_equivalent_device_data(self, equivalent_device, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_equivalent_device_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_equivalent_device_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_equivalent_device_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_equivalent_device_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_line_data(self, line, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_line_integer_data(ibus, jbus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_line_float_data(ibus, jbus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_line_boolean_data(ibus, jbus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_line_string_data(ibus, jbus, ickt, par_name, self.toolkit_index)) + return None + + def get_transformer_data(self, transformer, par_type, side, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + side = side.upper() + if side not in ['PRIMARY', 'SECONDARY', 'TERTIARY', 'TRANSFORMER']: + return None + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_transformer_integer_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_transformer_float_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_transformer_boolean_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_transformer_string_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index)) + return None + + def get_hvdc_data(self, hvdc, par_type, side, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + side = side.upper() + if side not in ['RECTIFIER', 'INVERTER', 'HVDC']: + return None + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_hvdc_integer_data(ibus, jbus, ickt, side, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_hvdc_float_data(ibus, jbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_hvdc_boolean_data(ibus, jbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_hvdc_string_data(ibus, jbus, ickt, side, par_name, self.toolkit_index)) + return None + + def get_area_data(self, area, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_area_integer_data(area, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_area_float_data(area, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_area_boolean_data(area, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_area_string_data(area, par_name, self.toolkit_index)) + return None + + def get_zone_data(self, zone, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_zone_integer_data(zone, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_zone_float_data(zone, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_zone_boolean_data(zone, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_zone_string_data(zone, par_name, self.toolkit_index)) + return None + + def get_owner_data(self, owner, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_owner_integer_data(owner, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_owner_float_data(owner, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_owner_boolean_data(owner, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_owner_string_data(owner, par_name, self.toolkit_index)) + return None + + + def set_bus_data(self, bus, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + STEPS_LIB.api_set_bus_integer_data(bus, par_name, value, self.toolkit_index) + return + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_bus_float_data(bus, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_bus_boolean_data(bus, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_bus_string_data(bus, par_name, value, self.toolkit_index) + return + + def __set_source_data(self, source, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(source) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_source_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_source_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_source_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_source_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_generator_data(self, generator, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(generator, par_type, par_name, value) + + def set_wt_generator_data(self, wt_generator, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(wt_generator, par_type, par_name, value) + + def set_pv_unit_data(self, pv_unit, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(pv_unit, par_type, par_name, value) + + def set_energy_storage_data(self, energy_storage, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(energy_storage, par_type, par_name, value) + + def set_load_data(self, load, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_load_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_load_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_load_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_load_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_fixed_shunt_data(self, fixed_shunt, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(fixed_shunt) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_fixed_shunt_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_fixed_shunt_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_fixed_shunt_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_fixed_shunt_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_equivalent_device_data(self, equivalent_device, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_equivalent_device_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_equivalent_device_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_equivalent_device_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_equivalent_device_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_line_data(self, line, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_line_integer_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_line_float_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_line_boolean_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_line_string_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + return + + def set_transformer_data(self, transformer, par_type, side, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_transformer_integer_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_transformer_float_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_transformer_boolean_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_transformer_string_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + return + + def set_hvdc_data(self, hvdc, par_type, side, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_hvdc_integer_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_hvdc_float_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_hvdc_boolean_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_hvdc_string_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + return + + def set_area_data(self, area, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_area_integer_data(area, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_area_float_data(area, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_area_boolean_data(area, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_area_string_data(area, par_name, value, self.toolkit_index) + return + + def set_zone_data(self, zone, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_zone_integer_data(zone, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_zone_float_data(zone, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_zone_boolean_data(zone, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_zone_string_data(zone, par_name, value, self.toolkit_index) + return + + def set_owner_data(self, owner, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_owner_integer_data(owner, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_owner_float_data(owner, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_owner_boolean_data(owner, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_owner_string_data(owner, par_name, value, self.toolkit_index) + return + + def set_dynamic_model(self, data, file_type): + global STEPS_LIB + data = self.__get_c_char_p_of_string(data) + file_type = self.__get_c_char_p_of_string(file_type) + STEPS_LIB.api_set_dynamic_model(data, file_type, self.toolkit_index) + return + + def get_generator_related_model_name(self, generator, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_generator_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_generator_related_model_data(self, generator, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_generator_related_model_data(self, generator, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_wt_generator_related_model_name(self, generator, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_wt_generator_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_wt_generator_related_model_data(self, generator, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_wt_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_wt_generator_related_model_data(self, generator, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_wt_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_pv_unit_related_model_name(self, pv_unit, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_pv_unit_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_pv_unit_related_model_data(self, pv_unit, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_pv_unit_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_pv_unit_related_model_data(self, pv_unit, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_pv_unit_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_load_related_model_name(self, load, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_load_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_load_related_model_data(self, load, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_load_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_load_related_model_data(self, load, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_load_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_line_related_model_name(self, line, model_type): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_line_related_model_name(ibus, jbus, ickt, model_type, self.toolkit_index)) + + def get_line_related_model_data(self, line, model_type, par_name): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_line_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, self.toolkit_index) + + def set_line_related_model_data(self, line, model_type, par_name, value): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_line_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_hvdc_related_model_name(self, hvdc, model_type): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_hvdc_related_model_name(ibus, jbus, ickt, model_type, self.toolkit_index)) + + def get_hvdc_related_model_data(self, hvdc, model_type, par_name): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_hvdc_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, self.toolkit_index) + + def set_hvdc_related_model_data(self, hvdc, model_type, par_name, value): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_hvdc_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_powerflow_solver_parameter(self, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_powerflow_solver_integer_parameter(par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_powerflow_solver_float_parameter(par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_powerflow_solver_boolean_parameter(par_name, self.toolkit_index) + return None + + def set_powerflow_solver_parameter(self, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_powerflow_solver_integer_parameter(par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_powerflow_solver_float_parameter(par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_powerflow_solver_boolean_parameter(par_name, value, self.toolkit_index) + return + + def solve_powerflow(self, method): + global STEPS_LIB + method = self.__get_c_char_p_of_string(method) + STEPS_LIB.api_solve_powerflow(method, self.toolkit_index) + return + + def is_powerflow_converged(self): + global STEPS_LIB + return STEPS_LIB.api_is_powerflow_converged(self.toolkit_index) + + def get_powerflow_loss(self): + global STEPS_LIB + p_gen = 0.0 + gens = self.get_generators_at_bus(0) + for gen in gens: + p_gen += self.get_generator_data(gen, 'd', 'Pgen_MW') + + gens = self.get_wt_generators_at_bus(0) + for gen in gens: + p_gen += self.get_wt_generator_data(gen, 'd', 'Pgen_MW') + + pvs = self.get_pv_units_at_bus(0) + for pv in pvs: + p_gen += self.get_pv_unit_data(pv, 'd', 'Pgen_MW') + + eses = self.get_energy_storages_at_bus(0) + for es in eses: + p_gen += self.get_energy_storage_data(es, 'd', 'Pgen_MW') + + p_load = 0.0 + loads = self.get_loads_at_bus(0) + for load in loads: + p_load += self.get_load_data(load, 'd', 'P_MW') + + return p_gen-p_load + + + def show_powerflow_result(self): + global STEPS_LIB + STEPS_LIB.api_show_powerflow_result(self.toolkit_index) + return + + def save_powerflow_result(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_powerflow_result(file, self.toolkit_index) + return + + def save_extended_powerflow_result(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_extended_powerflow_result(file, self.toolkit_index) + return + + def save_jacobian_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_jacobian_matrix(file, self.toolkit_index) + return + + def build_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_network_matrix(self.toolkit_index) + return + + def build_decoupled_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_decoupled_network_matrix(self.toolkit_index) + return + + def build_dc_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_dc_network_matrix(self.toolkit_index) + return + + def build_dynamic_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_dynamic_network_matrix(self.toolkit_index) + return + + def save_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_network_matrix(file, self.toolkit_index) + return + + def save_decoupled_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_decoupled_network_matrix(file, self.toolkit_index) + return + + def save_dc_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_dc_network_matrix(file, self.toolkit_index) + return + + def save_dynamic_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_dynamic_network_matrix(file, self.toolkit_index) + return + + + def get_dynamic_simulator_parameter(self, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_dynamic_simulator_integer_parameter(par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_dynamic_simulator_float_parameter(par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_dynamic_simulator_boolean_parameter(par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_dynamic_simulator_string_parameter(par_name, self.toolkit_index)) + return None + + def set_dynamic_simulator_parameter(self, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_dynamic_simulator_integer_parameter(par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_dynamic_simulator_float_parameter(par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_dynamic_simulator_boolean_parameter(par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_dynamic_simulator_string_parameter(par_name, value, self.toolkit_index) + return None + + def get_dynamic_simulator_output_file(self): + global STEPS_LIB + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_dynamic_simulator_output_file(self.toolkit_index)) + + def set_dynamic_simulator_output_file(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + return STEPS_LIB.api_set_dynamic_simulator_output_file(file, self.toolkit_index) + + def get_dynamic_simulation_time_step(self): + global STEPS_LIB + return STEPS_LIB.api_get_dynamic_simulation_time_step(self.toolkit_index) + + def set_dynamic_simulation_time_step(self, step): + global STEPS_LIB + return STEPS_LIB.api_set_dynamic_simulation_time_step(step, self.toolkit_index) + + def get_dynamic_simulation_time(self): + global STEPS_LIB + return STEPS_LIB.api_get_dynamic_simulation_time(self.toolkit_index) + + def prepare_meters(self, device_type): + global STEPS_LIB + device_type = device_type.upper() + if device_type not in ['ALL', 'BUS', 'GENERATOR', 'WT GENERATOR', 'LOAD', 'LINE', 'HVDC', 'EQUIVALENT DEVICE']: + return + if device_type in ['ALL']: + STEPS_LIB.api_prepare_meters(self.toolkit_index) + return + if device_type in ['BUS']: + STEPS_LIB.api_prepare_bus_related_meters(self.toolkit_index) + return + if device_type in ['GENERATOR']: + STEPS_LIB.api_prepare_generator_related_meters(self.toolkit_index) + return + if device_type in ['WT GENERATOR']: + STEPS_LIB.api_prepare_wt_generator_related_meters(self.toolkit_index) + return + if device_type in ['PV UNIT']: + STEPS_LIB.api_prepare_pv_unit_related_meters(self.toolkit_index) + return + if device_type in ['ENERGY STORAGE']: + STEPS_LIB.api_prepare_energy_storage_related_meters(self.toolkit_index) + return + if device_type in ['LOAD']: + STEPS_LIB.api_prepare_load_related_meters(self.toolkit_index) + return + if device_type in ['LINE']: + STEPS_LIB.api_prepare_line_related_meters(self.toolkit_index) + return + if device_type in ['HVDC']: + STEPS_LIB.api_prepare_hvdc_related_meters(self.toolkit_index) + return + if device_type in ['EQUIVALENT DEVICE']: + STEPS_LIB.api_prepare_equivalent_device_related_meters(self.toolkit_index) + return + return + + def prepare_bus_meter(self, bus, meter_type): + global STEPS_LIB + meter_type = self.__get_c_char_p_of_string(meter_type) + STEPS_LIB.api_prepare_bus_related_meter(bus, meter_type, self.toolkit_index) + return + + def prepare_generator_meter(self, generator, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_generator_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_wt_generator_meter(self, generator, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_wt_generator_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_pv_unit_meter(self, pvunit, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(pvunit) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_pv_unit_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_energy_storage_meter(self, estorage, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(estorage) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_energy_storage_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_load_meter(self, load, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_load_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_line_meter(self, line, meter_type, side, var_name=""): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + side = self.__get_c_char_p_of_string(side) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_line_related_meter(ibus, jbus, ickt, meter_type, side, var_name, self.toolkit_index) + return + + def prepare_hvdc_meter(self, hvdc, meter_type, side, var_name=""): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + side = self.__get_c_char_p_of_string(side) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_hvdc_related_meter(ibus, jbus, ickt, meter_type, side, var_name, self.toolkit_index) + return + + def prepare_equivalent_device_meter(self, edevice, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_equivalent_device_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def start_dynamic_simulation(self): + global STEPS_LIB + STEPS_LIB.api_start_dynamic_simulation(self.toolkit_index) + return + + def stop_dynamic_simulation(self): + global STEPS_LIB + STEPS_LIB.api_stop_dynamic_simulation(self.toolkit_index) + return + + def run_dynamic_simulation_to_time(self, time): + global STEPS_LIB + STEPS_LIB.api_run_simulation_to_time(time, self.toolkit_index) + return + + def run_a_step(self): + global STEPS_LIB + STEPS_LIB.api_run_a_step(self.toolkit_index) + return + + def set_bus_fault(self, bus, fault_type, fault_shunt): + global STEPS_LIB + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_set_bus_fault(bus, fault_type, fault_shunt[0], fault_shunt[1], self.toolkit_index) + return + + def clear_bus_fault(self, bus, fault_type): + global STEPS_LIB + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_clear_bus_fault(bus, fault_type, self.toolkit_index) + return + + def trip_bus(self, bus): + global STEPS_LIB + STEPS_LIB.api_trip_bus(bus, self.toolkit_index) + return + + def set_line_fault(self, line, fault_type, fault_location, fault_shunt): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_set_line_fault(ibus, jbus, ickt, fault_type, fault_location, fault_shunt[0], fault_shunt[1], self.toolkit_index) + return + + def clear_line_fault(self, line, fault_type, fault_location): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_clear_line_fault(ibus, jbus, ickt, fault_type, fault_location, self.toolkit_index) + return + + def trip_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_line(ibus, jbus, ickt, self.toolkit_index) + return + + def trip_line_breaker(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_line_breaker(ibus, jbus, ickt, self.toolkit_index) + return + + + def close_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_line(ibus, jbus, ickt, self.toolkit_index) + return + + def close_line_breaker(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_single_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_line_breaker(ibus, jbus, ickt, self.toolkit_index) + return + + + def trip_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def trip_transformer_breaker(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_transformer_breaker(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + + def close_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def close_transformer_breaker(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_transformer_breaker(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def trip_generator(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_generator(ibus, ickt, self.toolkit_index) + return + + def shed_generator(self, generator, percent): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_shed_generator(ibus, ickt, percent, self.toolkit_index) + return + + def trip_load(self, load): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_load(ibus, ickt, self.toolkit_index) + return + + def close_load(self, load): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_load(ibus, ickt, self.toolkit_index) + return + + def scale_load(self, load, percent): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_scale_load(ibus, ickt, percent, self.toolkit_index) + return + + def scale_all_loads(self, percent): + global STEPS_LIB + STEPS_LIB.api_scale_all_loads(percent, self.toolkit_index) + return + + def trip_fixed_shunt(self, shunt): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_fixed_shunt(ibus, ickt, self.toolkit_index) + return + + def close_fixed_shunt(self, shunt): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_fixed_shunt(ibus, ickt, self.toolkit_index) + return + + def manually_bypass_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_bypass_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_block_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_block_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_unbypass_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_unbypass_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_unblock_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_unblock_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def get_generator_voltage_reference_in_pu(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_get_generator_voltage_reference_in_pu(ibus, ickt, self.toolkit_index) + + def get_generator_power_reference_in_MW(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_get_generator_power_reference_in_MW(ibus, ickt, self.toolkit_index) + + def set_generator_voltage_reference_in_pu(self, generator, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_set_generator_voltage_reference_in_pu(ibus, ickt, value, self.toolkit_index) + + def set_generator_power_reference_in_MW(self, generator, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_set_generator_power_reference_in_MW(ibus, ickt, value, self.toolkit_index) \ No newline at end of file