Xyce  6.1
N_DEV_Xygra.C
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_Xygra.C,v $
27 //
28 // Purpose : Provide a linking device for coupling to Alegra
29 // simulations.
30 //
31 // Special Notes : Alegra uses API calls to set conductance and source
32 // information used to construct F (or RHS), and to retrieve
33 // nodal voltages.
34 //
35 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
36 //
37 // Creation Date : 08/18/08
38 //
39 // Revision Information:
40 // ---------------------
41 //
42 // Revision Number: $Revision: 1.52 $
43 //
44 // Revision Date : $Date: 2015/04/22 15:00:53 $
45 //
46 // Current Owner : $Author: dgbaur $
47 //-------------------------------------------------------------------------
48 #include <Xyce_config.h>
49 
50 // ---------- Standard Includes ----------
51 
52 #include <sstream>
53 
54 // ---------- Xyce Includes ----------
55 #include <N_DEV_DeviceOptions.h>
56 #include <N_DEV_DeviceMaster.h>
57 #include <N_DEV_ExternData.h>
58 #include <N_DEV_MatrixLoadData.h>
59 #include <N_DEV_SolverState.h>
60 #include <N_DEV_Xygra.h>
61 #include <N_DEV_Message.h>
62 #include <N_ERH_ErrorMgr.h>
63 
64 #include <N_LAS_Vector.h>
65 #include <N_LAS_Matrix.h>
66 #include <N_UTL_FeatureTest.h>
67 
68 namespace Xyce {
69 namespace Device {
70 
71 template<>
73 {
74  addPar ("NAME", "COIL0", &XygraCoilData::name);
75  addPar ("NUMWINDINGS", 1, &XygraCoilData::numWindings);
76 }
77 
79  static ParametricData<XygraCoilData> parMap;
80 
81  return parMap;
82 }
83 
84 
85 //-----------------------------------------------------------------------------
86 // Function : XygraCoilData::XygraCoilData
87 // Purpose : constructor
88 // Special Notes :
89 // Scope : public
90 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
91 // Creation Date : 9/11/2008
92 //-----------------------------------------------------------------------------
94  : CompositeParam(getParametricData()),
95  name("coil"),
96  numWindings(1)
97 {}
98 
99 //-----------------------------------------------------------------------------
100 // Function : XygraCoilData::processParams
101 // Purpose :
102 // Special Notes :
103 // Scope : public
104 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
105 // Creation Date : 9/11/2008
106 //-----------------------------------------------------------------------------
108 {
109 }
110 
111 //-----------------------------------------------------------------------------
112 // Function : operator<<
113 // Purpose : "<<" operator for XygraCoilData
114 // Special Notes :
115 // Scope : public
116 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
117 // Creation Date : 9/11/2008
118 //-----------------------------------------------------------------------------
119 std::ostream & operator<<(std::ostream & os, const XygraCoilData & xcd)
120 {
121  os << " XygraCoilData for: name = " << xcd.getName() <<
122  " numWindings=" << xcd.getNumWindings() <<
123  std::endl;
124 
125  return os;
126 }
127 
128 namespace Xygra {
129 
131 {
132  // Set up configuration constants:
134 }
135 
137 {}
138 
139 
140 // Class Instance
141 //-----------------------------------------------------------------------------
142 // Function : Instance::processParams
143 // Purpose :
144 // Special Notes :
145 // Scope : public
146 // Creator : Tom Russo
147 // Creation Date : 8/18/2008
148 //-----------------------------------------------------------------------------
150 {
151  // If there are any time dependent parameters, set their values at for
152  // the current time.
153 
154  // now set the temperature related stuff.
155  //updateTemperature(temp);
156 
157  return true;
158 }
159 
160 //-----------------------------------------------------------------------------
161 // Function : Instance::updateTemperature
162 // Purpose :
163 // Special Notes :
164 // Scope : public
165 // Creator : Tom Russo, Component Information and Models
166 // Creation Date : 8/18/2008
167 //-----------------------------------------------------------------------------
168 bool Instance::updateTemperature ( const double & temp)
169 {
170  bool bsuccess = true;
171  return bsuccess;
172 }
173 
174 //-----------------------------------------------------------------------------
175 // Function : Instance::Instance
176 // Purpose : constructor
177 // Special Notes :
178 // Scope : public
179 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
180 // Creation Date : 8/18/2008
181 //-----------------------------------------------------------------------------
183  const Configuration & configuration,
184  const InstanceBlock & IB,
185  Model & Miter,
186  const FactoryBlock & factory_block)
187 
188  : DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
189  model_(Miter),
190  t0_(0),
191  t1_(0)
192 {
193  numExtVars = IB.numExtVars; // we have as many as were specified on the
194  // instance line
195  numIntVars = 0;
196  numStateVars = 0;
197 
198  // Start with both vectors empty. We'll only make them the right size
199  // when they get set from setConductances or setSources, so we can tell
200  // whether to bother using them. If not the right size, no contribution
201  // from those terms.
202  theSourceVector_.clear();
203  theConductanceMatrix_.clear();
204  theKMatrix_.clear();
205  k0_.clear();
206  k1_.clear();
207  s0_.clear();
208  s1_.clear();
209 
210 
211  // Set params to constant default values:
212  setDefaultParams ();
213 
214  // Set params according to instance line and constant defaults from metadata:
215  setParams (IB.params);
216 
217  // Set any non-constant parameter defaults:
218 
219  //if (!given("TEMP"))
220  // temp = getDeviceOptions().temp.dVal();
221 
222  // Calculate any parameters specified as expressions:
224 
225  // calculate dependent (ie computed) params and check for errors:
226  processParams ();
227 
228 
229  int totalNumIntVars=0;
230  totalNumWindings = 0;
231  if (!coilDataVec.empty())
232  {
233  if (DEBUG_DEVICE)
234  {
235  Xyce::dout() << " We were given a coil spec." << std::endl;
236  Xyce::dout() << " There were " << coilDataVec.size() << " coils." << std::endl;
237  }
238 
239  // numExtVars is apparently 0 for the default device (which is never
240  // used except for parameter output) and its associated coilDataVec always
241  // has one. So skip this test if numExtVars==0.
242 
243  if ( numExtVars != 0 && numExtVars != coilDataVec.size()*2)
244  {
245  UserError0(*this) << "Xygra Device " << getName() << "has "<< coilDataVec.size() << " coils and " << numExtVars << " external nodes. Number of external nodes should be twice number of coils.";
246  }
247 
248  nCoils=coilDataVec.size();
249  nWindings.resize(nCoils);
250  coilNames.resize(nCoils);
251  for ( int i = 0; i < nCoils; ++i)
252  {
253  if (DEBUG_DEVICE)
254  {
255  Xyce::dout() << " Coil["<< i << "] name is " << coilDataVec[i]->getName() << ", has " << coilDataVec[i]->getNumWindings() << " windings. " << std::endl;
256  }
257  totalNumIntVars += coilDataVec[i]->getNumWindings() - 1;
258  nWindings[i] = coilDataVec[i]->getNumWindings();
259  coilNames[i] = coilDataVec[i]->getName();
261  }
262 
263  if (DEBUG_DEVICE)
264  {
265  Xyce::dout() << " We would have " << totalNumIntVars << " internal vars " << std::endl;
266  }
267  }
268  else
269  {
270  // if no coil spec given, each pair of external nodes corresponds to a
271  // one-winding coil.
272  nCoils=numExtVars/2;
273  nWindings.resize(nCoils,1);
275  if (nCoils*2 != numExtVars)
276  {
277  std::ostringstream ost;
278 
279  ost << "Instance::Instance:";
280  ost << "Number of nodes given to device " << getName() << "is not even."
281  << std::endl;
282  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str() );
283  }
284 
285  }
286  // we'll use these in mapping between winding currents/dV's and nodal
287  // contributions
288  coilExtStart.resize(nCoils);
289  coilIntStart.resize(nCoils);
291 
292  // set up numIntVars:
293  numIntVars = totalNumIntVars;
294 
295  // Now that we have computed our numIntVars, it's OK to
296  // set up jacStamp. For now, we'll have to assume a full (dense) Jacobian
297  // maybe there's a way to get this done later, but I think not, because
298  // topology needs to know it too soon, and we won't know the real structure
299  // until it's too late to use it.
300  //
301  setupJacStamp_();
302 
303  // set up numStateVars:
304  numStateVars = 0;
305 }
306 
307 //-----------------------------------------------------------------------------
308 // Function : Instance::~Instance
309 // Purpose : destructor
310 // Special Notes :
311 // Scope : public
312 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
313 // Creation Date : 8/18/2008
314 //-----------------------------------------------------------------------------
316 {
317 }
318 
319 //-----------------------------------------------------------------------------
320 // Function : Instance::setupJacStamp_
321 // Purpose : Utility function to set up the jacobian stamp
322 // Special Notes : Just makes a dense jacobian stamp for now
323 // Scope : private
324 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
325 // Creation Date : 8/18/08
326 //-----------------------------------------------------------------------------
328 {
329  int numNodes = numExtVars+numIntVars;
330  jacStamp_.resize(numNodes);
331  for (int i=0; i<numNodes; ++i)
332  {
333  jacStamp_[i].resize(numNodes);
334  for (int j=0; j<numNodes; ++j)
335  {
336  jacStamp_[i][j]=j;
337  }
338  }
339 }
340 
341 //-----------------------------------------------------------------------------
342 // Function : Instance::setConductances
343 // Purpose : take matrix of conductances, copy into our local array
344 // Special Notes : The matrix is dense
345 // Scope : public
346 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
347 // Creation Date : 8/18/08
348 //-----------------------------------------------------------------------------
349 bool Instance::setConductances(const std::vector< std::vector<double> > &cM )
350 {
351  int numNodes = numExtVars+numIntVars;
352  // Sanity check:
353  if (cM.size() != numNodes)
354  {
355  std::ostringstream ost;
356 
357  ost << "Instance::setConductances:";
358  ost << " Input matrix passed to device " << getName()
359  << " (" << cM.size()
360  << ") does not have number of rows required by netlist specification ("
361  << numNodes << ")." << std::endl;
362  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
363  }
364  theConductanceMatrix_.resize(numNodes);
365  for (int i=0; i<numNodes; ++i)
366  {
367  if (cM[i].size() != numNodes)
368  {
369  std::ostringstream ost;
370 
371  ost << "Instance::setConductances:";
372  ost << " row " << i << "of matrix passed to device " << getName()
373  << " has " << cM[i].size()
374  << " columns instead of number required by netlist specification ("
375  << numNodes << ")." << std::endl;
376  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
377  }
378 
379  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
380  {
381  Xyce::dout() << std::endl << subsection_divider << std::endl;
382  Xyce::dout() << " Device " << getName() << " setConductances called for time " << getSolverState().currTime_ << std::endl;
383  Xyce::dout() << std::endl << subsection_divider << std::endl;
384  }
385 
386  theConductanceMatrix_[i].resize(numNodes);
387  theConductanceMatrix_[i]=cM[i];
388  }
389  return true;
390 }
391 
392 //-----------------------------------------------------------------------------
393 // Function : Instance::setK
394 // Purpose : take matrix of K values, copy into our local array
395 // Special Notes : The matrix is dense
396 // Scope : public
397 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
398 // Creation Date : 8/18/08
399 //-----------------------------------------------------------------------------
400 bool Instance::setK(const std::vector< std::vector<double> > &kM ,
401  const double t)
402 {
403  std::vector<std::vector<double> > * kPtr;
404 
405  // Decide which of our two K's we're setting
406  if (t==0 || t == getSolverState().currTime_)
407  {
408  kPtr = &k0_;
409  t0_=t;
410  }
411  else
412  {
413  kPtr = &k1_;
414  k0_=k1_; // copy old "future" K to "current" K, because we're resetting
415  // future
416  t0_=t1_; // save old "future" time
417  t1_=t; // set new one
418  }
419 
420  // Sanity check:
421  if (kM.size() != totalNumWindings)
422  {
423  std::ostringstream ost;
424 
425  ost << "Instance::setK:";
426  ost << " Input matrix passed to device " << getName()
427  << " (" << kM.size()
428  << ") does not have number of rows required by netlist specification ("
429  << totalNumWindings << ")." << std::endl;
430  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
431  }
432 
433  for (int i=0; i<totalNumWindings; ++i)
434  {
435  if (kM[i].size() != totalNumWindings)
436  {
437  std::ostringstream ost;
438 
439  ost << "Instance::setK:";
440  ost << " row " << i << "of matrix passed to device " << getName()
441  << " has " << kM[i].size()
442  << " columns instead of number required by netlist specification ("
443  << totalNumWindings << ")." << std::endl;
444  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
445  }
446  }
447 
448  // Sanity check is done, the matrix we're given fits our needs. Now just
449  // copy it.
450  (*kPtr) = kM;
451 
452  // If this is the first call, we have to set K1 properly.
453  if (t==0)
454  {
455  k1_ = k0_; // initialize k1
456  t1_=t0_;
457  }
458 
459  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
460  {
461  Xyce::dout() << std::endl << subsection_divider << std::endl;
462  Xyce::dout() << " Device " << getName() << " setK called for time " << getSolverState().currTime_ << std::endl;
463  Xyce::dout() << std::endl << subsection_divider << std::endl;
464  }
465  return true;
466 }
467 
468 //-----------------------------------------------------------------------------
469 // Function : Instance::getVoltages
470 // Purpose : Copy the values of this devices' nodal voltages
471 // into the provided array.
472 // Special Notes :
473 // Scope : public
474 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
475 // Creation Date : 8/18/08
476 //-----------------------------------------------------------------------------
477 bool Instance::getVoltages( std::vector< double > &nV )
478 {
479  bool bsuccess=true;
480  Linear::Vector * solVectorPtr = extData.nextSolVectorPtr;
481  int numNodes = numExtVars + numIntVars;
482  nV.resize(numNodes);
483 
484  // We will output these in a different order than we have them stored,
485  // so that all of a coil's nodes are in a predictable order:
486  // Coil1 positive
487  // [coil1 internal nodes]
488  // coil1 negative
489  // coil2 positive [...etc....]
490  int offset = 0;
491  for (int coil=0; coil < nCoils; ++coil)
492  {
493  nV[offset++] = (*solVectorPtr)[li_Nodes_[coilExtStart[coil]]];
494  for (int winding=0; winding< nWindings[coil]-1; ++winding)
495  {
496  nV[offset++] = (*solVectorPtr)[li_Nodes_[coilIntStart[coil]+winding]];
497  }
498  nV[offset++] = (*solVectorPtr)[li_Nodes_[coilExtStart[coil]+1]];
499  }
500 
501  return bsuccess;
502 }
503 
504 //-----------------------------------------------------------------------------
505 // Function : Instance::getCoilWindings
506 // Purpose : return individual winding counts for each coil in provided
507 // array
508 // Special Notes :
509 // Scope : public
510 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
511 // Creation Date : 9/15/08
512 //-----------------------------------------------------------------------------
513 void Instance::getCoilWindings( std::vector< int > &cW )
514 {
515  cW = nWindings;
516  return;
517 }
518 
519 //-----------------------------------------------------------------------------
520 // Function : Instance::getCoilNames
521 // Purpose : return individual names for each coil in provided
522 // array
523 // Special Notes :
524 // Scope : public
525 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
526 // Creation Date : 9/29/08
527 //-----------------------------------------------------------------------------
528 void Instance::getCoilNames( std::vector< std::string > &cN )
529 {
530  cN = coilNames;
531  return;
532 }
533 
534 //-----------------------------------------------------------------------------
535 // Function : Instance::setSources
536 // Purpose : take vector of source terms, copy into our local array
537 // Special Notes :
538 // Scope : public
539 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
540 // Creation Date : 8/18/08
541 //-----------------------------------------------------------------------------
542 bool Instance::setSources(const std::vector< double > &sV,
543  const double t)
544 {
545  int numNodes = numExtVars + numIntVars;
546 
547  std::vector<double> * sPtr;
548 
549  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
550  {
551  Xyce::dout() << std::endl << subsection_divider << std::endl;
552  Xyce::dout() << " Device " << getName() << " setSources called for time " << getSolverState().currTime_ << " with value t= " << t << std::endl;
553  Xyce::dout() << std::endl << subsection_divider << std::endl;
554  }
555 
556  // Decide which of our two S's we're setting
557  if (t==0 || t == getSolverState().currTime_)
558  {
559  sPtr = &s0_;
560  t0_=t;
561  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
562  {
563  Xyce::dout() << " setting source s0 for t=" << t << std::endl;
564  }
565  }
566  else
567  {
568  sPtr = &s1_;
569  s0_=s1_; // copy old "future" S to "current" S, because we're resetting
570  // future
571  t0_=t1_; // save old "future" time
572  t1_=t; // set new one
573  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
574  {
575  Xyce::dout() << " setting source s1 for t=" << t << std::endl;
576  }
577  }
578 
579  // Sanity check:
580  if (sV.size() != totalNumWindings)
581  {
582  std::ostringstream ost;
583 
584  ost << "Instance::setSources:";
585  ost << " Input vector passed to device " << getName()
586  << " (" << sV.size()
587  << ") does not have number of rows required by netlist specification ("
588  << totalNumWindings << ")." << std::endl;
589  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
590  }
591 
592  // Sanity check passes, copy the vector
593  (*sPtr) = sV;
594  // If this is the first call, we have to set S1 properly.
595  if (t==0)
596  {
597  s1_ = s0_; // initialize k1
598  t1_=t0_;
599  }
600 
601 
602  return true;
603 }
604 
605 //-----------------------------------------------------------------------------
606 // Function : Instance::interpolateSandK_
607 // Purpose : use s0,k0,t0, s1, k1, t1 to interpolate S and K to current
608 // time
609 // Special Notes :
610 // Scope : private
611 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
612 // Creation Date : 9/15/2008
613 //-----------------------------------------------------------------------------
615 {
616  // if S has been set at all:
617  if (!s0_.empty())
618  {
620  if (getSolverState().currTime_ > t0_ && !s1_.empty() && t0_ != t1_)
621  {
622  double fac=(getSolverState().currTime_ - t0_)/(t1_-t0_);
623  for (int i=0;i<totalNumWindings; ++i)
624  {
625  theSourceVector_[i] += (s1_[i]-s0_[i])*fac;
626  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
627  {
628  Xyce::dout() << " interpolated source for t=" << getSolverState().currTime_ << std::endl;
629  Xyce::dout() << " source vector is: " << std::endl;
630  Xyce::dout() << " s0["<<i<<"] = " << s0_[i] << std::endl;
631  Xyce::dout() << " s1["<<i<<"] = " << s1_[i] << std::endl;
632  Xyce::dout() << " fac = " << fac << std::endl;
633  Xyce::dout() << " s["<<i<<"] = " << theSourceVector_[i] << std::endl;
634  }
635  }
636  }
637  }
638 
639  // if K has been set at all:
640  if (!k0_.empty())
641  {
643  if (getSolverState().currTime_ > t0_ && !k1_.empty() && t0_ != t1_)
644  {
645  double fac=(getSolverState().currTime_ - t0_)/(t1_-t0_);
646  for (int i=0;i<totalNumWindings; ++i)
647  {
648  for (int j=0;i<totalNumWindings; ++i)
649  {
650  theKMatrix_[i][j] += (k1_[i][j]-k0_[i][j])*fac;
651  }
652  }
653  }
654  }
655 }
656 
657 //-----------------------------------------------------------------------------
658 // Function : Instance::registerLIDs
659 // Purpose :
660 // Special Notes :
661 // Scope : public
662 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
663 // Creation Date : 8/18/2008
664 //-----------------------------------------------------------------------------
665 void Instance::registerLIDs(const std::vector<int> & intLIDVecRef,
666  const std::vector<int> & extLIDVecRef)
667 {
668  AssertLIDs(intLIDVecRef.size() == numIntVars);
669  AssertLIDs(extLIDVecRef.size() == numExtVars);
670 
671  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
672  {
673  Xyce::dout() << std::endl << section_divider << std::endl;
674  Xyce::dout() << " Instance::registerLIDs" << std::endl;
675  Xyce::dout() << " name = " << getName() << std::endl;
676  }
677 
678  int numNodes = numExtVars + numIntVars;
679 
680  // copy over the global ID lists.
681  intLIDVec = intLIDVecRef;
682  extLIDVec = extLIDVecRef;
683 
684  li_Nodes_.resize(numNodes);
685 
686  int extVar=0;
687  int intVar=0;
688  int theVar=0;
689 
690  // First comes the external nodes
691  for (int coil=0; coil<nCoils; ++coil)
692  {
693  coilExtStart[coil] = theVar;
694  li_Nodes_[theVar++] = extLIDVec[extVar++];
695  li_Nodes_[theVar++] = extLIDVec[extVar++];
696  }
697  // now the internals
698 
699  for (int coil=0; coil<nCoils; ++coil)
700  {
701  coilIntStart[coil] = theVar;
702  for( int i=0; i< nWindings[coil]-1; ++i)
703  {
704  li_Nodes_[theVar++] = intLIDVec[intVar++];
705  }
706  }
707 
708  // This doesn't really belong in registerLIDs, but since it's only here that
709  // we've calculated everything we need to know, and we need this stuff
710  // later, this is a good place to do it.
711 
712  int globalWinding=0;
713  for (int coil=0; coil<nCoils; ++coil)
714  {
715  for ( int coilWinding=0; coilWinding<nWindings[coil]; coilWinding++)
716  {
717  int posNode;
718  int negNode;
719  if (coilWinding==0)
720  {
721  posNode=coilExtStart[coil];
722  }
723  else
724  {
725  posNode=coilIntStart[coil]+(coilWinding-1);
726  }
727  if (coilWinding==nWindings[coil]-1)
728  {
729  negNode=coilExtStart[coil]+1;
730  }
731  else
732  {
733  negNode=coilIntStart[coil]+coilWinding;
734  }
735  windingNodes[globalWinding++] = std::pair<int,int>(posNode,negNode);
736  }
737  }
738 
739  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
740  {
741  for (int i=0; i<numNodes; ++i)
742  {
743  Xyce::dout() << " li_Nodes_[" <<i << "] = " << li_Nodes_[i] << std::endl;
744  }
745 
746  for (int winding=0; winding<totalNumWindings; winding++)
747  {
748  Xyce::dout() << "Winding " << winding << " between node "
749  << windingNodes[winding].first << " and "
750  << windingNodes[winding].second << std::endl;
751  }
752  }
753 
754  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
755  {
756  Xyce::dout() << section_divider << std::endl;
757  }
758 }
759 
760 //-----------------------------------------------------------------------------
761 // Function : Instance::loadNodeSymbols
762 // Purpose :
763 // Special Notes :
764 // Scope : public
765 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
766 // Creation Date : 05/13/05
767 //-----------------------------------------------------------------------------
768 void Instance::loadNodeSymbols(Util::SymbolTable &symbol_table) const
769 {
770  if (numIntVars != 0)
771  {
772  for (int i = 0; i < nCoils; ++i)
773  {
774  if (nWindings[i] > 1)
775  {
776  // this coil has internal nodes
777  for (int nodeOffset = 1; nodeOffset < nWindings[i]; ++nodeOffset)
778  {
779  int localIndex = li_Nodes_[coilIntStart[i] + nodeOffset - 1];
780  std::ostringstream ost;
781  ost << "coil" << i << "_Internal" << nodeOffset;
782  addInternalNode(symbol_table, localIndex, getName(), ost.str());
783  }
784  }
785  }
786  }
787 }
788 
789 //-----------------------------------------------------------------------------
790 // Function : Instance::registerStateLIDs
791 // Purpose :
792 // Special Notes :
793 // Scope : public
794 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
795 // Creation Date : 8/18/2008
796 //-----------------------------------------------------------------------------
797 void Instance::registerStateLIDs( const std::vector<int> & staLIDVecRef )
798 {
799  AssertLIDs(staLIDVecRef.size() == numStateVars);
800 
801  // copy over the global ID lists.
802  staLIDVec = staLIDVecRef;
803 }
804 
805 //-----------------------------------------------------------------------------
806 // Function : Instance::jacobianStamp
807 // Purpose :
808 // Special Notes :
809 // Scope : public
810 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
811 // Creation Date : 8/18/2008
812 //-----------------------------------------------------------------------------
813 const std::vector< std::vector<int> > & Instance::jacobianStamp() const
814 {
815  return jacStamp_;
816 }
817 
818 //-----------------------------------------------------------------------------
819 // Function : Instance::registerJacLIDs
820 // Purpose :
821 // Special Notes :
822 // Scope : public
823 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
824 // Creation Date : 8/18/2008
825 //-----------------------------------------------------------------------------
826 void Instance::registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec )
827 {
828  DeviceInstance::registerJacLIDs( jacLIDVec );
829  int numNodes=numExtVars+numIntVars;
830  A_Equ_NodeOffsets_.resize(numNodes);
831  for (int equ=0; equ < numNodes; ++equ)
832  {
833  A_Equ_NodeOffsets_[equ].resize(numNodes);
834  for (int node=0; node < numNodes; ++node)
835  {
836  A_Equ_NodeOffsets_[equ][node] = jacLIDVec[equ][node];
837  }
838  }
839 
840 }
841 
842 //-----------------------------------------------------------------------------
843 // Function : Instance::updatePrimaryState
844 // Purpose :
845 // Special Notes :
846 // Scope : public
847 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
848 // Creation Date : 8/18/2008
849 //-----------------------------------------------------------------------------
851 {
852  bool bsuccess = true;
853 
854  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
855  {
856  Xyce::dout() << "Instance::updatePrimaryState" <<std::endl;
857  }
858  bsuccess = updateIntermediateVars();
859  return bsuccess;
860 }
861 
862 //-----------------------------------------------------------------------------
863 // Function : Instance::updateSecondaryState
864 // Purpose :
865 // Special Notes :
866 // Scope : public
867 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
868 // Creation Date : 8/18/2008
869 //-----------------------------------------------------------------------------
871 {
872  bool bsuccess = true;
873 
874  return bsuccess;
875 }
876 
877 
878 //-----------------------------------------------------------------------------
879 // Function : Instance::updateIntermediateVars
880 // Purpose :
881 // Special Notes :
882 // Scope : public
883 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
884 // Creation Date : 9/12/2008
885 //-----------------------------------------------------------------------------
887 {
888 
889  bool bsuccess=true;
890  int numNodes=numIntVars+numExtVars;
891  Linear::Vector * solVectorPtr = extData.nextSolVectorPtr;
892 
893 
894  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
895  {
896  Xyce::dout() << subsection_divider << std::endl;
897  Xyce::dout() << "Instance::updateIntermediateVars "<<std::endl;
898  Xyce::dout() << " name = " << getName() << std::endl;
899  }
900 
901  if (getSolverState().newtonIter == 0) // start of new timestep
902  {
904  }
905 
906  if (solutionVars.size() != numNodes)
907  {
908  // set up all the Fad vectors with the right sizes
909  // We only need to do this the first time around
910  solutionVars.resize(numNodes);
911  fContributions.resize(numNodes);
912  dV.resize(totalNumWindings);
914 
915  // Now, we have to loop over all those vectors and do "resize" operations
916  // on every element in them --- this sets the number of derivatives
917  // on the "DFad" type
918  for (int node=0 ; node<numNodes ; ++node)
919  {
920  solutionVars[node].resize(numNodes);
921  fContributions[node].resize(numNodes);
922  }
923  for (int winding=0 ; winding<totalNumWindings ; ++winding)
924  {
925  dV[winding].resize(numNodes);
926  windingCurrents[winding].resize(numNodes);
927  }
928  }
929  // initialize all the contributions to zero (automatically zeros derivs)
930  for (int node=0; node<numNodes; ++node)
931  {
932  fContributions[node] = 0.0;
933  }
934 
935  // same for the windings:
936  for (int winding=0; winding<totalNumWindings; ++winding)
937  {
938  windingCurrents[winding] = 0.0;
939  }
940 
941 
942  // Extract solution variables and set as DFad independent variables:
943  // (diff sets the row of the derivatives matrix to the identity row
944  for (int node=0; node<numNodes; ++node)
945  {
946  solutionVars[node] = (*solVectorPtr)[li_Nodes_[node]];
947  solutionVars[node].diff(node,numNodes);
948  if (DEBUG_DEVICE)
949  {
950  Xyce::dout() << "solutionVar[" << node << "] = " << solutionVars[node] << std::endl;
951  }
952  }
953 
954  // Now compute winding dV's:
955  for (int winding=0; winding<totalNumWindings; ++winding)
956  {
957  int posNode=windingNodes[winding].first;
958  int negNode=windingNodes[winding].second;
959  dV[winding] = solutionVars[posNode]-solutionVars[negNode];
960  }
961 
962  // Now compute winding currents:
963  // I_i=S_i + sum(j=0,totalNumWindings,K_ij*dV_j)
964  for (int windingI=0; windingI<totalNumWindings; ++windingI)
965  {
966  // we might nave no source vector
967  if (!theSourceVector_.empty())
968  windingCurrents[windingI] = theSourceVector_[windingI];
969 
970  // we might nave no K matrix
971  if (!theKMatrix_.empty())
972  {
973  for (int windingJ=0; windingJ<totalNumWindings; ++windingJ)
974  {
975  windingCurrents[windingI] += theKMatrix_[windingI][windingJ]*dV[windingJ];
976  }
977  }
978  }
979 
980  // Now assemble the contributions for the nodes:
981  for (int winding=0; winding<totalNumWindings; ++winding)
982  {
983  int posNode=windingNodes[winding].first;
984  int negNode=windingNodes[winding].second;
985  if (DEBUG_DEVICE)
986  {
987  Xyce::dout() << "Winding " << winding << " adding " << windingCurrents[winding]
988  << "to contribution to node " << posNode << " and subtracting same "
989  << " from node " << negNode << std::endl;
990  }
991  fContributions[posNode] += windingCurrents[winding];
992  fContributions[negNode] -= windingCurrents[winding];
993  }
994 
995  if (DEBUG_DEVICE)
996  {
997  Xyce::dout() << " Contributions for device " << getName() << std::endl;
998  for (int node=0; node<numNodes; ++node)
999  {
1000  Xyce::dout() << " F[" << node << "] = " << fContributions[node] << std::endl;
1001  }
1002  Xyce::dout() << "Winding potential drops and currents: " << std::endl;
1003  for (int winding=0; winding<totalNumWindings; ++winding)
1004  {
1005  Xyce::dout() << " dV[" << winding << "] = " << dV[winding] << std::endl;
1006  Xyce::dout() << " I[" << winding << "] = " << windingCurrents[winding] << std::endl;
1007  }
1008  }
1009 
1010  return bsuccess;
1011 }
1012 
1013 //-----------------------------------------------------------------------------
1014 // Function : Instance::loadDAEQVector
1015 //
1016 // Purpose : Loads the Q-vector contributions for a single
1017 // instance.
1018 //
1019 // Special Notes : The "Q" vector is part of a standard DAE formalism in
1020 // which the system of equations is represented as:
1021 //
1022 // f(x) = dQ(x)/dt + F(x) - B(t) = 0
1023 //
1024 // Scope : public
1025 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1026 // Creation Date : 8/18/2008
1027 //-----------------------------------------------------------------------------
1029 {
1030  bool bsuccess = true;
1031 
1032  Linear::Vector * solVectorPtr = extData.nextSolVectorPtr;
1033  Linear::Vector * staVectorPtr = extData.nextStaVectorPtr;
1034 
1035  return bsuccess;
1036 }
1037 
1038 
1039 
1040 //-----------------------------------------------------------------------------
1041 // Function : Instance::loadDAEFVector
1042 //
1043 // Purpose : Loads the F-vector contributions for a single
1044 // instance.
1045 //
1046 // Special Notes :
1047 //
1048 // Scope : public
1049 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1050 // Creation Date : 8/18/2008
1051 //-----------------------------------------------------------------------------
1053 {
1054  bool bsuccess=true;
1055 
1056  Linear::Vector * daeFVecPtr = extData.daeFVectorPtr;
1057  int numNodes = numExtVars+numIntVars;
1058 
1059  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
1060  {
1061  Xyce::dout() << subsection_divider << std::endl;
1062  Xyce::dout() << "Instance::loadDAEFVector "<<std::endl;
1063  Xyce::dout() << " name = " << getName() << std::endl;
1064  }
1065 
1066  for (int node=0; node<numNodes; ++node)
1067  {
1068  (*daeFVecPtr)[li_Nodes_[node]] += fContributions[node].val();
1069  if (DEBUG_DEVICE)
1070  {
1071  Xyce::dout() << " fVec[" << node << "] += "
1072  << fContributions[node].val() << std::endl;
1073  Xyce::dout() << " loaded into local ID " << li_Nodes_[node] << std::endl;
1074  }
1075  }
1076 
1077  return bsuccess;
1078 }
1079 
1080 //-----------------------------------------------------------------------------
1081 // Function : Instance::loadDAEdQdx
1082 //
1083 // Purpose : Loads the Q-vector contributions for a single
1084 // instance.
1085 // Scope : public
1086 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1087 // Creation Date : 8/18/2008
1088 //-----------------------------------------------------------------------------
1090 {
1091  bool bsuccess = true;
1092 
1093  // Linear::Matrix * dQdxMatPtr = extData.dQdxMatrixPtr;
1094 
1095  return bsuccess;
1096 }
1097 
1098 
1099 
1100 //-----------------------------------------------------------------------------
1101 // Function : Instance::loadDAEdFdx ()
1102 //
1103 // Purpose : Loads the F-vector contributions for a single
1104 // instance.
1105 //
1106 // Special Notes :
1107 //
1108 // Scope : public
1109 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1110 // Creation Date : 8/18/2008
1111 //-----------------------------------------------------------------------------
1113 {
1114  bool bsuccess = true;
1115 
1116  Linear::Matrix * dFdxMatPtr = extData.dFdxMatrixPtr;
1117  Linear::Vector * staVectorPtr = extData.nextStaVectorPtr;
1118  Linear::Vector * solVectorPtr = extData.nextSolVectorPtr;
1119 
1120  int numNodes = numExtVars+numIntVars;
1121  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
1122  {
1123  Xyce::dout() << subsection_divider << std::endl;
1124  Xyce::dout() << "Instance::loadDAEdFdx "<<std::endl;
1125  Xyce::dout() << " name = " << getName() << std::endl;
1126  }
1127 
1128 #if 0
1129  // Problem: In orginal Xygra testing, I tried to have multi-winding,
1130  // source-only coils. This lead to the problem where internal nodes were
1131  // completely floating, and lead to singular jacobians. My initial reaction
1132  // was to populate the diagonals of the jacobian for source-only
1133  // coils. This is The Wrong Thing To Do.
1134  // It breaks the completely acceptable case of source-only single-winding
1135  // "coils" such as those needed by Emphasis, leading to nonlinear convergence
1136  // failures on what should be a completely linear problem.
1137  //
1138  // There should be something sane to do for multi-winding source-only
1139  // coils, but these are probably not going to be an important issue for now.
1140  // So punt it.
1141  if (theKMatrix_.empty())
1142  {
1143  for (int equ=0; equ < numNodes; ++equ)
1144  {
1145  (*dFdxMatPtr)[li_Nodes_[equ]][A_Equ_NodeOffsets_[equ][equ]] += 1.0;
1146  }
1147  }
1148  else
1149 #endif
1150  {
1151  // Using Sacado differentiation, set the dFdX terms
1152  for (int equ=0; equ < numNodes; ++equ)
1153  {
1154  for (int node=0; node < numNodes; ++node)
1155  {
1156  (*dFdxMatPtr)[li_Nodes_[equ]][A_Equ_NodeOffsets_[equ][node]]
1157  += fContributions[equ].dx(node);
1158  if (DEBUG_DEVICE)
1159  {
1160  Xyce::dout() << " dFdX[" << equ << "]["<<node<<"] += "
1161  << fContributions[equ].dx(node) << std::endl;
1162  }
1163  }
1164  }
1165  }
1166 
1167  return bsuccess;
1168 }
1169 
1170 //-----------------------------------------------------------------------------
1171 // Function : Instance::setIC
1172 // Purpose :
1173 // Special Notes :
1174 // Scope : public
1175 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1176 // Creation Date : 8/18/2008
1177 //-----------------------------------------------------------------------------
1179 {
1180  bool bsuccess = true;
1181 
1182  return bsuccess;
1183 }
1184 
1185 //-----------------------------------------------------------------------------
1186 // Function : Instance::varTypes
1187 // Purpose :
1188 // Special Notes :
1189 // Scope : public
1190 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1191 // Creation Date : 8/18/2008
1192 //-----------------------------------------------------------------------------
1193 void Instance::varTypes( std::vector<char> & varTypeVec )
1194 {
1195  //varTypeVec.resize(1);
1196  //varTypeVec[0] = 'I';
1197 }
1198 
1199 //-----------------------------------------------------------------------------
1200 // Function : Instance::constructComposite
1201 // Purpose :
1202 // Special Notes :
1203 // Scope : public
1204 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1205 // Creation Date : 9/11/2008
1206 //-----------------------------------------------------------------------------
1207 CompositeParam *Instance::constructComposite(const std::string & cName, const std::string & pName)
1208 {
1209  if (cName == "COIL")
1210  {
1211  XygraCoilData *xcd = new XygraCoilData ();
1212  coilDataVec.push_back(xcd);
1213  return (static_cast<CompositeParam *> (xcd));
1214  }
1215  else
1216  {
1217  std::string msg =
1218  "Instance::constructComposite: unrecognized composite name: ";
1219  msg += cName;
1220  N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
1221  }
1222  // never reached
1223  return NULL;
1224 }
1225 
1226 //-----------------------------------------------------------------------------
1227 // Function : Model::processParams
1228 // Purpose :
1229 // Special Notes :
1230 // Scope : public
1231 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1232 // Creation Date : 8/18/2008
1233 //-----------------------------------------------------------------------------
1235 {
1236  return true;
1237 }
1238 
1239 //----------------------------------------------------------------------------
1240 // Function : Model::processInstanceParams
1241 // Purpose :
1242 // Special Notes :
1243 // Scope : public
1244 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1245 // Creation Date : 8/18/2008
1246 //----------------------------------------------------------------------------
1248 {
1249 
1250  std::vector<Instance*>::iterator iter;
1251  std::vector<Instance*>::iterator first = instanceContainer.begin();
1252  std::vector<Instance*>::iterator last = instanceContainer.end();
1253 
1254  for (iter=first; iter!=last; ++iter)
1255  {
1256  (*iter)->processParams();
1257  }
1258 
1259  return true;
1260 }
1261 
1262 //-----------------------------------------------------------------------------
1263 // Function : Model::Model
1264 // Purpose : block constructor
1265 // Special Notes :
1266 // Scope : public
1267 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1268 // Creation Date : 8/18/2008
1269 //-----------------------------------------------------------------------------
1271  const Configuration & configuration,
1272  const ModelBlock & MB,
1273  const FactoryBlock & factory_block)
1274  : DeviceModel(MB, configuration.getModelParameters(), factory_block)
1275 {
1276 
1277  // // Set up mapping from param names to class variables:
1278  // if (parMap.empty())
1279  // {
1280  // // Set up double precision variables:
1281 
1282  // }
1283 
1284  // Set params to constant default values:
1285  setDefaultParams ();
1286 
1287  // Set params according to .model line and constant defaults from metadata:
1288  setModParams (MB.params);
1289 
1290  // Set any non-constant parameter defaults:
1291  //if (!given("TNOM"))
1292  // tnom = getDeviceOptions().tnom;
1293 
1294  // Calculate any parameters specified as expressions:
1296 
1297  // calculate dependent (ie computed) params and check for errors:
1298 
1299  processParams ();
1300 }
1301 
1302 //-----------------------------------------------------------------------------
1303 // Function : Model::~Model
1304 // Purpose : destructor
1305 // Special Notes :
1306 // Scope : public
1307 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1308 // Creation Date : 8/18/2008
1309 //-----------------------------------------------------------------------------
1311 {
1312  std::vector<Instance*>::iterator iter;
1313  std::vector<Instance*>::iterator first = instanceContainer.begin();
1314  std::vector<Instance*>::iterator last = instanceContainer.end();
1315 
1316  for (iter=first; iter!=last; ++iter)
1317  {
1318  delete (*iter);
1319  }
1320 
1321 }
1322 
1323 // additional Declarations
1324 
1325 //-----------------------------------------------------------------------------
1326 // Function : Model::printOutInstances
1327 // Purpose : debugging tool.
1328 // Special Notes :
1329 // Scope : public
1330 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1331 // Creation Date : 8/18/2008
1332 //-----------------------------------------------------------------------------
1333 std::ostream &Model::printOutInstances(std::ostream &os) const
1334 {
1335  std::vector<Instance*>::const_iterator iter;
1336  std::vector<Instance*>::const_iterator first = instanceContainer.begin();
1337  std::vector<Instance*>::const_iterator last = instanceContainer.end();
1338 
1339  int i, isize;
1340  isize = instanceContainer.size();
1341 
1342  os << std::endl;
1343  os << "Number of Xygra instances: " << isize << std::endl;
1344  os << " name=\t\tmodelName\tParameters" << std::endl;
1345  for (i=0, iter=first; iter!=last; ++iter, ++i)
1346  {
1347  os << " " << i << ": " << (*iter)->getName() << "\t";
1348  os << getName();
1349  os << std::endl;
1350  }
1351 
1352  os << std::endl;
1353 
1354  return os;
1355 }
1356 
1357 //-----------------------------------------------------------------------------
1358 // Function : Model::forEachInstance
1359 // Purpose :
1360 // Special Notes :
1361 // Scope : public
1362 // Creator : David Baur
1363 // Creation Date : 2/4/2014
1364 //-----------------------------------------------------------------------------
1365 /// Apply a device instance "op" to all instances associated with this
1366 /// model
1367 ///
1368 /// @param[in] op Operator to apply to all instances.
1369 ///
1370 ///
1371 void Model::forEachInstance(DeviceInstanceOp &op) const /* override */
1372 {
1373  for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1374  op(*it);
1375 }
1376 
1377 
1378 Device *Traits::factory(const Configuration &configuration, const FactoryBlock &factory_block)
1379 {
1380 
1381  return new DeviceMaster<Traits>(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
1382 }
1383 
1385 {
1387  .registerDevice("xygra", 1)
1388  .registerModelType("xygra", 1);
1389 }
1390 
1391 } // namespace Xygra
1392 } // namespace Device
1393 } // namespace Xyce
const InstanceName & getName() const
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_Xygra.C:1333
std::vector< double > theSourceVector_
Definition: N_DEV_Xygra.h:230
std::vector< XygraCoilData * > coilDataVec
Definition: N_DEV_Xygra.h:238
std::vector< std::vector< double > > theConductanceMatrix_
Definition: N_DEV_Xygra.h:226
std::vector< int > coilIntStart
Definition: N_DEV_Xygra.h:250
const SolverState & solverState_
std::string getName() const
Definition: N_DEV_Xygra.h:85
std::map< std::string, XygraCoilData * > coilDataMap
Definition: N_DEV_Xygra.h:199
std::vector< int > li_Nodes_
Definition: N_DEV_Xygra.h:213
Linear::Vector * nextSolVectorPtr
bool setK(const std::vector< std::vector< double > > &kMatrix, const double t=0)
Definition: N_DEV_Xygra.C:400
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_Xygra.C:136
bool setSources(const std::vector< double > &sourceVector, const double t=0)
Definition: N_DEV_Xygra.C:542
Pure virtual class to augment a linear system.
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
static ParametricData< XygraCoilData > & getParametricData()
Definition: N_DEV_Xygra.C:78
bool processParams()
processParams
Definition: N_DEV_Xygra.C:1234
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
Definition: N_DEV_Xygra.C:182
std::vector< std::vector< int > > jacStamp_
Definition: N_DEV_Xygra.h:223
std::vector< XygraFadType > windingCurrents
Definition: N_DEV_Xygra.h:260
#define AssertLIDs(cmp)
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_Xygra.C:768
bool getVoltages(std::vector< double > &voltageValues)
Definition: N_DEV_Xygra.C:477
void getCoilNames(std::vector< std::string > &coilNames)
Definition: N_DEV_Xygra.C:528
CompositeParam * constructComposite(const std::string &, const std::string &)
Definition: N_DEV_Xygra.C:1207
std::vector< std::vector< double > > k1_
Definition: N_DEV_Xygra.h:229
std::vector< Param > params
Parameters from the line.
void setParams(const std::vector< Param > &params)
const std::string & getName() const
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
std::vector< XygraFadType > dV
Definition: N_DEV_Xygra.h:258
std::vector< XygraFadType > fContributions
Definition: N_DEV_Xygra.h:262
std::vector< std::vector< double > > theKMatrix_
Definition: N_DEV_Xygra.h:227
void addComposite(const char *comp_name, const ParametricData< U > &composite_pars, std::map< std::string, U * > V::*composite_map)
Adds a composite parameter to the parameter map.
Definition: N_DEV_Pars.h:1553
std::vector< std::pair< int, int > > windingNodes
Definition: N_DEV_Xygra.h:252
bool processInstanceParams()
processInstanceParams
Definition: N_DEV_Xygra.C:1247
const DeviceOptions & deviceOptions_
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_Xygra.C:813
Linear::Vector * nextStaVectorPtr
std::vector< std::vector< int > > A_Equ_NodeOffsets_
Definition: N_DEV_Xygra.h:221
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
std::vector< int > coilExtStart
Definition: N_DEV_Xygra.h:248
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
std::vector< Instance * > instanceContainer
Definition: N_DEV_Xygra.h:308
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_Xygra.C:1371
void getCoilWindings(std::vector< int > &coilWindings)
Definition: N_DEV_Xygra.C:513
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_Xygra.C:1378
Class Configuration contains device configuration data.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_Xygra.C:665
const SolverState & getSolverState() const
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_Xygra.C:826
void processParams()
processParams post processes the parameters that have been set in the object of the derived class...
Definition: N_DEV_Xygra.C:107
Linear::Vector * daeFVectorPtr
bool setConductances(const std::vector< std::vector< double > > &conductanceMatrix)
Definition: N_DEV_Xygra.C:349
ParametricData()
Constructs the parameter data map.
Definition: N_DEV_Pars.h:1392
void varTypes(std::vector< char > &varTypeVec)
Definition: N_DEV_Xygra.C:1193
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_Xygra.C:797
ModelBlock represents a .MODEL line from the netlist.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_Xygra.C:130
std::vector< Param > params
std::vector< double > s0_
Definition: N_DEV_Xygra.h:231
std::vector< double > s1_
Definition: N_DEV_Xygra.h:232
std::vector< std::vector< double > > k0_
Definition: N_DEV_Xygra.h:228
bool updateTemperature(const double &temp_tmp)
Definition: N_DEV_Xygra.C:168
std::vector< int > nWindings
Definition: N_DEV_Xygra.h:242
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
std::vector< std::string > coilNames
Definition: N_DEV_Xygra.h:244
void setModParams(const std::vector< Param > &params)
std::ostream & operator<<(std::ostream &os, const Configuration &configuration)
Definition: N_DEV_Dump.C:134
std::vector< XygraFadType > solutionVars
Definition: N_DEV_Xygra.h:256