00001
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <errno.h>
00027 #include <math.h>
00028 #include <iostream>
00029 using namespace std;
00030
00031 #include "transformer.h"
00032
00034
00036 CLASS* transformer_configuration::oclass = NULL;
00037 CLASS* transformer_configuration::pclass = NULL;
00038
00039 transformer_configuration::transformer_configuration(MODULE *mod) : powerflow_library(mod)
00040 {
00041 if(oclass == NULL)
00042 {
00043 oclass = gl_register_class(mod,"transformer_configuration",sizeof(transformer_configuration),NULL);
00044 if (oclass==NULL)
00045 throw "unable to register class transformer_configuration";
00046 else
00047 oclass->trl = TRL_PROVEN;
00048
00049 if(gl_publish_variable(oclass,
00050 PT_enumeration,"connect_type",PADDR(connect_type),PT_DESCRIPTION,"connect type enum: Wye-Wye, single-phase, etc.",
00051 PT_KEYWORD,"UNKNOWN",UNKNOWN,
00052 PT_KEYWORD,"WYE_WYE",(enumeration)WYE_WYE,
00053 PT_KEYWORD,"DELTA_DELTA",(enumeration)DELTA_DELTA,
00054 PT_KEYWORD,"DELTA_GWYE",(enumeration)DELTA_GWYE,
00055 PT_KEYWORD,"SINGLE_PHASE",(enumeration)SINGLE_PHASE,
00056 PT_KEYWORD,"SINGLE_PHASE_CENTER_TAPPED",(enumeration)SINGLE_PHASE_CENTER_TAPPED,
00057 PT_enumeration,"install_type",PADDR(install_type),PT_DESCRIPTION,"Defines location of the transformer installation",
00058 PT_KEYWORD,"UNKNOWN",UNKNOWN,
00059 PT_KEYWORD,"POLETOP",(enumeration)POLETOP,
00060 PT_KEYWORD,"PADMOUNT",(enumeration)PADMOUNT,
00061 PT_KEYWORD,"VAULT",(enumeration)VAULT,
00062 PT_enumeration,"coolant_type", PADDR(coolant_type),PT_DESCRIPTION,"coolant type, used in life time model",
00063 PT_KEYWORD,"UNKNOWN", UNKNOWN,
00064 PT_KEYWORD,"MINERAL_OIL", (enumeration)MINERAL_OIL,
00065 PT_KEYWORD,"DRY",(enumeration)DRY,
00066 PT_enumeration, "cooling_type", PADDR(cooling_type),PT_DESCRIPTION,"type of coolant fluid used in life time model",
00067 PT_KEYWORD,"UNKNOWN", UNKNOWN,
00068 PT_KEYWORD,"OA", (enumeration)OA,
00069 PT_KEYWORD,"FA", (enumeration)FA,
00070 PT_KEYWORD,"NDFOA", (enumeration)NDFOA,
00071 PT_KEYWORD,"NDFOW", (enumeration)NDFOW,
00072 PT_KEYWORD,"DFOA", (enumeration)DFOA,
00073 PT_KEYWORD,"DFOW", (enumeration)DFOW,
00074
00075 PT_double, "primary_voltage[V]", PADDR(V_primary),PT_DESCRIPTION,"primary voltage level in L-L value kV",
00076 PT_double, "secondary_voltage[V]",PADDR(V_secondary),PT_DESCRIPTION,"secondary voltage level kV",
00077 PT_double, "power_rating[kVA]",PADDR(kVA_rating),PT_DESCRIPTION,"kVA rating of transformer, total",
00078 PT_double, "powerA_rating[kVA]",PADDR(phaseA_kVA_rating),PT_DESCRIPTION,"kVA rating of transformer, phase A",
00079 PT_double, "powerB_rating[kVA]",PADDR(phaseB_kVA_rating),PT_DESCRIPTION,"kVA rating of transformer, phase B",
00080 PT_double, "powerC_rating[kVA]",PADDR(phaseC_kVA_rating),PT_DESCRIPTION,"kVA rating of transformer, phase C",
00081 PT_double, "resistance[pu*Ohm]",PADDR(impedance.Re()),PT_DESCRIPTION,"Series impedance, pu, real",
00082 PT_double, "reactance[pu*Ohm]",PADDR(impedance.Im()),PT_DESCRIPTION,"Series impedance, pu, imag",
00083 PT_complex, "impedance[pu*Ohm]",PADDR(impedance),PT_DESCRIPTION,"Series impedance, pu",
00084 PT_double, "resistance1[pu*Ohm]",PADDR(impedance1.Re()),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu, real",
00085 PT_double, "reactance1[pu*Ohm]",PADDR(impedance1.Im()),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu, imag",
00086 PT_complex, "impedance1[pu*Ohm]",PADDR(impedance1),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu",
00087 PT_double, "resistance2[pu*Ohm]",PADDR(impedance2.Re()),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu, real",
00088 PT_double, "reactance2[pu*Ohm]",PADDR(impedance2.Im()),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu, imag",
00089 PT_complex, "impedance2[pu*Ohm]",PADDR(impedance2),PT_DESCRIPTION,"Secondary series impedance (only used when you want to define each individual winding seperately, pu",
00090 PT_double, "shunt_resistance[pu*Ohm]",PADDR(shunt_impedance.Re()),PT_DESCRIPTION,"Shunt impedance on primary side, pu, real",
00091 PT_double, "shunt_reactance[pu*Ohm]",PADDR(shunt_impedance.Im()),PT_DESCRIPTION,"Shunt impedance on primary side, pu, imag",
00092 PT_complex, "shunt_impedance[pu*Ohm]",PADDR(shunt_impedance),PT_DESCRIPTION,"Shunt impedance on primary side, pu",
00093
00094 PT_double, "core_coil_weight[lb]", PADDR(core_coil_weight),PT_DESCRIPTION,"The weight of the core and coil assembly in pounds",
00095 PT_double, "tank_fittings_weight[lb]", PADDR(tank_fittings_weight),PT_DESCRIPTION,"The weight of the tank and fittings in pounds",
00096 PT_double, "oil_volume[gal]", PADDR(oil_vol),PT_DESCRIPTION,"The number of gallons of oil in the transformer",
00097 PT_double, "rated_winding_time_constant[h]", PADDR(t_W),PT_DESCRIPTION,"The rated winding time constant in hours",
00098 PT_double, "rated_winding_hot_spot_rise[degC]", PADDR(dtheta_H_AR),PT_DESCRIPTION,"winding hottest-spot rise over ambient temperature at rated load, degrees C",
00099 PT_double, "rated_top_oil_rise[degC]", PADDR(dtheta_TO_R),PT_DESCRIPTION,"top-oil hottest-spot rise over ambient temperature at rated load, degrees C",
00100 PT_double, "no_load_loss[pu]", PADDR(no_load_loss),PT_DESCRIPTION,"Another method of specifying transformer impedances, defined as per unit power values (shunt)",
00101 PT_double, "full_load_loss[pu]", PADDR(full_load_loss),PT_DESCRIPTION,"Another method of specifying transformer impedances, defined as per unit power values (shunt and series)",
00102 PT_double, "reactance_resistance_ratio", PADDR(RX),PT_DESCRIPTION,"the reactance to resistance ratio (X/R)",
00103 PT_double, "installed_insulation_life[h]", PADDR(installed_insulation_life),PT_DESCRIPTION,"the normal lifetime of the transformer insulation at rated load, hours",
00104
00105
00106 PT_enumeration,"magnetization_location",PADDR(magnetization_location),PT_DESCRIPTION,"winding to place magnetization influence for in-rush calculations",
00107 PT_KEYWORD,"NONE",(enumeration)NO_MAG,
00108 PT_KEYWORD,"PRIMARY",(enumeration)PRI_MAG,
00109 PT_KEYWORD,"SECONDARY",(enumeration)SEC_MAG,
00110 PT_KEYWORD,"BOTH",(enumeration)BOTH_MAG,
00111 PT_bool, "inrush_saturation_enabled", PADDR(model_inrush_saturation), PT_DESCRIPTION,"flag to include saturation effects during inrush calculations",
00112 PT_double, "L_A[pu]", PADDR(LA_pu), PT_DESCRIPTION,"Air core inductance of transformer",
00113 PT_double, "phi_K[pu]", PADDR(phiK_pu), PT_DESCRIPTION,"Knee flux value where the air core inductance interstes the flux axis of the saturation curve",
00114 PT_double, "phi_M[pu]", PADDR(phiM_pu), PT_DESCRIPTION,"Peak magnetization flux at rated voltage of the saturation curve",
00115 PT_double, "I_M[pu]", PADDR(IM_pu), PT_DESCRIPTION,"Peak magnetization current at rated voltage of the saturation curve",
00116 PT_double, "T_D", PADDR(TD_val), PT_DESCRIPTION, "Inrush decay time constant for inrush current",
00117
00118 NULL) < 1) GL_THROW("unable to publish properties in %s",__FILE__);
00119 }
00120 }
00121
00122 int transformer_configuration::isa(char *classname)
00123 {
00124 return strcmp(classname,"transformer_configuration")==0;
00125 }
00126
00127 int transformer_configuration::create(void)
00128 {
00129 int result = powerflow_library::create();
00130 memset(&connect_type,0,sizeof(connect_type));
00131 memset(&install_type,0,sizeof(install_type));
00132 V_primary = 0.0;
00133 V_secondary = 0.0;
00134 phaseA_kVA_rating = 0.0;
00135 phaseB_kVA_rating = 0.0;
00136 phaseC_kVA_rating = 0.0;
00137 kVA_rating = 0;
00138 impedance = impedance1 = impedance2 = complex(0.0,0.0);
00139 shunt_impedance = complex(999999999,999999999);
00140 no_load_loss = full_load_loss = 0.0;
00141 RX = 4.5;
00142
00143 magnetization_location = NO_MAG;
00144 IM_pu = 0.01;
00145 model_inrush_saturation = false;
00146
00147
00148 LA_pu = 0.2;
00149 phiK_pu = 1.17;
00150 phiM_pu = 1.0;
00151 TD_val = 0.5;
00152
00153 return result;
00154 }
00155
00156 int transformer_configuration::init(OBJECT *parent)
00157 {
00158
00159 OBJECT *obj = OBJECTHDR(this);
00160
00161
00162 if (kVA_rating==0)
00163
00164
00165 kVA_rating = phaseA_kVA_rating+phaseB_kVA_rating+phaseC_kVA_rating;
00166
00167
00168 if (phaseA_kVA_rating+phaseB_kVA_rating+phaseC_kVA_rating==0 && kVA_rating>0)
00169 phaseA_kVA_rating = phaseB_kVA_rating = phaseC_kVA_rating = kVA_rating/3;
00170
00171
00172 if (connect_type==UNKNOWN)
00173 GL_THROW("connection type not specified");
00174
00175
00176
00177
00178
00179
00180 if (install_type==UNKNOWN)
00181 gl_verbose("installation type not specified");
00182
00183
00184
00185
00186
00187
00188
00189 if (V_primary==0)
00190 GL_THROW("V_primary must be positive");
00191
00192
00193
00194
00195 if (V_secondary==0)
00196 GL_THROW("V_secondary must be positive");
00197
00198
00199
00200
00201
00202
00203 if (kVA_rating<=0)
00204 GL_THROW("kVA_rating(s) must be positive");
00205
00206
00207
00208
00209 if (fabs((kVA_rating-phaseA_kVA_rating-phaseB_kVA_rating-phaseC_kVA_rating)/kVA_rating)>0.01)
00210 GL_THROW("kVA rating mismatch across phases exceeds 1%");
00211
00212
00213
00214
00215
00216
00217
00218 if (connect_type!=SINGLE_PHASE_CENTER_TAPPED)
00219 {
00220 if ((impedance1.Re() != 0.0 && impedance1.Im() != 0.0) || (impedance2.Re() != 0.0 && impedance2.Im() != 0.0))
00221 gl_warning("This connection type on transformer:%d (%s) does not support impedance (impedance1 or impedance2) of secondaries at this time.",obj->id,obj->name);
00222
00223
00224
00225
00226 if (connect_type!=WYE_WYE)
00227 {
00228 if (shunt_impedance.Re() != 999999999 || shunt_impedance.Im() != 999999999)
00229 gl_warning("This connection type on transformer:%d (%s) does not support shunt_impedance at this time.",obj->id,obj->name);
00230
00231
00232
00233
00234 }
00235 if (no_load_loss != 0.0 || full_load_loss != 0.0)
00236 gl_warning("This connection type on transformer:%d (%s) does not support shunt_impedance at this time.",obj->id,obj->name);
00237
00238
00239
00240
00241 }
00242 else
00243 {
00244 if (no_load_loss > 0 && full_load_loss > 0)
00245
00246 {
00247 if (RX == 4.5 && kVA_rating > 500)
00248 gl_warning("transormer_configuration:%d (%s) reactance_resistance_ratio was not set and defaulted to 4.5. This may cause issues with larger transformers (>0.5 MVA)",obj->id,obj->name);
00249
00250
00251
00252
00253
00254 impedance = complex(full_load_loss,RX*full_load_loss);
00255 shunt_impedance = complex(1/no_load_loss,RX/no_load_loss);
00256 }
00257 if ((impedance1.Re() == 0.0 && impedance1.Im() == 0.0) && (impedance2.Re() != 0.0 && impedance2.Im() != 0.0))
00258 {
00259 impedance1 = impedance2;
00260 gl_warning("impedance2 was defined, but impedance1 was not -- assuming they are equal");
00261
00262
00263
00264
00265
00266 }
00267 else if ((impedance1.Re() != 0.0 && impedance1.Im() != 0.0) && (impedance2.Re() == 0.0 && impedance2.Im() == 0.0))
00268 {
00269 impedance2 = impedance1;
00270 gl_warning("impedance1 was defined, but impedance2 was not -- assuming they are equal");
00271
00272
00273
00274
00275
00276 }
00277
00278 }
00279
00280 if (impedance.Re()<=0 || impedance1.Re()<0 || impedance2.Re()<0)
00281 GL_THROW("resistance must be non-negative");
00282
00283
00284
00285 if (impedance.Im()<=0 || impedance1.Im()<0 || impedance2.Im()<0)
00286 GL_THROW("reactance must be non-negative");
00287
00288
00289
00290 if (shunt_impedance.Re()<0)
00291 GL_THROW("shunt_resistance must be non-negative");
00292
00293
00294
00295 if (shunt_impedance.Im()<0)
00296 GL_THROW("shunt_reactance must be non-negative");
00297
00298
00299
00300 return 1;
00301 }
00302
00304
00306
00314 EXPORT int create_transformer_configuration(OBJECT **obj, OBJECT *parent)
00315 {
00316 try
00317 {
00318 *obj = gl_create_object(transformer_configuration::oclass);
00319 if (*obj!=NULL)
00320 {
00321 transformer_configuration *my = OBJECTDATA(*obj,transformer_configuration);
00322 gl_set_parent(*obj,parent);
00323 return my->create();
00324 }
00325 else
00326 return 0;
00327 }
00328 CREATE_CATCHALL(transformer_configuration);
00329 }
00330
00331 EXPORT int init_transformer_configuration(OBJECT *obj, OBJECT *parent)
00332 {
00333 try {
00334 return OBJECTDATA(obj,transformer_configuration)->init(parent);
00335 }
00336 INIT_CATCHALL(transformer_configuration);
00337 }
00338
00339 EXPORT TIMESTAMP sync_transformer_configuration(OBJECT *obj, TIMESTAMP t1, PASSCONFIG pass)
00340 {
00341 return TS_NEVER;
00342 }
00343
00344 EXPORT int isa_transformer_configuration(OBJECT *obj, char *classname)
00345 {
00346 return OBJECTDATA(obj,transformer_configuration)->isa(classname);
00347 }
00348