Xyce  6.1
N_DEV_PowerGridGenBus.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_PowerGridGenBus.h,v $
27 //
28 // Purpose : PowerGrid classes: provides a device that calculates the
29 // steady state power flow in an Ideal Generator Bus in a
30 // transmission grid. This device has a fixed output power (P)
31 // and a fixed voltage magnitude (VM).
32 //
33 // Special Notes : Experimental new device for an LDRD.
34 //
35 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
36 //
37 // Creation Date : 12/9/14
38 //
39 // Revision Information:
40 // ---------------------
41 //
42 // Revision Number: $Revision: 1.1.2.2 $
43 //
44 // Revision Date : $Date: 2015/04/02 18:20:11 $
45 //
46 // Current Owner : $Author: tvrusso $
47 //-----------------------------------------------------------------------------
48 
49 #ifndef Xyce_N_DEV_PowerGridGenBus_h
50 #define Xyce_N_DEV_PowerGridGenBus_h
51 
52 #include <complex>
53 
54 // ---------- Xyce Includes ----------
55 #include <N_DEV_Configuration.h>
56 #include <N_DEV_DeviceBlock.h>
57 #include <N_DEV_DeviceInstance.h>
58 #include <N_DEV_DeviceModel.h>
59 
60 namespace Xyce {
61 namespace Device {
62 namespace PowerGridGenBus {
63 
64 class Model;
65 class Instance;
66 
67 struct Traits : public DeviceTraits<Model, Instance>
68 {
69  static const char *name() {return "PowerGridGenBus";}
70  static const char *deviceTypeName() {return "PowerGridGenBus level 1";}
71  static int numNodes() {return 4;}
72  static int numOptionalNodes() {return 0;}
73  static bool isLinearDevice() {return true;}
74 
75  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
76  static void loadModelParameters(ParametricData<Model> &model_parameters);
77  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
78 };
79 
80 //-----------------------------------------------------------------------------
81 // Class : Instance
82 // Purpose :
83 //
84 // This is the instance class for a Power Grid Gen Bus device.
85 //
86 // Special Notes :
87 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
88 // Creation Date : 12/9/14
89 //-----------------------------------------------------------------------------
90 class Instance : public DeviceInstance
91 {
92  friend class ParametricData<Instance>;
93  friend class Model;
94  friend class Traits;
95 
96  // enum for the analysis type
97  enum aType {IV, PQR, PQP, DVS};
98 
99 public:
100 
101  Instance(
102  const Configuration & configuration,
103  const InstanceBlock & IB,
104  Model & Riter,
105  const FactoryBlock & factory_block);
106 
107  ~Instance();
108 
109 private:
110  Instance(const Instance &);
111  Instance &operator=(const Instance &);
112 
113 public:
114  void registerLIDs( const std::vector<int> & intLIDVecRef,
115  const std::vector<int> & extLIDVecRef );
116  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
117 
118  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
119 
120  bool updateIntermediateVars ();
121  bool updatePrimaryState ();
122  //bool updateSecondaryState ();
123 
124  const std::vector< std::vector<int> > & jacobianStamp() const;
125  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
126 
127  // load functions, residual:
128  bool loadDAEQVector () { return true; }
129  bool loadDAEFVector ();
130  bool loadDAEBVector ();
131 
132  // load functions, Jacobian:
133  bool loadDAEdQdx () { return true; }
134  bool loadDAEdFdx ();
135 
136 public:
137  // iterator reference to the ACC model which owns this instance.
138  // Getters and setters
140  {
141  return model_;
142  }
143 
144 private:
145  static std::vector< std::vector<int> > jacStamp;
146 
147  Model & model_; //< Owning model
148 
149  // user-specified parameters:
150  std::string analysisTypeStr_;
151  double power_, VMag_, QMax_, QMin_;
152 
153  // enum-based version of the analysisTypeStr_
155 
156  // these are used only for the I=YV formulation
157  double IR1, IR2, II1, II2;
158  double VR1, VR2, VI1, VI2;
161 
162  // These definitions will go away. They were copied from the branch device
163  double g11, g12, g21, g22;
164  double b11, b12, b21, b22;
165  std::complex<double> y11, y12, y21, y22;
166 
168 
177 
178  // these are used only for the PQ formulation
179  double P1, P2, Q1, Q2, reactPower_;
180  double VM1, VM2, Theta1, Theta2;
182 
184 
187 
188  // used for PQR
192 };
193 
194 //-----------------------------------------------------------------------------
195 // Class : Model
196 // Purpose :
197 //
198 //
199 // Special Notes :
200 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
201 // Creation Date : 12/9/14
202 //-----------------------------------------------------------------------------
203 class Model : public DeviceModel
204 {
205  typedef std::vector<Instance *> InstanceVector;
206 
207  friend class ParametricData<Model>;
208  friend class Instance;
209  friend class Traits;
210 
211 public:
212  Model(
213  const Configuration & configuration,
214  const ModelBlock & MB,
215  const FactoryBlock & factory_block);
216  ~Model();
217 
218 private:
219  Model();
220  Model(const Model &);
221  Model &operator=(const Model &);
222 
223 public:
224  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
225 
226  virtual std::ostream &printOutInstances(std::ostream &os) const;
227 
228  virtual bool processParams()
229  {
230  return true;
231  }
232 
233  virtual bool processInstanceParams()
234  {
235  return true;
236  }
237 
238 public:
239  void addInstance(Instance *instance)
240  {
241  instanceContainer.push_back(instance);
242  }
243 
244 private:
245  std::vector<Instance*> instanceContainer;
246 
247 private:
248 };
249 
250 void registerDevice();
251 
252 } // namespace PowerGridGenBus
253 } // namespace Device
254 } // namespace Xyce
255 
256 #endif // Xyce_N_DEV_PowerGridGenBus_h
Pure virtual class to augment a linear system.
std::vector< Instance * > instanceContainer
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
virtual bool processInstanceParams()
processInstanceParams
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Instance & operator=(const Instance &)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
static void loadModelParameters(ParametricData< Model > &model_parameters)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static std::vector< std::vector< int > > jacStamp
Model & operator=(const Model &)
Class Configuration contains device configuration data.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
const std::vector< std::vector< int > > & jacobianStamp() const
ModelBlock represents a .MODEL line from the netlist.
virtual std::ostream & printOutInstances(std::ostream &os) const
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
virtual bool processParams()
processParams