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.5 $
43 //
44 // Revision Date : $Date: 2015/08/26 17:57:10 $
45 //
46 // Current Owner : $Author: peshola $
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, VCS, CCS, RCB};
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 
178 
179  // these are used only for the PQ formulation
180  double P1, P2, Q1, Q2, reactPower_;
181  double VM1, VM2, Theta1, Theta2;
184 
186 
191 
192  // used for PQR
196 
197  // used for RCB
199 
200  // used to delay enforcing the Q limits in updateIntermediateVars() based
201  // on the number of Newton Iterations reported by the getSolverState() function
203 };
204 
205 //-----------------------------------------------------------------------------
206 // Class : Model
207 // Purpose :
208 //
209 //
210 // Special Notes :
211 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
212 // Creation Date : 12/9/14
213 //-----------------------------------------------------------------------------
214 class Model : public DeviceModel
215 {
216  typedef std::vector<Instance *> InstanceVector;
217 
218  friend class ParametricData<Model>;
219  friend class Instance;
220  friend class Traits;
221 
222 public:
223  Model(
224  const Configuration & configuration,
225  const ModelBlock & MB,
226  const FactoryBlock & factory_block);
227  ~Model();
228 
229 private:
230  Model();
231  Model(const Model &);
232  Model &operator=(const Model &);
233 
234 public:
235  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
236 
237  virtual std::ostream &printOutInstances(std::ostream &os) const;
238 
239  virtual bool processParams()
240  {
241  return true;
242  }
243 
244  virtual bool processInstanceParams()
245  {
246  return true;
247  }
248 
249 public:
250  void addInstance(Instance *instance)
251  {
252  instanceContainer.push_back(instance);
253  }
254 
255 private:
256  std::vector<Instance*> instanceContainer;
257 
258 private:
259 };
260 
261 void registerDevice();
262 
263 } // namespace PowerGridGenBus
264 } // namespace Device
265 } // namespace Xyce
266 
267 #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