Xyce  6.1
N_DEV_Resistor3.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_Resistor3.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, Electrical and Microsystems Modeling
33 //
34 // Creation Date : 2/1/10
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.54 $
40 //
41 // Revision Date : $Date: 2015/04/17 20:32:11 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-------------------------------------------------------------------------
45 #include <Xyce_config.h>
46 
47 #include <memory>
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 #include <N_DEV_DeviceOptions.h>
53 #include <N_DEV_ExternData.h>
54 #include <N_DEV_MatrixLoadData.h>
55 #include <N_DEV_Resistor3.h>
56 #include <N_DEV_SolverState.h>
57 #include <N_DEV_Message.h>
58 #include <N_ERH_ErrorMgr.h>
59 
60 #include <N_DEV_Resistor.h>
61 
62 #include <N_LAS_Vector.h>
63 #include <N_LAS_Matrix.h>
64 #include <N_UTL_FeatureTest.h>
65 
66 namespace Xyce {
67 namespace Device {
68 namespace Resistor3 {
69 
71 {
72  p.addPar ("R",1000.0,&Resistor3::Instance::R)
73  .setExpressionAccess(ParameterType::TIME_DEP)
74  .setUnit(U_OHM)
75  .setCategory(CAT_NONE)
76  .setDescription("Resistance");
77 
79  .setUnit(U_METER)
80  .setCategory(CAT_NONE)
81  .setDescription("Length");
82 
84  .setUnit(U_METER)
85  .setCategory(CAT_NONE)
86  .setDescription("Width");
87 
88  p.addPar ("TEMP",0.0,&Resistor3::Instance::temp)
89  .setExpressionAccess(ParameterType::TIME_DEP)
90  .setUnit(U_DEGC)
91  .setCategory(CAT_NONE)
92  .setDescription("Device temperature");
93 
95  .setGivenMember(&Resistor3::Instance::tempCoeff1Given)
96  .setUnit(U_DEGCM1)
97  .setCategory(CAT_NONE)
98  .setDescription("Linear Temperature Coefficient");
99 
101  .setGivenMember(&Resistor3::Instance::tempCoeff2Given)
102  .setUnit(U_DEGCM2)
103  .setCategory(CAT_NONE)
104  .setDescription("Quadratic Temperature Coefficient");
105 
106  // This call tells the parameter handling code that TC can be specified
107  // as a vector with up to two elements as in TC=a,b. It then translates
108  // TC=a,b into TC1=a TC2=b. Likewise,TC=a will translate into TC1=a
109  p.makeVector ("TC",2);
110 
111  p.addPar ("DTEMP",0.0,&Resistor3::Instance::dtemp)
112  .setGivenMember(&Resistor3::Instance::dtempGiven)
113  .setUnit(U_DEGC)
114  .setCategory(CAT_NONE)
115  .setDescription("Device Temperature -- For compatibility only. Parameter is NOT used");
116 }
117 
119 {}
120 
121 std::vector< std::vector<int> > Instance::jacStamp;
122 std::vector< std::vector<int> > Instance::jacStampPDE;
123 
124 
125 // Class Instance
126 //-----------------------------------------------------------------------------
127 // Function : Instance::Instance
128 // Purpose : "instance block" constructor
129 // Special Notes :
130 // Scope : public
131 // Creator : Richard Schiek, Electrical and Microsystems Modeling
132 // Creation Date : 2/1/10
133 //-----------------------------------------------------------------------------
135  const Configuration & configuration,
136  const InstanceBlock & IB,
137  Model & Viter,
138  const FactoryBlock & factory_block)
139  : DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
140  model_(Viter),
141  srcCurrent(0.0),
142  srcVoltage(0.0),
143  srcDrop(0.0),
144  srcBC(0.0),
145 
146  li_Pos(-1),
147  li_Neg(-1),
148  li_Bra(-1),
149  tempCoeff1(0.0),
150  tempCoeff2(0.0),
151  dtemp(0.0),
152  tempCoeff1Given(false),
153  tempCoeff2Given(false),
154  dtempGiven(false),
155 
156  ABraEquPosNodeOffset(-1),
157  ABraEquNegNodeOffset(-1),
158  APosEquBraVarOffset(-1),
159  ANegEquBraVarOffset(-1),
160  ABraEquBraVarOffset(-1),
161  APosEquPosNodeOffset(-1),
162  ANegEquNegNodeOffset(-1),
163 
165  fBraEquPosNodePtr(0),
166  fBraEquNegNodePtr(0),
167  fPosEquBraVarPtr(0),
168  fNegEquBraVarPtr(0),
169  fPosEquPosNodePtr(0),
170  fNegEquNegNodePtr(0),
171  fBraEquBraVarPtr(0),
172 #endif
173 
174  scale(1.0),
175  nlstep(-1),
176  source(0.0),
177  v_pos(0.0),
178  v_neg(0.0),
179  i_bra(0.0)
180 {
181  numIntVars = 1;
182  numExtVars = 2;
183  numStateVars = 0;
184 
185  if( jacStamp.empty() )
186  {
187  jacStamp.resize(3);
188  jacStamp[0].resize(1);
189  jacStamp[0][0] = 2;
190  jacStamp[1].resize(1);
191  jacStamp[1][0] = 2;
192  jacStamp[2].resize(2);
193  jacStamp[2][0] = 0;
194  jacStamp[2][1] = 1;
195 
196  // PDE supporting stamp. This includes diagonal elements, needed by the
197  // 2-level Newton.
198  jacStampPDE.resize(3);
199  jacStampPDE[0].resize(2);
200  jacStampPDE[0][0] = 0;
201  jacStampPDE[0][1] = 2;
202  jacStampPDE[1].resize(2);
203  jacStampPDE[1][0] = 1;
204  jacStampPDE[1][1] = 2;
205  jacStampPDE[2].resize(3);
206  jacStampPDE[2][0] = 0;
207  jacStampPDE[2][1] = 1;
208  jacStampPDE[2][2] = 2;
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  processParams();
218 
219  // Calculate any parameters specified as expressions:
221  processParams();
222 }
223 
224 //-----------------------------------------------------------------------------
225 // Function : Instance::~Instance
226 // Purpose : destructor
227 // Special Notes :
228 // Scope : public
229 // Creator : Richard Schiek, Electrical and Microsystems Modeling
230 // Creation Date : 2/1/10
231 //-----------------------------------------------------------------------------
233 {
234 }
235 
236 //-----------------------------------------------------------------------------
237 // Function : Instance::processParams
238 // Purpose :
239 // Special Notes :
240 // Scope : public
241 // Creator : Richard Schiek, Electrical and Microsystems Modeling
242 // Creation Date : 2/1/10
243 //-----------------------------------------------------------------------------
245 {
246  return true;
247 }
248 
249 //-----------------------------------------------------------------------------
250 // Function : Instance::registerLIDs
251 // Purpose :
252 // Special Notes :
253 // Scope : public
254 // Creator : Richard Schiek, Electrical and Microsystems Modeling
255 // Creation Date : 2/1/10
256 //-----------------------------------------------------------------------------
257 void Instance::registerLIDs ( const std::vector<int> & intLIDVecRef,
258  const std::vector<int> & extLIDVecRef)
259 {
260  std::string msg;
261 
262  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
263  {
264  Xyce::dout() << std::endl << section_divider << std::endl;
265  Xyce::dout() << " Instance::registerLIDs" << std::endl;
266  Xyce::dout() << " name = " << getName() << std::endl;
267  }
268 
269  // Check if the size of the ID lists corresponds to the
270  // proper number of internal and external variables.
271  int numInt = intLIDVecRef.size();
272  int numExt = extLIDVecRef.size();
273 
274  if (numInt != numIntVars)
275  {
276  msg = "Instance::registerLIDs:";
277  msg += "numInt != numIntVars";
278  N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
279  }
280 
281  if (numExt != numExtVars)
282  {
283  msg = "Instance::registerLIDs:";
284  msg += "numExt != numExtVars";
285  N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
286  }
287 
288  // copy over the global ID lists.
289  intLIDVec = intLIDVecRef;
290  extLIDVec = extLIDVecRef;
291 
292  // Now use these lists to obtain the indices into the
293  // linear algebra entities. This assumes an order.
294  // For the matrix indices, first do the rows.
295 
296  li_Pos = extLIDVec[0];
297  li_Neg = extLIDVec[1];
298  li_Bra = intLIDVec[0];
299 
300  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
301  {
302  Xyce::dout() << " li_Pos = " << li_Pos << std::endl;
303  Xyce::dout() << " li_Neg = " << li_Neg << std::endl;
304  Xyce::dout() << " li_Bra = " << li_Bra << std::endl;
305  Xyce::dout() << section_divider << std::endl;
306  }
307 }
308 
309 //-----------------------------------------------------------------------------
310 // Function : Instance::loadNodeSymbols
311 // Purpose :
312 // Special Notes :
313 // Scope : public
314 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
315 // Creation Date : 05/13/05
316 //-----------------------------------------------------------------------------
317 void Instance::loadNodeSymbols(Util::SymbolTable &symbol_table) const
318 {
319  addInternalNode(symbol_table, li_Bra, getName(), "branch");
320 }
321 
322 //-----------------------------------------------------------------------------
323 // Function : Instance::registerStateLIDs
324 // Purpose :
325 // Special Notes :
326 // Scope : public
327 // Creator : Richard Schiek, Electrical and Microsystems Modeling
328 // Creation Date : 2/1/10
329 //-----------------------------------------------------------------------------
330 void Instance::registerStateLIDs( const std::vector<int> & staLIDVecRef )
331 {
332  AssertLIDs(staLIDVecRef.size() == numStateVars);
333 }
334 
335 //-----------------------------------------------------------------------------
336 // Function : Instance::jacobianStamp
337 // Purpose :
338 // Special Notes :
339 // Scope : public
340 // Creator : Richard Schiek, Electrical and Microsystems Modeling
341 // Creation Date : 2/1/10
342 //-----------------------------------------------------------------------------
343 const std::vector< std::vector<int> > & Instance::jacobianStamp() const
344 {
345  if (getSolverState().isPDESystem_)
346  return jacStampPDE;
347 
348  return jacStamp;
349 }
350 
351 //-----------------------------------------------------------------------------
352 // Function : Instance::registerJacLIDs
353 // Purpose :
354 // Special Notes :
355 // Scope : public
356 // Creator : Richard Schiek, Electrical and Microsystems Modeling
357 // Creation Date : 2/1/10
358 //-----------------------------------------------------------------------------
359 void Instance::registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec )
360 {
361  DeviceInstance::registerJacLIDs( jacLIDVec );
362  if (getSolverState().isPDESystem_)
363  {
364  APosEquBraVarOffset = jacLIDVec[0][1];
365  ANegEquBraVarOffset = jacLIDVec[1][1];
366  ABraEquPosNodeOffset = jacLIDVec[2][0];
367  ABraEquNegNodeOffset = jacLIDVec[2][1];
368  }
369  else
370  {
371  APosEquBraVarOffset = jacLIDVec[0][0];
372  ANegEquBraVarOffset = jacLIDVec[1][0];
373  ABraEquPosNodeOffset = jacLIDVec[2][0];
374  ABraEquNegNodeOffset = jacLIDVec[2][1];
375  }
376 
377 }
378 
379 //-----------------------------------------------------------------------------
380 // Function : Instance::setupPointers
381 // Purpose :
382 // Special Notes :
383 // Scope : public
384 // Creator : Richard Schiek, Electrical and Microsystems Modeling
385 // Creation Date : 2/1/10
386 //-----------------------------------------------------------------------------
388 {
389 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
390  Linear::Matrix & dFdx = *(extData.dFdxMatrixPtr);
391 
396 #endif
397 }
398 
399 //-----------------------------------------------------------------------------
400 // Function : Instance::updateIntermediateVars
401 // Purpose :
402 // Special Notes :
403 // Scope : public
404 // Creator : Richard Schiek, Electrical and Microsystems Modeling
405 // Creation Date : 2/1/10
406 //-----------------------------------------------------------------------------
408 {
409  double * solVec = extData.nextSolVectorRawPtr;
410 
411  // Get the value for the source.
412  source = 0.0;
413 
414  // get the value for v_pos, v_neg, i_bra
415  v_pos = solVec[li_Pos];
416  v_neg = solVec[li_Neg];
417  i_bra = solVec[li_Bra];
418 
419  srcCurrent = i_bra;
420  srcDrop = (v_pos-v_neg);
421  srcBC = source;
423 
424  if( getDeviceOptions().scale_src != 0.0 )
425  {
426  srcCurrent *= scale;
427 
428  // first newton step, generate new scaling
429  //if( nlsMgrPtr->getNonLinearIter() != nlstep )
430  if( getSolverState().newtonIter != nlstep )
431  {
432  //nlstep = nlsMgrPtr->getNonLinearIter();
434  double new_scale = fabs(i_bra) * scale;
435 
436  scale = std::max( new_scale, getDeviceOptions().scale_src );
437  }
438 
439  srcVoltage *= scale;
440  srcDrop *= scale;
441  srcBC *= scale;
442  }
443 
444  return true;
445 }
446 
447 //-----------------------------------------------------------------------------
448 // Function : Instance::updatePrimaryState
449 // Purpose :
450 // Special Notes :
451 // Scope : public
452 // Creator : Richard Schiek, Electrical and Microsystems Modeling
453 // Creation Date : 2/1/10
454 //-----------------------------------------------------------------------------
456 {
457  bool bsuccess = updateIntermediateVars ();
458  return bsuccess;
459 }
460 
461 //-----------------------------------------------------------------------------
462 // Function : Instance::loadDAEFVector
463 //
464 // Purpose : Loads the F-vector contributions for a single
465 // vsrc instance.
466 //
467 // Special Notes :
468 //
469 // Scope : public
470 // Creator : Richard Schiek, Electrical and Microsystems Modeling
471 // Creation Date : 2/1/10
472 //-----------------------------------------------------------------------------
474 {
475  // Using values determined during the loadRHS function call.
476  // (srcCurrent, srcVoltage).
477 
478  double * fVec = extData.daeFVectorRawPtr;
479 
480  fVec[li_Pos] += srcCurrent;
481  fVec[li_Neg] += -srcCurrent;
482  fVec[li_Bra] += srcDrop;
483  fVec[li_Bra] -= srcBC;
484 
485  return true;
486 }
487 
488 //-----------------------------------------------------------------------------
489 // Function : Instance::loadDAEdFdx ()
490 //
491 // Purpose : Loads the F-vector contributions for a single
492 // resistor instance.
493 //
494 // Special Notes :
495 //
496 // Scope : public
497 // Creator : Richard Schiek, Electrical and Microsystems Modeling
498 // Creation Date : 2/1/10
499 //-----------------------------------------------------------------------------
501 {
502  Linear::Matrix & dFdx = *(extData.dFdxMatrixPtr);
503 
504  dFdx[li_Pos][APosEquBraVarOffset] += 1.0;
505  dFdx[li_Neg][ANegEquBraVarOffset] -= 1.0;
506  dFdx[li_Bra][ABraEquPosNodeOffset] += 1.0;
507  dFdx[li_Bra][ABraEquNegNodeOffset] -= 1.0;
508 
509  return true;
510 }
511 
512 // end of new-DAE functions
513 
514 //-----------------------------------------------------------------------------
515 // Function : Instance::getMaxTimeStepSize
516 // Purpose :
517 // Special Notes :
518 // Scope : public
519 // Creator : Richard Schiek, Electrical and Microsystems Modeling
520 // Creation Date : 2/1/10
521 //-----------------------------------------------------------------------------
523 {
524  double maxStep = 1.0e99;
525  return maxStep;
526 }
527 
528 //-----------------------------------------------------------------------------
529 // Function : Instance::varTypes
530 // Purpose :
531 // Special Notes :
532 // Scope : public
533 // Creator : Richard Schiek, Electrical and Microsystems Modeling
534 // Creation Date : 2/1/10
535 //-----------------------------------------------------------------------------
536 void Instance::varTypes( std::vector<char> & varTypeVec )
537 {
538  varTypeVec.resize(1);
539  varTypeVec[0] = 'I';
540 }
541 
542 // Class Model
543 
544 //-----------------------------------------------------------------------------
545 // Function : Model::Model
546 // Purpose : copy constructor
547 // Special Notes :
548 // Scope : public
549 // Creator : Richard Schiek, Electrical and Microsystems Modeling
550 // Creation Date : 2/1/10
551 //-----------------------------------------------------------------------------
553  const Configuration & configuration,
554  const ModelBlock & MB,
555  const FactoryBlock & factory_block)
556  : DeviceModel(MB, configuration.getModelParameters(), factory_block),
557  DC_TRAN (0)
558 {
559 }
560 
561 //-----------------------------------------------------------------------------
562 // Function : Model::~Model
563 // Purpose : destructor
564 // Special Notes :
565 // Scope : public
566 // Creator : Richard Schiek, Electrical and Microsystems Modeling
567 // Creation Date : 2/1/10
568 //-----------------------------------------------------------------------------
570 {
571  std::vector<Instance*>::iterator iter;
572  std::vector<Instance*>::iterator first = instanceContainer.begin();
573  std::vector<Instance*>::iterator last = instanceContainer.end();
574 
575  for (iter=first; iter!=last; ++iter)
576  {
577  delete (*iter);
578  }
579 }
580 
581 // Additional Declarations
582 
583 //-----------------------------------------------------------------------------
584 // Function : Model::printOutInstances
585 // Purpose : debugging tool.
586 // Special Notes :
587 // Scope : public
588 // Creator : Richard Schiek, Electrical and Microsystems Modeling
589 // Creation Date : 2/1/10
590 //-----------------------------------------------------------------------------
591 std::ostream &Model::printOutInstances(std::ostream &os) const
592 {
593  std::vector<Instance*>::const_iterator iter;
594  std::vector<Instance*>::const_iterator first = instanceContainer.begin();
595  std::vector<Instance*>::const_iterator last = instanceContainer.end();
596 
597  int i;
598  os << std::endl;
599  os << " name model name Parameters" << std::endl;
600  for (i=0, iter=first; iter!=last; ++iter, ++i)
601  {
602  os << " " << i << ": " << (*iter)->getName() << " ";
603  os << getName();
604  os << std::endl;
605  }
606 
607  os << std::endl;
608 
609  return os;
610 }
611 
612 //-----------------------------------------------------------------------------
613 // Function : Model::forEachInstance
614 // Purpose :
615 // Special Notes :
616 // Scope : public
617 // Creator : David Baur
618 // Creation Date : 2/4/2014
619 //-----------------------------------------------------------------------------
620 /// Apply a device instance "op" to all instances associated with this
621 /// model
622 ///
623 /// @param[in] op Operator to apply to all instances.
624 ///
625 ///
626 void Model::forEachInstance(DeviceInstanceOp &op) const /* override */
627 {
628  for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
629  op(*it);
630 }
631 
632 
633 
634 //-----------------------------------------------------------------------------
635 // Vsrc Master functions:
636 //-----------------------------------------------------------------------------
637 
638 
639 //-----------------------------------------------------------------------------
640 // Function : Master::updateState
641 // Purpose :
642 // Special Notes :
643 // Scope : public
644 // Creator : Richard Schiek, Electrical and Microsystems Modeling
645 // Creation Date : 2/1/10
646 //-----------------------------------------------------------------------------
647 bool Master::updateState (double * solVec, double * staVec, double * stoVec)
648 {
649  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
650  {
651  Instance & vi = *(*it);
652 
653  // Get the value for the source.
654  vi.source = 0.0;
655 
656  // get the value for v_pos, v_neg, i_bra
657  vi.v_pos = solVec[vi.li_Pos];
658  vi.v_neg = solVec[vi.li_Neg];
659  vi.i_bra = solVec[vi.li_Bra];
660 
661  vi.srcCurrent = vi.i_bra;
662  vi.srcDrop = (vi.v_pos-vi.v_neg);
663  vi.srcBC = vi.source;
664  vi.srcVoltage = vi.srcDrop-vi.srcBC;
665 
666  if( getDeviceOptions().scale_src != 0.0 )
667  {
668  vi.srcCurrent *= vi.scale;
669 
670  // first newton step, generate new scaling
671  if( getSolverState().newtonIter != vi.nlstep )
672  {
674  double new_scale = fabs(vi.i_bra) * vi.scale;
675 
676  vi.scale = std::max( new_scale, getDeviceOptions().scale_src );
677  }
678 
679  vi.srcVoltage *= vi.scale;
680  vi.srcDrop *= vi.scale;
681  vi.srcBC *= vi.scale;
682  }
683  }
684 // }
685 
686  return true;
687 }
688 
689 //-----------------------------------------------------------------------------
690 // Function : Master::loadDAEVectors
691 // Purpose :
692 // Special Notes :
693 // Scope : public
694 // Creator : Richard Schiek, Electrical and Microsystems Modeling
695 // Creation Date : 2/1/10
696 //-----------------------------------------------------------------------------
697 bool Master::loadDAEVectors (double * solVec, double * fVec, double *qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV)
698 {
699  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
700  {
701  Instance & vi = *(*it);
702 
703 
704  fVec[vi.li_Pos] += vi.srcCurrent;
705 
706  fVec[vi.li_Neg] += -vi.srcCurrent;
707 
708  fVec[vi.li_Bra] += vi.srcDrop;
709 
710  fVec[vi.li_Bra] -= vi.srcBC;
711  }
712 
713  return true;
714 }
715 
716 //-----------------------------------------------------------------------------
717 // Function : Master::loadDAEMatrices
718 // Purpose :
719 // Special Notes :
720 // Scope : public
721 // Creator : Richard Schiek, Electrical and Microsystems Modeling
722 // Creation Date : 2/1/10
723 //-----------------------------------------------------------------------------
724 bool Master::loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx)
725 {
726  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
727  {
728  Instance & vi = *(*it);
729 
730 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
731 
732  *(vi.fPosEquBraVarPtr) += 1.0;
733 
734  *(vi.fNegEquBraVarPtr) -= 1.0;
735 
736  *(vi.fBraEquPosNodePtr) += 1.0;
737 
738  *(vi.fBraEquNegNodePtr) -= 1.0;
739 #else
740 
741  dFdx[vi.li_Pos][vi.APosEquBraVarOffset] += 1.0;
742 
743  dFdx[vi.li_Neg][vi.ANegEquBraVarOffset] -= 1.0;
744 
745  dFdx[vi.li_Bra][vi.ABraEquPosNodeOffset] += 1.0;
746 
747  dFdx[vi.li_Bra][vi.ABraEquNegNodeOffset] -= 1.0;
748 #endif
749 
750  }
751 
752  return true;
753 }
754 
755 Device *
756 Traits::factory(const Configuration &configuration, const FactoryBlock &factory_block)
757 {
758  return new Master(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
759 }
760 
762 {
764  .registerDevice("r", 3)
765  .registerModelType("r", 3);
766 }
767 
768 } // namespace Resistor3
769 } // namespace Device
770 } // namespace Xyce
const InstanceName & getName() const
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
const DeviceOptions & deviceOptions_
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
const std::vector< std::vector< int > > & jacobianStamp() const
Pure virtual class to augment a linear system.
Parameter may be specified as time dependent expression from netlist.
Definition: N_DEV_Pars.h:67
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
void makeVector(const std::string &cname, int len)
Allows the parameter to be specified as a vector.
Definition: N_DEV_Pars.h:1597
InstanceVector::const_iterator getInstanceEnd() const
Returns an iterator to the ending of the vector of all instances created for this device...
#define AssertLIDs(cmp)
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
static std::vector< std::vector< int > > jacStampPDE
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
void varTypes(std::vector< char > &varTypeVec)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Viter, const FactoryBlock &factory_block)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
InstanceVector::const_iterator getInstanceBegin() const
Returns an iterator to the beginning of the vector of all instances created for this device...
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...
const DeviceOptions & getDeviceOptions() const
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
const DeviceOptions & getDeviceOptions() const
Returns the device options given during device construction.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
const SolverState & solverState_
Class Configuration contains device configuration data.
const SolverState & getSolverState() const
std::vector< Instance * > instanceContainer
#define Xyce_NONPOINTER_MATRIX_LOAD
Definition: N_DEV_Bsrc.C:97
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
double scale_src
scaling for source loads
ModelBlock represents a .MODEL line from the netlist.
virtual std::ostream & printOutInstances(std::ostream &os) const
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
static void loadModelParameters(ParametricData< Model > &model_parameters)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
static std::vector< std::vector< int > > jacStamp
const SolverState & getSolverState() const
Returns the solver state given during device construction.
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.