Xyce  6.1
N_DEV_PowerGridBusShunt.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_PowerGridBusShunt.h,v $
27 //
28 // Purpose : PowerGrid classes: provides a device that calculates the
29 // steady state power flow in a transmission grid bus shunt
30 //
31 // Special Notes : Experimental new device for an LDRD.
32 //
33 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
34 //
35 // Creation Date : 12/4/14
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.7.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:11 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_PowerGridBusShunt_h
48 #define Xyce_N_DEV_PowerGridBusShunt_h
49 
50 #include <complex>
51 
52 // ---------- Xyce Includes ----------
53 #include <N_DEV_Configuration.h>
54 #include <N_DEV_DeviceBlock.h>
55 #include <N_DEV_DeviceInstance.h>
56 #include <N_DEV_DeviceModel.h>
57 
58 namespace Xyce {
59 namespace Device {
60 namespace PowerGridBusShunt {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance>
66 {
67  static const char *name() {return "PowerGridBusShunt";}
68  static const char *deviceTypeName() {return "PowerGridBusShunt level 1";}
69  static int numNodes() {return 4;}
70  static int numOptionalNodes() {return 0;}
71  static bool isLinearDevice() {return true;}
72 
73  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
74  static void loadModelParameters(ParametricData<Model> &model_parameters);
75  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
76 };
77 
78 //-----------------------------------------------------------------------------
79 // Class : Instance
80 // Purpose :
81 //
82 // This is the instance class for a Power Grid Bus Shunt device.
83 //
84 // Special Notes :
85 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
86 // Creation Date : 12/4/14
87 //-----------------------------------------------------------------------------
88 class Instance : public DeviceInstance
89 {
90  friend class ParametricData<Instance>;
91  friend class Model;
92  friend class Traits;
93 
94  // enum for the analysis type
95  enum aType {IV, PQR, PQP};
96 
97 public:
98 
99  Instance(
100  const Configuration & configuration,
101  const InstanceBlock & IB,
102  Model & Riter,
103  const FactoryBlock & factory_block);
104 
105  ~Instance();
106 
107 private:
108  Instance(const Instance &);
109  Instance &operator=(const Instance &);
110 
111 public:
112  void registerLIDs( const std::vector<int> & intLIDVecRef,
113  const std::vector<int> & extLIDVecRef );
114  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
115 
116  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
117 
118  bool updateIntermediateVars ();
119  bool updatePrimaryState ();
120  //bool updateSecondaryState ();
121 
122  const std::vector< std::vector<int> > & jacobianStamp() const;
123  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
124 
125  // load functions, residual:
126  bool loadDAEQVector ();
127  bool loadDAEFVector ();
128 
129  // load functions, Jacobian:
130  bool loadDAEdQdx ();
131  bool loadDAEdFdx ();
132 
133 public:
134  // iterator reference to the ACC model which owns this instance.
135  // Getters and setters
137  {
138  return model_;
139  }
140 
141 private:
142  static std::vector< std::vector<int> > jacStamp;
143 
144  Model & model_; //< Owning model
145 
146  // user-specified parameters:
147  std::string analysisTypeStr_;
149 
150  // enum-based version of the analysisTypeStr_
152 
153  // definitions for power grid bus shunt device
154  double g11, g12, g21, g22;
155  double b11, b12, b21, b22;
156  std::complex<double> y11, y12, y21, y22;
157 
158  // these are used only for the I=YV formulation
159  double IR1, IR2, II1, II2;
160 
162 
167 
172 
177 
182 
183  // these are used only for the PQ formulation
184  double P1, P2, Q1, Q2;
185 
187 
192 
197 
202 
207 };
208 
209 //-----------------------------------------------------------------------------
210 // Class : Model
211 // Purpose :
212 //
213 //
214 // Special Notes :
215 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
216 // Creation Date : 12/4/14
217 //-----------------------------------------------------------------------------
218 class Model : public DeviceModel
219 {
220  typedef std::vector<Instance *> InstanceVector;
221 
222  friend class ParametricData<Model>;
223  friend class Instance;
224  friend class Traits;
225 
226 public:
227  Model(
228  const Configuration & configuration,
229  const ModelBlock & MB,
230  const FactoryBlock & factory_block);
231  ~Model();
232 
233 private:
234  Model();
235  Model(const Model &);
236  Model &operator=(const Model &);
237 
238 public:
239  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
240 
241  virtual std::ostream &printOutInstances(std::ostream &os) const;
242 
243  virtual bool processParams()
244  {
245  return true;
246  }
247 
248  virtual bool processInstanceParams()
249  {
250  return true;
251  }
252 
253 public:
254  void addInstance(Instance *instance)
255  {
256  instanceContainer.push_back(instance);
257  }
258 
259 private:
260  std::vector<Instance*> instanceContainer;
261 
262 private:
263 };
264 
265 void registerDevice();
266 
267 } // namespace PowerGridBusShunt
268 } // namespace Device
269 } // namespace Xyce
270 
271 #endif // Xyce_N_DEV_PowerGridBusShunt_h
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
virtual bool processInstanceParams()
processInstanceParams
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Pure virtual class to augment a linear system.
Instance & operator=(const Instance &)
virtual std::ostream & printOutInstances(std::ostream &os) const
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static std::vector< std::vector< int > > jacStamp
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.
const std::vector< std::vector< int > > & jacobianStamp() const
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
static void loadModelParameters(ParametricData< Model > &model_parameters)