00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _controller_dg_H_
00009 #define _controller_dg_H_
00010
00011 #include <stdarg.h>
00012
00013 #include "../powerflow/switch_object.h"
00014 #include "../powerflow/node.h"
00015 #include "gridlabd.h"
00016 #include "generators.h"
00017 #include "diesel_dg.h"
00018
00019 EXPORT SIMULATIONMODE interupdate_controller_dg(OBJECT *obj, unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val);
00020 EXPORT STATUS postupdate_controller_dg(OBJECT *obj, complex *useful_value, unsigned int mode_pass);
00021
00022
00023 typedef struct {
00024 double w_measured;
00025 double x;
00026 double Pref_ctrl;
00027 double wref_ctrl;
00028
00029 double Vset_ref;
00030 double x_QV;
00031 double Vset_ctrl;
00032
00033 } CTRL_VARS;
00034
00035
00036 typedef struct {
00037 CTRL_VARS *curr_state;
00038 CTRL_VARS *next_state;
00039 } CTRL_Gen;
00040
00041 class controller_dg: public gld_object
00042 {
00043 private:
00044 bool first_run;
00045 bool flag_switchOn;
00046 unsigned int64 controlTime;
00047
00048 switch_object **pSwitch;
00049 FINDLIST *switches;
00050 diesel_dg **pDG;
00051 FINDLIST *dgs;
00052
00053 CTRL_Gen **ctrlGen;
00054 node **GenPobj;
00055
00056 double *prev_Pref_val;
00057 double *prev_Vset_val;
00058
00059 char **DGpNdName;
00060 OBJECT **dgSwitchObj;
00061 int dgswitchFound;
00062
00063 CTRL_VARS predictor_vals;
00064 CTRL_VARS corrector_vals;
00065
00066 bool deltamode_inclusive;
00067 double *mapped_freq_variable;
00068
00069 public:
00070 char32 controlled_dgs;
00071
00072 double omega_ref;
00073 double nominal_voltage;
00074
00075 double kp;
00076 double ki;
00077 double gain;
00078
00079 double kp_QV;
00080 double ki_QV;
00081 double gain_QV;
00082
00083
00084 double controller_Pref_convergence_criterion;
00085
00086 public:
00087 static CLASS *oclass;
00088 static controller_dg *defaults;
00089 STATUS apply_dynamics(CTRL_VARS *curr_time, CTRL_VARS *curr_delta, double deltaT, int index);
00090 STATUS init_dynamics(CTRL_VARS *curr_time, int index);
00091
00092 public:
00093
00094 controller_dg(MODULE *module);
00095 int create(void);
00096 int init(OBJECT *parent);
00097 TIMESTAMP presync(TIMESTAMP t0, TIMESTAMP t1);
00098 TIMESTAMP sync(TIMESTAMP t0, TIMESTAMP t1);
00099 TIMESTAMP postsync(TIMESTAMP t0, TIMESTAMP t1);
00100
00101 SIMULATIONMODE inter_deltaupdate(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val);
00102 STATUS post_deltaupdate(complex *useful_value, unsigned int mode_pass);
00103
00104 };
00105
00106 #endif