Xyce  6.1
N_DEV_TransLine.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright (c) 2002-2015, Sandia Corporation, Albuquerque, NM, USA. Under the
5 // terms of Contract DE-AC04-94AL85000, there is a non-exclusive license for
6 // use of this work by or on behalf of the U.S. Government. Export of this
7 // program may require a license from the United States Government.
8 //
9 // Xyce(TM) Parallel Electrical Simulator
10 // Copyright (C) 2002-2015 Sandia Corporation
11 //
12 // This program is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //-----------------------------------------------------------------------------
25 
26 //-------------------------------------------------------------------------
27 // Filename : $RCSfile: N_DEV_TransLine.C,v $
28 //
29 // Purpose :
30 //
31 // Special Notes :
32 //
33 // Creator : Eric Keiter, SNL
34 //
35 // Creation Date : 9/17/2013
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.34.2.2 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:29:38 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 
50 // ---------- Standard Includes ----------
51 #include <algorithm>
52 #include <N_UTL_Math.h>
53 
54 // ---------- Xyce Includes ----------
55 #include <N_DEV_Const.h>
56 #include <N_DEV_DeviceMaster.h>
57 #include <N_DEV_DeviceOptions.h>
58 #include <N_DEV_ExternData.h>
59 #include <N_DEV_MatrixLoadData.h>
60 #include <N_DEV_Message.h>
61 #include <N_DEV_SolverState.h>
62 #include <N_DEV_TransLine.h>
63 #include <N_ERH_ErrorMgr.h>
64 #include <N_IO_mmio.h>
65 #include <N_LAS_Matrix.h>
66 #include <N_LAS_Vector.h>
67 #include <N_UTL_Expression.h>
68 #include <N_UTL_FeatureTest.h>
69 
70 #include <Teuchos_BLAS.hpp>
71 #include <Teuchos_Utils.hpp>
72 #include <Teuchos_LAPACK.hpp>
73 
74 #undef HAVE_CMATH
75 #undef HAVE_CSTDIO
76 #undef HAVE_CSTDLIB
77 #undef HAVE_INTTYPES_H
78 #undef HAVE_IOSTREAM
79 #undef HAVE_STDINT_H
80 #include <Trilinos_Util.h>
81 
82 namespace Xyce {
83 namespace Device {
84 
85 namespace TransLine {
86 
88 {
90  .setGivenMember(&TransLine::Instance::numLumpsGiven);
91 
92  p.addPar ("LEN",0.0,&TransLine::Instance::length)
93  .setGivenMember(&TransLine::Instance::lengthGiven)
94  .setUnit(U_METER)
95  .setCategory(CAT_NONE)
96  .setDescription("length of line");
97 }
98 
100 {
101  p.addPar ("R",0.0,&TransLine::Model::resist)
102  .setGivenMember(&TransLine::Model::resistGiven)
103  .setUnit(U_OHMMM1)
104  .setCategory(CAT_NONE)
105  .setDescription("Resistance per unit length");
106 
107  p.addPar ("L",0.0,&TransLine::Model::induct)
108  .setGivenMember(&TransLine::Model::inductGiven)
109  .setUnit(U_HMM1)
110  .setCategory(CAT_NONE)
111  .setDescription("Inductance per unit length");
112 
113  p.addPar ("G",0.0,&TransLine::Model::conduct)
114  .setGivenMember(&TransLine::Model::conductGiven)
115  .setUnit(U_OHMM1MM1)
116  .setCategory(CAT_NONE)
117  .setDescription("Conductance per unit length");
118 
119  p.addPar ("C",0.0,&TransLine::Model::capac)
120  .setGivenMember(&TransLine::Model::capacGiven)
121  .setUnit(U_FARADMM1)
122  .setCategory(CAT_NONE)
123  .setDescription("Capacitance per unit length");
124 
126  .setGivenMember(&TransLine::Model::elevNumberGiven);
127 }
128 
129 // Class Instance
130 //-----------------------------------------------------------------------------
131 // Function : Instance::processParams
132 // Purpose :
133 // Special Notes :
134 // Scope : public
135 // Creator : Eric Keiter, SNL
136 // Creation Date : 9/17/2013
137 //-----------------------------------------------------------------------------
139 {
140  return true;
141 }
142 
143 //-----------------------------------------------------------------------------
144 // Function : Instance::updateTemperature
145 // Purpose :
146 // Special Notes :
147 // Scope : public
148 // Creator : Eric Keiter, SNL
149 // Creation Date : 9/17/2013
150 //-----------------------------------------------------------------------------
151 bool Instance::updateTemperature ( const double & temp_tmp)
152 {
153  return true;
154 }
155 
156 //-----------------------------------------------------------------------------
157 // Function : Instance::Instance
158 // Purpose : instance block constructor
159 // Special Notes :
160 // Scope : public
161 // Creator : Eric Keiter, SNL
162 // Creation Date : 9/17/2013
163 //-----------------------------------------------------------------------------
165  const Configuration & configuration,
166  const InstanceBlock & IB,
167  Model & TransLineiter,
168  const FactoryBlock & factory_block)
169  : DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
170  model_(TransLineiter),
171  numLumps(1),
172  numTransLineVars(0),
173  length(0.0),
174  numLumpsGiven(false),
175  lengthGiven(false),
176  L(0.0),C(0.0),G(0.0),R(0.0)
177 {
178  numExtVars = IB.numExtVars; // we have as many as were specified on the
179  // instance line
180 
181  // Set params to constant default values:
182  setDefaultParams ();
183 
184  // Set params according to instance line and constant defaults from metadata:
185  setParams (IB.params);
186 
187  // Calculate any parameters specified as expressions:
189 
190  // calculate dependent (ie computed) params:
191  processParams ();
192 
193 
194  // setup R,L,C,G.
195  double dx = (1.0/static_cast<double>(numLumps))*length;
196  if (model_.resistGiven)
197  {
198  R = model_.resist*dx;
199  G = 1/R;
200  }
201  if (model_.capacGiven)
202  {
203  C = model_.capac*dx;
204  }
205  if (model_.inductGiven)
206  {
207  L = model_.induct*dx;
208  }
209 
210  // Initialize which case this is based on the nonzero user-specified
211  // parameters.
212  if ((model_.resist == 0) && (model_.conduct == 0) &&
213  (model_.capac != 0) && (model_.induct != 0))
214  {
216  }
217  else if ((model_.resist != 0) && (model_.conduct == 0) &&
218  (model_.capac != 0) && (model_.induct != 0))
219  {
221  }
222 
223  if (DEBUG_DEVICE)
224  {
225  if (isActive(Diag::DEVICE_PARAMETERS))
226  {
227  std::cout << "model_.resist = " << model_.resist <<std::endl;
228  std::cout << "model_.capac = " << model_.capac <<std::endl;
229  std::cout << "model_.induct = " << model_.induct <<std::endl;
230 
231  std::cout << "R = " << R <<std::endl;
232  std::cout << "G = " << G <<std::endl;
233  std::cout << "C = " << C <<std::endl;
234  std::cout << "L = " << L <<std::endl;
235 
237  {
238  std::cout << "RLC line" <<std::endl;
239  }
240  else if (model_.specialCase == TRANS_MOD_LC)
241  {
242  std::cout << "LC line" <<std::endl;
243  }
244  }
245  }
246 
248  {
249  // RLC line.
250  //
251  // each RLC lump has 2 voltage nodes and 1 branch current (3 vars)
252  // there are two external variables, at opposite ends of the line.
253  // One of them has to be subtracted from the numIntVars.
254  //
255  // lump 1 lump 2 lump 3 lump 4
256  // Input --L--1--R--2 --L--3--R--4 --L--5--R--6 --L--7--R--x Output
257  // | | | |
258  // C C C C
259  // | | | |
260  // 0(gnd) 0(gnd) 0(gnd) 0(gnd)
261  //
262  //
263  numIntVars = numLumps*3-1;
264  numExtVars = 2;
265  numStateVars = 0;
266 
267  lumpVec.resize(numLumps);
268 
269  // loop over the lumps, set up nominal indices
270  for (int lump=0;lump<numLumps;++lump)
271  {
272  int varsPerLump=3; // 2 voltage nodes and one branch current.
273  lumpVec[lump].indexV1 = lump*varsPerLump; // voltage node 1
274  lumpVec[lump].indexV2 = lump*varsPerLump+1; // voltage node 2
275  lumpVec[lump].indexI = lump*varsPerLump+2; // branch current
276  lumpVec[lump].indexV3 = (lump+1)*varsPerLump; // voltage node 3
277  }
278 
279  if (DEBUG_DEVICE)
280  {
281  if (isActive(Diag::DEVICE_PARAMETERS))
282  {
283  std::cout << "lumps = " << numLumps <<std::endl;
284  for (int lump=0;lump<numLumps;++lump)
285  {
286  std::cout << "lumpVec["<<lump<<"]: v1 = " << lumpVec[lump].indexV1;
287  std::cout << " v2 = " << lumpVec[lump].indexV2;
288  std::cout << " i = " << lumpVec[lump].indexI ;
289  std::cout << " v3 = " << lumpVec[lump].indexV3;
290  std::cout << std::endl;
291  }
292  }
293  }
294 
295  // now correct the lump vector to account for the ends of the
296  // line, which are external vars. The first node (input) will not cause a
297  // correction as it is naturally the first index(0) anyway.
298  //
299  // All nodes that are greater than 0 will need to be incremented by 1,
300  // as the next external node will be index 1.
301  for (int lump=0;lump<numLumps;++lump)
302  {
303  if (lumpVec[lump].indexV1 > 0) lumpVec[lump].indexV1++;
304  if (lumpVec[lump].indexV2 > 0) lumpVec[lump].indexV2++;
305  if (lumpVec[lump].indexI > 0) lumpVec[lump].indexI++;
306  if (lumpVec[lump].indexV3 > 0) lumpVec[lump].indexV3++;
307  }
308 
309  // the last index (being an external var) much be set back to 1.
310  lumpVec[numLumps-1].indexV3 = 1;
311 
312 
313  if (DEBUG_DEVICE)
314  {
315  if (isActive(Diag::DEVICE_PARAMETERS))
316  {
317  std::cout << "lumps = " << numLumps <<std::endl;
318  for (int lump=0;lump<numLumps;++lump)
319  {
320  std::cout << "lumpVec["<<lump<<"]: v1 = " << lumpVec[lump].indexV1;
321  std::cout << " v2 = " << lumpVec[lump].indexV2;
322  std::cout << " i = " << lumpVec[lump].indexI ;
323  std::cout << " v3 = " << lumpVec[lump].indexV3;
324  std::cout << std::endl;
325  }
326  }
327  }
328 
329  // setup jacobian stamp
331 
332  // do jacStamp for the exterior lumps
333  {
334  int lump=0;
335  int n1 = lumpVec[lump].indexV1;
336  int n2 = lumpVec[lump].indexV2;
337  int ii = lumpVec[lump].indexI;
338  int n3 = lumpVec[lump].indexV3;
339 
340  jacStamp[n1].resize(1);
341  jacStamp[n1][0] = ii;
342  jacStamp[n2].resize(3);
343  jacStamp[n2][0] = n2;
344  jacStamp[n2][1] = ii;
345  jacStamp[n2][2] = n3;
346  jacStamp[ii].resize(3);
347  jacStamp[ii][0] = n1;
348  jacStamp[ii][1] = n2;
349  jacStamp[ii][2] = ii;
350 
351  if (numLumps==1)
352  {
353  jacStamp[n3].resize(2);
354  jacStamp[n3][0] = n2;
355  jacStamp[n3][1] = n3;
356  }
357  }
358 
359  if (numLumps>1)
360  {
361  int lump=numLumps-1;
362  int n1 = lumpVec[lump].indexV1;
363  int n2 = lumpVec[lump].indexV2;
364  int ii = lumpVec[lump].indexI;
365  int n3 = lumpVec[lump].indexV3;
366 
367  jacStamp[n1].resize(3);
368  jacStamp[n1][0] = lumpVec[lump-1].indexV2;
369  jacStamp[n1][1] = n1;
370  jacStamp[n1][2] = ii;
371 
372  jacStamp[n2].resize(3);
373  jacStamp[n2][0] = n2;
374  jacStamp[n2][1] = ii;
375  jacStamp[n2][2] = n3;
376 
377  jacStamp[ii].resize(3);
378  jacStamp[ii][0] = n1;
379  jacStamp[ii][1] = n2;
380  jacStamp[ii][2] = ii;
381 
382  jacStamp[n3].resize(2);
383  jacStamp[n3][0] = n2;
384  jacStamp[n3][1] = n3;
385 
386  }
387 
388  // do jacStamp for the interior lumps
389  for (int lump=1;lump<numLumps-1;++lump)
390  {
391  int n1 = lumpVec[lump].indexV1;
392  int n2 = lumpVec[lump].indexV2;
393  int ii = lumpVec[lump].indexI;
394  int n3 = lumpVec[lump].indexV3;
395 
396  jacStamp[n1].resize(3);
397  jacStamp[n1][0] = lumpVec[lump-1].indexV2;
398  jacStamp[n1][1] = n1;
399  jacStamp[n1][2] = ii;
400  jacStamp[n2].resize(3);
401  jacStamp[n2][0] = n2;
402  jacStamp[n2][1] = ii;
403  jacStamp[n2][2] = n3;
404  jacStamp[ii].resize(3);
405  jacStamp[ii][0] = n1;
406  jacStamp[ii][1] = n2;
407  jacStamp[ii][2] = ii;
408  }
409  }
410  else if ( model_.specialCase == TRANS_MOD_LC)
411  {
412  // LC line.
413  //
414  // each LC lump has 1 voltage node and 1 branch current (2 vars)
415  // there are two external variables, at opposite ends of the line.
416  // One of them has to be subtracted from the numIntVars.
417  //
418  // lump 1 lump 2 lump 3 lump 4
419  // Input --L--------1----L--------2----L--------3----L--------x Output
420  // | | | |
421  // C C C C
422  // | | | |
423  // 0(gnd) 0(gnd) 0(gnd) 0(gnd)
424  //
425  numIntVars = numLumps*2-1;
426  numExtVars = 2;
427  numStateVars = 0;
428 
429  lumpVec.resize(numLumps);
430 
431  // loop over the lumps, set up nominal indices
432  for (int lump=0;lump<numLumps;++lump)
433  {
434  int varsPerLump=2; // 2 voltage nodes and one branch current.
435  lumpVec[lump].indexV1 = lump*varsPerLump; // voltage node 1
436  lumpVec[lump].indexI = lump*varsPerLump+1; // branch current
437  lumpVec[lump].indexV2 = (lump+1)*varsPerLump; // voltage node 3
438  }
439 
440  if (DEBUG_DEVICE)
441  {
442  if (isActive(Diag::DEVICE_PARAMETERS))
443  {
444  std::cout << "lumps = " << numLumps <<std::endl;
445  for (int lump=0;lump<numLumps;++lump)
446  {
447  std::cout << "lumpVec["<<lump<<"]: v1 = " << lumpVec[lump].indexV1;
448  std::cout << " i = " << lumpVec[lump].indexI ;
449  std::cout << " v2 = " << lumpVec[lump].indexV2;
450  std::cout << std::endl;
451  }
452  }
453  }
454 
455  // now correct the lump vector to account for the ends of the
456  // line, which are external vars. The first node (input) will not cause a
457  // correction as it is naturally the first index(0) anyway.
458  //
459  // All nodes that are greater than 0 will need to be incremented by 1,
460  // as the next external node will be index 1.
461  for (int lump=0;lump<numLumps;++lump)
462  {
463  if (lumpVec[lump].indexV1 > 0) lumpVec[lump].indexV1++;
464  if (lumpVec[lump].indexI > 0) lumpVec[lump].indexI++;
465  if (lumpVec[lump].indexV2 > 0) lumpVec[lump].indexV2++;
466  }
467 
468  // the last index (being an external var) much be set back to 1.
469  lumpVec[numLumps-1].indexV2 = 1;
470 
471 
472  if (DEBUG_DEVICE)
473  {
474  if (isActive(Diag::DEVICE_PARAMETERS))
475  {
476  std::cout << "lumps = " << numLumps <<std::endl;
477  for (int lump=0;lump<numLumps;++lump)
478  {
479  std::cout << "lumpVec["<<lump<<"]: v1 = " << lumpVec[lump].indexV1;
480  std::cout << " i = " << lumpVec[lump].indexI ;
481  std::cout << " v2 = " << lumpVec[lump].indexV2;
482  std::cout << std::endl;
483  }
484  }
485  }
486 
487  // setup jacobian stamp
489 
490  // do jacStamp for the exterior lumps
491  {
492  int lump=0;
493  int n1 = lumpVec[lump].indexV1;
494  int n2 = lumpVec[lump].indexV2;
495  int ii = lumpVec[lump].indexI;
496 
497  jacStamp[n1].resize(1);
498  jacStamp[n1][0] = ii;
499 
500  jacStamp[ii].resize(3);
501  jacStamp[ii][0] = n1;
502  jacStamp[ii][1] = ii;
503  jacStamp[ii][2] = n2;
504 
505  if (numLumps==1)
506  {
507  jacStamp[n2].resize(2);
508  jacStamp[n2][0] = ii;
509  jacStamp[n2][1] = n2;
510  }
511  }
512 
513  if (numLumps>1)
514  {
515  int lump=numLumps-1;
516  int n1 = lumpVec[lump].indexV1;
517  int n2 = lumpVec[lump].indexV2;
518  int ii = lumpVec[lump].indexI;
519 
520  jacStamp[n1].resize(3);
521  jacStamp[n1][0] = lumpVec[lump-1].indexI;
522  jacStamp[n1][1] = n1;
523  jacStamp[n1][2] = ii;
524 
525  jacStamp[ii].resize(3);
526  jacStamp[ii][0] = n1;
527  jacStamp[ii][1] = ii;
528  jacStamp[ii][2] = n2;
529 
530  jacStamp[n2].resize(2);
531  jacStamp[n2][0] = ii;
532  jacStamp[n2][1] = n2;
533  }
534 
535  // do jacStamp for the interior lumps
536  for (int lump=1;lump<numLumps-1;++lump)
537  {
538  int n1 = lumpVec[lump].indexV1;
539  int n2 = lumpVec[lump].indexV2;
540  int ii = lumpVec[lump].indexI;
541 
542  jacStamp[n1].resize(3);
543  jacStamp[n1][0] = lumpVec[lump-1].indexI;
544  jacStamp[n1][1] = n1;
545  jacStamp[n1][2] = ii;
546 
547  jacStamp[ii].resize(3);
548  jacStamp[ii][0] = n1;
549  jacStamp[ii][1] = ii;
550  jacStamp[ii][2] = n2;
551  }
552  }
553 
554  if (DEBUG_DEVICE)
555  {
556  if (isActive(Diag::DEVICE_PARAMETERS))
557  {
558  int size=jacStamp.size();
559  for (int i=0; i<size; ++i)
560  {
561  int sizeJ = jacStamp[i].size();
562  for (int j=0;j<sizeJ;++j)
563  {
564  std::cout << "jacStamp["<<i<<"]["<<j<<"] = " << jacStamp[i][j];
565  std::cout << std::endl;
566  }
567  }
568  }
569 
570  }
571 
572 }
573 
574 //-----------------------------------------------------------------------------
575 // Function : Instance::~Instance
576 // Purpose : destructor
577 // Special Notes :
578 // Scope : public
579 // Creator : Eric Keiter, SNL
580 // Creation Date : 9/17/2013
581 //-----------------------------------------------------------------------------
583 {
584 }
585 
586 // Additional Declarations
587 
588 //-----------------------------------------------------------------------------
589 // Function : Instance::registerLIDs
590 // Purpose :
591 // Special Notes :
592 // Scope : public
593 // Creator : Eric Keiter, SNL
594 // Creation Date : 9/17/2013
595 //-----------------------------------------------------------------------------
596 void Instance::registerLIDs( const std::vector<int> & intLIDVecRef,
597  const std::vector<int> & extLIDVecRef)
598 {
599  AssertLIDs(intLIDVecRef.size() == numIntVars);
600  AssertLIDs(extLIDVecRef.size() == numExtVars);
601 
602  // Copy over the local ID lists:
603  intLIDVec = intLIDVecRef;
604  extLIDVec = extLIDVecRef;
605 
606  // Now use these lists to obtain the indices into the linear algebra entities.
607 
609  {
610  lumpVec[0].li_V1 = extLIDVec[0];
611  lumpVec[numLumps-1].li_V3 = extLIDVec[1];
612 
613  int lid=0;
614  lumpVec[0].li_V2 = intLIDVec[lid++];
615  lumpVec[0].li_I = intLIDVec[lid++];
616 
617  if (numLumps>1)
618  {
619  for (int i=1;i<numLumps-1;++i)
620  {
621  lumpVec[i].li_V1 = intLIDVec[lid++];
622  lumpVec[i].li_V2 = intLIDVec[lid++];
623  lumpVec[i].li_I = intLIDVec[lid++];
624  }
625 
626  lumpVec[numLumps-1].li_V1 = intLIDVec[lid++];
627  lumpVec[numLumps-1].li_V2 = intLIDVec[lid++];
628  lumpVec[numLumps-1].li_I = intLIDVec[lid++];
629 
630  for (int i=0;i<numLumps-1;++i)
631  {
632  lumpVec[i].li_V3 = lumpVec[i+1].li_V1;
633  }
634  }
635  }
636  else if ( model_.specialCase == TRANS_MOD_LC)
637  {
638  lumpVec[0].li_V1 = extLIDVec[0];
639  lumpVec[numLumps-1].li_V2 = extLIDVec[1];
640 
641  int lid=0;
642  lumpVec[0].li_I = intLIDVec[lid++];
643 
644  if (numLumps>1)
645  {
646  for (int i=1;i<numLumps-1;++i)
647  {
648  lumpVec[i].li_V1 = intLIDVec[lid++];
649  lumpVec[i].li_I = intLIDVec[lid++];
650  }
651 
652  lumpVec[numLumps-1].li_V1 = intLIDVec[lid++];
653  lumpVec[numLumps-1].li_I = intLIDVec[lid++];
654 
655  for (int i=0;i<numLumps-1;++i)
656  {
657  lumpVec[i].li_V2 = lumpVec[i+1].li_V1;
658  }
659  }
660  }
661 
662  if (DEBUG_DEVICE)
663  {
664  if (isActive(Diag::DEVICE_PARAMETERS))
665  {
666  for (int i=0; i<numIntVars; i++)
667  {
668  std::cout << "intLIDVec["<<i<<"] = " << intLIDVec[i] << std::endl;
669  }
670 
672  {
673  for (int i=0; i<numLumps; i++)
674  {
675  std::cout << "lumpVec["<<i<<"].li_V1 = " << lumpVec[i].li_V1 <<std::endl;
676  std::cout << "lumpVec["<<i<<"].li_V2 = " << lumpVec[i].li_V2 <<std::endl;
677  std::cout << "lumpVec["<<i<<"].li_I = " << lumpVec[i].li_I <<std::endl;
678  std::cout << "lumpVec["<<i<<"].li_V3 = " << lumpVec[i].li_V3 <<std::endl;
679  }
680  }
681  else if ( model_.specialCase == TRANS_MOD_LC)
682  {
683  for (int i=0; i<numLumps; i++)
684  {
685  std::cout << "lumpVec["<<i<<"].li_V1 = " << lumpVec[i].li_V1 <<std::endl;
686  std::cout << "lumpVec["<<i<<"].li_I = " << lumpVec[i].li_I <<std::endl;
687  std::cout << "lumpVec["<<i<<"].li_V2 = " << lumpVec[i].li_V2 <<std::endl;
688  }
689  }
690  }
691  }
692 
693 }
694 
695 //-----------------------------------------------------------------------------
696 // Function : Instance::registerStateLIDs
697 // Purpose :
698 // Special Notes :
699 // Scope : public
700 // Creator : Eric Keiter, SNL
701 // Creation Date : 9/17/2013
702 //-----------------------------------------------------------------------------
703 void Instance::registerStateLIDs( const std::vector<int> & staLIDVecRef)
704 {
705  AssertLIDs(staLIDVecRef.size() == numStateVars);
706 
707  // Copy over the global ID lists:
708  staLIDVec = staLIDVecRef;
709 }
710 
711 //-----------------------------------------------------------------------------
712 // Function : Instance::loadNodeSymbols
713 // Purpose :
714 // Special Notes :
715 // Scope : public
716 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
717 // Creation Date : 05/13/05
718 //-----------------------------------------------------------------------------
719 void Instance::loadNodeSymbols(Util::SymbolTable &symbol_table) const
720 {
721  for (int i = 0; i < numLumps; i++)
722  {
724  {
725  if (i != 0)
726  addInternalNode(symbol_table, lumpVec[i].li_V1, getName(), "v1_lump" + Teuchos::Utils::toString(i));
727  addInternalNode(symbol_table, lumpVec[i].li_V2, getName(), "v2_lump" + Teuchos::Utils::toString(i));
728  addInternalNode(symbol_table, lumpVec[i].li_I, getName(), "I__lump" + Teuchos::Utils::toString(i));
729  }
730  else if (model_.specialCase == TRANS_MOD_LC)
731  {
732  if (i != 0)
733  addInternalNode(symbol_table, lumpVec[i].li_V1, getName(), "v1_lump" + Teuchos::Utils::toString(i));
734  addInternalNode(symbol_table, lumpVec[i].li_I, getName(), "I__lump" + Teuchos::Utils::toString(i));
735  }
736  }
737 }
738 
739 //-----------------------------------------------------------------------------
740 // Function : Instance::jacobianStamp
741 // Purpose :
742 // Special Notes :
743 // Scope : public
744 // Creator : Eric Keiter, SNL
745 // Creation Date : 9/17/2013
746 //-----------------------------------------------------------------------------
747 const std::vector< std::vector<int> > & Instance::jacobianStamp() const
748 {
749  return jacStamp;
750 }
751 
752 //-----------------------------------------------------------------------------
753 // Function : Instance::registerJacLIDs
754 // Purpose :
755 // Special Notes :
756 // Scope : public
757 // Creator : Eric Keiter, SNL
758 // Creation Date : 9/17/2013
759 //-----------------------------------------------------------------------------
760 void Instance::registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec )
761 {
762  DeviceInstance::registerJacLIDs( jacLIDVec );
763 
764 
766  {
767  // do jacStamp for the exterior lumps
768  {
769  int lump=0;
770  int n1 = lumpVec[lump].indexV1;
771  int n2 = lumpVec[lump].indexV2;
772  int ii = lumpVec[lump].indexI;
773  int n3 = lumpVec[lump].indexV3;
774 
775  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][0];
776 
777  lumpVec[lump].offset_v2_v2 = jacLIDVec[n2][0];
778  lumpVec[lump].offset_v2_ii = jacLIDVec[n2][1];
779  lumpVec[lump].offset_v2_v3 = jacLIDVec[n2][2];
780 
781  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
782  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][1];
783  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][2];
784 
785  if (numLumps==1)
786  {
787  lumpVec[lump].offset_v3_v2 = jacLIDVec[n3][0];
788  lumpVec[lump].offset_v3_v3 = jacLIDVec[n3][1];
789  }
790  }
791 
792  if (numLumps>1)
793  {
794  int lump=numLumps-1;
795  int n1 = lumpVec[lump].indexV1;
796  int n2 = lumpVec[lump].indexV2;
797  int ii = lumpVec[lump].indexI;
798  int n3 = lumpVec[lump].indexV3;
799 
800  lumpVec[lump].offset_v1_v2m1 = jacLIDVec[n1][0];
801  lumpVec[lump].offset_v1_v1 = jacLIDVec[n1][1];
802  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][2];
803 
804  lumpVec[lump].offset_v2_v2 = jacLIDVec[n2][0];
805  lumpVec[lump].offset_v2_ii = jacLIDVec[n2][1];
806  lumpVec[lump].offset_v2_v3 = jacLIDVec[n2][2];
807 
808  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
809  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][1];
810  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][2];
811 
812  lumpVec[lump].offset_v3_v2 = jacLIDVec[n3][0];
813  lumpVec[lump].offset_v3_v3 = jacLIDVec[n3][1];
814  }
815 
816  // do jacLIDVec for the interior lumps
817  for (int lump=1;lump<numLumps-1;++lump)
818  {
819  int n1 = lumpVec[lump].indexV1;
820  int n2 = lumpVec[lump].indexV2;
821  int ii = lumpVec[lump].indexI;
822  int n3 = lumpVec[lump].indexV3;
823 
824  lumpVec[lump].offset_v1_v2m1 = jacLIDVec[n1][0];
825  lumpVec[lump].offset_v1_v1 = jacLIDVec[n1][1];
826  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][2];
827 
828  lumpVec[lump].offset_v2_v2 = jacLIDVec[n2][0];
829  lumpVec[lump].offset_v2_ii = jacLIDVec[n2][1];
830  lumpVec[lump].offset_v2_v3 = jacLIDVec[n2][2];
831 
832  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
833  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][1];
834  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][2];
835  }
836 
837  // add the v3 offsets
838  for (int lump=0; lump<numLumps-1; ++lump)
839  {
840  lumpVec[lump].offset_v3_v2 = lumpVec[lump+1].offset_v1_v2m1;
841  lumpVec[lump].offset_v3_v3 = lumpVec[lump+1].offset_v1_v1;
842  }
843  }
844  else if ( model_.specialCase == TRANS_MOD_LC)
845  {
846  // do jacStamp for the exterior lumps
847  {
848  int lump=0;
849  int n1 = lumpVec[lump].indexV1;
850  int n2 = lumpVec[lump].indexV2;
851  int ii = lumpVec[lump].indexI;
852 
853  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][0];
854 
855  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
856  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][1];
857  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][2];
858 
859  if (numLumps==1)
860  {
861  lumpVec[lump].offset_v2_ii = jacLIDVec[n2][0];
862  lumpVec[lump].offset_v2_v2 = jacLIDVec[n2][1];
863  }
864  }
865 
866  if (numLumps>1)
867  {
868  int lump=numLumps-1;
869  int n1 = lumpVec[lump].indexV1;
870  int n2 = lumpVec[lump].indexV2;
871  int ii = lumpVec[lump].indexI;
872 
873  lumpVec[lump].offset_v1_iim1 = jacLIDVec[n1][0];
874  lumpVec[lump].offset_v1_v1 = jacLIDVec[n1][1];
875  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][2];
876 
877  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
878  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][1];
879  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][2];
880 
881  lumpVec[lump].offset_v2_ii = jacLIDVec[n2][0];
882  lumpVec[lump].offset_v2_v2 = jacLIDVec[n2][1];
883  }
884 
885  // do jacLIDVec for the interior lumps
886  for (int lump=1;lump<numLumps-1;++lump)
887  {
888  int n1 = lumpVec[lump].indexV1;
889  int n2 = lumpVec[lump].indexV2;
890  int ii = lumpVec[lump].indexI;
891 
892  lumpVec[lump].offset_v1_iim1 = jacLIDVec[n1][0];
893  lumpVec[lump].offset_v1_v1 = jacLIDVec[n1][1];
894  lumpVec[lump].offset_v1_ii = jacLIDVec[n1][2];
895 
896  lumpVec[lump].offset_ii_v1 = jacLIDVec[ii][0];
897  lumpVec[lump].offset_ii_ii = jacLIDVec[ii][1];
898  lumpVec[lump].offset_ii_v2 = jacLIDVec[ii][2];
899  }
900 
901  // add the v2 offsets
902  for (int lump=0; lump<numLumps-1; ++lump)
903  {
904  lumpVec[lump].offset_v2_ii = lumpVec[lump+1].offset_v1_iim1;
905  lumpVec[lump].offset_v2_v2 = lumpVec[lump+1].offset_v1_v1;
906  }
907  }
908 
909 
910  if (DEBUG_DEVICE)
911  {
912  if (isActive(Diag::DEVICE_PARAMETERS))
913  {
915  {
916  for (int i=0;i<numLumps;++i)
917  {
918  std::cout << "lump = " << i <<std::endl;
919 
920  std::cout << "offset_v1_v2m1 = " << lumpVec[i].offset_v1_v2m1 << std::endl;
921  std::cout << "offset_v1_v1 = " << lumpVec[i].offset_v1_v1 << std::endl;
922  std::cout << "offset_v1_ii = " << lumpVec[i].offset_v1_ii << std::endl;
923 
924 
925  std::cout << "offset_v2_v2 = " << lumpVec[i].offset_v2_v2 << std::endl;
926  std::cout << "offset_v2_ii = " << lumpVec[i].offset_v2_ii << std::endl;
927  std::cout << "offset_v2_v3 = " << lumpVec[i].offset_v2_v3 << std::endl;
928 
929 
930  std::cout << "offset_ii_v1 = " << lumpVec[i].offset_ii_v1 << std::endl;
931  std::cout << "offset_ii_v2 = " << lumpVec[i].offset_ii_v2 << std::endl;
932  std::cout << "offset_ii_ii = " << lumpVec[i].offset_ii_ii << std::endl;
933 
934  std::cout << "offset_v3_v2 = " << lumpVec[i].offset_v3_v2 << std::endl;
935  std::cout << "offset_v3_v3 = " << lumpVec[i].offset_v3_v3 << std::endl;
936  }
937  }
938  else if ( model_.specialCase == TRANS_MOD_LC)
939  {
940  for (int i=0;i<numLumps;++i)
941  {
942  std::cout << "lump = " << i <<std::endl;
943 
944  std::cout << "offset_v1_iim1 = " << lumpVec[i].offset_v1_iim1 << std::endl;
945  std::cout << "offset_v1_v1 = " << lumpVec[i].offset_v1_v1 << std::endl;
946  std::cout << "offset_v1_ii = " << lumpVec[i].offset_v1_ii << std::endl;
947 
948  std::cout << "offset_ii_v1 = " << lumpVec[i].offset_ii_v1 << std::endl;
949  std::cout << "offset_ii_ii = " << lumpVec[i].offset_ii_ii << std::endl;
950  std::cout << "offset_ii_v2 = " << lumpVec[i].offset_ii_v2 << std::endl;
951 
952  std::cout << "offset_v2_ii = " << lumpVec[i].offset_v2_ii << std::endl;
953  std::cout << "offset_v2_v2 = " << lumpVec[i].offset_v2_v2 << std::endl;
954  }
955  }
956  }
957  }
958 }
959 
960 //-----------------------------------------------------------------------------
961 // Function : Instance::setupPointers
962 // Purpose :
963 // Special Notes :
964 // Scope : public
965 // Creator : Eric Keiter, SNL
966 // Creation Date : 9/17/2013
967 //-----------------------------------------------------------------------------
969 {
970 
971 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
972 #endif
973 }
974 
975 //-----------------------------------------------------------------------------
976 // Function : Instance::updateIntermediateVars ()
977 // Purpose :
978 // Special Notes :
979 // Scope : public
980 // Creator : Eric Keiter, SNL
981 // Creation Date : 10/30/2013
982 //-----------------------------------------------------------------------------
984 {
985  double * solVec = extData.nextSolVectorRawPtr;
987  {
988  for (int i=0;i<numLumps;++i)
989  {
990  // inductor
991  double current = solVec[lumpVec[i].li_I];
992  double v_pos = solVec[lumpVec[i].li_V1];
993  double v_neg = solVec[lumpVec[i].li_V2];
994  double vind = v_pos-v_neg;
995  lumpVec[i].i0_ind = current;
996  lumpVec[i].f0_ind = L*current;
997  lumpVec[i].coef_ind = -vind;
998 
999  // resistor
1000  v_pos = solVec[lumpVec[i].li_V2];
1001  v_neg = solVec[lumpVec[i].li_V3];
1002  lumpVec[i].i0_res = (v_pos-v_neg)*G;
1003 
1004  // capacitor
1005  double vcap = solVec[lumpVec[i].li_V3];
1006  lumpVec[i].q0_cap = C*vcap;
1007  }
1008  }
1009  else if ( model_.specialCase == TRANS_MOD_LC)
1010  {
1011  for (int i=0;i<numLumps;++i)
1012  {
1013  // inductor
1014  double current = solVec[lumpVec[i].li_I];
1015  double v_pos = solVec[lumpVec[i].li_V1];
1016  double v_neg = solVec[lumpVec[i].li_V2];
1017  double vind = v_pos-v_neg;
1018  lumpVec[i].i0_ind = current;
1019  lumpVec[i].f0_ind = L*current;
1020  lumpVec[i].coef_ind = -vind;
1021 
1022  // capacitor
1023  double vcap = solVec[lumpVec[i].li_V2];
1024  lumpVec[i].q0_cap = C*vcap;
1025  }
1026  }
1027 
1028  return true;
1029 }
1030 
1031 //-----------------------------------------------------------------------------
1032 // Function : Instance::updatePrimaryState
1033 // Purpose :
1034 // Special Notes :
1035 // Scope : public
1036 // Creator : Eric Keiter, SNL
1037 // Creation Date : 9/17/2013
1038 //-----------------------------------------------------------------------------
1040 {
1041  return updateIntermediateVars();
1042 
1043  return true;
1044 }
1045 
1046 //-----------------------------------------------------------------------------
1047 // Function : Instance::loadDAEQVector
1048 //
1049 // Purpose : Loads the Q-vector contributions for a single
1050 // TransLine instance.
1051 //
1052 // Special Notes : The "Q" std::vector is part of a standard DAE formalism in
1053 // which the system of equations is represented as:
1054 //
1055 // f(x) = dQ(x)/dt + F(x) - B(t) = 0
1056 //
1057 // Scope : public
1058 // Creator : Eric Keiter, SNL
1059 // Creation Date : 9/17/2013
1060 //-----------------------------------------------------------------------------
1062 {
1063  double * qVec = extData.daeQVectorRawPtr;
1065  {
1066  for (int i=0; i<numLumps;++i)
1067  {
1068  qVec[lumpVec[i].li_I] += lumpVec[i].f0_ind;
1069  qVec[lumpVec[i].li_V3] += lumpVec[i].q0_cap;
1070  }
1071  }
1072  else if ( model_.specialCase == TRANS_MOD_LC)
1073  {
1074  for (int i=0; i<numLumps;++i)
1075  {
1076  qVec[lumpVec[i].li_I] += lumpVec[i].f0_ind;
1077  qVec[lumpVec[i].li_V2] += lumpVec[i].q0_cap;
1078  }
1079  }
1080  return true;
1081 }
1082 
1083 //-----------------------------------------------------------------------------
1084 // Function : Instance::loadDAEFVector
1085 //
1086 // Purpose : Loads the F-vector contributions for a single
1087 // TransLine instance.
1088 //
1089 // Special Notes :
1090 //
1091 // Scope : public
1092 // Creator : Eric Keiter, SNL
1093 // Creation Date : 9/17/2013
1094 //-----------------------------------------------------------------------------
1096 {
1097  double * fVec = extData.daeFVectorRawPtr;
1098 
1100  {
1101  for (int i=0; i<numLumps; i++)
1102  {
1103  // inductor
1104  fVec[lumpVec[i].li_V1] += lumpVec[i].i0_ind;
1105  fVec[lumpVec[i].li_V2] += -lumpVec[i].i0_ind;
1106  fVec[lumpVec[i].li_I ] += lumpVec[i].coef_ind;
1107 
1108  // resistor
1109  fVec[lumpVec[i].li_V2] += lumpVec[i].i0_res;
1110  fVec[lumpVec[i].li_V3] -= lumpVec[i].i0_res;
1111  }
1112  }
1113  else if ( model_.specialCase == TRANS_MOD_LC)
1114  {
1115  for (int i=0; i<numLumps; i++)
1116  {
1117  // inductor
1118  fVec[lumpVec[i].li_V1] += lumpVec[i].i0_ind;
1119  fVec[lumpVec[i].li_V2] += -lumpVec[i].i0_ind;
1120  fVec[lumpVec[i].li_I ] += lumpVec[i].coef_ind;
1121  }
1122  }
1123 
1124  return true;
1125 }
1126 
1127 //-----------------------------------------------------------------------------
1128 // Function : Instance::loadDAEdQdx
1129 //
1130 // Purpose : Loads the dQdx-matrix contributions for a single
1131 // TransLine instance.
1132 //
1133 // Special Notes : The "Q" std::vector is part of a standard DAE formalism in
1134 // which the system of equations is represented as:
1135 //
1136 // f(x) = dQ(x)/dt + F(x) - B(t) = 0
1137 //
1138 // Scope : public
1139 // Creator : Eric Keiter, SNL
1140 // Creation Date : 9/17/2013
1141 //-----------------------------------------------------------------------------
1143 {
1144  Linear::Matrix & dQdx = *(extData.dQdxMatrixPtr);
1146  {
1147  for (int i=0; i<numLumps; i++)
1148  {
1149  // inductor
1150  dQdx[lumpVec[i].li_I][lumpVec[i].offset_ii_ii] += L;
1151 
1152  // capacitor
1153  dQdx[lumpVec[i].li_V3][lumpVec[i].offset_v3_v3] += C;
1154  }
1155  }
1156  else if ( model_.specialCase == TRANS_MOD_LC)
1157  {
1158  for (int i=0; i<numLumps; i++)
1159  {
1160  // inductor
1161  dQdx[lumpVec[i].li_I][lumpVec[i].offset_ii_ii] += L;
1162 
1163  // capacitor
1164  dQdx[lumpVec[i].li_V2][lumpVec[i].offset_v2_v2] += C;
1165  }
1166  }
1167 
1168  return true;
1169 }
1170 
1171 //-----------------------------------------------------------------------------
1172 // Function : Instance::loadDAEdFdx ()
1173 //
1174 // Purpose : Loads the F-vector contributions for a single
1175 // TransLine instance.
1176 //
1177 // Special Notes :
1178 //
1179 // Scope : public
1180 // Creator : Eric Keiter, SNL
1181 // Creation Date : 9/17/2013
1182 //-----------------------------------------------------------------------------
1184 {
1185  Linear::Matrix & dFdx = *(extData.dFdxMatrixPtr);
1186 
1188  {
1189  for (int i=0; i<numLumps; i++)
1190  {
1191  // inductor
1192  dFdx[lumpVec[i].li_V1][lumpVec[i].offset_v1_ii] += 1.0;
1193  dFdx[lumpVec[i].li_V2][lumpVec[i].offset_v2_ii] -= 1.0;
1194  dFdx[lumpVec[i].li_I ][lumpVec[i].offset_ii_v1] -= 1.0;
1195  dFdx[lumpVec[i].li_I ][lumpVec[i].offset_ii_v2] += 1.0;
1196 
1197  // resistor
1198  dFdx[lumpVec[i].li_V2][lumpVec[i].offset_v2_v2] += G;
1199  dFdx[lumpVec[i].li_V2][lumpVec[i].offset_v2_v3] -= G;
1200  dFdx[lumpVec[i].li_V3][lumpVec[i].offset_v3_v2] -= G;
1201  dFdx[lumpVec[i].li_V3][lumpVec[i].offset_v3_v3] += G;
1202  }
1203  }
1204  else if ( model_.specialCase == TRANS_MOD_LC)
1205  {
1206  for (int i=0; i<numLumps; i++)
1207  {
1208  // inductor
1209  dFdx[lumpVec[i].li_V1][lumpVec[i].offset_v1_ii] += 1.0;
1210  dFdx[lumpVec[i].li_V2][lumpVec[i].offset_v2_ii] -= 1.0;
1211  dFdx[lumpVec[i].li_I ][lumpVec[i].offset_ii_v1] -= 1.0;
1212  dFdx[lumpVec[i].li_I ][lumpVec[i].offset_ii_v2] += 1.0;
1213  }
1214  }
1215 
1216  return true;
1217 }
1218 
1219 //-----------------------------------------------------------------------------
1220 // Function : Instance::varTypes
1221 // Purpose :
1222 // Special Notes :
1223 // Scope : public
1224 // Creator : Eric Keiter, SNL
1225 // Creation Date : 9/17/2013
1226 //-----------------------------------------------------------------------------
1227 void Instance::varTypes( std::vector<char> & varTypeVec )
1228 {
1229 }
1230 
1231 
1232 // Class Model
1233 
1234 //-----------------------------------------------------------------------------
1235 // Function : Model::processParams
1236 // Purpose :
1237 // Special Notes :
1238 // Scope : public
1239 // Creator : Eric Keiter, SNL
1240 // Creation Date : 9/17/2013
1241 //-----------------------------------------------------------------------------
1243 {
1244  return true;
1245 }
1246 
1247 //----------------------------------------------------------------------------
1248 // Function : Model::processInstanceParams
1249 // Purpose :
1250 // Special Notes :
1251 // Scope : public
1252 // Creator : Eric Keiter, SNL
1253 // Creation Date : 9/17/2013
1254 //----------------------------------------------------------------------------
1256 {
1257  std::vector<Instance*>::iterator iter;
1258  std::vector<Instance*>::iterator first = instanceContainer.begin();
1259  std::vector<Instance*>::iterator last = instanceContainer.end();
1260 
1261  for (iter=first; iter!=last; ++iter)
1262  {
1263  (*iter)->processParams();
1264  }
1265 
1266  return true;
1267 }
1268 
1269 //-----------------------------------------------------------------------------
1270 // Function : Model::Model
1271 // Purpose : block constructor
1272 // Special Notes :
1273 // Scope : public
1274 // Creator : Eric Keiter, SNL
1275 // Creation Date : 9/17/2013
1276 //-----------------------------------------------------------------------------
1277 
1279  const Configuration & configuration,
1280  const ModelBlock & MB,
1281  const FactoryBlock & factory_block)
1282  : DeviceModel(MB, configuration.getModelParameters(), factory_block),
1283  elevNumber(2),
1284  resist(0.0),
1285  induct(0.0),
1286  conduct(0.0),
1287  capac(0.0),
1288 
1289  elevNumberGiven(false),
1290  resistGiven(false),
1291  inductGiven(false),
1292  conductGiven(false),
1293  capacGiven(false),
1294  specialCase(TRANS_MOD_RLC)
1295 {
1296 
1297  // Set params to constant default values:
1298  setDefaultParams ();
1299 
1300  // Set params according to .model line and constant defaults from metadata:
1301  setModParams (MB.params);
1302 
1303  // Calculate any parameters specified as expressions:
1305 
1306  // calculate dependent (ie computed) params and check for errors:
1307  processParams ();
1308 }
1309 
1310 //-----------------------------------------------------------------------------
1311 // Function : Model::Model
1312 // Purpose : destructor
1313 // Special Notes :
1314 // Scope : public
1315 // Creator : Eric Keiter, SNL
1316 // Creation Date : 9/17/2013
1317 //-----------------------------------------------------------------------------
1318 
1320 {
1321  std::vector<Instance*>::iterator iter;
1322  std::vector<Instance*>::iterator first = instanceContainer.begin();
1323  std::vector<Instance*>::iterator last = instanceContainer.end();
1324 
1325  for (iter=first; iter!=last; ++iter)
1326  {
1327  delete (*iter);
1328  }
1329 
1330 }
1331 
1332 //-----------------------------------------------------------------------------
1333 // Function : Model::printOutInstances
1334 // Purpose : debugging tool.
1335 // Special Notes :
1336 // Scope : public
1337 // Creator : Eric Keiter, SNL
1338 // Creation Date : 9/17/2013
1339 //-----------------------------------------------------------------------------
1340 
1341 std::ostream &Model::printOutInstances(std::ostream &os) const
1342 {
1343  std::vector<Instance*>::const_iterator iter;
1344  std::vector<Instance*>::const_iterator first = instanceContainer.begin();
1345  std::vector<Instance*>::const_iterator last = instanceContainer.end();
1346 
1347  int i,isize;
1348 
1349  isize = instanceContainer.size();
1350  os << std::endl;
1351  os << "Number of TransLine instances: " << isize << std::endl;
1352  os << " name\t\tmodelName\tParameters" << std::endl;
1353 
1354  for (i = 0, iter = first; iter != last; ++iter, ++i)
1355  {
1356  os << " " << i << ": " << (*iter)->getName() << "\t";
1357  os << getName();
1358  os << std::endl;
1359  }
1360 
1361  os << std::endl;
1362 
1363  return os;
1364 }
1365 
1366 //-----------------------------------------------------------------------------
1367 // Function : Model::forEachInstance
1368 // Purpose :
1369 // Special Notes :
1370 // Scope : public
1371 // Creator : David Baur
1372 // Creation Date : 2/4/2014
1373 //-----------------------------------------------------------------------------
1374 /// Apply a device instance "op" to all instances associated with this
1375 /// model
1376 ///
1377 /// @param[in] op Operator to apply to all instances.
1378 ///
1379 ///
1380 void Model::forEachInstance(DeviceInstanceOp &op) const /* override */
1381 {
1382  for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1383  op(*it);
1384 }
1385 
1386 
1387 Device *Traits::factory(const Configuration &configuration, const FactoryBlock &factory_block)
1388 {
1389 
1390  return new DeviceMaster<Traits> ( configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
1391 
1392 }
1393 
1395 {
1397  .registerDevice("transline", 1)
1398  .registerModelType("transline", 1);
1399 }
1400 
1401 } // namespace TransLine
1402 } // namespace Device
1403 } // namespace Xyce
const InstanceName & getName() const
bool updateTemperature(const double &temp_tmp)
virtual std::ostream & printOutInstances(std::ostream &os) const
const SolverState & solverState_
void varTypes(std::vector< char > &varTypeVec)
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
Definition: N_DEV_Pars.h:1429
Pure virtual class to augment a linear system.
const std::vector< std::vector< int > > & jacobianStamp() const
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
#define TRANS_MOD_RLC
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
bool processInstanceParams()
processInstanceParams
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.
#define AssertLIDs(cmp)
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
static void loadModelParameters(ParametricData< Model > &model_parameters)
std::vector< Param > params
Parameters from the line.
void setParams(const std::vector< Param > &params)
const std::string & getName() const
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...
std::vector< std::vector< int > > jacStamp
#define TRANS_MOD_LC
const DeviceOptions & deviceOptions_
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
bool processParams()
processParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Citer, const FactoryBlock &factory_block)
std::vector< Instance * > instanceContainer
Class Configuration contains device configuration data.
#define L
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
std::vector< lumpData > lumpVec
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.
std::vector< Param > params
Linear::Matrix * dQdxMatrixPtr
void setModParams(const std::vector< Param > &params)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)