Xyce  6.1
N_DEV_PowerGridTransformer.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_PowerGridTransformer.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 : 2/22/15
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.5 $
41 //
42 // Revision Date : $Date: 2015/04/08 19:18:24 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_PowerGridTransformer_h
48 #define Xyce_N_DEV_PowerGridTransformer_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 PowerGridTransformer {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance>
66 {
67  static const char *name() {return "PowerGridTransformer";}
68  static const char *deviceTypeName() {return "PowerGridTransformer 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 Transformer 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 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_;
150 
151  // enum-based version of the analysisTypeStr_
153 
154  // definitions for power grid branch device
155  double g11, g12, g21, g22;
156  double b11, b12, b21, b22;
157  std::complex<double> y11, y12, y21, y22;
158 
159  // these are used only for the I=YV formulation
160  double IR1, IR2, II1, II2;
161 
163 
168 
173 
178 
183 
184  // these are used only for the PQ formulation
185  double P1, P2, Q1, Q2;
186 
188 
193 
198 
203 
208 };
209 
210 //-----------------------------------------------------------------------------
211 // Class : Model
212 // Purpose :
213 //
214 //
215 // Special Notes :
216 // Creator : Pete Sholander, SNL, Electrical and Microsystems Modeling
217 // Creation Date : 9/12/14
218 //-----------------------------------------------------------------------------
219 class Model : public DeviceModel
220 {
221  typedef std::vector<Instance *> InstanceVector;
222 
223  friend class ParametricData<Model>;
224  friend class Instance;
225  friend class Traits;
226 
227 public:
228  Model(
229  const Configuration & configuration,
230  const ModelBlock & MB,
231  const FactoryBlock & factory_block);
232  ~Model();
233 
234 private:
235  Model();
236  Model(const Model &);
237  Model &operator=(const Model &);
238 
239 public:
240  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
241 
242  virtual std::ostream &printOutInstances(std::ostream &os) const;
243 
244  virtual bool processParams()
245  {
246  return true;
247  }
248 
249  virtual bool processInstanceParams()
250  {
251  return true;
252  }
253 
254 public:
255  void addInstance(Instance *instance)
256  {
257  instanceContainer.push_back(instance);
258  }
259 
260 private:
261  std::vector<Instance*> instanceContainer;
262 
263 private:
264 };
265 
266 void registerDevice();
267 
268 } // namespace PowerGridTransformer
269 } // namespace Device
270 } // namespace Xyce
271 
272 #endif // Xyce_N_DEV_PowerGridTransformer_h
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Pure virtual class to augment a linear system.
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)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
const std::vector< std::vector< int > > & jacobianStamp() const
Class Configuration contains device configuration data.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
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
virtual std::ostream & printOutInstances(std::ostream &os) const
InstanceBlock represent a device instance line from the netlist.
Instance & operator=(const Instance &)
static std::vector< std::vector< int > > jacStamp
virtual bool processInstanceParams()
processInstanceParams
static void loadModelParameters(ParametricData< Model > &model_parameters)