00001
00007 #ifndef _NODE_H
00008 #define _NODE_H
00009
00010 #include "lock.h"
00011 #include "powerflow.h"
00012
00013 #define I_INJ(V, S, Z, I) (I_S(S, V) + ((Z.IsFinite()) ? I_Z(Z, V) : complex(0.0)) + I_I(I))
00014 #define I_S(S, V) (~((S) / (V))) // Current injection - constant power load
00015 #define I_Z(Z, V) ((V) / (Z)) // Current injection - constant impedance load
00016 #define I_I(I) (I) // Current injection - constant current load
00017
00018 #define NF_NONE 0x0000
00019 #define NF_HASSOURCE 0x0001
00020
00021
00022 #define voltageA voltage[0]
00023 #define voltageB voltage[1]
00024 #define voltageC voltage[2]
00025
00026 #define voltageAB voltaged[0]
00027 #define voltageBC voltaged[1]
00028 #define voltageCA voltaged[2]
00029
00030 #define currentA current[0]
00031 #define currentB current[1]
00032 #define currentC current[2]
00033
00034 #define powerA power[0]
00035 #define powerB power[1]
00036 #define powerC power[2]
00037
00038 #define shuntA shunt[0]
00039 #define shuntB shunt[1]
00040 #define shuntC shunt[2]
00041
00042
00043 #define voltage1 voltage[0]
00044 #define voltage2 voltage[1]
00045 #define voltageN voltage[2]
00046
00047 #define voltage12 voltaged[0]
00048 #define voltage2N voltaged[1]
00049 #define voltage1N voltaged[2]
00050
00051 #define current1 current[0]
00052 #define current2 current[1]
00053 #define currentN current[2]
00054
00055 #define power1 power[0]
00056 #define power2 power[1]
00057 #define power12 power[2]
00058
00059 #define shunt1 shunt[0]
00060 #define shunt2 shunt[1]
00061 #define shunt12 shunt[2]
00062
00063 typedef struct s_linkconnected {
00064 OBJECT *connectedlink;
00065 OBJECT *fnodeconnected;
00066 OBJECT *tnodeconnected;
00067 struct s_linkconnected *next;
00068 } LINKCONNECTED;
00069
00070 typedef enum {
00071 NONE=0,
00072 CHILD=1,
00073 CHILD_NOINIT=2,
00074 PARENT=3,
00075 DIFF_CHILD=4,
00076 DIFF_PARENT=5
00077 } SUBNODETYPE;
00078
00079 class node : public powerflow_object
00080 {
00081 private:
00082 LINKCONNECTED nodelinks;
00083 complex last_voltage[3];
00084 complex current_inj[3];
00085 TIMESTAMP prev_NTime;
00086 complex last_child_power[3][3];
00087 complex last_child_current12;
00088 bool GS_converged;
00089 void *GS_P_C_NodeChecks(TIMESTAMP t0, TIMESTAMP t1, OBJECT *obj, LINKCONNECTED *linktable);
00090 public:
00091 double frequency;
00092 object reference_bus;
00093 static unsigned int n;
00094 unsigned short k;
00095 public:
00096
00097 enum {
00098 PQ=0,
00099 PV=1,
00100 SWING=2
00101 } bustype;
00102 enum { NOMINAL=1,
00103 UNDERVOLT,
00104 OVERVOLT,
00105 } status;
00106 SUBNODETYPE SubNode;
00107 set busflags;
00108 set busphasesIn;
00109 set busphasesOut;
00110 double maximum_voltage_error;
00111
00112
00113 complex voltage[3];
00114 complex voltaged[3];
00115 complex current[3];
00116 complex power[3];
00117 complex shunt[3];
00118 complex Ys[3][3];
00119 complex YVs[3];
00120 complex current12;
00121 complex nom_res_curr[3];
00122 bool house_present;
00123 complex *Triplex_Data;
00124 complex *Extra_Data;
00125 unsigned int NR_connected_links[2];
00126 int *NR_link_table;
00127
00128 int NR_node_reference;
00129 int *NR_subnode_reference;
00130
00131 inline bool is_split() {return (phases&PHASE_S)!=0;};
00132 public:
00133 static CLASS *oclass;
00134 static CLASS *pclass;
00135 public:
00136 node(MODULE *mod);
00137 inline node(CLASS *cl=oclass):powerflow_object(cl){};
00138 int create(void);
00139 int init(OBJECT *parent=NULL);
00140 TIMESTAMP presync(TIMESTAMP t0);
00141 TIMESTAMP sync(TIMESTAMP t0);
00142 TIMESTAMP postsync(TIMESTAMP t0);
00143 int isa(char *classname);
00144
00145 LINKCONNECTED *attachlink(OBJECT *obj);
00146 int *NR_populate(void);
00147 object SubNodeParent;
00148
00149 friend class link;
00150 friend class meter;
00151 friend class substation;
00152 friend class triplex_meter;
00153 friend class fuse;
00154 friend class frequency_gen;
00155
00156 int kmldump(FILE *fp);
00157 };
00158
00159 #include "load.h"
00160 #include "triplex_node.h"
00161
00162 #endif // _NODE_H
00163