00001
00009 #ifndef _battery_H
00010 #define _battery_H
00011
00012 #include <stdarg.h>
00013
00014 #include "generators.h"
00015 #include "energy_storage.h"
00016
00017 EXPORT STATUS preupdate_battery(OBJECT *obj,TIMESTAMP t0, unsigned int64 delta_time);
00018 EXPORT SIMULATIONMODE interupdate_battery(OBJECT *obj, unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val);
00019 EXPORT STATUS postupdate_battery(OBJECT *obj, complex *useful_value, unsigned int mode_pass);
00020
00021
00022 class battery : public energy_storage
00023 {
00024 private:
00025 TIMESTAMP prev_time;
00026 int first_time_step;
00027 int number_of_phases_out;
00028 int prev_state;
00029
00030
00031 double n_series;
00032 double internal_battery_load;
00033 double r_in;
00034 double v_oc;
00035 double v_t;
00036 double p_br;
00037
00038 bool deltamode_inclusive;
00039 bool first_run;
00040 bool enableDelta;
00041
00042 gld_property *pCircuit_V[3];
00043 gld_property *pLine_I[3];
00044 gld_property *pLine12;
00045 gld_property *pPower;
00046
00047 gld_property *pTout;
00048 gld_property *pSoc;
00049 gld_property *pBatteryLoad;
00050 gld_property *pSocReserve;
00051 gld_property *pRatedPower;
00052
00053
00054 gld_property *peff;
00055 gld_property *pinverter_VA_Out;
00056
00057 complex value_Circuit_V[3];
00058 complex value_Line_I[3];
00059 complex value_Line12;
00060
00061 double value_Tout;
00062
00063 bool parent_is_meter;
00064 bool parent_is_triplex;
00065 bool parent_is_inverter;
00066 bool climate_object_found;
00067
00068 void push_powerflow_currents(void);
00069 protected:
00070
00071 public:
00072
00073 set phases;
00074 double power_transferred;
00075 enum GENERATOR_MODE {
00076 GM_UNKNOWN=0,
00077 GM_CONSTANT_V=1,
00078 GM_CONSTANT_PQ,
00079 GM_CONSTANT_PF,
00080 GM_SUPPLY_DRIVEN,
00081 GM_POWER_DRIVEN,
00082 GM_VOLTAGE_CONTROLLED,
00083 GM_POWER_VOLTAGE_HYBRID
00084 };
00085 enumeration gen_mode_v;
00086
00087
00088
00089 enum GENERATOR_STATUS {
00090 OFFLINE=1,
00091 ONLINE=2
00092 };
00093 enumeration gen_status_v;
00094
00095 enum ADDITIONAL_CONTROLS {
00096 AC_NONE=0,
00097 AC_LINEAR_TEMPERATURE=1
00098 };
00099 enumeration additional_controls;
00100
00101 enum POWER_TYPE {
00102 DC=1,
00103 AC=2
00104 };
00105 enumeration power_type_v;
00106
00107 enum RFB_SIZE {
00108 SMALL=1,
00109 MED_COMMERCIAL,
00110 MED_HIGH_ENERGY,
00111 LARGE,
00112 HOUSEHOLD
00113 };
00114 enumeration rfb_size_v;
00115
00116 enum BATTERY_STATE {
00117 BS_WAITING = 0,
00118 BS_CHARGING = 1,
00119 BS_DISCHARGING = 2,
00120 BS_FULL = 3,
00121 BS_EMPTY = 4,
00122 BS_CONFLICTED = 5,
00123 };
00124 enumeration battery_state;
00125
00126
00127 double power_set_high;
00128 double power_set_low;
00129 double power_set_high_highT;
00130 double power_set_low_highT;
00131 double voltage_set_high;
00132 double voltage_set_low;
00133 double deadband;
00134 double check_power;
00135 double pf;
00136
00137 complex last_current[3];
00138 double no_of_cycles;
00139 bool Iteration_Toggle;
00140 double parasitic_power_draw;
00141 double high_temperature;
00142 double low_temperature;
00143 double midpoint_temperature;
00144 double sensitivity;
00145 double check_power_high;
00146 double check_power_low;
00147 double B_scheduled_power;
00148
00149
00150 bool use_internal_battery_model;
00151 enum {LI_ION=1, LEAD_ACID};
00152 enumeration battery_type;
00153 double soc;
00154 double bat_load;
00155 double last_bat_load;
00156 double b_soc_reserve;
00157
00158 TIMESTAMP state_change_time;
00159
00160
00161
00162 double v_max;
00163 double p_max;
00164
00165 double e_max;
00166 double eta_rt;
00167
00168 double deltat;
00169 unsigned int64 state_change_time_delta;
00170 double pre_soc;
00171 double Pout_delta;
00172
00173 public:
00174
00175 battery(MODULE *module);
00176 int create(void);
00177 int init(OBJECT *parent);
00178
00179 TIMESTAMP rfb_event_time(TIMESTAMP t0, complex power, double e);
00180 TIMESTAMP presync(TIMESTAMP t0, TIMESTAMP t1);
00181 TIMESTAMP sync(TIMESTAMP t0, TIMESTAMP t1);
00182 TIMESTAMP postsync(TIMESTAMP t0, TIMESTAMP t1);
00183
00184 STATUS pre_deltaupdate(TIMESTAMP t0, unsigned int64 delta_time);
00185 SIMULATIONMODE inter_deltaupdate(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val);
00186 STATUS post_deltaupdate(complex *useful_value, unsigned int mode_pass);
00187 void update_soc(unsigned int64 delta_time);
00188 double check_state_change_time_delta(unsigned int64 delta_time, unsigned long dt);
00189
00190 double calculate_efficiency(complex voltage, complex current);
00191 complex calculate_v_terminal(complex v, complex i);
00192
00193 gld_property *map_complex_value(OBJECT *obj, char *name);
00194 gld_property *map_double_value(OBJECT *obj, char *name);
00195 public:
00196 static CLASS *oclass;
00197 static battery *defaults;
00198 #ifdef OPTIONAL
00199 static CLASS *pclass;
00200 TIMESTAMP plc(TIMESTAMP t0, TIMESTAMP t1);
00201 #endif
00202 };
00203
00204 #endif