Skip to content

Commit

Permalink
v1.5.0. Add APIs to get generator-related model internal variables. A…
Browse files Browse the repository at this point in the history
…dd interfaces for linearization of sg_models. Add version code to STEPS, and add version check in stepspy. stepspy is also updated.
  • Loading branch information
changgang committed Mar 24, 2021
1 parent fdd39b3 commit 7708fa1
Show file tree
Hide file tree
Showing 113 changed files with 1,802 additions and 579 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python/*.xlsx
python/*.tex
python/*.log
python/*.md
python/*.txt
python/__*
python/stepspy-current/build/
python/stepspy-current/dist/
Expand Down
255 changes: 128 additions & 127 deletions code/steps/STEPS.depend

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions code/steps/header/apis/steps_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
extern "C" {
#endif

EXPORT_STEPS_DLL unsigned int api_get_api_major_version();
EXPORT_STEPS_DLL unsigned int api_get_api_minor_version();
EXPORT_STEPS_DLL unsigned int api_get_api_patch_version();

EXPORT_STEPS_DLL unsigned int api_get_const_INDEX_NOT_EXIST();

EXPORT_STEPS_DLL void api_set_toolkit_log_file(char* log_file, bool log_file_append_mode=false, unsigned int toolkit_index=INDEX_NOT_EXIST);
Expand Down Expand Up @@ -248,6 +252,10 @@ EXPORT_STEPS_DLL double api_get_generator_related_model_float_parameter(unsigned
EXPORT_STEPS_DLL void api_set_generator_related_model_float_parameter(unsigned int bus, char* identifier, char* model_type, char* parameter_name, double value, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL unsigned int api_get_generator_related_model_float_parameter_count(unsigned int bus, char* identifier, char* model_type, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL const char* api_get_generator_related_model_float_parameter_name(unsigned int bus, char* identifier, char* model_type, unsigned int parameter_index, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL unsigned int api_get_generator_related_model_internal_variable_count(unsigned int bus, char* identifier, char* model_type, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL double api_get_generator_related_model_internal_variable_with_name(unsigned int bus, char* identifier, char* model_type, char* variable_name, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL double api_get_generator_related_model_internal_variable_with_index(unsigned int bus, char* identifier, char* model_type, unsigned int variable_index, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL const char* api_get_generator_related_model_internal_variable_name(unsigned int bus, char* identifier, char* model_type, unsigned int variable_index, unsigned int toolkit_index=INDEX_NOT_EXIST);

EXPORT_STEPS_DLL const char* api_get_wt_generator_related_model_name(unsigned int bus, char* identifier, char* model_type, unsigned int toolkit_index=INDEX_NOT_EXIST);
EXPORT_STEPS_DLL double api_get_wt_generator_related_model_float_parameter(unsigned int bus, char* identifier, char* model_type, char* parameter_name, unsigned int toolkit_index=INDEX_NOT_EXIST);
Expand Down
11 changes: 6 additions & 5 deletions code/steps/header/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ class MODEL
bool is_model_data_exist(unsigned int var_index) const;

void clear_model_internal_variable_table();
void add_model_inernal_variable_name_and_index_pair(string var_name, unsigned int var_index);
unsigned int get_model_inernal_variable_index(string var_name) const;
string get_model_inernal_variable_name(unsigned int var_index) const;
bool is_model_inernal_variable_exist(string var_name) const;
bool is_model_inernal_variable_exist(unsigned int var_index) const;
void add_model_internal_variable_name_and_index_pair(string var_name, unsigned int var_index);
unsigned int get_model_internal_variable_count() const;
unsigned int get_model_internal_variable_index(string var_name) const;
string get_model_internal_variable_name(unsigned int var_index) const;
bool is_model_internal_variable_exist(string var_name) const;
bool is_model_internal_variable_exist(unsigned int var_index) const;

void set_device_id(DEVICE_ID did);
NONBUS_DEVICE* get_device_pointer() const;
Expand Down
1 change: 1 addition & 0 deletions code/steps/header/model/model_var_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MODEL_VAR_TABLE
virtual ~MODEL_VAR_TABLE();
void clear();
void add_variable_name_index_pair(string var_name, unsigned int var_index);
unsigned int size() const;

unsigned int operator[](const string var_name) const;
string operator[](const unsigned int var_index) const;
Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/compensator_model/COMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class COMP: public COMPENSATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const COMP& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/compensator_model/IEEEVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class IEEEVC: public COMPENSATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const IEEEVC& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/compensator_model/PSASPVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class PSASPVC: public COMPENSATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPVC& model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class COMPENSATOR_MODEL : public SG_MODEL
complex<double> get_generator_terminal_complex_current_in_pu() const;
double get_generator_terminal_voltage_in_pu();
double get_generator_terminal_current_in_pu() const;

virtual STEPS_SPARSE_MATRIX* get_linearized_matrix(string matrix_type);
virtual void set_linearized_matrix(string matrix_type, STEPS_SPARSE_MATRIX* matrix);
public: // specific compensator
virtual string get_model_name() const = 0;

Expand Down Expand Up @@ -56,6 +59,9 @@ class COMPENSATOR_MODEL : public SG_MODEL
virtual string get_dynamic_data_in_steps_format() const = 0;
private:
double ecomp;

STEPS_SPARSE_MATRIX* comp_matrix;
STEPS_SPARSE_MATRIX* comp_avr_matrix;
};

#endif // COMPENSATOR_MODEL_H
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/CSEET1.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class CSEET1: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const CSEET1& model);
double get_initial_Ve_with_Fex_function() const;
Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/CSEET2.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class CSEET2: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const CSEET2& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/IEEET1.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class IEEET1: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const IEEET1& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/PSASPE1.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class PSASPE1: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPE1& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/PSASPE13.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class PSASPE13: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPE13& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/PSASPE14.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class PSASPE14: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPE14& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/PSASPE2.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class PSASPE2: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPE2& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/exciter_model/SEXS.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class SEXS: public EXCITER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const SEXS& model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class EXCITER_MODEL : public SG_MODEL
// reference
void set_voltage_reference_in_pu(double vref);
double get_voltage_reference_in_pu() const;

virtual STEPS_SPARSE_MATRIX* get_linearized_matrix(string matrix_type);
virtual void set_linearized_matrix(string matrix_type, STEPS_SPARSE_MATRIX* matrix);
public: // specific exciter
virtual string get_model_name() const = 0;

Expand Down Expand Up @@ -58,6 +61,11 @@ class EXCITER_MODEL : public SG_MODEL
virtual string get_dynamic_data_in_steps_format() const = 0;
private:
double voltage_reference_in_pu;

STEPS_SPARSE_MATRIX* avr_matrix;
STEPS_SPARSE_MATRIX* avr_gen_matrix;
STEPS_SPARSE_MATRIX* avr_pss_matrix;
STEPS_SPARSE_MATRIX* avr_comp_matrix;
};

#endif // EXCITER_MODEL_H
5 changes: 5 additions & 0 deletions code/steps/header/model/sg_models/sg_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "header/model/model.h"
#include "header/device/bus.h"
#include "header/basic/sparse_matrix_define.h"
#include <complex>

class GENERATOR;
Expand Down Expand Up @@ -49,6 +50,10 @@ class SG_MODEL : public MODEL
virtual string get_dynamic_data_in_psse_format() const = 0;
virtual string get_dynamic_data_in_bpa_format() const = 0;
virtual string get_dynamic_data_in_steps_format() const = 0;

virtual void linearize() = 0;
virtual STEPS_SPARSE_MATRIX* get_linearized_matrix(string matrix_type) = 0;
virtual void set_linearized_matrix(string matrix_type, STEPS_SPARSE_MATRIX* matrix) = 0;
private:

};
Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/IEE2ST.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class IEE2ST : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const IEE2ST& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS1.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class PSASPS1 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS1& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class PSASPS2 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS2& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS3.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class PSASPS3 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS3& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS4.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class PSASPS4 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS4& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS5.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class PSASPS5 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS5& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS6.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class PSASPS6 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS6& model);

Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/model/sg_models/stabilizer_model/PSASPS8.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class PSASPS8 : public STABILIZER_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const PSASPS8& model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class STABILIZER_MODEL : public SG_MODEL
//
SIGNAL prepare_signal_with_signal_type_and_bus(unsigned int signal_type, unsigned int bus);
SIGNAL prepare_signal_with_signal_type_and_device_id(unsigned int signal_type, DEVICE_ID did);

virtual STEPS_SPARSE_MATRIX* get_linearized_matrix(string matrix_type);
virtual void set_linearized_matrix(string matrix_type, STEPS_SPARSE_MATRIX* matrix);
public: // specific model level
virtual string get_model_name() const = 0;

Expand Down Expand Up @@ -72,6 +75,10 @@ class STABILIZER_MODEL : public SG_MODEL
SIGNAL* get_nonconst_pointer_of_signal_at_slot(unsigned int slot);
private:
SIGNAL signal_0, signal_1, signal_2, signal_3, signal_4;

STEPS_SPARSE_MATRIX* pss_matrix;
STEPS_SPARSE_MATRIX* pss_avr_matrix;
STEPS_SPARSE_MATRIX* pss_gen_matrix;
};

#endif // STABILIZER_MODEL_H
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class GENCLS : public SYNC_GENERATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const GENCLS& model);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class GENROU : public SYNC_GENERATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
public:
// the following two functions are used to model GENROU as ideal voltage source
// with set_excitation_voltage_in_pu(), GENROU is user controllable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class GENSAL : public SYNC_GENERATOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
public:
// the following two functions are used to model GENSAL as ideal voltage source
// with set_excitation_voltage_in_pu(), GENSAL is user controllable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class SYNC_GENERATOR_MODEL : public SG_MODEL
double get_mechanical_power_in_MW() const;
double get_excitation_voltage_in_pu();
public:

virtual STEPS_SPARSE_MATRIX* get_linearized_matrix(string matrix_type);
virtual void set_linearized_matrix(string matrix_type, STEPS_SPARSE_MATRIX* matrix);
public: // specific sync generator model
virtual string get_model_name() const = 0;

Expand Down Expand Up @@ -145,6 +146,8 @@ class SYNC_GENERATOR_MODEL : public SG_MODEL
virtual string get_dynamic_data_in_psse_format() const = 0;
virtual string get_dynamic_data_in_bpa_format() const = 0;
virtual string get_dynamic_data_in_steps_format() const = 0;

virtual void linearize() = 0;
public:
// the following two functions are used to model GENCLS as ideal voltage source
// with set_excitation_voltage_in_pu(), GENCLS is user controllable.
Expand All @@ -165,6 +168,10 @@ class SYNC_GENERATOR_MODEL : public SG_MODEL
SATURATION_TYPE saturation_type;

double Pmech0, Efd0;

STEPS_SPARSE_MATRIX *gen_matrix;
STEPS_SPARSE_MATRIX *gen_avr_matrix;
STEPS_SPARSE_MATRIX *gen_gov_matrix;
};

#endif // SYNC_GENERATOR_MODEL_H
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class GAST2A : public TURBINE_GOVERNOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const GAST2A& model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class IEEEG1 : public TURBINE_GOVERNOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const IEEEG1& model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class IEEEG1SB : public TURBINE_GOVERNOR_MODEL
virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual void linearize();
private:
void copy_from_const_model(const IEEEG1SB& model);

Expand Down
Loading

0 comments on commit 7708fa1

Please sign in to comment.