00001 #ifndef _autoinit_h_
00002 #define _autoinit_h_
00003 #include "ElectricalData.h"
00004 #include <map>
00005 #include <exception>
00006
00010 class DataFileFormatException:
00011 public std::exception
00012 {
00013 public:
00014 DataFileFormatException(std::string err_msg):
00015 std::exception(),err_msg(err_msg)
00016 {
00017 }
00018 const char* what() const throw() { return err_msg.c_str(); }
00019 ~DataFileFormatException() throw() {}
00020 private:
00021 const std::string err_msg;
00022 };
00023
00028 class AutoInitializingData:
00029 public ElectricalData
00030 {
00031 public:
00033 AutoInitializingData();
00035 virtual unsigned getGenrCount() { return genr_nodes.size(); }
00037 virtual unsigned getNodeCount() { return nodes.size(); }
00039 virtual const std::vector<unsigned>& getGenrs() { return genr_nodes; }
00041 virtual const std::vector<line_t>& getLines() { return lines; }
00046 virtual Complex getAdmittance(unsigned node);
00050 virtual load_param_t getLoadParams(unsigned bus)
00051 {
00052 load_param_t default_values;
00053 return default_values;
00054 }
00056 virtual genr_t getGenrParams(unsigned genr);
00062 void setGenrParams(unsigned at_node, genr_t params);
00069 void setInitialConditions();
00071 ~AutoInitializingData();
00072 protected:
00073 struct bus_data_t
00074 {
00075 int ID;
00076 double v;
00077 double theta;
00078 double load_mw;
00079 double load_mvar;
00080 double genr_mw;
00081 double genr_mvar;
00082 Complex B;
00083 };
00084 std::vector<unsigned> genr_nodes;
00085 std::vector<bus_data_t> nodes;
00086 std::map<unsigned,genr_t> genrs;
00087 std::vector<line_t> lines;
00093 void addGenr(bus_data_t bus_data, double mvar_base, double kv_base = 13.8);
00094 private:
00095 bool init_done;
00096 };
00097
00098 #endif