00001
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <errno.h>
00014 #include <math.h>
00015 #include <iostream>
00016 using namespace std;
00017
00018 #include "regulator_configuration.h"
00019
00021
00023
00024 CLASS* regulator_configuration::oclass = NULL;
00025 CLASS* regulator_configuration::pclass = NULL;
00026
00027 regulator_configuration::regulator_configuration(MODULE *mod) : powerflow_library(mod)
00028 {
00029 if (oclass==NULL)
00030 {
00031
00032 oclass = gl_register_class(mod,"regulator_configuration",sizeof(regulator_configuration),0x00);
00033 if (oclass==NULL)
00034 throw "unable to register class regulator_configuration";
00035 else
00036 oclass->trl = TRL_PROVEN;
00037
00038
00039 if (gl_publish_variable(oclass,
00040 PT_enumeration, "connect_type",PADDR(connect_type),PT_DESCRIPTION,"Designation of connection style",
00041 PT_KEYWORD, "UNKNOWN", (enumeration)UNKNOWN,
00042 PT_KEYWORD, "WYE_WYE", (enumeration)WYE_WYE,
00043 PT_KEYWORD, "OPEN_DELTA_ABBC", (enumeration)OPEN_DELTA_ABBC,
00044 PT_KEYWORD, "OPEN_DELTA_BCAC", (enumeration)OPEN_DELTA_BCAC,
00045 PT_KEYWORD, "OPEN_DELTA_CABA", (enumeration)OPEN_DELTA_CABA,
00046 PT_KEYWORD, "CLOSED_DELTA", (enumeration)CLOSED_DELTA,
00047 PT_double, "band_center[V]",PADDR(band_center),PT_DESCRIPTION,"band center setting of regulator control",
00048 PT_double, "band_width[V]",PADDR(band_width),PT_DESCRIPTION,"band width setting of regulator control",
00049 PT_double, "time_delay[s]",PADDR(time_delay),PT_DESCRIPTION,"mechanical time delay between tap changes",
00050 PT_double, "dwell_time[s]",PADDR(dwell_time),PT_DESCRIPTION,"time delay before a control action of regulator control",
00051 PT_int16, "raise_taps",PADDR(raise_taps),PT_DESCRIPTION,"number of regulator raise taps, or the maximum raise voltage tap position",
00052 PT_int16, "lower_taps",PADDR(lower_taps),PT_DESCRIPTION,"number of regulator lower taps, or the minimum lower voltage tap position",
00053 PT_double, "current_transducer_ratio[pu]",PADDR(CT_ratio),PT_DESCRIPTION,"primary rating of current transformer",
00054 PT_double, "power_transducer_ratio[pu]",PADDR(PT_ratio),PT_DESCRIPTION,"potential transformer rating",
00055 PT_double, "compensator_r_setting_A[V]",PADDR(ldc_R_V_A),PT_DESCRIPTION,"Line Drop Compensation R setting of regulator control (in volts) on Phase A",
00056 PT_double, "compensator_r_setting_B[V]",PADDR(ldc_R_V_B),PT_DESCRIPTION,"Line Drop Compensation R setting of regulator control (in volts) on Phase B",
00057 PT_double, "compensator_r_setting_C[V]",PADDR(ldc_R_V_C),PT_DESCRIPTION,"Line Drop Compensation R setting of regulator control (in volts) on Phase C",
00058 PT_double, "compensator_x_setting_A[V]",PADDR(ldc_X_V_A),PT_DESCRIPTION,"Line Drop Compensation X setting of regulator control (in volts) on Phase A",
00059 PT_double, "compensator_x_setting_B[V]",PADDR(ldc_X_V_B),PT_DESCRIPTION,"Line Drop Compensation X setting of regulator control (in volts) on Phase B",
00060 PT_double, "compensator_x_setting_C[V]",PADDR(ldc_X_V_C),PT_DESCRIPTION,"Line Drop Compensation X setting of regulator control (in volts) on Phase C",
00061 PT_set, "CT_phase",PADDR(CT_phase),PT_DESCRIPTION,"phase(s) monitored by CT",
00062 PT_KEYWORD, "A",(set)PHASE_A,
00063 PT_KEYWORD, "B",(set)PHASE_B,
00064 PT_KEYWORD, "C",(set)PHASE_C,
00065 PT_set, "PT_phase",PADDR(PT_phase),PT_DESCRIPTION,"phase(s) monitored by PT",
00066 PT_KEYWORD, "A",(set)PHASE_A,
00067 PT_KEYWORD, "B",(set)PHASE_B,
00068 PT_KEYWORD, "C",(set)PHASE_C,
00069 PT_double, "regulation",PADDR(regulation),PT_DESCRIPTION,"regulation of voltage regulator in %",
00070 PT_enumeration, "control_level",PADDR(control_level),PT_DESCRIPTION,"Designates whether control is on per-phase or banked level",
00071 PT_KEYWORD, "INDIVIDUAL", (enumeration)INDIVIDUAL,
00072 PT_KEYWORD, "BANK", (enumeration)BANK,
00073 PT_enumeration, "Control",PADDR(Control),PT_DESCRIPTION,"Type of control used for regulating voltage",
00074 PT_KEYWORD, "MANUAL", (enumeration)MANUAL,
00075 PT_KEYWORD, "OUTPUT_VOLTAGE", (enumeration)OUTPUT_VOLTAGE,
00076 PT_KEYWORD, "LINE_DROP_COMP", (enumeration)LINE_DROP_COMP,
00077 PT_KEYWORD, "REMOTE_NODE", (enumeration)REMOTE_NODE,
00078 PT_enumeration, "reverse_flow_control",PADDR(reverse_flow_control),PT_DESCRIPTION,"Type of control used when power is flowing in reverse through the regulator",
00079 PT_KEYWORD, "LOCK_NONE", (enumeration)LOCK_NONE,
00080 PT_KEYWORD, "LOCK_NEUTRAL", (enumeration)LOCK_NEUTRAL,
00081 PT_KEYWORD, "LOCK_CURRENT_POSITION", (enumeration)LOCK_CURRENT,
00082 PT_enumeration, "Type",PADDR(Type),PT_DESCRIPTION,"Defines regulator type",
00083 PT_KEYWORD, "A", (enumeration)A,
00084 PT_KEYWORD, "B", (enumeration)B,
00085 PT_int16, "tap_pos_A",PADDR(tap_posA),PT_DESCRIPTION,"initial tap position of phase A",
00086 PT_int16, "tap_pos_B",PADDR(tap_posB),PT_DESCRIPTION,"initial tap position of phase B",
00087 PT_int16, "tap_pos_C",PADDR(tap_posC),PT_DESCRIPTION,"initial tap position of phase C",
00088 NULL)<1) GL_THROW("unable to publish properties in %s",__FILE__);
00089 }
00090 }
00091
00092 int regulator_configuration::isa(char *classname)
00093 {
00094 return strcmp(classname,"regulator_configuration")==0;
00095 }
00096
00097 int regulator_configuration::create(void)
00098 {
00099 int result = powerflow_library::create();
00100 band_center = 0.0;
00101 band_width = 0.0;
00102 time_delay = 0.0;
00103 dwell_time = 0.0;
00104 raise_taps = 0;
00105 lower_taps = 0;
00106 CT_ratio = 0;
00107 PT_ratio = 0;
00108 ldc_R_V[0] = ldc_R_V[1] = ldc_R_V[2] = 0.0;
00109 ldc_X_V[0] = ldc_X_V[1] = ldc_X_V[2] = 0.0;
00110 CT_phase = PHASE_ABC;
00111 PT_phase = PHASE_ABC;
00112 Control = MANUAL;
00113 control_level = INDIVIDUAL;
00114 reverse_flow_control = LOCK_NONE;
00115 Type = B;
00116 regulation = 0.0;
00117
00118
00119 tap_pos[0] = tap_pos[1] = tap_pos[2] = 999;
00120
00121 return result;
00122 }
00123 int regulator_configuration::init(OBJECT *parent)
00124 {
00125
00126 if (Control == LINE_DROP_COMP)
00127 {
00128 if (PT_ratio == 0)
00129 GL_THROW("power_transducer_ratio must be set as a non-zero value when operating in LINE_DROP_COMP mode");
00130
00131
00132
00133
00134 }
00135
00136 if (control_level == BANK)
00137 {
00138 if (CT_phase == 1 || CT_phase == 2 || CT_phase == 4)
00139 {
00140 }
00141 else
00142 GL_THROW("There are too many CT_phases specified for a BANK control_level (or it wasn't specified). Should only be one phase monitored.");
00143 if (PT_phase == 1 || PT_phase == 2 || PT_phase == 4)
00144 {
00145 }
00146 else
00147 GL_THROW("There are too many PT_phases specified for a BANK control_level (or it wasn't specified). Should only be one phase monitored.");
00148 }
00149 if (raise_taps <= 0 || lower_taps <= 0)
00150 GL_THROW("raise and lower taps must be specified to non-zero numbers");
00151
00152
00153
00154
00155
00156
00157 if (Control != MANUAL)
00158 {
00159 if (band_width == 0)
00160 gl_warning("band_width is set to zero in automatic control. May cause oscillations.");
00161 if (regulation == 0)
00162 GL_THROW("regulation must be set to a non-zero number when operating in an automatic controlled mode.");
00163
00164
00165
00166
00167
00168 if (connect_type != WYE_WYE)
00169 GL_THROW("At this time, only WYE_WYE regulators are supported in automatic control modes.");
00170
00171
00172
00173
00174
00175 }
00176
00177 if (connect_type != WYE_WYE && solver_method != SM_FBS)
00178 GL_THROW("Only WYE_WYE regulator connections are fully supported in FBS & NR solvers at this time.");
00179
00180 if (solver_method == SM_GS)
00181 GL_THROW("Regulators are not supported in the Gauss-Seidel solver method.");
00182
00183 return 1;
00184 }
00185
00187
00189
00197 EXPORT int create_regulator_configuration(OBJECT **obj, OBJECT *parent)
00198 {
00199 try
00200 {
00201 *obj = gl_create_object(regulator_configuration::oclass);
00202 if (*obj!=NULL)
00203 {
00204 regulator_configuration *my = OBJECTDATA(*obj,regulator_configuration);
00205 gl_set_parent(*obj,parent);
00206 return my->create();
00207 }
00208 else
00209 return 0;
00210 }
00211 CREATE_CATCHALL(regulator_configuration);
00212 }
00213
00214 EXPORT int init_regulator_configuration(OBJECT *obj)
00215 {
00216 try {
00217 regulator_configuration *my = OBJECTDATA(obj,regulator_configuration);
00218 return my->init(obj->parent);
00219 }
00220 INIT_CATCHALL(regulator_configuration);
00221 }
00222
00223 EXPORT TIMESTAMP sync_regulator_configuration(OBJECT *obj, TIMESTAMP t1, PASSCONFIG pass)
00224 {
00225 return TS_NEVER;
00226 }
00227
00228 EXPORT int isa_regulator_configuration(OBJECT *obj, char *classname)
00229 {
00230 return OBJECTDATA(obj,regulator_configuration)->isa(classname);
00231 }
00232