Skip to content

Commit

Permalink
initialize adding interfaces to get linearized system variables for e…
Browse files Browse the repository at this point in the history
…ach elementary block. PID and second_order_block need further improvement since they need two states.
  • Loading branch information
changgang committed Nov 21, 2023
1 parent ccd4349 commit 722b02e
Show file tree
Hide file tree
Showing 20 changed files with 649 additions and 15 deletions.
27 changes: 14 additions & 13 deletions code/steps/STEPS.depend
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@
<vector>
<string>

1697457172 d:\steps\code\steps\header\block\block.h
1700585903 d:\steps\code\steps\header\block\block.h
"header/basic/steps_enum.h"
<vector>
<cctype>

1697457172 d:\steps\code\steps\header\basic\steps_enum.h
<iso646.h>
Expand Down Expand Up @@ -111,7 +112,7 @@
1664187911 d:\steps\code\steps\header\model\bus_frequency_model\bus_frequency_model.h
"header/block/differential_block.h"

1697457172 d:\steps\code\steps\header\block\differential_block.h
1700585564 d:\steps\code\steps\header\block\differential_block.h
"header/block/block.h"

1697457172 d:\steps\code\steps\header\device\generator.h
Expand Down Expand Up @@ -150,7 +151,7 @@
"header/basic/sparse_matrix_define.h"
<complex>

1583938871 d:\steps\code\steps\header\block\integral_block.h
1700585694 d:\steps\code\steps\header\block\integral_block.h
"header/block/block.h"

1583938871 d:\steps\code\steps\header\block\saturation_block.h
Expand Down Expand Up @@ -1113,7 +1114,7 @@
"header/block/proportional_block.h"
"header/STEPS.h"

1583938871 d:\steps\code\steps\header\block\proportional_block.h
1700585632 d:\steps\code\steps\header\block\proportional_block.h
"header/block/block.h"

1583938871 d:\steps\code\steps\header\block\integral_block_test.h
Expand Down Expand Up @@ -1143,7 +1144,7 @@
"header/block/first_order_block.h"
"header/STEPS.h"

1697457172 d:\steps\code\steps\header\block\first_order_block.h
1700585710 d:\steps\code\steps\header\block\first_order_block.h
"header/block/block.h"
"header/block/proportional_block.h"

Expand All @@ -1156,7 +1157,7 @@
"header/block/lead_lag_block.h"
"header/STEPS.h"

1697457172 d:\steps\code\steps\header\block\lead_lag_block.h
1700585691 d:\steps\code\steps\header\block\lead_lag_block.h
"header/block/block.h"
"header/block/first_order_block.h"

Expand All @@ -1169,7 +1170,7 @@
"header/block/pid_block.h"
"header/STEPS.h"

1583938871 d:\steps\code\steps\header\block\pid_block.h
1700585652 d:\steps\code\steps\header\block\pid_block.h
"header/block/block.h"
"header/block/proportional_block.h"
"header/block/integral_block.h"
Expand All @@ -1184,7 +1185,7 @@
"header/block/pi_block.h"
"header/STEPS.h"

1583938871 d:\steps\code\steps\header\block\pi_block.h
1700585671 d:\steps\code\steps\header\block\pi_block.h
"header/block/block.h"
"header/block/pid_block.h"

Expand All @@ -1197,7 +1198,7 @@
"header/block/pd_block.h"
"header/STEPS.h"

1583938871 d:\steps\code\steps\header\block\pd_block.h
1700585680 d:\steps\code\steps\header\block\pd_block.h
"header/block/block.h"
"header/block/proportional_block.h"
"header/block/differential_block.h"
Expand All @@ -1211,7 +1212,7 @@
"header/block/second_order_block.h"
"header/STEPS.h"

1583938871 d:\steps\code\steps\header\block\second_order_block.h
1700585241 d:\steps\code\steps\header\block\second_order_block.h
"header/block/block.h"
"header/block/proportional_block.h"
"header/block/first_order_block.h"
Expand Down Expand Up @@ -2404,7 +2405,7 @@
"header/basic/utility.h"
"header/steps_namespace.h"

1690725806 source:d:\steps\code\steps\source\apis\steps_api_powerflow.cpp
1698919537 source:d:\steps\code\steps\source\apis\steps_api_powerflow.cpp
"header/apis/steps_api.h"
"header/basic/utility.h"
"header/steps_namespace.h"
Expand Down Expand Up @@ -3214,7 +3215,7 @@
<cstdio>
"header/steps_namespace.h"

1697457172 source:d:\steps\code\steps\source\block\block.cpp
1700585898 source:d:\steps\code\steps\source\block\block.cpp
"header/block/block.h"
"header/steps_namespace.h"
"header/basic/utility.h"
Expand Down Expand Up @@ -5806,7 +5807,7 @@
<cstdio>
<cmath>

1698917743 source:d:\steps\code\steps\source\toolkit\powerflow_solver\powerflow_solver.cpp
1698919454 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"
Expand Down
6 changes: 6 additions & 0 deletions code/steps/header/block/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "header/basic/steps_enum.h"
#include <vector>
#include <cctype>

using namespace std;

Expand Down Expand Up @@ -47,6 +48,9 @@ class BLOCK
static bool get_automatic_large_time_step_logic();

void check_limiter() const;

void set_state_index(unsigned int index);
unsigned int get_state_index() const;
public:
void set_state_WITH_CAUTION(double value);
protected:
Expand All @@ -64,5 +68,7 @@ class BLOCK

BLOCK_INTEGRATION_TIME_STEP_MODE integration_time_step_mode;
double old_input_of_last_main_step;

unsigned int state_index;
};
#endif // BLOCK_H
11 changes: 11 additions & 0 deletions code/steps/header/block/differential_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ class DIFFERENTIAL_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();

private:
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/first_order_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class FIRST_ORDER_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();

private:
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/integral_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ class INTEGRAL_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();
private:
void integrate();
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/lead_lag_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ class LEAD_LAG_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();
private:
void determine_block_integration_time_step_mode();
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/pd_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class PD_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();
private:
void integrate();
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/pi_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ class PI_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();

private:
Expand Down
11 changes: 11 additions & 0 deletions code/steps/header/block/pid_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ class PID_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();
private:
void integrate();
Expand Down
2 changes: 1 addition & 1 deletion code/steps/header/block/proportional_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class PROPORTIONAL_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);
virtual void check();

virtual void check();
private:
void integrate();
void update();
Expand Down
12 changes: 11 additions & 1 deletion code/steps/header/block/second_order_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ class SECOND_ORDER_BLOCK : public BLOCK

void initialize();
void run(DYNAMIC_MODE mode);
virtual void check();

double get_linearized_system_variable(char var) const;
double get_linearized_system_A() const;
double get_linearized_system_B() const;
double get_linearized_system_C() const;
double get_linearized_system_D() const;
double get_linearized_system_E() const;
double get_linearized_system_F() const;
double get_linearized_system_G() const;
double get_linearized_system_H() const;

virtual void check();
private:
void integrate();
void update();
Expand Down
12 changes: 12 additions & 0 deletions code/steps/source/block/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ BLOCK::BLOCK(STEPS& toolkit)
lower_limit = 0.0;
input = 0.0;
output = 0.0;

state_index = INDEX_NOT_EXIST;
}

BLOCK::~BLOCK()
Expand Down Expand Up @@ -164,3 +166,13 @@ void BLOCK::check_limiter() const
}
}
}

void BLOCK::set_state_index(unsigned int index)
{
state_index = index;
}

unsigned int BLOCK::get_state_index() const
{
return state_index;
}
66 changes: 66 additions & 0 deletions code/steps/source/block/differential_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,72 @@ void DIFFERENTIAL_BLOCK::update_large_time_step_mode()
update_normal_time_step_mode();
}

double DIFFERENTIAL_BLOCK::get_linearized_system_variable(char var) const
{
var = toupper(var);
switch(var)
{
case 'A':
return get_linearized_system_A();
case 'B':
return get_linearized_system_B();
case 'C':
return get_linearized_system_C();
case 'D':
return get_linearized_system_D();
case 'E':
return get_linearized_system_E();
case 'F':
return get_linearized_system_F();
case 'G':
return get_linearized_system_G();
case 'H':
return get_linearized_system_H();
default:
return 0.0;
}
}

double DIFFERENTIAL_BLOCK::get_linearized_system_A() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_B() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_C() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_D() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_E() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_F() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_G() const
{
return 0.0;
}

double DIFFERENTIAL_BLOCK::get_linearized_system_H() const
{
return 0.0;
}

void DIFFERENTIAL_BLOCK::check()
{
if(get_limiter_type() != NO_LIMITER)
Expand Down
Loading

0 comments on commit 722b02e

Please sign in to comment.