From 8ee3827e37901ec7962ca48648c461284c70428d Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Sat, 11 Dec 2021 07:29:56 -0800 Subject: [PATCH 1/2] Fix warnings --- module/generators/windturb_dg.cpp | 2 -- module/powerflow/fault_check.cpp | 2 +- module/powerflow/load.cpp | 5 +-- module/powerflow/node.cpp | 5 ++- module/powerflow/solver_nr.cpp | 58 +++++++++++++++---------------- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/module/generators/windturb_dg.cpp b/module/generators/windturb_dg.cpp index 7491d4a16..5692a5296 100644 --- a/module/generators/windturb_dg.cpp +++ b/module/generators/windturb_dg.cpp @@ -240,7 +240,6 @@ int windturb_dg::init(OBJECT *parent) complex tst, tst2, tst3, tst4; gld_property *temp_property_pointer; enumeration temp_enum; - bool NR_detect; switch (Turbine_Model) { case GENERIC_IND_LARGE: @@ -456,7 +455,6 @@ int windturb_dg::init(OBJECT *parent) } static complex default_line123_voltage[3], default_line1_current[3]; - size_t i; //Map phases set *phaseInfo = NULL; diff --git a/module/powerflow/fault_check.cpp b/module/powerflow/fault_check.cpp index 9bd38f365..44cbf29cf 100644 --- a/module/powerflow/fault_check.cpp +++ b/module/powerflow/fault_check.cpp @@ -2227,7 +2227,7 @@ void fault_check::search_associated_grids(unsigned int node_int, int grid_counte //Function to remove a divergent island STATUS fault_check::disable_island(int island_number) { - int index_value; + unsigned int index_value; TIMESTAMP curr_time_val_TS; double curr_time_val_DBL; FILE *FPOutput; diff --git a/module/powerflow/load.cpp b/module/powerflow/load.cpp index f6188f563..dc319e815 100644 --- a/module/powerflow/load.cpp +++ b/module/powerflow/load.cpp @@ -405,7 +405,7 @@ int load::isa(char *classname) int load::create(void) { int res = node::create(); - char index_x,index_y; + int index_x,index_y; maximum_voltage_error = 0; @@ -596,8 +596,6 @@ TIMESTAMP load::presync(TIMESTAMP t0) TIMESTAMP load::sync(TIMESTAMP t0) { - //bool all_three_phases; - bool fault_mode; TIMESTAMP result; //Check for straggler nodes - fix so segfaults don't occur @@ -3475,7 +3473,6 @@ int load::notify(int update_mode, PROPERTY *prop, char *value) SIMULATIONMODE load::inter_deltaupdate_load(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val,bool interupdate_pos) { OBJECT *hdr = THISOBJECTHDR; - bool fault_mode; double deltat, deltatimedbl; STATUS return_status_val; diff --git a/module/powerflow/node.cpp b/module/powerflow/node.cpp index f554e559d..df86e259f 100644 --- a/module/powerflow/node.cpp +++ b/module/powerflow/node.cpp @@ -3500,9 +3500,8 @@ int node::NR_populate(void) { //Object header for names OBJECT *me = THISOBJECTHDR; - node *temp_par_node = NULL; gld_property *temp_bool_property; - gld_wlock *test_rlock; + gld_wlock test_rlock(me); bool temp_bool_val; //Lock the SWING for global operations @@ -3568,7 +3567,7 @@ int node::NR_populate(void) } //Pull the value - temp_bool_property->getp(temp_bool_val,*test_rlock); + temp_bool_property->getp(temp_bool_val,test_rlock); //Clear the property delete temp_bool_property; diff --git a/module/powerflow/solver_nr.cpp b/module/powerflow/solver_nr.cpp index da3657007..513c96ab1 100644 --- a/module/powerflow/solver_nr.cpp +++ b/module/powerflow/solver_nr.cpp @@ -165,9 +165,9 @@ void sparse_reset(SPARSE* sm, int ncols) } //Add in new elements to the sparse notation -inline void sparse_add(SPARSE* sm, int row, int col, double value, BUSDATA *bus_values, unsigned int bus_values_count, NR_SOLVER_STRUCT *powerflow_information, int island_number_curr) +inline void sparse_add(SPARSE* sm, int row, int col, double value, BUSDATA *bus_values, int bus_values_count, NR_SOLVER_STRUCT *powerflow_information, int island_number_curr) { - unsigned int bus_index_val, bus_start_val, bus_end_val; + int bus_index_val, bus_start_val, bus_end_val; bool found_proper_bus_val; SP_E* insertion_point = sm->cols[col]; @@ -390,8 +390,8 @@ int64 solver_nr(unsigned int bus_count, //Miscellaneous index variable unsigned int indexer, tempa, tempb, jindexer, kindexer; - char jindex, kindex; - char temp_index, temp_index_b; + int jindex, kindex; + int temp_index, temp_index_b; unsigned int temp_index_c; //Working matrix for admittance collapsing/determinations @@ -408,7 +408,7 @@ int64 solver_nr(unsigned int bus_count, complex aval, avalsq; //Temporary size variable - size_t temp_size, temp_size_b, temp_size_c; + int temp_size, temp_size_b, temp_size_c; //Temporary admittance variables complex Temp_Ad_A[3][3]; @@ -1049,9 +1049,9 @@ int64 solver_nr(unsigned int bus_count, } //Store the admittance values into the BA_diag matrix structure - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { - for (kindex=0; kindex<(size_t)powerflow_values->BA_diag[indexer].size; kindex++) //Store values - assume square matrix - don't bother parsing what doesn't exist. + for ( kindex = 0; kindex < powerflow_values->BA_diag[indexer].size ; kindex++ ) //Store values - assume square matrix - don't bother parsing what doesn't exist. { powerflow_values->BA_diag[indexer].Y[jindex][kindex] = tempY[jindex][kindex];// Store the self admittance terms. } @@ -1060,9 +1060,9 @@ int64 solver_nr(unsigned int bus_count, //Copy values into node-specific link (if needed) if (bus[indexer].full_Y_all != NULL) { - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { - for (kindex=0; kindex<(size_t)powerflow_values->BA_diag[indexer].size; kindex++) //Store values - assume square matrix - don't bother parsing what doesn't exist. + for ( kindex = 0 ; kindex < powerflow_values->BA_diag[indexer].size ; kindex++ ) //Store values - assume square matrix - don't bother parsing what doesn't exist. { bus[indexer].full_Y_all[jindex*3+kindex] = tempY[jindex][kindex];// Store the self admittance terms. } @@ -1929,12 +1929,12 @@ int64 solver_nr(unsigned int bus_count, } }//end line switch/case - if ((int)temp_size_c==-99) + if ( temp_size_c == -99 ) { continue; //Next iteration of branch loop } - if ((int)temp_size_c==-1) //Make sure it is right + if ( temp_size_c == -1 ) //Make sure it is right { GL_THROW("NR: A line's phase was flagged as not full three-phase, but wasn't: (%s) %u %u %u %u", branch[jindexer].name, branch[jindexer].phases, branch[jindexer].origphases, phase_worka, phase_workb); @@ -2244,7 +2244,7 @@ int64 solver_nr(unsigned int bus_count, }//End switch/case for to //Make sure everything was set before proceeding - if (((int)temp_index==-1) || ((int)temp_index_b==-1) || ((int)temp_size==-1) || ((int)temp_size_b==-1) || ((int)temp_size_c==-1)) + if ( (temp_index==-1) || (temp_index_b==-1) || (temp_size==-1) || (temp_size_b==-1) || (temp_size_c==-1)) { GL_THROW("NR: Failure to construct single/double phase line indices"); /* TROUBLESHOOT @@ -2255,9 +2255,9 @@ int64 solver_nr(unsigned int bus_count, if (Full_Mat_A) //From side is a full ABC and we have AC { - for (jindex=0; jindexBA_diag[jindexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[jindexer].size ; jindex++ ) { - for (kindex=0; kindex<(size_t)powerflow_values->BA_diag[jindexer].size; kindex++) + for ( kindex = 0 ; kindex < powerflow_values->BA_diag[jindexer].size ; kindex++ ) { if ((powerflow_values->BA_diag[jindexer].Y[jindex][kindex]).Im() != 0 && bus[jindexer].type != 1 && jindex!=kindex) { @@ -2700,7 +2700,7 @@ int64 solver_nr(unsigned int bus_count, } }//End PF_DYNINIT and SWING is still the same - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) // rows - for specific phase that exists + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) // rows - for specific phase that exists { tempIcalcReal = tempIcalcImag = 0; @@ -2934,7 +2934,7 @@ int64 solver_nr(unsigned int bus_count, tempPbus = - bus[indexer].PL[jindex]; //Copy load amounts in tempQbus = - bus[indexer].QL[jindex]; - for (kindex=0; kindex<(size_t)powerflow_values->BA_diag[indexer].size; kindex++) //cols - Still only for specified phases + for ( kindex = 0 ; kindex < powerflow_values->BA_diag[indexer].size ; kindex++ ) //cols - Still only for specified phases { //Determine our indices, based on phase information temp_index = -1; @@ -3703,14 +3703,14 @@ int64 solver_nr(unsigned int bus_count, indexer = 0; //Rest positional counter - for (jindexer=0; jindexer 1) && (bus[jindexer].swing_functions_enabled == true)) //Swing bus - and we aren't ignoring it { - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[jindexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[jindexer].size ; jindex++ ) { powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].row_ind = 2*bus[jindexer].Matrix_Loc + jindex; powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].col_ind = powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].row_ind; @@ -3736,7 +3736,7 @@ int64 solver_nr(unsigned int bus_count, if ((bus[jindexer].type == 0) || ((bus[jindexer].type > 1) && bus[jindexer].swing_functions_enabled == false)) //Only do on PQ (or SWING masquerading as PQ) { - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[jindexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[jindexer].size ; jindex++ ) { powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].row_ind = 2*bus[jindexer].Matrix_Loc + jindex; powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].col_ind = powerflow_values->island_matrix_values[island_loop_index].Y_diag_update[indexer].row_ind; @@ -3971,7 +3971,7 @@ int64 solver_nr(unsigned int bus_count, m = 2*powerflow_values->island_matrix_values[island_loop_index].total_variables; //Print the size - should be the matrix size, but put here for ease of use - fprintf(FPoutVal,"Matrix RHS Information - %lld elements\n",m); + fprintf(FPoutVal,"Matrix RHS Information - %d elements\n",m); //Print a header - row information isn't really needed, but include, just for ease of viewing fprintf(FPoutVal,"RHS Information - row, value\n"); @@ -3979,7 +3979,7 @@ int64 solver_nr(unsigned int bus_count, //Loop through and output the RHS values for (jindexer=0; jindexerisland_matrix_values[island_loop_index].deltaI_NR[jindexer]); + fprintf(FPoutVal,"%d,%f\n",jindexer,powerflow_values->island_matrix_values[island_loop_index].deltaI_NR[jindexer]); }//End output RHS //Print an extra line, just for spacing for ALL/PERCALL @@ -4577,7 +4577,7 @@ int64 solver_nr(unsigned int bus_count, }//end split phase update else //Not split phase { - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) //parse through the phases + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) //parse through the phases { switch(bus[indexer].phases & 0x07) { case 0x01: //C @@ -5092,7 +5092,7 @@ void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT complex adjust_temp_nominal_voltage[6], adjusted_constant_current[6]; complex delta_current[3], voltageDel[3], undeltacurr[3]; complex temp_current[3], temp_store[3]; - char jindex, temp_index, temp_index_b; + int jindex, temp_index, temp_index_b; STATUS temp_status; //Loop through the buses @@ -5361,7 +5361,7 @@ void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT temp_index = -1; temp_index_b = -1; - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { switch(bus[indexer].phases & 0x07) { case 0x01: //C @@ -5750,7 +5750,7 @@ void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT undeltacurr[0] = undeltacurr[1] = undeltacurr[2] = complex(0.0,0.0); //Zero it } - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { switch(bus[indexer].phases & 0x07) { case 0x01: //C @@ -6132,7 +6132,7 @@ void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT temp_index = -1; temp_index_b = -1; - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { switch(bus[indexer].phases & 0x07) { case 0x01: //C @@ -6246,7 +6246,7 @@ void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT temp_index = -1; temp_index_b = -1; - for (jindex=0; jindex<(size_t)powerflow_values->BA_diag[indexer].size; jindex++) + for ( jindex = 0 ; jindex < powerflow_values->BA_diag[indexer].size ; jindex++ ) { switch(bus[indexer].phases & 0x07) { case 0x01: //C From 1e5b2509aaf9d58e1f94e601b474892e0d83a8ec Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Sat, 11 Dec 2021 07:41:44 -0800 Subject: [PATCH 2/2] Update node.cpp --- module/powerflow/node.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/powerflow/node.cpp b/module/powerflow/node.cpp index df86e259f..f9fb5249b 100644 --- a/module/powerflow/node.cpp +++ b/module/powerflow/node.cpp @@ -3501,7 +3501,6 @@ int node::NR_populate(void) //Object header for names OBJECT *me = THISOBJECTHDR; gld_property *temp_bool_property; - gld_wlock test_rlock(me); bool temp_bool_val; //Lock the SWING for global operations @@ -3567,7 +3566,7 @@ int node::NR_populate(void) } //Pull the value - temp_bool_property->getp(temp_bool_val,test_rlock); + temp_bool_property->getp(temp_bool_val); //Clear the property delete temp_bool_property;