Skip to content

Commit

Permalink
fix bug in SPARSE_MATRIX_CSPARSE introduced in +-*/ operation. Linear…
Browse files Browse the repository at this point in the history
…ization of generator device is achieved but need tests.
  • Loading branch information
changgang committed Mar 19, 2024
1 parent 374143f commit 3f864d1
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 42 deletions.
26 changes: 14 additions & 12 deletions code/steps/STEPS.depend
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"header/basic/sparse_matrix_csparse.h"
"header/basic/complex_sparse_matrix_csparse.h"

1710130550 d:\steps\code\steps\header\basic\sparse_matrix_csparse.h
1710811274 d:\steps\code\steps\header\basic\sparse_matrix_csparse.h
"cs.h"
<vector>
<ctime>
Expand Down Expand Up @@ -197,7 +197,7 @@
"header/block/first_order_block.h"
"header/block/saturation_block.h"

1710078187 d:\steps\code\steps\header\model\sg_models\sg_model.h
1710835120 d:\steps\code\steps\header\model\sg_models\sg_model.h
"header/model/model.h"
"header/device/bus.h"
"header/basic/sparse_matrix_define.h"
Expand Down Expand Up @@ -3012,7 +3012,7 @@
<fstream>
<ctime>

1664187911 source:d:\steps\code\steps\source\basic\complex_sparse_matrix_test.cpp
1710830645 source:d:\steps\code\steps\source\basic\complex_sparse_matrix_test.cpp
"header/basic/test_macro.h"
"header/basic/complex_sparse_matrix_test.h"
"header/basic/utility.h"
Expand Down Expand Up @@ -3216,10 +3216,11 @@
<iostream>
<fstream>

1710130955 source:d:\steps\code\steps\source\basic\sparse_matrix_csparse.cpp
1710835537 source:d:\steps\code\steps\source\basic\sparse_matrix_csparse.cpp
"header/basic/sparse_matrix_csparse.h"
"header/basic/constants.h"
"header/basic/utility.h"
"header/steps_namespace.h"
<string>
<istream>
<ostream>
Expand Down Expand Up @@ -3639,7 +3640,7 @@
<cstring>
<cstdio>

1710744553 source:d:\steps\code\steps\source\block\first_order_block.cpp
1710830645 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"
Expand All @@ -3656,7 +3657,7 @@
<cstring>
<cstdio>

1710744501 source:d:\steps\code\steps\source\block\integral_block.cpp
1710830645 source:d:\steps\code\steps\source\block\integral_block.cpp
"header/block/integral_block.h"
"header/basic/utility.h"
"header/steps_namespace.h"
Expand Down Expand Up @@ -4101,7 +4102,7 @@
<cstdio>
<cstdlib>

1710745061 source:d:\steps\code\steps\source\device\generator.cpp
1710834640 source:d:\steps\code\steps\source\device\generator.cpp
"header/device/generator.h"
"header/basic/utility.h"
"header/STEPS.h"
Expand Down Expand Up @@ -5280,7 +5281,7 @@
"header/basic/utility.h"
"header/steps_namespace.h"

1710744892 source:d:\steps\code\steps\source\model\sg_models\exciter_model\sexs.cpp
1710834390 source:d:\steps\code\steps\source\model\sg_models\exciter_model\sexs.cpp
"header/model/sg_models/exciter_model/SEXS.h"
"header/basic/utility.h"
"header/STEPS.h"
Expand All @@ -5294,11 +5295,12 @@
"header/basic/utility.h"
"header/steps_namespace.h"

1710078665 source:d:\steps\code\steps\source\model\sg_models\sg_model.cpp
1710835240 source:d:\steps\code\steps\source\model\sg_models\sg_model.cpp
"header/model/sg_models/sg_model.h"
"header/basic/utility.h"
"header/power_system_database.h"
"header/STEPS.h"
<iostream>

1634637238 source:d:\steps\code\steps\source\model\sg_models\sg_model_test.cpp
"header/basic/test_macro.h"
Expand Down Expand Up @@ -5474,7 +5476,7 @@
<cstdio>
<cmath>

1710744854 source:d:\steps\code\steps\source\model\sg_models\sync_generator_model\gensal.cpp
1710835232 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"
Expand Down Expand Up @@ -6065,7 +6067,7 @@
"header/steps_namespace.h"
<cstdio>

1710227581 source:d:\steps\code\steps\source\network\network_matrix.cpp
1710830603 source:d:\steps\code\steps\source\network\network_matrix.cpp
"header/network/network_matrix.h"
"header/basic/utility.h"
"header/STEPS.h"
Expand Down Expand Up @@ -6554,7 +6556,7 @@
"header/STEPS.h"
<iostream>

1710744074 source:d:\steps\code\steps\main_small_signal_analysis.cpp
1710834851 source:d:\steps\code\steps\main_small_signal_analysis.cpp
<istream>
<iostream>
"header/power_system_database.h"
Expand Down
2 changes: 2 additions & 0 deletions code/steps/header/basic/sparse_matrix_csparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class SPARSE_MATRIX_CSPARSE : public SPARSE_MATRIX
double *LU_workspace;
double* bb;
unsigned int bb_size;

bool add_entry_callled;
};


Expand Down
1 change: 1 addition & 0 deletions code/steps/header/model/sg_models/sg_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SG_MODEL : public MODEL

void initialize_ABCD_matrix_for_linearization();
void build_linearized_matrix_ABCD_with_basic_ABCD_and_EFGH(vector<STEPS_SPARSE_MATRIX*> matrix);
void show_linearized_matrix_ABCD();
STEPS_SPARSE_MATRIX get_linearized_matrix_variable(char var) const;
STEPS_SPARSE_MATRIX get_linearized_matrix_A() const;
STEPS_SPARSE_MATRIX get_linearized_matrix_B() const;
Expand Down
10 changes: 4 additions & 6 deletions code/steps/main_small_signal_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ using namespace std;
int main()
{
default_toolkit.disable_use_steps_fast_math_logic();
default_toolkit.open_log_file("ssa-ieee9.log");
//default_toolkit.enable_detailed_log();

ostringstream osstream;

Expand All @@ -23,7 +25,6 @@ int main()
PSSE_IMEXPORTER importer(default_toolkit);

importer.load_powerflow_data("../../../bench/IEEE9.raw");
cout<<"Done loading powerflow file"<<endl;

powerflow_solver.set_max_iteration(30);
powerflow_solver.set_allowed_max_active_power_imbalance_in_MW(0.00001);
Expand All @@ -37,6 +38,7 @@ int main()
powerflow_solver.save_extended_powerflow_result_to_file("9_bus.csv");

importer.load_dynamic_data("IEEE9_ssa.dyr");
psdb.check_dynamic_data();

default_toolkit.set_dynamic_simulation_time_step_in_s(0.001);
simulator.set_allowed_max_power_imbalance_in_MVA(0.01);
Expand All @@ -48,18 +50,14 @@ int main()

simulator.start(); // initialize all devices

cout<<"Done initialization"<<endl;

vector<GENERATOR*> gens = psdb.get_all_generators();
unsigned int n = gens.size();
for(unsigned int i = 0; i<n; ++i)
{
GENERATOR* gen = gens[i];
osstream<<"Show ABCD of "<<gen->get_compound_device_name();
default_toolkit.show_information_with_leading_time_stamp(osstream);

gen->build_linearized_matrix_ABCD();
}

default_toolkit.close_log_file();
return 0;
}
3 changes: 0 additions & 3 deletions code/steps/source/basic/complex_sparse_matrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,8 @@ void COMPLEX_SPARSE_MATRIX_TEST::test_transpose()

prepare_basic_matrix();

matrix.report_brief();
matrix.transpose();

matrix.report_brief();

TEST_ASSERT(matrix.get_entry_value(0,0)==complex<double>(1.0, 0.0));
TEST_ASSERT(matrix.get_entry_value(1,0)==complex<double>(0.0, 0.0));
TEST_ASSERT(matrix.get_entry_value(2,0)==complex<double>(0.0, 0.0));
Expand Down
Loading

0 comments on commit 3f864d1

Please sign in to comment.