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.h"
00019 #include "node.h"
00020
00022
00024
00025 CLASS* regulator_configuration::oclass = NULL;
00026 CLASS* regulator_configuration::pclass = NULL;
00027
00028 regulator_configuration::regulator_configuration(MODULE *mod) : powerflow_library(mod)
00029 {
00030 if (oclass==NULL)
00031 {
00032
00033 oclass = gl_register_class(mod,"regulator_configuration",sizeof(regulator_configuration),0x00);
00034 if (oclass==NULL)
00035 GL_THROW("unable to register object class implemented by %s",__FILE__);
00036
00037
00038 if (gl_publish_variable(oclass,
00039 PT_enumeration, "connect_type",PADDR(connect_type),
00040 PT_KEYWORD, "UNKNOWN", UNKNOWN,
00041 PT_KEYWORD, "WYE_WYE", WYE_WYE,
00042 PT_KEYWORD, "OPEN_DELTA_ABBC", OPEN_DELTA_ABBC,
00043 PT_KEYWORD, "OPEN_DELTA_BCAC", OPEN_DELTA_BCAC,
00044 PT_KEYWORD, "OPEN_DELTA_CABA", OPEN_DELTA_CABA,
00045 PT_KEYWORD, "CLOSED_DELTA", CLOSED_DELTA,
00046 PT_double, "band_center[V]",PADDR(band_center),
00047 PT_double, "band_width[V]",PADDR(band_width),
00048 PT_double, "time_delay[s]",PADDR(time_delay),
00049 PT_double, "dwell_time[s]",PADDR(dwell_time),
00050 PT_int16, "raise_taps",PADDR(raise_taps),
00051 PT_int16, "lower_taps",PADDR(lower_taps),
00052 PT_double, "current_transducer_ratio[pu]",PADDR(CT_ratio),
00053 PT_double, "power_transducer_ratio[pu]",PADDR(PT_ratio),
00054 PT_double, "compensator_r_setting_A[V]",PADDR(ldc_R_V_A),
00055 PT_double, "compensator_r_setting_B[V]",PADDR(ldc_R_V_B),
00056 PT_double, "compensator_r_setting_C[V]",PADDR(ldc_R_V_C),
00057 PT_double, "compensator_x_setting_A[V]",PADDR(ldc_X_V_A),
00058 PT_double, "compensator_x_setting_B[V]",PADDR(ldc_X_V_B),
00059 PT_double, "compensator_x_setting_C[V]",PADDR(ldc_X_V_C),
00060 PT_set, "CT_phase",PADDR(CT_phase),
00061 PT_KEYWORD, "A",(set)PHASE_A,
00062 PT_KEYWORD, "B",(set)PHASE_B,
00063 PT_KEYWORD, "C",(set)PHASE_C,
00064 PT_set, "PT_phase",PADDR(PT_phase),
00065 PT_KEYWORD, "A",(set)PHASE_A,
00066 PT_KEYWORD, "B",(set)PHASE_B,
00067 PT_KEYWORD, "C",(set)PHASE_C,
00068 PT_double, "regulation",PADDR(regulation),
00069 PT_enumeration, "control_level",PADDR(control_level),
00070 PT_KEYWORD, "INDIVIDUAL", INDIVIDUAL,
00071 PT_KEYWORD, "BANK", BANK,
00072 PT_enumeration, "Control",PADDR(Control),
00073 PT_KEYWORD, "MANUAL", MANUAL,
00074 PT_KEYWORD, "OUTPUT_VOLTAGE", OUTPUT_VOLTAGE,
00075 PT_KEYWORD, "LINE_DROP_COMP", LINE_DROP_COMP,
00076 PT_KEYWORD, "REMOTE_NODE", REMOTE_NODE,
00077 PT_enumeration, "Type",PADDR(Type),
00078 PT_KEYWORD, "A", A,
00079 PT_KEYWORD, "B", B,
00080 PT_int16, "tap_pos_A",PADDR(tap_posA),
00081 PT_int16, "tap_pos_B",PADDR(tap_posB),
00082 PT_int16, "tap_pos_C",PADDR(tap_posC),
00083 NULL)<1) GL_THROW("unable to publish properties in %s",__FILE__);
00084 }
00085 }
00086
00087 int regulator_configuration::isa(char *classname)
00088 {
00089 return strcmp(classname,"regulator_configuration")==0;
00090 }
00091
00092 int regulator_configuration::create(void)
00093 {
00094 int result = powerflow_library::create();
00095 band_center = 0.0;
00096 band_width = 0.0;
00097 time_delay = 0.0;
00098 dwell_time = 0.0;
00099 raise_taps = 0;
00100 lower_taps = 0;
00101 CT_ratio = 0;
00102 PT_ratio = 0;
00103 ldc_R_V[0] = ldc_R_V[1] = ldc_R_V[2] = 0.0;
00104 ldc_X_V[0] = ldc_X_V[1] = ldc_X_V[2] = 0.0;
00105 CT_phase = PHASE_ABC;
00106 PT_phase = PHASE_ABC;
00107 Control = MANUAL;
00108 control_level = INDIVIDUAL;
00109 Type = B;
00110 regulation = 0.0;
00111
00112
00113 tap_pos[0] = tap_pos[1] = tap_pos[2] = 999;
00114
00115 return result;
00116 }
00117 int regulator_configuration::init(OBJECT *parent)
00118 {
00119
00120 if (Control == LINE_DROP_COMP)
00121 {
00122 if (PT_ratio == 0)
00123 GL_THROW("power_transducer_ratio must be set as a non-zero value when operating in LINE_DROP_COMP mode");
00124
00125
00126
00127
00128 if (solver_method != SM_FBS)
00129 GL_THROW("Line drop compensation is only supported for regulators in FBS at this time.");
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 }
00209 catch (const char *msg)
00210 {
00211 gl_error("create_regulator_configuration: %s", msg);
00212 }
00213 return 0;
00214 }
00215
00216 EXPORT int init_regulator_configuration(OBJECT *obj)
00217 {
00218 regulator_configuration *my = OBJECTDATA(obj,regulator_configuration);
00219 try {
00220 return my->init(obj->parent);
00221 }
00222 catch (const char *msg)
00223 {
00224 GL_THROW("%s (regulator_configuration:%d): %s", my->get_name(), my->get_id(), msg);
00225 return 0;
00226 }
00227 }
00228
00229 EXPORT TIMESTAMP sync_regulator_configuration(OBJECT *obj, TIMESTAMP t1, PASSCONFIG pass)
00230 {
00231 return TS_NEVER;
00232 }
00233
00234 EXPORT int isa_regulator_configuration(OBJECT *obj, char *classname)
00235 {
00236 return OBJECTDATA(obj,regulator_configuration)->isa(classname);
00237 }
00238