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