From ccd4349a43a177a02867c18fddfdbbb95a7a2c53 Mon Sep 17 00:00:00 2001 From: Changgang Li Date: Thu, 2 Nov 2023 18:51:33 +0800 Subject: [PATCH] add function to check if NAN is detected in powerflow solver. --- README.md | 3 +- code/steps/STEPS.cbp | 1 - code/steps/STEPS.depend | 174 +++++----- code/steps/header/apis/steps_api.h | 1 + code/steps/header/basic/utility.h | 2 + .../powerflow_solver/powerflow_solver.h | 2 + .../steps/source/apis/steps_api_powerflow.cpp | 7 + code/steps/source/basic/utility.cpp | 7 +- .../powerflow_solver/powerflow_solver.cpp | 312 +++++++++++------- python/stepspy-current/README.md | 1 + python/stepspy-current/setup.py | 2 +- .../stepspy/libsteps/pylibsteps.py | 2 + python/stepspy-current/stepspy/stepspy.py | 30 ++ 13 files changed, 326 insertions(+), 218 deletions(-) diff --git a/README.md b/README.md index 7585cd54..9f6821ac 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ - Reminder of major repository: * The github repository may lag behind the gitee repository due to some GIT PUSH issues. So, use gitee repository first. * The 'dev' branch is constantly updating while the 'main' branch is updated when major functions are added. Use 'main' branch for stable applications, and try 'dev' branch for new features. -- Date of Readme: Oct. 16, 2023 +- Date of Readme: Nov. 2, 2023 # Reference Please cite STEPS with the following papers: @@ -23,6 +23,7 @@ Though BPA dat format is supported, it will be supported in the future version i You are encouraged to join us for further development. ## Major versions +- v2.1.0. Add function to check if NAN is detected in powerflow solver. stepspy is also updated. Compile option '-ffast-math' is disabled. - v2.0.0. Major version. (1) Short circuit functions added. Short circuit analysis with direct solution is supported. APIs are added to stepspy. Short circuit analysis with iterative solution is implemented in C++, and APIs will be added in later version. (2) Two toolkit functions added: Correct Three Winding Transformer Impedance Logic and Blockwise Automatic Large Step Logic. If the 'Correct' logic is enabled, zero impedance winding of 3-winding transformer can be automatically fixed to avoid NaN error. If the 'Blockwise' logic is enabled, dynamic simulation time step can be increased for fast simulation (See Reference Paper [2]). The 'Blockwise' logic is implemented with changes of dynamic blocks of first order, differential, and lead-lag. (3) Option 'libsteps_file' is added to stepspy when creating STEPS() object when dynamic library with name different from 'libSTEPS' is used. (4) Some wind turbine model bugs are fixed. (5) stepspy module is also upgraded to v2.0.0. - v1.6.0. Add VSC HVDC for powerflow and dynamic simulation. stepspy also updated. Released on April 13, 2022. - v1.5.4. Update to improve performance. Released on Oct. 20, 2021. diff --git a/code/steps/STEPS.cbp b/code/steps/STEPS.cbp index 8f5f65d5..69b079cd 100644 --- a/code/steps/STEPS.cbp +++ b/code/steps/STEPS.cbp @@ -23,7 +23,6 @@ - diff --git a/code/steps/STEPS.depend b/code/steps/STEPS.depend index 24e64a2c..b4968d48 100644 --- a/code/steps/STEPS.depend +++ b/code/steps/STEPS.depend @@ -11,7 +11,7 @@ "header/prepare_for_tests/prepare_models_for_test.h" "header/data_imexporter/equivalent_model_imexporter.h" -1664187970 d:\steps\code\steps\header\power_system_database.h +1697457172 d:\steps\code\steps\header\power_system_database.h "header/device/bus.h" "header/device/generator.h" "header/device/wt_generator.h" @@ -73,11 +73,11 @@ -1697192105 d:\steps\code\steps\header\block\block.h +1697457172 d:\steps\code\steps\header\block\block.h "header/basic/steps_enum.h" -1697192105 d:\steps\code\steps\header\basic\steps_enum.h +1697457172 d:\steps\code\steps\header\basic\steps_enum.h 1664187911 d:\steps\code\steps\header\model\model.h @@ -111,10 +111,10 @@ 1664187911 d:\steps\code\steps\header\model\bus_frequency_model\bus_frequency_model.h "header/block/differential_block.h" -1697448473 d:\steps\code\steps\header\block\differential_block.h +1697457172 d:\steps\code\steps\header\block\differential_block.h "header/block/block.h" -1677643900 d:\steps\code\steps\header\device\generator.h +1697457172 d:\steps\code\steps\header\device\generator.h "header/device/source.h" @@ -125,7 +125,7 @@ "header/model/sg_models/turbine_governor_model/turbine_governor_model.h" "header/model/sg_models/turbine_load_controller_model/turbine_load_controller_model.h" -1691316185 d:\steps\code\steps\header\device\source.h +1697457172 d:\steps\code\steps\header\device\source.h "header/device/nonbus_device.h" @@ -138,7 +138,7 @@ -1697449927 d:\steps\code\steps\header\model\sg_models\sync_generator_model\sync_generator_model.h +1697457172 d:\steps\code\steps\header\model\sg_models\sync_generator_model\sync_generator_model.h "header/model/sg_models/sg_model.h" "header/block/integral_block.h" "header/block/first_order_block.h" @@ -186,7 +186,7 @@ "header/basic/constants.h" "header/meter/meter.h" -1677644191 d:\steps\code\steps\header\device\wt_generator.h +1697457172 d:\steps\code\steps\header\device\wt_generator.h "header/device/source.h" @@ -208,7 +208,7 @@ "header/device/bus.h" -1691325745 d:\steps\code\steps\header\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model.h +1697457172 d:\steps\code\steps\header\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model.h "header/model/wtg_models/wtg_model.h" @@ -233,7 +233,7 @@ 1634637238 d:\steps\code\steps\header\model\wtg_models\wt_relay_model\wt_relay_model.h "header/model/wtg_models/wtg_model.h" -1677633766 d:\steps\code\steps\header\device\pv_unit.h +1697457172 d:\steps\code\steps\header\device\pv_unit.h "header/device/source.h" @@ -262,7 +262,7 @@ 1634637238 d:\steps\code\steps\header\model\pvu_models\pv_irradiance_model\pv_irradiance_model.h "header/model/pvu_models/pvu_model.h" -1677633766 d:\steps\code\steps\header\device\energy_storage.h +1697457172 d:\steps\code\steps\header\device\energy_storage.h "header/device/source.h" @@ -272,7 +272,7 @@ "header/model/model.h" -1677633766 d:\steps\code\steps\header\device\load.h +1697457172 d:\steps\code\steps\header\device\load.h "header/device/nonbus_device.h" "header/model/load_model/load_model.h" "header/model/load_relay_model/load_voltage_relay_model.h" @@ -297,7 +297,7 @@ 1634637238 d:\steps\code\steps\header\model\load_relay_model\load_frequency_relay_model.h "header/model/load_relay_model/load_relay_model.h" -1677633766 d:\steps\code\steps\header\device\line.h +1697457172 d:\steps\code\steps\header\device\line.h "header/device/nonbus_device.h" "header/basic/device_id.h" "header/basic/rating.h" @@ -307,14 +307,14 @@ 1583938871 d:\steps\code\steps\header\basic\rating.h -1677633766 d:\steps\code\steps\header\device\transformer.h +1697457172 d:\steps\code\steps\header\device\transformer.h "header/device/nonbus_device.h" "header/basic/steps_enum.h" "header/basic/rating.h" -1677633766 d:\steps\code\steps\header\device\fixed_shunt.h +1697457172 d:\steps\code\steps\header\device\fixed_shunt.h "header/device/nonbus_device.h" @@ -379,7 +379,7 @@ "header/basic/string_int_map.h" -1697192105 d:\steps\code\steps\header\steps.h +1697457172 d:\steps\code\steps\header\steps.h "header/power_system_database.h" "header/dynamic_model_database.h" "header/toolkit/powerflow_solver/powerflow_solver.h" @@ -395,12 +395,12 @@ "header/model/model.h" -1690725828 d:\steps\code\steps\header\toolkit\powerflow_solver\powerflow_solver.h +1698919368 d:\steps\code\steps\header\toolkit\powerflow_solver\powerflow_solver.h "header/network/network_matrix.h" "header/network/jacobian_builder.h" "header/basic/sparse_matrix_define.h" -1677633766 d:\steps\code\steps\header\network\network_matrix.h +1697457172 d:\steps\code\steps\header\network\network_matrix.h "header/power_system_database.h" "header/basic/sparse_matrix_define.h" "header/basic/inphno.h" @@ -481,7 +481,7 @@ -1677642538 d:\steps\code\steps\header\basic\utility.h +1698916868 d:\steps\code\steps\header\basic\utility.h "header/power_system_database.h" "header/network/network_matrix.h" "header/toolkit/powerflow_solver/powerflow_solver.h" @@ -489,14 +489,14 @@ "header/basic/complex3.h" -1664187970 d:\steps\code\steps\header\data_imexporter\psse_imexporter.h +1697457172 d:\steps\code\steps\header\data_imexporter\psse_imexporter.h "header/data_imexporter/data_imexporter.h" "header/device/source.h" "header/device/transformer.h" "header/device/hvdc.h" -1691316185 d:\steps\code\steps\header\data_imexporter\data_imexporter.h +1697457172 d:\steps\code\steps\header\data_imexporter\data_imexporter.h "header/power_system_database.h" @@ -856,7 +856,7 @@ "header/basic/continuous_buffer.h" "header/STEPS.h" -1691329786 d:\steps\code\steps\header\basic\continuous_buffer.h +1697457172 d:\steps\code\steps\header\basic\continuous_buffer.h "header/device/device.h" "header/basic/base.h" @@ -1034,7 +1034,7 @@ "header/data_imexporter/steps_imexporter.h" "header/STEPS.h" -1691316185 d:\steps\code\steps\header\data_imexporter\steps_imexporter.h +1697457172 d:\steps\code\steps\header\data_imexporter\steps_imexporter.h "header/data_imexporter/data_imexporter.h" "header/device/source.h" "header/device/transformer.h" @@ -1143,7 +1143,7 @@ "header/block/first_order_block.h" "header/STEPS.h" -1697192105 d:\steps\code\steps\header\block\first_order_block.h +1697457172 d:\steps\code\steps\header\block\first_order_block.h "header/block/block.h" "header/block/proportional_block.h" @@ -1156,7 +1156,7 @@ "header/block/lead_lag_block.h" "header/STEPS.h" -1697442895 d:\steps\code\steps\header\block\lead_lag_block.h +1697457172 d:\steps\code\steps\header\block\lead_lag_block.h "header/block/block.h" "header/block/first_order_block.h" @@ -1940,7 +1940,7 @@ "header/power_system_database.h" "header/STEPS.h" -1691317215 d:\steps\code\steps\header\model\wtg_models\wt_generator_model\wt3g0.h +1697457172 d:\steps\code\steps\header\model\wtg_models\wt_generator_model\wt3g0.h "header/model/wtg_models/wt_generator_model/wt_generator_model.h" "header/model/wtg_models/wt_generator_model/lvpl.h" "header/block/integral_block.h" @@ -2264,7 +2264,7 @@ "header/model/wtg_models/wt_generator_model/wt3g1.h" "header/model/wtg_models/wt_generator_model/wt3g2.h" -1691316924 d:\steps\code\steps\header\model\wtg_models\wt_generator_model\wt3g2.h +1697457172 d:\steps\code\steps\header\model\wtg_models\wt_generator_model\wt3g2.h "header/model/wtg_models/wt_generator_model/wt_generator_model.h" "header/model/wtg_models/wt_generator_model/lvpl.h" "header/block/integral_block.h" @@ -2353,7 +2353,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 d:\steps\code\steps\header\apis\steps_api.h +1698919510 d:\steps\code\steps\header\apis\steps_api.h "header/basic/constants.h" "header/basic/dc_device_id.h" @@ -2376,7 +2376,7 @@ "header/toolkit/powerflow_solver/powerflow_solver.h" "header/toolkit/dynamic_simulator/dynamic_simulator.h" -1664187943 source:d:\steps\code\steps\source\apis\steps_api_data_import_export.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_data_import_export.cpp "header/apis/steps_api.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -2447,7 +2447,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1664187943 source:d:\steps\code\steps\source\apis\steps_api_set_get_bus_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_bus_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2455,7 +2455,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_fixed_shunt_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_fixed_shunt_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2487,7 +2487,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_line_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_line_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2503,7 +2503,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_load_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_load_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2541,7 +2541,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_transformer_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_transformer_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2615,7 +2615,7 @@ -1697443372 source:d:\steps\code\steps\source\apis\steps_api_utilities.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_utilities.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -2666,7 +2666,7 @@ "header/basic/constants_test.h" "header/basic/utility.h" -1691330034 source:d:\steps\code\steps\source\basic\continuous_buffer.cpp +1697457172 source:d:\steps\code\steps\source\basic\continuous_buffer.cpp "header/basic/continuous_buffer.h" "header/steps_namespace.h" "header/basic/utility.h" @@ -3170,7 +3170,7 @@ -1691316185 source:d:\steps\code\steps\source\basic\utility.cpp +1698916862 source:d:\steps\code\steps\source\basic\utility.cpp "header/basic/utility.h" "header/basic/constants.h" "header/steps_namespace.h" @@ -3214,12 +3214,12 @@ "header/steps_namespace.h" -1697192105 source:d:\steps\code\steps\source\block\block.cpp +1697457172 source:d:\steps\code\steps\source\block\block.cpp "header/block/block.h" "header/steps_namespace.h" "header/basic/utility.h" -1697448469 source:d:\steps\code\steps\source\block\differential_block.cpp +1697457172 source:d:\steps\code\steps\source\block\differential_block.cpp "header/block/differential_block.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3236,7 +3236,7 @@ -1697424888 source:d:\steps\code\steps\source\block\first_order_block.cpp +1697457172 source:d:\steps\code\steps\source\block\first_order_block.cpp "header/block/first_order_block.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3270,7 +3270,7 @@ -1697442892 source:d:\steps\code\steps\source\block\lead_lag_block.cpp +1697457172 source:d:\steps\code\steps\source\block\lead_lag_block.cpp "header/block/lead_lag_block.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3427,7 +3427,7 @@ -1691316185 source:d:\steps\code\steps\source\data_imexporter\data_imexporter.cpp +1697457172 source:d:\steps\code\steps\source\data_imexporter\data_imexporter.cpp "header/data_imexporter/data_imexporter.h" "header/STEPS.h" "header/basic/utility.h" @@ -3487,7 +3487,7 @@ -1664187943 source:d:\steps\code\steps\source\data_imexporter\psse_powerflow_imexporter.cpp +1697457172 source:d:\steps\code\steps\source\data_imexporter\psse_powerflow_imexporter.cpp "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/steps_imexporter.h" "header/basic/utility.h" @@ -3526,7 +3526,7 @@ -1664187943 source:d:\steps\code\steps\source\data_imexporter\steps_powerflow_imexporter.cpp +1697457172 source:d:\steps\code\steps\source\data_imexporter\steps_powerflow_imexporter.cpp "header/data_imexporter/steps_imexporter.h" "header/basic/utility.h" "header/device/bus.h" @@ -3570,7 +3570,7 @@ -1677633766 source:d:\steps\code\steps\source\device\energy_storage.cpp +1697457172 source:d:\steps\code\steps\source\device\energy_storage.cpp "header/device/energy_storage.h" "header/basic/utility.h" "header/model/energy_storage_model/energy_storage_models.h" @@ -3615,7 +3615,7 @@ -1677633766 source:d:\steps\code\steps\source\device\fixed_shunt.cpp +1697457172 source:d:\steps\code\steps\source\device\fixed_shunt.cpp "header/device/fixed_shunt.h" "header/basic/utility.h" "header/STEPS.h" @@ -3635,7 +3635,7 @@ -1677643922 source:d:\steps\code\steps\source\device\generator.cpp +1697457172 source:d:\steps\code\steps\source\device\generator.cpp "header/device/generator.h" "header/basic/utility.h" "header/STEPS.h" @@ -3667,7 +3667,7 @@ -1664187970 source:d:\steps\code\steps\source\device\hvdc.cpp +1697457172 source:d:\steps\code\steps\source\device\hvdc.cpp "header/device/hvdc.h" "header/basic/utility.h" "header/basic/constants.h" @@ -3693,7 +3693,7 @@ -1677633766 source:d:\steps\code\steps\source\device\line.cpp +1697457172 source:d:\steps\code\steps\source\device\line.cpp "header/device/line.h" "header/basic/utility.h" "header/basic/constants.h" @@ -3715,7 +3715,7 @@ -1677633766 source:d:\steps\code\steps\source\device\load.cpp +1697457172 source:d:\steps\code\steps\source\device\load.cpp "header/device/load.h" "header/basic/utility.h" "header/STEPS.h" @@ -3745,7 +3745,7 @@ -1677633766 source:d:\steps\code\steps\source\device\pv_unit.cpp +1697457172 source:d:\steps\code\steps\source\device\pv_unit.cpp "header/device/pv_unit.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3770,7 +3770,7 @@ -1691316185 source:d:\steps\code\steps\source\device\source.cpp +1697457172 source:d:\steps\code\steps\source\device\source.cpp "header/device/source.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3792,7 +3792,7 @@ -1677633766 source:d:\steps\code\steps\source\device\transformer.cpp +1697457172 source:d:\steps\code\steps\source\device\transformer.cpp "header/device/transformer.h" "header/basic/utility.h" "header/STEPS.h" @@ -3812,7 +3812,7 @@ -1677633766 source:d:\steps\code\steps\source\device\vsc_hvdc.cpp +1697457172 source:d:\steps\code\steps\source\device\vsc_hvdc.cpp "header/device/vsc_hvdc.h" "header/basic/utility.h" "header/basic/steps_define.h" @@ -3824,7 +3824,7 @@ -1677633766 d:\steps\code\steps\header\device\vsc_hvdc.h +1697457172 d:\steps\code\steps\header\device\vsc_hvdc.h "header/device/nonbus_device.h" "header/device/vsc_hvdc_var.h" "header/basic/device_id.h" @@ -3881,7 +3881,7 @@ "header/power_system_database.h" "header/STEPS.h" -1677644215 source:d:\steps\code\steps\source\device\wt_generator.cpp +1697457172 source:d:\steps\code\steps\source\device\wt_generator.cpp "header/device/wt_generator.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -3921,7 +3921,7 @@ -1691326484 source:d:\steps\code\steps\source\meter\meter.cpp +1697457172 source:d:\steps\code\steps\source\meter\meter.cpp "header/meter/meter.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -4877,7 +4877,7 @@ -1697450191 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\genrou.cpp +1697457172 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\genrou.cpp "header/model/sg_models/sync_generator_model/genrou.h" "header/basic/utility.h" "header/STEPS.h" @@ -4897,7 +4897,7 @@ -1697450211 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\gensal.cpp +1697457172 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\gensal.cpp "header/model/sg_models/sync_generator_model/gensal.h" "header/basic/utility.h" "header/STEPS.h" @@ -4916,7 +4916,7 @@ -1697449935 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\sync_generator_model.cpp +1697457172 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\sync_generator_model.cpp "header/model/sg_models/sync_generator_model/sync_generator_model.h" "header/basic/utility.h" "header/basic/constants.h" @@ -4936,7 +4936,7 @@ -1691330669 source:d:\steps\code\steps\source\model\sg_models\turbine_governors\gast2a.cpp +1697457172 source:d:\steps\code\steps\source\model\sg_models\turbine_governors\gast2a.cpp "header/model/sg_models/turbine_governor_model/GAST2A.h" "header/basic/utility.h" "header/STEPS.h" @@ -5033,7 +5033,7 @@ "header/model/sg_models/turbine_governor_model/TGOV1.h" "header/model/sg_models/sync_generator_model/gencls.h" -1691330992 source:d:\steps\code\steps\source\model\sg_models\turbine_governors\urcsct.cpp +1697457172 source:d:\steps\code\steps\source\model\sg_models\turbine_governors\urcsct.cpp "header/model/sg_models/turbine_governor_model/URCSCT.h" "header/basic/utility.h" "header/STEPS.h" @@ -5127,25 +5127,25 @@ -1691321507 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\aerdf.cpp +1697457172 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\aerdf.cpp "header/model/wtg_models/wt_aerodynamic_model/aerdf.h" "header/basic/utility.h" "header/steps_namespace.h" -1691321023 d:\steps\code\steps\header\model\wtg_models\wt_aerodynamic_model\aerdf.h +1697457172 d:\steps\code\steps\header\model\wtg_models\wt_aerodynamic_model\aerdf.h "header/model/wtg_models/wt_aerodynamic_model/wt_aerodynamic_model.h" -1691326411 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model.cpp +1697457172 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model.cpp "header/model/wtg_models/wt_aerodynamic_model/wt_aerodynamic_model.h" "header/basic/utility.h" "header/STEPS.h" -1691326527 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model_test.cpp +1697457172 source:d:\steps\code\steps\source\model\wtg_models\wt_aerodynamic_model\wt_aerodynamic_model_test.cpp "header/basic/test_macro.h" "header/model/wtg_models/wt_aerodynamic_model/wt_aerodynamic_model_test.h" "header/basic/utility.h" @@ -5162,7 +5162,7 @@ "header/model/wtg_models/wt_electrical_model/wind_turbine_power_speed_lookup_table.h" "header/basic/utility.h" -1691318996 source:d:\steps\code\steps\source\model\wtg_models\wt_electrical_model\wt3e0.cpp +1697457172 source:d:\steps\code\steps\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" @@ -5221,7 +5221,7 @@ "header/basic/constants.h" -1691317498 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g0.cpp +1697457172 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g0.cpp "header/model/wtg_models/wt_generator_model/wt3g0.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -5261,7 +5261,7 @@ -1691317123 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g2.cpp +1697457172 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g2.cpp "header/model/wtg_models/wt_generator_model/wt3g2.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -5434,7 +5434,7 @@ "header/steps_namespace.h" -1696853753 source:d:\steps\code\steps\source\network\network_matrix.cpp +1697457172 source:d:\steps\code\steps\source\network\network_matrix.cpp "header/network/network_matrix.h" "header/basic/utility.h" "header/STEPS.h" @@ -5455,7 +5455,7 @@ -1664187970 source:d:\steps\code\steps\source\power_system_database.cpp +1697457172 source:d:\steps\code\steps\source\power_system_database.cpp "header/power_system_database.h" "header/STEPS.h" "header/steps_namespace.h" @@ -5664,7 +5664,7 @@ "header/steps_namespace.h" "header/basic/utility.h" -1697192105 source:d:\steps\code\steps\source\steps.cpp +1697457172 source:d:\steps\code\steps\source\steps.cpp "header/STEPS.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -5806,7 +5806,7 @@ -1691316152 source:d:\steps\code\steps\source\toolkit\powerflow_solver\powerflow_solver.cpp +1698917743 source:d:\steps\code\steps\source\toolkit\powerflow_solver\powerflow_solver.cpp "header/toolkit/powerflow_solver/powerflow_solver.h" "header/basic/utility.h" "header/basic/constants.h" @@ -18818,13 +18818,13 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 d:\steps\code\steps\header\toolkit\short_circuit_solver\short_circuit_solver.h +1697457172 d:\steps\code\steps\header\toolkit\short_circuit_solver\short_circuit_solver.h "header/basic/complex3.h" "header/network/network_matrix.h" "header/network/jacobian_builder.h" "header/basic/sparse_matrix_define.h" -1691316185 source:d:\steps\code\steps\main_short_circuit.cpp +1697457172 source:d:\steps\code\steps\main_short_circuit.cpp "header/power_system_database.h" @@ -18834,7 +18834,7 @@ "header/basic/utility.h" "header/data_imexporter/psse_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_generator_sequence_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_generator_sequence_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -18842,7 +18842,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1664187943 source:d:\steps\code\steps\source\apis\steps_api_set_get_pv_unit_sequence_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_pv_unit_sequence_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -18850,7 +18850,7 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_set_get_wt_generator_sequence_parameters.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_set_get_wt_generator_sequence_parameters.cpp "header/apis/steps_api.h" "header/apis/steps_api_common.h" "header/basic/utility.h" @@ -18858,13 +18858,13 @@ "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/bpa_imexporter.h" -1691316185 source:d:\steps\code\steps\source\apis\steps_api_short_circuit.cpp +1697457172 source:d:\steps\code\steps\source\apis\steps_api_short_circuit.cpp "header/apis/steps_api.h" "header/basic/utility.h" "header/steps_namespace.h" -1677638738 source:d:\steps\code\steps\source\data_imexporter\psse_short_circuit_imexporter.cpp +1697457172 source:d:\steps\code\steps\source\data_imexporter\psse_short_circuit_imexporter.cpp "header/data_imexporter/psse_imexporter.h" "header/data_imexporter/steps_imexporter.h" "header/basic/utility.h" @@ -18874,7 +18874,7 @@ -1691316185 source:d:\steps\code\steps\source\data_imexporter\steps_short_circuit_imexporter.cpp +1697457172 source:d:\steps\code\steps\source\data_imexporter\steps_short_circuit_imexporter.cpp "header/data_imexporter/steps_imexporter.h" "header/basic/utility.h" "header/steps_namespace.h" @@ -18883,7 +18883,7 @@ -1691316185 source:d:\steps\code\steps\source\toolkit\short_circuit_solver\short_circuit_solver.cpp +1697457172 source:d:\steps\code\steps\source\toolkit\short_circuit_solver\short_circuit_solver.cpp "header/toolkit/short_circuit_solver/short_circuit_solver.h" "header/basic/utility.h" "header/basic/constants.h" @@ -18894,7 +18894,7 @@ -1664187943 source:d:\steps\code\steps\source\toolkit\short_circuit_solver\short_circuit_solver_test.cpp +1697457172 source:d:\steps\code\steps\source\toolkit\short_circuit_solver\short_circuit_solver_test.cpp "header/basic/test_macro.h" "header/toolkit/powerflow_solver/powerflow_solver_test.h" "header/basic/utility.h" @@ -43939,12 +43939,12 @@ "header/basic/utility.h" "header/data_imexporter/psse_imexporter.h" -1664187970 d:\steps\code\steps\header\device\mutual_data.h +1697457172 d:\steps\code\steps\header\device\mutual_data.h "header/device/device.h" -1664187970 source:d:\steps\code\steps\source\device\mutual_data.cpp +1697457172 source:d:\steps\code\steps\source\device\mutual_data.cpp "header/device/mutual_data.h" "header/basic/utility.h" "header/basic/constants.h" @@ -43953,11 +43953,11 @@ -1677642127 d:\steps\code\steps\header\basic\complex3.h +1697457172 d:\steps\code\steps\header\basic\complex3.h -1677642100 source:d:\steps\code\steps\source\basic\complex3.cpp +1697457172 source:d:\steps\code\steps\source\basic\complex3.cpp "header/basic/complex3.h" diff --git a/code/steps/header/apis/steps_api.h b/code/steps/header/apis/steps_api.h index 22276693..9b4722f3 100644 --- a/code/steps/header/apis/steps_api.h +++ b/code/steps/header/apis/steps_api.h @@ -348,6 +348,7 @@ EXPORT_STEPS_DLL void api_show_powerflow_solver_configuration(unsigned int toolk EXPORT_STEPS_DLL void api_solve_powerflow(char* method, unsigned int toolkit_index=INDEX_NOT_EXIST); EXPORT_STEPS_DLL bool api_is_powerflow_converged(unsigned int toolkit_index=INDEX_NOT_EXIST); +EXPORT_STEPS_DLL bool api_is_nan_detected_in_powerflow_solution(unsigned int toolkit_index=INDEX_NOT_EXIST); EXPORT_STEPS_DLL void api_show_powerflow_result(unsigned int toolkit_index=INDEX_NOT_EXIST); EXPORT_STEPS_DLL void api_save_powerflow_result(char* file, unsigned int toolkit_index=INDEX_NOT_EXIST); EXPORT_STEPS_DLL void api_save_extended_powerflow_result(char* file, unsigned int toolkit_index=INDEX_NOT_EXIST); diff --git a/code/steps/header/basic/utility.h b/code/steps/header/basic/utility.h index 53c0716e..b5467697 100644 --- a/code/steps/header/basic/utility.h +++ b/code/steps/header/basic/utility.h @@ -33,6 +33,8 @@ double deg2rad(double angle); double radps2hz(double w); double hz2radps(double f); +bool is_nan(double& x); + double steps_sin(double angle_in_rad); double steps_fast_sin(double angle_in_rad); diff --git a/code/steps/header/toolkit/powerflow_solver/powerflow_solver.h b/code/steps/header/toolkit/powerflow_solver/powerflow_solver.h index 8b4b2b3b..ff6653a5 100644 --- a/code/steps/header/toolkit/powerflow_solver/powerflow_solver.h +++ b/code/steps/header/toolkit/powerflow_solver/powerflow_solver.h @@ -54,6 +54,7 @@ class POWERFLOW_SOLVER bool get_convergence_flag() const; bool is_converged(); + bool is_nan_detected(); double get_maximum_active_power_mismatch_in_MW() const; double get_maximum_reactive_power_mismatch_in_MVar() const; @@ -149,6 +150,7 @@ class POWERFLOW_SOLVER bool export_jacobian_matrix_step_by_step; bool converged; + bool nan_is_detected; vector< complex > bus_current, bus_power; diff --git a/code/steps/source/apis/steps_api_powerflow.cpp b/code/steps/source/apis/steps_api_powerflow.cpp index 32ac38ba..ca397dbe 100644 --- a/code/steps/source/apis/steps_api_powerflow.cpp +++ b/code/steps/source/apis/steps_api_powerflow.cpp @@ -228,6 +228,13 @@ bool api_is_powerflow_converged(unsigned int toolkit_index) return solver.is_converged(); } +bool api_is_nan_detected_in_powerflow_solution(unsigned int toolkit_index) +{ + STEPS& toolkit = get_toolkit(toolkit_index); + POWERFLOW_SOLVER& solver = toolkit.get_powerflow_solver(); + return solver.is_nan_detected(); +} + void api_show_powerflow_result(unsigned int toolkit_index) { STEPS& toolkit = get_toolkit(toolkit_index); diff --git a/code/steps/source/basic/utility.cpp b/code/steps/source/basic/utility.cpp index d4b84493..a4b4bfd1 100644 --- a/code/steps/source/basic/utility.cpp +++ b/code/steps/source/basic/utility.cpp @@ -170,6 +170,11 @@ double hz2radps(double f) return DOUBLE_PI*f; } +bool is_nan(double& x) +{ + return x!=x; +} + double round_angle_in_rad_to_PI(double angle) { double abs_angle = fabs(angle); @@ -1320,7 +1325,7 @@ vector > > get_all_columns_of_inverse_matrix(STEPS_COMPLE int n2 = n+n; vector > > Z; - for(unsigned int j=0; j I; I.reserve(n2); diff --git a/code/steps/source/toolkit/powerflow_solver/powerflow_solver.cpp b/code/steps/source/toolkit/powerflow_solver/powerflow_solver.cpp index 541f40e5..cd481509 100644 --- a/code/steps/source/toolkit/powerflow_solver/powerflow_solver.cpp +++ b/code/steps/source/toolkit/powerflow_solver/powerflow_solver.cpp @@ -222,6 +222,7 @@ void POWERFLOW_SOLVER::show_powerflow_solver_configuration() const void POWERFLOW_SOLVER::solve_with_full_Newton_Raphson_solution() { + nan_is_detected = false; POWER_SYSTEM_DATABASE& psdb = toolkit->get_power_system_database(); if(psdb.get_bus_count()!=0) { @@ -233,7 +234,7 @@ void POWERFLOW_SOLVER::solve_with_full_Newton_Raphson_solution() NETWORK_MATRIX& network_matrix = get_network_matrix(); - double max_P_mismatch_in_MW, max_Q_mismatch_in_MW; + double max_P_mismatch_in_MW, max_Q_mismatch_in_MVar; vector bus_delta_voltage_angle; network_matrix.build_network_Y_matrix(); @@ -251,7 +252,7 @@ void POWERFLOW_SOLVER::solve_with_full_Newton_Raphson_solution() calculate_raw_bus_power_mismatch(); max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); + max_Q_mismatch_in_MVar = get_maximum_reactive_power_mismatch_in_MVar(); bool bus_type_changed = false; if(get_var_limit_check_logic()==true) @@ -267,49 +268,60 @@ void POWERFLOW_SOLVER::solve_with_full_Newton_Raphson_solution() calculate_raw_bus_power_mismatch(); max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); + max_Q_mismatch_in_MVar = get_maximum_reactive_power_mismatch_in_MVar(); } - if(max_P_mismatch_in_MW < get_allowed_max_active_power_imbalance_in_MW() and - max_Q_mismatch_in_MW < get_allowed_max_reactive_power_imbalance_in_MVar()) + if(is_nan(max_P_mismatch_in_MW) or is_nan(max_Q_mismatch_in_MVar)) { - set_convergence_flag(true); - - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow converged within %u iterations.",iteration_count); + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "NAN is detected when checking powerflow convergence. No further powerflow solution will be attempted."); toolkit->show_information_with_leading_time_stamp(buffer); + set_convergence_flag(false); + nan_is_detected = true; break; } else - set_convergence_flag(false); - - if(get_iteration_count()>=get_max_iteration()) { - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow failed to converge within %u iterations.",get_max_iteration()); - toolkit->show_information_with_leading_time_stamp(buffer); - break; - } + if(max_P_mismatch_in_MW < get_allowed_max_active_power_imbalance_in_MW() and + max_Q_mismatch_in_MVar < get_allowed_max_reactive_power_imbalance_in_MVar()) + { + set_convergence_flag(true); - build_bus_power_mismatch_vector_for_coupled_solution(); + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow converged within %u iterations.",iteration_count); + toolkit->show_information_with_leading_time_stamp(buffer); + break; + } + else + set_convergence_flag(false); - jacobian_builder->update_seprate_jacobians(); + if(get_iteration_count()>=get_max_iteration()) + { + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow failed to converge within %u iterations.",get_max_iteration()); + toolkit->show_information_with_leading_time_stamp(buffer); + break; + } - jacobian = jacobian_builder->get_full_coupled_jacobian_with_P_and_Q_equation_internal_buses(internal_P_equation_buses, - internal_Q_equation_buses); + build_bus_power_mismatch_vector_for_coupled_solution(); - if(get_export_jacobian_matrix_step_by_step_logic()==true) - { - jacobian_builder->save_jacobian_matrix_to_file("Jacobian-NR-Iter-"+num2str(get_iteration_count())+".csv"); - } - bus_delta_voltage_angle = S_mismatch/jacobian; - if(jacobian.is_lu_factorization_successful()) - { - update_bus_voltage_and_angle(bus_delta_voltage_angle); - ++iteration_count; - } - else - { - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "No further powerflow solution will be attempted since LU factorization of N-R Jacobian matrix is failed."); - toolkit->show_information_with_leading_time_stamp(buffer); - break; + jacobian_builder->update_seprate_jacobians(); + + jacobian = jacobian_builder->get_full_coupled_jacobian_with_P_and_Q_equation_internal_buses(internal_P_equation_buses, + internal_Q_equation_buses); + + if(get_export_jacobian_matrix_step_by_step_logic()==true) + { + jacobian_builder->save_jacobian_matrix_to_file("Jacobian-NR-Iter-"+num2str(get_iteration_count())+".csv"); + } + bus_delta_voltage_angle = S_mismatch/jacobian; + if(jacobian.is_lu_factorization_successful()) + { + update_bus_voltage_and_angle(bus_delta_voltage_angle); + ++iteration_count; + } + else + { + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "No further powerflow solution will be attempted since LU factorization of N-R Jacobian matrix is failed."); + toolkit->show_information_with_leading_time_stamp(buffer); + break; + } } } //show_powerflow_result(); @@ -318,8 +330,8 @@ void POWERFLOW_SOLVER::solve_with_full_Newton_Raphson_solution() void POWERFLOW_SOLVER::solve_with_fast_decoupled_solution() { + nan_is_detected = false; POWER_SYSTEM_DATABASE& psdb = toolkit->get_power_system_database(); - ostringstream osstream; if(psdb.get_bus_count()!=0) { @@ -331,7 +343,7 @@ void POWERFLOW_SOLVER::solve_with_fast_decoupled_solution() NETWORK_MATRIX& network_matrix = get_network_matrix(); - double max_P_mismatch_in_MW, max_Q_mismatch_in_MW; + double max_P_mismatch_in_MW, max_Q_mismatch_in_MVar; vector bus_delta_voltage, bus_delta_angle; network_matrix.build_network_Y_matrix(); @@ -360,7 +372,7 @@ void POWERFLOW_SOLVER::solve_with_fast_decoupled_solution() calculate_raw_bus_power_mismatch(); max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); + max_Q_mismatch_in_MVar = get_maximum_reactive_power_mismatch_in_MVar(); bool bus_type_changed = false; if(get_var_limit_check_logic()==true) @@ -379,7 +391,7 @@ void POWERFLOW_SOLVER::solve_with_fast_decoupled_solution() calculate_raw_bus_power_mismatch(); max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); + max_Q_mismatch_in_MVar = get_maximum_reactive_power_mismatch_in_MVar(); //continue; } @@ -389,88 +401,99 @@ void POWERFLOW_SOLVER::solve_with_fast_decoupled_solution() BQ.save_matrix_to_file("Jacobian-BQ-PQ-Iter-"+num2str(get_iteration_count())+".csv"); }*/ - if(max_P_mismatch_in_MW < get_allowed_max_active_power_imbalance_in_MW() and - max_Q_mismatch_in_MW < get_allowed_max_reactive_power_imbalance_in_MVar()) + if(is_nan(max_P_mismatch_in_MW) or is_nan(max_Q_mismatch_in_MVar)) { - set_convergence_flag(true); - - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow converged within %u iterations.",iteration_count); + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "NAN is detected when checking powerflow convergence. No further powerflow solution will be attempted."); toolkit->show_information_with_leading_time_stamp(buffer); + set_convergence_flag(false); + nan_is_detected = true; break; } else - set_convergence_flag(false); - - if(get_iteration_count()>=get_max_iteration()) { - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow failed to converge within %u iterations.",get_max_iteration()); - toolkit->show_information_with_leading_time_stamp(buffer); - break; - } + if(max_P_mismatch_in_MW < get_allowed_max_active_power_imbalance_in_MW() and + max_Q_mismatch_in_MVar < get_allowed_max_reactive_power_imbalance_in_MVar()) + { + set_convergence_flag(true); - build_bus_P_power_mismatch_vector_for_decoupled_solution(); - unsigned int n = internal_P_equation_buses.size(); + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow converged within %u iterations.",iteration_count); + toolkit->show_information_with_leading_time_stamp(buffer); + break; + } + else + set_convergence_flag(false); - #ifdef ENABLE_OPENMP_FOR_POWERFLOW_SOLVER - set_openmp_number_of_threads(toolkit->get_thread_number()); - #pragma omp parallel for schedule(static) - #endif // ENABLE_OPENMP_FOR_POWERFLOW_SOLVER - for(unsigned int i=0; ishow_information_with_leading_time_stamp(buffer); - break; - } - //BP.report_brief(); - //for(unsigned int i=0; i=get_max_iteration()) + { + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Powerflow failed to converge within %u iterations.",get_max_iteration()); + toolkit->show_information_with_leading_time_stamp(buffer); + break; + } - try_to_solve_dc_system_steady_state(); - calculate_raw_bus_power_mismatch(); + build_bus_P_power_mismatch_vector_for_decoupled_solution(); + unsigned int n = internal_P_equation_buses.size(); - max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); - - build_bus_Q_power_mismatch_vector_for_decoupled_solution(); - n = internal_Q_equation_buses.size(); - #ifdef ENABLE_OPENMP_FOR_POWERFLOW_SOLVER - set_openmp_number_of_threads(toolkit->get_thread_number()); - #pragma omp parallel for schedule(static) - #endif // ENABLE_OPENMP_FOR_POWERFLOW_SOLVER - for(unsigned int i=0; ishow_information_with_leading_time_stamp(buffer); - break; - } + #ifdef ENABLE_OPENMP_FOR_POWERFLOW_SOLVER + set_openmp_number_of_threads(toolkit->get_thread_number()); + #pragma omp parallel for schedule(static) + #endif // ENABLE_OPENMP_FOR_POWERFLOW_SOLVER + for(unsigned int i=0; ishow_information_with_leading_time_stamp(buffer); + break; + } + //BP.report_brief(); + //for(unsigned int i=0; iget_thread_number()); + #pragma omp parallel for schedule(static) + #endif // ENABLE_OPENMP_FOR_POWERFLOW_SOLVER + for(unsigned int i=0; ishow_information_with_leading_time_stamp(buffer); + break; + } - update_bus_voltage(bus_delta_voltage); + update_bus_voltage(bus_delta_voltage); - iteration_count ++; + iteration_count ++; + } } //show_powerflow_result(); } @@ -1028,17 +1051,30 @@ bool POWERFLOW_SOLVER::is_converged() calculate_raw_bus_power_mismatch(); double max_P_mismatch_in_MW = get_maximum_active_power_mismatch_in_MW(); - double max_Q_mismatch_in_MW = get_maximum_reactive_power_mismatch_in_MVar(); + double max_Q_mismatch_in_MVar = get_maximum_reactive_power_mismatch_in_MVar(); - if(max_P_mismatch_in_MWshow_information_with_leading_time_stamp(osstream); return false; + } + else + { + if(max_P_mismatch_in_MWshow_information_with_leading_time_stamp(buffer); @@ -1527,16 +1573,26 @@ double POWERFLOW_SOLVER::get_maximum_reactive_power_mismatch_in_MVar() const double max_Q_error_in_pu = 0.0, max_Q_error_in_MVar; unsigned int max_Q_error_physical_bus = 0; + double bus_Q_error = 0; for(unsigned int i=0; i!=nQ; ++i) { internal_bus = internal_Q_equation_buses[i]; - if(fabs(bus_power[internal_bus].imag()) < max_Q_error_in_pu) - continue; + bus_Q_error = fabs(bus_power[internal_bus].imag()); + if(not std::isnan(bus_Q_error)) + { + if(bus_Q_error < max_Q_error_in_pu) + continue; + else + { + physical_bus = network_matrix.get_physical_bus_number_of_internal_bus(internal_bus); + max_Q_error_in_pu = bus_Q_error; + max_Q_error_physical_bus = physical_bus; + } + } else { - physical_bus = network_matrix.get_physical_bus_number_of_internal_bus(internal_bus); - max_Q_error_in_pu = fabs(bus_power[internal_bus].imag()); - max_Q_error_physical_bus = physical_bus; + max_Q_error_in_pu = bus_Q_error; + break; } } max_Q_error_in_MVar = max_Q_error_in_pu*psdb.get_system_base_power_in_MVA(); @@ -1544,7 +1600,7 @@ double POWERFLOW_SOLVER::get_maximum_reactive_power_mismatch_in_MVar() const string maxbusname = psdb.bus_number2bus_name(max_Q_error_physical_bus); char buffer[STEPS_MAX_TEMP_CHAR_BUFFER_SIZE]; - snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Maximum reactive power mismatch found: %10.6fMVar at bus %u [%s].", + snprintf(buffer, STEPS_MAX_TEMP_CHAR_BUFFER_SIZE, "Maximum reactive power mismatch found: %10.6f MVar at bus %u [%s].", max_Q_error_in_MVar,max_Q_error_physical_bus, maxbusname.c_str()); toolkit->show_information_with_leading_time_stamp(buffer); @@ -2426,6 +2482,7 @@ void POWERFLOW_SOLVER::update_bus_voltage_and_angle(vector& update) void POWERFLOW_SOLVER::update_bus_voltage(vector& update) { + POWER_SYSTEM_DATABASE& psdb = toolkit->get_power_system_database(); ostringstream osstream; NETWORK_MATRIX& network_matrix = get_network_matrix(); @@ -2445,7 +2502,7 @@ void POWERFLOW_SOLVER::update_bus_voltage(vector& update) max_delta_v_bus = network_matrix.get_physical_bus_number_of_internal_bus(internal_bus); } } - osstream<<"Maximum voltage change is: "<show_information_with_leading_time_stamp(osstream); if(max_dv>limit) @@ -2523,6 +2580,7 @@ void POWERFLOW_SOLVER::update_bus_voltage(vector& update) void POWERFLOW_SOLVER::update_bus_angle(vector& update) { + POWER_SYSTEM_DATABASE& psdb = toolkit->get_power_system_database(); ostringstream osstream; NETWORK_MATRIX& network_matrix = get_network_matrix(); @@ -2542,7 +2600,7 @@ void POWERFLOW_SOLVER::update_bus_angle(vector& update) max_delta_angle_bus = network_matrix.get_physical_bus_number_of_internal_bus(internal_bus); } } - osstream<<"Maximum angle change is: "<show_information_with_leading_time_stamp(osstream); if(max_dv>limit) diff --git a/python/stepspy-current/README.md b/python/stepspy-current/README.md index ba823c99..d59f5e4e 100644 --- a/python/stepspy-current/README.md +++ b/python/stepspy-current/README.md @@ -22,6 +22,7 @@ stepspy is a Python module of Simulation Toolkit for Electrical Power Systems (S STEPS is a simulation toolkit for powerflow, short circuit and dynamic simulation of large-scale power systems. It provides detailed models of bus, line, transformer, HVDC, VSC-HVDC, generator, wind turbine generator, photovoltaic unit, load, and fixed shunt. For more information about STEPS, see (https://gitee.com/lichgang/steps/ or https://github.com/changgang/steps). ## Release Note +- 2.1.0. Nov. 2, 2023. Add API to check if NAN is detected in powerflow solution: is_nan_detected_in_powerflow_soulution, and get_powerflow_convergence_status - 2.0.0. Oct. 16, 2023. Major version. Add short circuit analysis functions. - 1.6.2. Oct. 13, 2023. Add option to select libSTEPS version when calling STEPS(). - 1.6.1. Sep. 26, 2022. Fix bug in set_bus_capacity. diff --git a/python/stepspy-current/setup.py b/python/stepspy-current/setup.py index b096c58a..d1cc9cef 100644 --- a/python/stepspy-current/setup.py +++ b/python/stepspy-current/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="stepspy", - version="2.0.0", + version="2.1.0", author="Changgang Li", author_email="lichgang@sdu.edu.cn", description="Python module of Simulation Toolkit for Electrical Power Systems", diff --git a/python/stepspy-current/stepspy/libsteps/pylibsteps.py b/python/stepspy-current/stepspy/libsteps/pylibsteps.py index 744bd6e6..6018a0b4 100644 --- a/python/stepspy-current/stepspy/libsteps/pylibsteps.py +++ b/python/stepspy-current/stepspy/libsteps/pylibsteps.py @@ -627,6 +627,8 @@ def load_library(libsteps_file): 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_is_nan_detected_in_powerflow_solution.restype = (c_bool) + libsteps.api_is_nan_detected_in_powerflow_solution.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 diff --git a/python/stepspy-current/stepspy/stepspy.py b/python/stepspy-current/stepspy/stepspy.py index 0ed9b7ef..5361e9b2 100644 --- a/python/stepspy-current/stepspy/stepspy.py +++ b/python/stepspy-current/stepspy/stepspy.py @@ -3891,6 +3891,36 @@ def is_powerflow_converged(self): """ global STEPS_LIB return STEPS_LIB.api_is_powerflow_converged(self.toolkit_index) + + def is_nan_detected_in_powerflow_soulution(self): + """ + Check if NAN is detected in powerflow solution. + Args: N/A + Rets: + (1) Boolean value. True for NAN detected, False for not detected. + Example: N/A + """ + global STEPS_LIB + return STEPS_LIB.api_is_nan_detected_in_powerflow_solution(self.toolkit_index) + + def get_powerflow_convergence_status(self): + """ + Get powerflow convergence status string + Args: N/A + Rets: + (1)String value. "CONVERGED" for converged, "DIVERGED" for not converged, "NANFAILED" for NAN detected. + Example: N/A + """ + global STEPS_LIB + flag_converged = self.is_powerflow_converged() + flag_nan_detected = self.is_nan_detected_in_powerflow_soulution() + if flag_converged: + return "CONVERGED" + elif not flag_nan_detected: + return "DIVERGED" + else: + return "NANFAILED" + def get_powerflow_loss(self): """