00001
00002
00003
00004
00005 #ifndef _SOLVER_NR
00006 #define _SOLVER_NR
00007
00008 #include "complex.h"
00009 #include "object.h"
00010
00011 typedef struct {
00012 int type;
00013 unsigned char phases;
00014 unsigned char origphases;
00015 set *busflag;
00016 complex *V;
00017 complex *S;
00018 complex *Y;
00019 complex *I;
00020 complex *prerot_I;
00021 complex *S_dy;
00022 complex *Y_dy;
00023 complex *I_dy;
00024 complex *full_Y;
00025 complex *full_Y_all;
00026 complex *full_Y_load;
00027 complex *extra_var;
00028 complex *house_var;
00029 int *Link_Table;
00030 unsigned int Link_Table_Size;
00031 double PL[3];
00032 double QL[3];
00033 bool *dynamics_enabled;
00034 bool swing_functions_enabled;
00035 complex *PGenTotal;
00036 complex *DynCurrent;
00037 complex *BusHistTerm;
00038 complex *BusSatTerm;
00039 double volt_base;
00040 double mva_base;
00041 double Jacob_A[3];
00042 double Jacob_B[3];
00043 double Jacob_C[3];
00044 double Jacob_D[3];
00045 unsigned int Matrix_Loc;
00046 double max_volt_error;
00047 char *name;
00048 OBJECT *obj;
00049 FUNCTIONADDR ExtraCurrentInjFunc;
00050 OBJECT *ExtraCurrentInjFuncObject;
00051 int island_number;
00052 } BUSDATA;
00053
00054 typedef struct {
00055 complex *Yfrom;
00056 complex *Yto;
00057 complex *YSfrom;
00058 complex *YSto;
00059 unsigned char phases;
00060 unsigned char origphases;
00061 unsigned char faultphases;
00062 int from;
00063 int to;
00064 int fault_link_below;
00065 enumeration *status;
00066 unsigned char lnk_type;
00067 double v_ratio;
00068 char *name;
00069 OBJECT *obj;
00070 complex *If_from;
00071 complex *If_to;
00072 FUNCTIONADDR limit_check;
00073 FUNCTIONADDR ExtraDeltaModeFunc;
00074 int island_number;
00075 } BRANCHDATA;
00076
00077 typedef struct Y_NR{
00078 int row_ind;
00079 int col_ind;
00080 double Y_value;
00081 } Y_NR;
00082
00083 typedef struct {
00084 int row_ind;
00085 int col_ind;
00086 complex Y[3][3];
00087 char size;
00088 } Bus_admit;
00089
00090 typedef struct {
00091 double *a_LU;
00092 double *rhs_LU;
00093 int *cols_LU;
00094 int *rows_LU;
00095 } NR_SOLVER_VARS;
00096
00097 typedef enum {
00098 PF_NORMAL=0,
00099 PF_DYNINIT=1,
00100 PF_DYNCALC=2
00101 } NRSOLVERMODE;
00102
00103
00104 typedef struct SP_E {
00105 struct SP_E* next;
00106 int row_ind;
00107 double value;
00108 } SP_E;
00109
00110
00111 typedef struct {
00112 SP_E** cols;
00113 SP_E* llheap;
00114 unsigned int llptr;
00115 unsigned int ncols;
00116 } SPARSE;
00117
00118 typedef struct {
00119 double *deltaI_NR;
00120 unsigned int size_offdiag_PQ;
00121 unsigned int size_diag_fixed;
00122 unsigned int total_variables;
00123 unsigned int size_diag_update;
00124 unsigned int size_Amatrix;
00125 unsigned int max_size_offdiag_PQ;
00126 unsigned int max_size_diag_fixed;
00127 unsigned int max_total_variables;
00128 unsigned int max_size_diag_update;
00129 unsigned int prev_m;
00130 unsigned int index_count;
00131 unsigned int bus_count;
00132 unsigned int indexer;
00133 bool NR_realloc_needed;
00134 Y_NR *Y_offdiag_PQ;
00135 Y_NR *Y_diag_fixed;
00136 Y_NR *Y_diag_update;
00137 SPARSE *Y_Amatrix;
00138 NR_SOLVER_VARS matrices_LU;
00139 void *LU_solver_vars;
00140 int64 iteration_count;
00141 bool new_iteration_required;
00142 bool swing_converged;
00143 bool swing_is_a_swing;
00144 bool SaturationMismatchPresent;
00145 int solver_info;
00146 int64 return_code;
00147 double max_mismatch_converge;
00148 } NR_MATRIX_CONSTRUCTION;
00149
00150 typedef struct {
00151 NR_MATRIX_CONSTRUCTION *island_matrix_values;
00152 Bus_admit *BA_diag;
00153 } NR_SOLVER_STRUCT;
00154
00155
00156 typedef struct {
00157 complex *z_matrix;
00158 int NodeRefNum;
00159 int return_code;
00160 } NR_MESHFAULT_IMPEDANCE;
00161
00162
00163
00164
00165
00166
00167
00168 int64 solver_nr(unsigned int bus_count, BUSDATA *bus, unsigned int branch_count, BRANCHDATA *branch, NR_SOLVER_STRUCT *powerflow_values, NRSOLVERMODE powerflow_type , NR_MESHFAULT_IMPEDANCE *mesh_imped_vals, bool *bad_computations);
00169 void compute_load_values(unsigned int bus_count, BUSDATA *bus, NR_SOLVER_STRUCT *powerflow_values, bool jacobian_pass, int island_number);
00170
00171
00172 STATUS NR_array_structure_free(NR_SOLVER_STRUCT *struct_of_interest,int number_of_islands);
00173 STATUS NR_array_structure_allocate(NR_SOLVER_STRUCT *struct_of_interest,int number_of_islands);
00174
00175 #endif