Xyce  6.1
N_DEV_PowerGridBranch.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_PowerGridBranch.h,v $
27 //
28 // Purpose : PowerGrid classes: provides a device that calculates the
29 // steady state power flow in a transmission grid
30 //
31 // Special Notes : Experimental new device for an LDRD.
32 //
33 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
34 //
35 // Creation Date : 9/12/14
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.9 $
41 //
42 // Revision Date : $Date: 2015/04/08 19:18:24 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_PowerGridBranch_h
48 #define Xyce_N_DEV_PowerGridBranch_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 PowerGridBranch {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance>
66 {
67  static const char *name() {return "PowerGridBranch";}
68  static const char *deviceTypeName() {return "PowerGridBranch 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 Branch device.
83 //
84 // Special Notes :
85 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
86 // Creation Date : 10/16/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  // turnsRatio_ was moved into the transformer model
154  //double turnsRatio_;
155  // Shunt parameters were moved into the bus shunt model
156  //double bus1ShuntConductance_, bus2ShuntConductance_;
157  //double bus1ShuntSusceptance_, bus2ShuntSusceptance_;
158 
159  // definitions for power grid branch device
160  double g11, g12, g21, g22;
161  double b11, b12, b21, b22;
162  std::complex<double> y11, y12, y21, y22;
163 
164  // these are used only for the I=YV formulation
165  double IR1, IR2, II1, II2;
166 
168 
173 
178 
183 
188 
189  // these are used only for the PQ formulation
190  double P1, P2, Q1, Q2;
191 
193 
198 
203 
208 
213 };
214 
215 //-----------------------------------------------------------------------------
216 // Class : Model
217 // Purpose :
218 //
219 //
220 // Special Notes :
221 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
222 // Creation Date : 9/12/14
223 //-----------------------------------------------------------------------------
224 class Model : public DeviceModel
225 {
226  typedef std::vector<Instance *> InstanceVector;
227 
228  friend class ParametricData<Model>;
229  friend class Instance;
230  friend class Traits;
231 
232 public:
233  Model(
234  const Configuration & configuration,
235  const ModelBlock & MB,
236  const FactoryBlock & factory_block);
237  ~Model();
238 
239 private:
240  Model();
241  Model(const Model &);
242  Model &operator=(const Model &);
243 
244 public:
245  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
246 
247  virtual std::ostream &printOutInstances(std::ostream &os) const;
248 
249  virtual bool processParams()
250  {
251  return true;
252  }
253 
254  virtual bool processInstanceParams()
255  {
256  return true;
257  }
258 
259 public:
260  void addInstance(Instance *instance)
261  {
262  instanceContainer.push_back(instance);
263  }
264 
265 private:
266  std::vector<Instance*> instanceContainer;
267 
268 private:
269 };
270 
271 void registerDevice();
272 
273 } // namespace PowerGridBranch
274 } // namespace Device
275 } // namespace Xyce
276 
277 #endif // Xyce_N_DEV_PowerGridBranch_h
static std::vector< std::vector< int > > jacStamp
Pure virtual class to augment a linear system.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static void loadModelParameters(ParametricData< Model > &model_parameters)
virtual bool processInstanceParams()
processInstanceParams
std::vector< Instance * > instanceContainer
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
const std::vector< std::vector< int > > & jacobianStamp() const
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)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Class Configuration contains device configuration data.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Instance & operator=(const Instance &)
Model & operator=(const Model &)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
InstanceBlock represent a device instance line from the netlist.
virtual std::ostream & printOutInstances(std::ostream &os) const
virtual bool processParams()
processParams
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)