Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.40.2.3 $
40 //
41 // Revision Date : $Date: 2014/03/06 23:33:43 $
42 //
43 // Current Owner : $Author: tvrusso $
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_BreakPoint.h>
65 
66 namespace Xyce {
67 namespace Device {
68 namespace Resistor3 {
69 
71 {
72  p.addPar ("R", 1000.0, false, ParameterType::TIME_DEP,
74  U_OHM, CAT_NONE, "Resistance");
75 
76  p.addPar ("L", 0.0, false, ParameterType::NO_DEP,
78  U_METER, CAT_NONE, "Length");
79 
80  p.addPar ("W", 0.0, false, ParameterType::NO_DEP,
82  U_METER, CAT_NONE, "Width");
83 
84  p.addPar ("TEMP", 0.0, false, ParameterType::TIME_DEP,
86  U_DEGC, CAT_NONE, "Device temperature");
87 
88  p.addPar ("TC1", 0.0, false, ParameterType::NO_DEP,
91  U_DEGCM1, CAT_NONE, "Linear Temperature Coefficient");
92 
93  p.addPar ("TC2", 0.0, false, ParameterType::NO_DEP,
96  U_DEGCM2, CAT_NONE, "Quadratic Temperature Coefficient");
97 
98  // This call tells the parameter handling code that TC can be specified
99  // as a vector with up to two elements as in TC=a,b. It then translates
100  // TC=a,b into TC1=a TC2=b. Likewise, TC=a will translate into TC1=a
101  p.makeVector ("TC", 2);
102 
103  p.addPar ("DTEMP", 0.0, false, ParameterType::NO_DEP,
106  U_DEGC, CAT_NONE, "Device Temperature -- For compatibility only. Parameter is NOT used");
107 }
108 
110 {}
111 
112 std::vector< std::vector<int> > Instance::jacStamp;
113 std::vector< std::vector<int> > Instance::jacStampPDE;
114 
115 
116 // Class Instance
117 //-----------------------------------------------------------------------------
118 // Function : Instance::Instance
119 // Purpose : "instance block" constructor
120 // Special Notes :
121 // Scope : public
122 // Creator : Richard Schiek, Electrical and Microsystems Modeling
123 // Creation Date : 2/1/10
124 //-----------------------------------------------------------------------------
126  const Configuration & configuration,
127  const InstanceBlock & IB,
128  Model & Viter,
129  const FactoryBlock & factory_block)
130  : DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
131  model_(Viter),
132  srcCurrent(0.0),
133  srcVoltage(0.0),
134  srcDrop(0.0),
135  srcBC(0.0),
136 
137  li_Pos(-1),
138  li_Neg(-1),
139  li_Bra(-1),
140  tempCoeff1(0.0),
141  tempCoeff2(0.0),
142  dtemp(0.0),
143  tempCoeff1Given(false),
144  tempCoeff2Given(false),
145  dtempGiven(false),
146 
147  ABraEquPosNodeOffset(-1),
148  ABraEquNegNodeOffset(-1),
149  APosEquBraVarOffset(-1),
150  ANegEquBraVarOffset(-1),
151  ABraEquBraVarOffset(-1),
152  APosEquPosNodeOffset(-1),
153  ANegEquNegNodeOffset(-1),
154 
156  fBraEquPosNodePtr(0),
157  fBraEquNegNodePtr(0),
158  fPosEquBraVarPtr(0),
159  fNegEquBraVarPtr(0),
160  fPosEquPosNodePtr(0),
161  fNegEquNegNodePtr(0),
162  fBraEquBraVarPtr(0),
163 #endif
164 
165  scale(1.0),
166  nlstep(-1),
167  source(0.0),
168  v_pos(0.0),
169  v_neg(0.0),
170  i_bra(0.0)
171 {
172  numIntVars = 1;
173  numExtVars = 2;
174  numStateVars = 0;
175 
176  if( jacStamp.empty() )
177  {
178  jacStamp.resize(3);
179  jacStamp[0].resize(1);
180  jacStamp[0][0] = 2;
181  jacStamp[1].resize(1);
182  jacStamp[1][0] = 2;
183  jacStamp[2].resize(2);
184  jacStamp[2][0] = 0;
185  jacStamp[2][1] = 1;
186 
187  // PDE supporting stamp. This includes diagonal elements, needed by the
188  // 2-level Newton.
189  jacStampPDE.resize(3);
190  jacStampPDE[0].resize(2);
191  jacStampPDE[0][0] = 0;
192  jacStampPDE[0][1] = 2;
193  jacStampPDE[1].resize(2);
194  jacStampPDE[1][0] = 1;
195  jacStampPDE[1][1] = 2;
196  jacStampPDE[2].resize(3);
197  jacStampPDE[2][0] = 0;
198  jacStampPDE[2][1] = 1;
199  jacStampPDE[2][2] = 2;
200  }
201 
202  // Set params to constant default values:
203  setDefaultParams ();
204 
205  // Set params according to instance line and constant defaults from metadata:
206  setParams (IB.params);
207 
208  processParams();
209 
210  // Calculate any parameters specified as expressions:
212  processParams();
213 }
214 
215 //-----------------------------------------------------------------------------
216 // Function : Instance::~Instance
217 // Purpose : destructor
218 // Special Notes :
219 // Scope : public
220 // Creator : Richard Schiek, Electrical and Microsystems Modeling
221 // Creation Date : 2/1/10
222 //-----------------------------------------------------------------------------
224 {
225 }
226 
227 //-----------------------------------------------------------------------------
228 // Function : Instance::processParams
229 // Purpose :
230 // Special Notes :
231 // Scope : public
232 // Creator : Richard Schiek, Electrical and Microsystems Modeling
233 // Creation Date : 2/1/10
234 //-----------------------------------------------------------------------------
236 {
237  return true;
238 }
239 
240 //-----------------------------------------------------------------------------
241 // Function : Instance::registerLIDs
242 // Purpose :
243 // Special Notes :
244 // Scope : public
245 // Creator : Richard Schiek, Electrical and Microsystems Modeling
246 // Creation Date : 2/1/10
247 //-----------------------------------------------------------------------------
248 void Instance::registerLIDs ( const std::vector<int> & intLIDVecRef,
249  const std::vector<int> & extLIDVecRef)
250 {
251  std::string msg;
252 
253 #ifdef Xyce_DEBUG_DEVICE
254  if (getDeviceOptions().debugLevel > 0 )
255  {
256  Xyce::dout() << std::endl << section_divider << std::endl;
257  Xyce::dout() << " Instance::registerLIDs" << std::endl;
258  Xyce::dout() << " name = " << getName() << std::endl;
259  }
260 #endif
261 
262  // Check if the size of the ID lists corresponds to the
263  // proper number of internal and external variables.
264  int numInt = intLIDVecRef.size();
265  int numExt = extLIDVecRef.size();
266 
267  if (numInt != numIntVars)
268  {
269  msg = "Instance::registerLIDs:";
270  msg += "numInt != numIntVars";
271  N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
272  }
273 
274  if (numExt != numExtVars)
275  {
276  msg = "Instance::registerLIDs:";
277  msg += "numExt != numExtVars";
278  N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
279  }
280 
281  // copy over the global ID lists.
282  intLIDVec = intLIDVecRef;
283  extLIDVec = extLIDVecRef;
284 
285  // Now use these lists to obtain the indices into the
286  // linear algebra entities. This assumes an order.
287  // For the matrix indices, first do the rows.
288 
289  li_Pos = extLIDVec[0];
290  li_Neg = extLIDVec[1];
291  li_Bra = intLIDVec[0];
292 
293 #ifdef Xyce_DEBUG_DEVICE
294  if (getDeviceOptions().debugLevel > 0 )
295  {
296  Xyce::dout() << " li_Pos = " << li_Pos << std::endl;
297  Xyce::dout() << " li_Neg = " << li_Neg << std::endl;
298  Xyce::dout() << " li_Bra = " << li_Bra << std::endl;
299  Xyce::dout() << section_divider << std::endl;
300  }
301 #endif
302 }
303 
304 //-----------------------------------------------------------------------------
305 // Function : Instance::getIntNameMap
306 // Purpose :
307 // Special Notes :
308 // Scope : public
309 // Creator : Richard Schiek, Electrical and Microsystems Modeling
310 // Creation Date : 2/1/10
311 //-----------------------------------------------------------------------------
312 std::map<int,std::string> & Instance::getIntNameMap ()
313 {
314  // set up the internal name map, if it hasn't been already.
315  if (intNameMap.empty ())
316  {
317  // set up the internal name map
318  std::string tmpstr(getName()+"_branch");
319  spiceInternalName (tmpstr);
320  intNameMap[ li_Bra ] = tmpstr;
321  }
322 
323  return intNameMap;
324 }
325 
326 
327 
328 //-----------------------------------------------------------------------------
329 // Function : Instance::registerStateLIDs
330 // Purpose :
331 // Special Notes :
332 // Scope : public
333 // Creator : Richard Schiek, Electrical and Microsystems Modeling
334 // Creation Date : 2/1/10
335 //-----------------------------------------------------------------------------
336 void Instance::registerStateLIDs( const std::vector<int> & staLIDVecRef )
337 {
338  AssertLIDs(staLIDVecRef.size() == numStateVars);
339 }
340 
341 //-----------------------------------------------------------------------------
342 // Function : Instance::jacobianStamp
343 // Purpose :
344 // Special Notes :
345 // Scope : public
346 // Creator : Richard Schiek, Electrical and Microsystems Modeling
347 // Creation Date : 2/1/10
348 //-----------------------------------------------------------------------------
349 const std::vector< std::vector<int> > & Instance::jacobianStamp() const
350 {
351  if (getSolverState().PDESystemFlag)
352  return jacStampPDE;
353 
354  return jacStamp;
355 }
356 
357 //-----------------------------------------------------------------------------
358 // Function : Instance::registerJacLIDs
359 // Purpose :
360 // Special Notes :
361 // Scope : public
362 // Creator : Richard Schiek, Electrical and Microsystems Modeling
363 // Creation Date : 2/1/10
364 //-----------------------------------------------------------------------------
365 void Instance::registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec )
366 {
367  DeviceInstance::registerJacLIDs( jacLIDVec );
368  if (getSolverState().PDESystemFlag)
369  {
370  APosEquBraVarOffset = jacLIDVec[0][1];
371  ANegEquBraVarOffset = jacLIDVec[1][1];
372  ABraEquPosNodeOffset = jacLIDVec[2][0];
373  ABraEquNegNodeOffset = jacLIDVec[2][1];
374  }
375  else
376  {
377  APosEquBraVarOffset = jacLIDVec[0][0];
378  ANegEquBraVarOffset = jacLIDVec[1][0];
379  ABraEquPosNodeOffset = jacLIDVec[2][0];
380  ABraEquNegNodeOffset = jacLIDVec[2][1];
381  }
382 
383 }
384 
385 //-----------------------------------------------------------------------------
386 // Function : Instance::setupPointers
387 // Purpose :
388 // Special Notes :
389 // Scope : public
390 // Creator : Richard Schiek, Electrical and Microsystems Modeling
391 // Creation Date : 2/1/10
392 //-----------------------------------------------------------------------------
394 {
395 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
396  N_LAS_Matrix & dFdx = *(extData.dFdxMatrixPtr);
397 
402 #endif
403 }
404 
405 //-----------------------------------------------------------------------------
406 // Function : Instance::updateIntermediateVars
407 // Purpose :
408 // Special Notes :
409 // Scope : public
410 // Creator : Richard Schiek, Electrical and Microsystems Modeling
411 // Creation Date : 2/1/10
412 //-----------------------------------------------------------------------------
414 {
415  double * solVec = extData.nextSolVectorRawPtr;
416 
417  // Get the value for the source.
418  source = 0.0;
419 
420  // get the value for v_pos, v_neg, i_bra
421  v_pos = solVec[li_Pos];
422  v_neg = solVec[li_Neg];
423  i_bra = solVec[li_Bra];
424 
425  srcCurrent = i_bra;
426  srcDrop = (v_pos-v_neg);
427  srcBC = source;
429 
430  if( getDeviceOptions().scale_src != 0.0 )
431  {
432  srcCurrent *= scale;
433 
434  // first newton step, generate new scaling
435  //if( nlsMgrPtr->getNonLinearIter() != nlstep )
436  if( getSolverState().newtonIter != nlstep )
437  {
438  //nlstep = nlsMgrPtr->getNonLinearIter();
440  double new_scale = fabs(i_bra) * scale;
441 
442  scale = Xycemax( new_scale, getDeviceOptions().scale_src );
443  }
444 
445  srcVoltage *= scale;
446  srcDrop *= scale;
447  srcBC *= scale;
448  }
449 
450  return true;
451 }
452 
453 //-----------------------------------------------------------------------------
454 // Function : Instance::updatePrimaryState
455 // Purpose :
456 // Special Notes :
457 // Scope : public
458 // Creator : Richard Schiek, Electrical and Microsystems Modeling
459 // Creation Date : 2/1/10
460 //-----------------------------------------------------------------------------
462 {
463  bool bsuccess = updateIntermediateVars ();
464  return bsuccess;
465 }
466 
467 //-----------------------------------------------------------------------------
468 // Function : Instance::loadDAEFVector
469 //
470 // Purpose : Loads the F-vector contributions for a single
471 // vsrc instance.
472 //
473 // Special Notes :
474 //
475 // Scope : public
476 // Creator : Richard Schiek, Electrical and Microsystems Modeling
477 // Creation Date : 2/1/10
478 //-----------------------------------------------------------------------------
480 {
481  // Using values determined during the loadRHS function call.
482  // (srcCurrent, srcVoltage).
483 
484  double * fVec = extData.daeFVectorRawPtr;
485 
486  fVec[li_Pos] += srcCurrent;
487  fVec[li_Neg] += -srcCurrent;
488  fVec[li_Bra] += srcDrop;
489  fVec[li_Bra] -= srcBC;
490 
491  return true;
492 }
493 
494 //-----------------------------------------------------------------------------
495 // Function : Instance::loadDAEdFdx ()
496 //
497 // Purpose : Loads the F-vector contributions for a single
498 // resistor instance.
499 //
500 // Special Notes :
501 //
502 // Scope : public
503 // Creator : Richard Schiek, Electrical and Microsystems Modeling
504 // Creation Date : 2/1/10
505 //-----------------------------------------------------------------------------
507 {
508  N_LAS_Matrix & dFdx = *(extData.dFdxMatrixPtr);
509 
510  dFdx[li_Pos][APosEquBraVarOffset] += 1.0;
511  dFdx[li_Neg][ANegEquBraVarOffset] -= 1.0;
512  dFdx[li_Bra][ABraEquPosNodeOffset] += 1.0;
513  dFdx[li_Bra][ABraEquNegNodeOffset] -= 1.0;
514 
515  return true;
516 }
517 
518 // end of new-DAE functions
519 
520 //-----------------------------------------------------------------------------
521 // Function : Instance::getMaxTimeStepSize
522 // Purpose :
523 // Special Notes :
524 // Scope : public
525 // Creator : Richard Schiek, Electrical and Microsystems Modeling
526 // Creation Date : 2/1/10
527 //-----------------------------------------------------------------------------
529 {
530  double maxStep = 1.0e99;
531  return maxStep;
532 }
533 
534 //-----------------------------------------------------------------------------
535 // Function : Instance::varTypes
536 // Purpose :
537 // Special Notes :
538 // Scope : public
539 // Creator : Richard Schiek, Electrical and Microsystems Modeling
540 // Creation Date : 2/1/10
541 //-----------------------------------------------------------------------------
542 void Instance::varTypes( std::vector<char> & varTypeVec )
543 {
544  varTypeVec.resize(1);
545  varTypeVec[0] = 'I';
546 }
547 
548 // Class Model
549 
550 //-----------------------------------------------------------------------------
551 // Function : Model::Model
552 // Purpose : copy constructor
553 // Special Notes :
554 // Scope : public
555 // Creator : Richard Schiek, Electrical and Microsystems Modeling
556 // Creation Date : 2/1/10
557 //-----------------------------------------------------------------------------
559  const Configuration & configuration,
560  const ModelBlock & MB,
561  const FactoryBlock & factory_block)
562  : DeviceModel(MB, configuration.getModelParameters(), factory_block),
563  DC_TRAN (0)
564 {
565 }
566 
567 //-----------------------------------------------------------------------------
568 // Function : Model::~Model
569 // Purpose : destructor
570 // Special Notes :
571 // Scope : public
572 // Creator : Richard Schiek, Electrical and Microsystems Modeling
573 // Creation Date : 2/1/10
574 //-----------------------------------------------------------------------------
576 {
577  std::vector<Instance*>::iterator iter;
578  std::vector<Instance*>::iterator first = instanceContainer.begin();
579  std::vector<Instance*>::iterator last = instanceContainer.end();
580 
581  for (iter=first; iter!=last; ++iter)
582  {
583  delete (*iter);
584  }
585 }
586 
587 // Additional Declarations
588 
589 //-----------------------------------------------------------------------------
590 // Function : Model::printOutInstances
591 // Purpose : debugging tool.
592 // Special Notes :
593 // Scope : public
594 // Creator : Richard Schiek, Electrical and Microsystems Modeling
595 // Creation Date : 2/1/10
596 //-----------------------------------------------------------------------------
597 std::ostream &Model::printOutInstances(std::ostream &os) const
598 {
599  std::vector<Instance*>::const_iterator iter;
600  std::vector<Instance*>::const_iterator first = instanceContainer.begin();
601  std::vector<Instance*>::const_iterator last = instanceContainer.end();
602 
603  int i;
604  os << std::endl;
605  os << " name model name Parameters" << std::endl;
606  for (i=0, iter=first; iter!=last; ++iter, ++i)
607  {
608  os << " " << i << ": " << (*iter)->getName() << " ";
609  os << getName();
610  os << std::endl;
611  }
612 
613  os << std::endl;
614 
615  return os;
616 }
617 
618 //-----------------------------------------------------------------------------
619 // Function : Model::forEachInstance
620 // Purpose :
621 // Special Notes :
622 // Scope : public
623 // Creator : David Baur
624 // Creation Date : 2/4/2014
625 //-----------------------------------------------------------------------------
626 /// Apply a device instance "op" to all instances associated with this
627 /// model
628 ///
629 /// @param[in] op Operator to apply to all instances.
630 ///
631 ///
632 void Model::forEachInstance(DeviceInstanceOp &op) const /* override */
633 {
634  for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
635  op(*it);
636 }
637 
638 
639 
640 //-----------------------------------------------------------------------------
641 // Vsrc Master functions:
642 //-----------------------------------------------------------------------------
643 
644 
645 //-----------------------------------------------------------------------------
646 // Function : Master::updateState
647 // Purpose :
648 // Special Notes :
649 // Scope : public
650 // Creator : Richard Schiek, Electrical and Microsystems Modeling
651 // Creation Date : 2/1/10
652 //-----------------------------------------------------------------------------
653 bool Master::updateState (double * solVec, double * staVec, double * stoVec)
654 {
655 
656  // // first loop over the models:
657  // for (ModelMap::const_iterator model_it = getModelMap().begin(); model_it != getModelMap().end(); ++model_it)
658  // {
659  // // loop over the instances for this model.
660  // InstanceVector::const_iterator first = (*model_it).second->instanceContainer.begin();
661  // InstanceVector::const_iterator last = (*model_it).second->instanceContainer.end();
662 
663  // for (InstanceVector::const_iterator it = first; it != last; ++it)
664  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
665  {
666  Instance & vi = *(*it);
667 
668  // Get the value for the source.
669  vi.source = 0.0;
670 
671  // get the value for v_pos, v_neg, i_bra
672  vi.v_pos = solVec[vi.li_Pos];
673  vi.v_neg = solVec[vi.li_Neg];
674  vi.i_bra = solVec[vi.li_Bra];
675 
676  vi.srcCurrent = vi.i_bra;
677  vi.srcDrop = (vi.v_pos-vi.v_neg);
678  vi.srcBC = vi.source;
679  vi.srcVoltage = vi.srcDrop-vi.srcBC;
680 
681  if( getDeviceOptions().scale_src != 0.0 )
682  {
683  vi.srcCurrent *= vi.scale;
684 
685  // first newton step, generate new scaling
686  if( getSolverState().newtonIter != vi.nlstep )
687  {
689  double new_scale = fabs(vi.i_bra) * vi.scale;
690 
691  vi.scale = Xycemax( new_scale, getDeviceOptions().scale_src );
692  }
693 
694  vi.srcVoltage *= vi.scale;
695  vi.srcDrop *= vi.scale;
696  vi.srcBC *= vi.scale;
697  }
698  }
699 // }
700 
701  return true;
702 }
703 
704 //-----------------------------------------------------------------------------
705 // Function : Master::loadDAEVectors
706 // Purpose :
707 // Special Notes :
708 // Scope : public
709 // Creator : Richard Schiek, Electrical and Microsystems Modeling
710 // Creation Date : 2/1/10
711 //-----------------------------------------------------------------------------
712 bool Master::loadDAEVectors (double * solVec, double * fVec, double *qVec, double * storeLeadF, double * storeLeadQ)
713 {
714  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
715  {
716  Instance & vi = *(*it);
717 
718 
719  fVec[vi.li_Pos] += vi.srcCurrent;
720 
721  fVec[vi.li_Neg] += -vi.srcCurrent;
722 
723  fVec[vi.li_Bra] += vi.srcDrop;
724 
725  fVec[vi.li_Bra] -= vi.srcBC;
726  }
727 
728  return true;
729 }
730 
731 //-----------------------------------------------------------------------------
732 // Function : Master::loadDAEMatrices
733 // Purpose :
734 // Special Notes :
735 // Scope : public
736 // Creator : Richard Schiek, Electrical and Microsystems Modeling
737 // Creation Date : 2/1/10
738 //-----------------------------------------------------------------------------
739 bool Master::loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx)
740 {
741  for (InstanceVector::const_iterator it = getInstanceBegin(); it != getInstanceEnd(); ++it)
742  {
743  Instance & vi = *(*it);
744 
745 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
746 
747  *(vi.fPosEquBraVarPtr) += 1.0;
748 
749  *(vi.fNegEquBraVarPtr) -= 1.0;
750 
751  *(vi.fBraEquPosNodePtr) += 1.0;
752 
753  *(vi.fBraEquNegNodePtr) -= 1.0;
754 #else
755 
756  dFdx[vi.li_Pos][vi.APosEquBraVarOffset] += 1.0;
757 
758  dFdx[vi.li_Neg][vi.ANegEquBraVarOffset] -= 1.0;
759 
760  dFdx[vi.li_Bra][vi.ABraEquPosNodeOffset] += 1.0;
761 
762  dFdx[vi.li_Bra][vi.ABraEquNegNodeOffset] -= 1.0;
763 #endif
764 
765  }
766 
767  return true;
768 }
769 
770 Device *
771 Traits::factory(const Configuration &configuration, const FactoryBlock &factory_block)
772 {
773  return new Master(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
774 }
775 
777 {
779  .registerDevice("r", 3)
780  .registerModelType("r", 3);
781 }
782 
783 } // namespace Resistor3
784 } // namespace Device
785 } // namespace Xyce