45 #include <Xyce_config.h>
61 #include <N_ERH_ErrorMgr.h>
62 #include <N_UTL_FeatureTest.h>
63 #include <N_UTL_Math.h>
68 #include <N_LAS_Vector.h>
69 #include <N_LAS_Matrix.h>
76 namespace MutIndNonLin {
84 .setDescription(
"Coupling coefficient");
90 .setDescription(
"Nonlinear coupling flag");
115 .setDescription(
"Coupling coefficient");
128 .setDescription(
"Thermal energy parameter");
133 .setDescription(
"Mean magnetic cross-sectional area");
138 .setDescription(
"Domain coupling parameter");
143 .setDescription(
"Modeling constant");
148 .setDescription(
"Modeling constant");
153 .setDescription(
"Domain flexing parameter");
158 .setDescription(
"Value below which domain flexing parameter will be treated as zero.");
163 .setDescription(
"Smoothing coefficient for voltage difference over first inductor");
168 .setDescription(
"Use constant scaling factor to smooth voltage difference over first inductor");
174 .setDescription(
"Flag to include the magnetics in the solution.");
179 .setDescription(
"Effective air gap");
184 .setDescription(
"Domain anisotropy parameter");
189 .setDescription(
"Domain anisotropy parameter");
194 .setDescription(
"Saturation magnetization");
199 .setDescription(
"for pspice compatibility -- ignored");
204 .setDescription(
"for pspice compatibility -- ignored");
209 .setDescription(
"Total mean magnetic path");
214 .setDescription(
"Reference temperature");
219 .setDescription(
"First order temperature coeff.");
224 .setDescription(
"Second order temperature coeff.");
229 .setDescription(
"Tolerance for nonlinear zero crossing");
234 .setDescription(
"M-variable scaling.");
239 .setDescription(
"R-variable scaling");
244 .setDescription(
"M-equation scaling");
249 .setDescription(
"R-equation scaling");
254 .setDescription(
"Flag to save state variables");
259 .setDescription(
"Flag to save state variables");
264 .setDescription(
"Flag to report B and H in SI units");
283 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
285 temp(getDeviceOptions().temp.getImmutableValue<double>()),
286 outputStateVarsFlag( false ),
287 maxVoltageDrop(1.0e-10)
335 LOI.resize( numInductors );
336 LO.resize( numInductors );
339 LO[i].resize( numInductors );
365 std::string filename(
"Inductor_" );
366 filename.append(
getName().getEncodedName() );
367 filename.append(
".dat" );
369 replace( filename.begin(), filename.end(),
'%',
'_' );
370 replace( filename.begin(), filename.end(),
':',
'_' );
373 outputFileStreamPtr->open( filename.c_str() );
374 if( !(*outputFileStreamPtr) )
376 UserError(*
this) <<
"Could not open file " << filename <<
" for output of state variables";
379 (*outputFileStreamPtr).setf(std::ios::scientific, std::ios::floatfield );
380 (*outputFileStreamPtr).width(20);
381 (*outputFileStreamPtr).precision(12);
386 dHe_dI.resize( numInductors );
390 dP_dI.resize( numInductors );
401 int numExtraEquations = 1;
406 numIntVars = numInductors + numExtraEquations;
465 jacStamp[2*numInductors + i].resize(numInductors + 5);
469 jacStamp[2*numInductors + i].resize(numInductors + 4);
477 jacStamp[2*i ][0] = 2*numInductors + i;
479 jacStamp[2*i+1][0] = 2*numInductors + i;
496 jacStamp[2*numInductors + i][0] = 0;
497 jacStamp[2*numInductors + i][1] = 1;
498 jacStamp[2*numInductors + i][2] = 2*i;
499 jacStamp[2*numInductors + i][3] = 2*i + 1;
502 jacStamp[2*numInductors + i][j+4] = 2*numInductors + j;
532 jacStamp[ 3*numInductors + rOffset].resize(numInductors + 1);
537 jacStamp[ 3*numInductors + rOffset ][i]=2*numInductors+i;
543 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
545 Xyce::dout() <<
"Instance::Instance----------" << std::endl;
546 Xyce::dout() <<
"numExtVars = " <<
numExtVars <<
", " << ibev << std::endl
547 <<
"numIntVars = " <<
numIntVars <<
", " << ibiv << std::endl
549 <<
"numInductors = " << numInductors << std::endl
550 <<
"jacStamp = " << std::endl;
551 for(
int i = 0; i<
jacStamp.size(); ++i )
553 Xyce::dout() <<
"jacStamp[ " << i <<
" ] = { ";
554 for(
int j=0; j<
jacStamp[i].size(); ++j)
557 if( j != (
jacStamp[i].size() -1 ) )
559 Xyce::dout() <<
", ";
562 Xyce::dout() <<
" }" << std::endl;
583 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
584 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
585 for ( ; currentInductor != endInductor ; ++currentInductor)
587 if (*currentInductor != NULL)
589 delete *currentInductor;
590 *currentInductor = NULL;
624 const std::vector<int> & extLIDVecRef)
637 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
638 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
641 while( currentInductor != endInductor )
643 (*currentInductor)->li_Pos =
extLIDVec[ i++ ];
644 (*currentInductor)->li_Neg =
extLIDVec[ i++ ];
645 (*currentInductor)->li_Branch = intLIDVec[ j++ ];
656 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
658 Xyce::dout() <<
"Instance::registerLIDs------------------------" << std::endl;
661 while( currentInductor != endInductor )
663 Xyce::dout() <<
"Inductor [ " << i++ <<
" ] "
664 <<
" li_Pos = " << (*currentInductor)->li_Pos
665 <<
" li_Neg = " << (*currentInductor)->li_Neg
666 <<
" li_Branch = " << (*currentInductor)->li_Branch << std::endl;
669 Xyce::dout() <<
" li_MagVar = " <<
li_MagVar << std::endl
670 <<
" li_RVar = " <<
li_RVar << std::endl;
684 for (std::vector<InductorInstanceData *>::const_iterator it =
instanceData.begin(), end =
instanceData.end(); it != end; ++it ) {
686 if(
getName().getSubcircuitName() ==
"" )
687 branchInductorName = (*it)->name;
729 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
731 Xyce::dout() <<
"Instance::registerStateLIDs-------------------" << std::endl;
733 Xyce::dout() <<
"li_MagVarState = " <<
li_MagVarState << std::endl
783 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
785 Xyce::dout() <<
"Instance::registerJacLIDs ----------------------------" << std::endl;
787 Xyce::dout() <<
"jacLIDVec = " << std::endl;
788 for(
int i = 0; i<
jacStamp.size(); ++i )
790 Xyce::dout() <<
"jacLIDVec[ " << i <<
" ] = { ";
791 for(
int j=0; j<jacLIDVec[i].size(); ++j)
793 Xyce::dout() << jacLIDVec[i][j];
794 if( j != ( jacLIDVec[i].size() -1 ) )
796 Xyce::dout() <<
", ";
799 Xyce::dout() <<
" }" << std::endl;
803 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
804 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
807 while( currentInductor != endInductor )
809 (*currentInductor)->APosEquBraVarOffset = jacLIDVec[ 2*i ][ 0 ];
810 (*currentInductor)->ANegEquBraVarOffset = jacLIDVec[ 2*i + 1 ][ 0 ];
811 (*currentInductor)->vPosOffset = jacLIDVec[ 2*
numInductors + i ][ 0 ];
812 (*currentInductor)->vNegOffset = jacLIDVec[ 2*
numInductors + i ][ 1 ];
818 (*currentInductor)->ABraEquPosNodeOffset = jacLIDVec[ 2*
numInductors + i ][ 0 + extraOffset ];
819 (*currentInductor)->ABraEquNegNodeOffset = jacLIDVec[ 2*
numInductors + i ][ 1 + extraOffset ];
824 (*currentInductor)->ABraEquBraVarOffset = jacLIDVec[ 2*numInductors + i ][ j + 2 + extraOffset ];
826 (*currentInductor)->inductorCurrentOffsets[ j ] = jacLIDVec[ 2*numInductors + i ][ j + 2 + extraOffset ];
830 (*currentInductor)->magOffset = jacLIDVec[ 2*numInductors + i ][ numInductors + 2 + extraOffset ];
859 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
863 while( currentInductor != endInductor )
865 Xyce::dout() <<
"Inductor [ " << i <<
" ] " << (*currentInductor)->name << std::endl
866 <<
" APosEquBraVarOffset = " << (*currentInductor)->APosEquBraVarOffset << std::endl
867 <<
" ANegEquBraVarOffset = " << (*currentInductor)->ANegEquBraVarOffset << std::endl
868 <<
" vPosOffset = " << (*currentInductor)->vPosOffset << std::endl
869 <<
" vNegOffset = " << (*currentInductor)->vNegOffset << std::endl
870 <<
" ABraEquPosNodeOffset = " << (*currentInductor)->ABraEquPosNodeOffset << std::endl
871 <<
" ABraEquNegNodeOffset = " << (*currentInductor)->ABraEquNegNodeOffset << std::endl
872 <<
" ABraEquBraVarOffset = " << (*currentInductor)->ABraEquBraVarOffset << std::endl
873 <<
" magOffset = " << (*currentInductor)->magOffset << std::endl;
874 Xyce::dout() <<
"\tInductor branch offsets = { ";
877 Xyce::dout() << (*currentInductor)->inductorCurrentOffsets[ j ] <<
", ";
879 Xyce::dout() <<
"} " << std::endl;
885 Xyce::dout() <<
"mEquInductorOffsets = ";
890 Xyce::dout() << std::endl
893 Xyce::dout() <<
"rEquInductorOffsets = ";
898 Xyce::dout() << std::endl
913 bool bsuccess =
true;
918 std::vector< InductorInstanceData* >::iterator currentData =
instanceData.begin();
923 (*currentData)->L = ((*currentData)->baseL)*factor;
943 bool bsuccess =
true;
945 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
947 Xyce::dout() <<
"Instance::updateIntermediateVars " << std::endl;
977 double voltageDrop= Vpos - Vneg;
992 qV = DeltaVScaling * voltageDrop;
999 double tanh_qV = 0.0;
1015 std::vector< InductorInstanceData* >::iterator currentInductor = instanceData.begin();
1016 std::vector< InductorInstanceData* >::iterator endInductor = instanceData.end();
1018 while( currentInductor != endInductor )
1026 double latestMag=0.0;
1029 latestMag = mVarScaling * solVector[
li_MagVar ];
1041 double H =
Happ - (Gap / Path) * latestMag;
1043 He = H + Alpha * latestMag;
1048 const double gap_path = Gap / Path;
1049 const double He2 = He*
He;
1050 const double Heo2 =
Heo*
Heo;
1051 const double sq_Heo2He2 = sqrt(Heo2 + He2);
1054 double Man = Ms * He / ( A + sq_Heo2He2 );
1055 delM = Man - latestMag;
1060 const double sq_delM02delM2 = sqrt( delM02 + delM2 );
1064 Mirrp = (delM * tanh_qV + sq_delM02delM2 ) / (2*( Kirr- Alpha * sq_delM02delM2));
1065 Manp = Ms * (A + Heo2/sq_Heo2He2) / pow(A + sq_Heo2He2, 2.0);
1066 P = ( C *
Manp + (1 - C) *
Mirrp) / ((1 + (gap_path - Alpha) * C *
Manp + gap_path * (1-C) *
Mirrp)*Ms);
1070 Mirrp = (delM * tanh_qV + sq_delM02delM2 ) / (2*( Kirr- Alpha * sq_delM02delM2));
1071 Manp = Ms * (A + Heo2/sq_Heo2He2) / pow(A + sq_Heo2He2, 2.0);
1072 P = ( C *
Manp + (1 - C) *
Mirrp) / (1 + (gap_path - Alpha) * C *
Manp + gap_path * (1-C) *
Mirrp);
1077 Xyce::dout() <<
"\tA = " << A << std::endl
1078 <<
"\tArea = " << Area << std::endl
1079 <<
"\tPath = " << Path << std::endl
1080 <<
"\tGap = " << Gap << std::endl
1081 <<
"\tC = " << C << std::endl
1082 <<
"\tVpos = " << Vpos << std::endl
1083 <<
"\tVneg = " << Vneg << std::endl
1084 <<
"\tvoltageDrop = " << voltageDrop << std::endl
1085 <<
"\tqV = " <<
qV << std::endl
1086 <<
"\tdelM0 = " << delM0 << std::endl
1087 <<
"\tHapp = " <<
Happ
1088 <<
"\tlatestMag = " << latestMag
1089 <<
"\tlatestR = " << rVarScaling * solVector[
li_RVar ] << std::endl
1090 <<
"\tHe = " << He << std::endl
1091 <<
"\tH = " << H << std::endl
1092 <<
"\tHeo = " << Heo << std::endl
1093 <<
"\tMan = " << Man << std::endl
1094 <<
"\tdelM = " << delM << std::endl
1095 <<
"\tMirrp = " <<
Mirrp << std::endl
1096 <<
"\tManp = " <<
Manp << std::endl
1097 <<
"\tP = " <<
P << std::endl
1104 double dHe_dM = ((Alpha - gap_path) * mVarScaling);
1106 double dManp_dM = ( -Ms * He / (pow(A + sq_Heo2He2, 2.0)*sq_Heo2He2)) *
1107 ( (Heo2 / (Heo2 + He2)) + (2.0*(A + Heo2 / sq_Heo2He2)/(A+sq_Heo2He2)) ) * dHe_dM;
1109 double ddelM_dM = ( dHe_dM*Ms/(A + sq_Heo2He2) ) * (1.0 - He2 / ((A + sq_Heo2He2)*sq_Heo2He2)) - mVarScaling;
1111 double dMirrp_dM = (1.0/(2.0*(Kirr - Alpha*sq_delM02delM2))) *
1112 (tanh_qV + delM/sq_delM02delM2 +
1113 (2.0*Alpha*delM*(delM*tanh_qV + sq_delM02delM2)
1114 /(2.0*(Kirr-Alpha*sq_delM02delM2)*sq_delM02delM2))) * ddelM_dM;
1116 double dP_Denom=0.0;
1119 dP_Denom = 1.0 + (gap_path - Alpha)*C*
Manp + gap_path * (1.0-C) *
Mirrp;
1121 dP_dM = (1.0/dP_Denom) * (C * dManp_dM + (1.0-C) * dMirrp_dM) -
1122 ( (C*
Manp + (1.0-C)*
Mirrp)/pow(dP_Denom,2.0) ) *
1123 ( (gap_path - Alpha)*C*dManp_dM + gap_path*(1.0-C)*dMirrp_dM );
1128 dP_Denom = 1.0 + (gap_path - Alpha)*C*
Manp + gap_path * (1.0-C) *
Mirrp;
1130 dP_dM = (1.0/dP_Denom) * (C * dManp_dM + (1.0-C) * dMirrp_dM) -
1131 ( (C*
Manp + (1.0-C)*
Mirrp)/pow(dP_Denom,2.0) ) *
1132 ( (gap_path - Alpha)*C*dManp_dM + gap_path*(1.0-C)*dMirrp_dM );
1137 Xyce::dout() <<
"\tA = " << A << std::endl
1138 <<
"\tAlpha = " << Alpha << std::endl
1139 <<
"\tC = " << C << std::endl
1140 <<
"\tGap = " << Gap << std::endl
1141 <<
"\tMs = " << Ms << std::endl
1142 <<
"\tKirr = " << Kirr << std::endl
1143 <<
"\tPath = " << Path << std::endl
1144 <<
"\tHe2 = " << He2 << std::endl
1145 <<
"\tHeo2 = " << Heo2 << std::endl
1146 <<
"\tdelM2 = " << delM2 << std::endl
1147 <<
"\tdelM02 = " << delM02 << std::endl
1148 <<
"\tdHe_dM = " << dHe_dM << std::endl
1149 <<
"\tdManp_dM = " << dManp_dM << std::endl
1150 <<
"\tddelM_dM = " << ddelM_dM << std::endl
1151 <<
"\tdMirrp_dM = " << dMirrp_dM << std::endl
1152 <<
"\tdP_dM = " <<
dP_dM << std::endl
1153 <<
"\tdenom 1+(1-lg/lt)P = " << (1+(1-Gap/Path)*
P) << std::endl;
1157 currentInductor = instanceData.begin();
1163 dManp_dI[i] = ( -Ms * He / (pow(A + sq_Heo2He2, 2.0)*sq_Heo2He2)) *
1164 ( (Heo2 / (Heo2 + He2)) + (2.0*(A + Heo2 / sq_Heo2He2)/(A+sq_Heo2He2)) ) *
dHe_dI[i];
1165 ddelM_dI[i] = (Ms / (A + sq_Heo2He2)) * (1.0 - He2/((A + sq_Heo2He2)*sq_Heo2He2)) *
dHe_dI[i];
1166 dMirrp_dI[i] = (1.0/(2.0*(Kirr - Alpha*sq_delM02delM2))) *
1167 (tanh_qV + delM/sq_delM02delM2 +
1168 (2.0*Alpha*delM*(delM*tanh_qV +
1169 sq_delM02delM2)/(2.0*(Kirr-Alpha*sq_delM02delM2)*sq_delM02delM2))) *
ddelM_dI[i];
1171 ( (C*
Manp + (1.0-C)*
Mirrp)/pow(dP_Denom,2.0) ) *
1181 Xyce::dout() <<
"\tdHe_dI[ " << i <<
" ] =" <<
dHe_dI[ i ] << std::endl
1182 <<
"\tdManp_dI[ " << i <<
" ] = " <<
dManp_dI[i] << std::endl
1183 <<
"\tddelM_dI[ " << i <<
" ] = " <<
ddelM_dI[i] << std::endl
1184 <<
"\tMirrp_dI[ " << i <<
" ] = " <<
dMirrp_dI[i] << std::endl
1185 <<
"\tdP_dI[ " << i <<
" ] = " <<
dP_dI[i] << std::endl;
1191 double dMirrp_dVp = (delM * DeltaVScaling * (1.0-pow(tanh_qV,2.0))) /
1192 (2.0 * (Kirr - Alpha * sq_delM02delM2));
1193 double dMirrp_dVn = -dMirrp_dVp;
1195 dP_dVp = (1.0/dP_Denom) * ((1.0-C) * dMirrp_dVp) -
1196 ( (C*
Manp + (1.0-C)*
Mirrp)/pow(dP_Denom,2.0) ) * ( gap_path*(1.0-C)*dMirrp_dVp );
1207 Xyce::dout() <<
"\tdMirrp_dVp = " << dMirrp_dVp << std::endl
1208 <<
"\tdMirrp_dVn = " << dMirrp_dVn << std::endl
1209 <<
"\tdP_dVp = " <<
dP_dVp << std::endl
1210 <<
"\tdP_dVn = " <<
dP_dVn << std::endl;
1230 std::vector< InductorInstanceData* >::iterator
1232 std::vector< InductorInstanceData* >::iterator
1237 while( currentInductor != endInductor )
1270 bool bsuccess =
true;
1271 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1273 Xyce::dout() <<
"Instance::updatePrimaryState---------------" << std::endl
1274 <<
"\tname = " <<
getName() << std::endl;
1288 double latestMag = 0.0;
1292 latestMag = mVarScaling * solVector[
li_MagVar ];
1323 bool bsuccess =
true;
1324 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1326 Xyce::dout() <<
"Instance::updateSecondaryState-------------" << std::endl
1327 <<
"\tname = " <<
getName() << std::endl;
1356 bool bsuccess =
true;
1362 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1364 Xyce::dout() <<
"Instance::loadDAEQVector------------------------" << std::endl
1365 <<
"\tname = " <<
getName() << std::endl;
1381 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
1382 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
1384 while( currentInductor != endInductor )
1386 if( (
getSolverState().dcopFlag) && (*currentInductor)->ICGiven ==
true )
1412 while( currentInductor != endInductor )
1415 qVec[((*currentInductor)->li_Branch)] +=
LOI[ i ];
1418 double windings = (*currentInductor)->L;
1420 qVec[
li_RVar ] += rEqScaling * current * windings;
1433 qVec[
li_MagVar ] += mEqScaling * latestMag;
1460 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1462 Xyce::dout() <<
"Instance::loadDAEFVector------------------------" << std::endl
1463 <<
"\tname = " <<
getName() << std::endl;
1473 double latestR = rVarScaling * stoVector[
li_RVarStore ];
1512 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
1513 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
1515 while( currentInductor != endInductor )
1517 double current = solVector[(*currentInductor)->li_Branch];
1518 double vNodePos = solVector[(*currentInductor)->li_Pos];
1519 double vNodeNeg = solVector[(*currentInductor)->li_Neg];
1522 fVec[((*currentInductor)->li_Pos)] +=
scalingRHS * current;
1524 fVec[((*currentInductor)->li_Neg)] += -
scalingRHS * current;
1526 fVec[((*currentInductor)->li_Branch)] += -((vNodePos - vNodeNeg)/mid);
1527 double windings = (*currentInductor)->L;
1531 Xyce::dout() <<
" Inductor = " << (*currentInductor)->name
1532 <<
" li_Pos = " << (*currentInductor)->li_Pos
1533 <<
" li_Neg = " << (*currentInductor)->li_Neg
1534 <<
" li_Branch = " << (*currentInductor)->li_Branch
1535 <<
"\tPos/Neg current*windings = " <<
scalingRHS*current*windings
1536 <<
"\tBranch = " << ((vNodePos - vNodeNeg)/mid)
1557 bool bsuccess =
true;
1566 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1568 Xyce::dout() <<
"Instance::loadDAEdQdx-----------------------" << std::endl
1569 <<
"\tname = " <<
getName() << std::endl;
1590 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
1591 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
1593 while( currentInductor != endInductor )
1597 (*dQdxMatPtr)[((*currentInductor)->li_Branch)]
1598 [(*currentInductor)->inductorCurrentOffsets[j]] +=
LO[i][j];
1622 bool bsuccess =
true;
1628 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1630 Xyce::dout() <<
"Instance::loadDAEdFdx----------------------" << std::endl
1631 <<
"\tname = " <<
getName() << std::endl;
1649 double latestR = rVarScaling * stoVector[
li_RVarStore ];
1664 mEqScaling *
dP_dI[i] * latestR / Path;
1699 std::vector< InductorInstanceData* >::iterator currentInductor =
instanceData.begin();
1700 std::vector< InductorInstanceData* >::iterator endInductor =
instanceData.end();
1701 while( currentInductor != endInductor )
1705 (*dFdxMatPtr)[((*currentInductor)->li_Pos)] [((*currentInductor)->APosEquBraVarOffset)] +=
scalingRHS;
1707 (*dFdxMatPtr)[((*currentInductor)->li_Neg)] [((*currentInductor)->ANegEquBraVarOffset)] += -
scalingRHS;
1709 (*dFdxMatPtr)[((*currentInductor)->li_Branch)][((*currentInductor)->ABraEquPosNodeOffset)] += -1.0/mid;
1711 (*dFdxMatPtr)[((*currentInductor)->li_Branch)][((*currentInductor)->ABraEquNegNodeOffset)] += 1.0/mid;
1716 <<
"(*currentInductor)->li_Pos = " << (*currentInductor)->li_Pos << std::endl
1717 <<
"(*currentInductor)->li_Neg = " << (*currentInductor)->li_Neg << std::endl
1718 <<
"(*currentInductor)->li_Branch = " << (*currentInductor)->li_Branch << std::endl
1719 <<
"(*currentInductor)->APosEquBraVarOffset = " << (*currentInductor)->APosEquBraVarOffset << std::endl
1720 <<
"(*currentInductor)->ANegEquBraVarOffset = " << (*currentInductor)->ANegEquBraVarOffset << std::endl
1721 <<
"(*currentInductor)->ABraEquPosNodeOffset = " << (*currentInductor)->ABraEquPosNodeOffset << std::endl
1722 <<
"(*currentInductor)->ABraEquNegNodeOffset = " << (*currentInductor)->ABraEquNegNodeOffset << std::endl
1723 <<
"(*dFdxMatPtr)["<<((*currentInductor)->li_Pos)<<
"] ["<<((*currentInductor)->APosEquBraVarOffset)<<
"] = " <<
scalingRHS << std::endl
1724 <<
"(*dFdxMatPtr)["<<((*currentInductor)->li_Neg)<<
"] ["<<((*currentInductor)->ANegEquBraVarOffset)<<
"] = " << -
scalingRHS << std::endl
1725 <<
"(*dFdxMatPtr)["<<((*currentInductor)->li_Branch)<<
"]["<<((*currentInductor)->ABraEquPosNodeOffset)<<
"] = " << -1/mid << std::endl
1726 <<
"(*dFdxMatPtr)["<<((*currentInductor)->li_Branch)<<
"]["<<((*currentInductor)->ABraEquNegNodeOffset)<<
"] = " << 1/mid << std::endl;
1729 double delV = solVector[(*currentInductor)->li_Pos] - solVector[(*currentInductor)->li_Neg];
1734 (*dFdxMatPtr)[((*currentInductor)->li_Branch)][(*currentInductor)->inductorCurrentOffsets[j]] +=
1735 delV * (1.0 - (Gap/Path)) *
dP_dI[j]/(mid*mid);
1737 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1739 Xyce::dout() <<
"(*dFdxMatPtr)[((*currentInductor)->li_Branch)][(*currentInductor)->inductorCurrentOffsets[j]] = " << delV * (1 - (Gap/Path)) *
dP_dI[j]/(mid*mid) << std::endl;
1744 (*dFdxMatPtr)[(*currentInductor)->li_Branch][(*currentInductor)->magOffset] += delV * (1.0 - (Gap/Path)) *
dP_dM/(mid*mid);
1746 (*dFdxMatPtr)[(*currentInductor)->li_Branch][(*currentInductor)->vPosOffset] += delV * (1.0 - (Gap/Path)) *
dP_dVp/(mid*mid);
1748 (*dFdxMatPtr)[(*currentInductor)->li_Branch][(*currentInductor)->vNegOffset] += delV * (1.0 - (Gap/Path)) *
dP_dVn/(mid*mid);
1776 bool bsuccess =
true;
1790 double latestR = rVarScaling * stoVector[
li_RVarStore ];
1791 (*outputFileStreamPtr)
1793 << latestMag <<
"\t "
1817 bool bsuccess =
true;
1834 varTypeVec[i] =
'I';
1838 varTypeVec[numInductors+1] =
'R';
1864 std::vector<Instance*>::iterator iter;
1868 for (iter=first; iter!=last; ++iter)
1870 (*iter)->processParams();
1888 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
1904 BCgsFactor( 10000.0 ),
1905 HCgsFactor( 0.012566370614359 ),
1906 UseConstantDeltaVScaling( false ),
1907 tnom(getDeviceOptions().tnom)
1964 std::vector<Instance*>::iterator iter;
1968 for (iter=first; iter!=last; ++iter)
1986 std::vector<Instance*>::const_iterator iter;
1994 os <<
"Number of MutIndNonLin instances: " << isize << std::endl;
1995 os <<
" name=\t\tmodelName\tParameters" << std::endl;
1996 for (i=0, iter=first; iter!=last; ++iter, ++i)
1998 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
2024 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
2039 bool bsuccess =
true;
2040 bool tmpBool =
true;
2044 tmpBool = (*it)->updatePrimaryState ();
2045 bsuccess = bsuccess && tmpBool;
2061 bool bsuccess =
true;
2062 bool tmpBool =
true;
2066 tmpBool = (*it)->updateSecondaryState ();
2067 bsuccess = bsuccess && tmpBool;
2081 bool Master::loadDAEVectors (
double * solVec,
double * fVec,
double *qVec,
double * bVec,
double * storeLeadF,
double * storeLeadQ,
double * leadF,
double * leadQ,
double * junctionV)
2083 bool bsuccess =
true;
2084 bool tmpBool =
true;
2088 tmpBool = (*it)->loadDAEFVector();
2089 bsuccess = bsuccess && tmpBool;
2090 tmpBool = (*it)->loadDAEQVector();
2091 bsuccess = bsuccess && tmpBool;
2107 bool bsuccess =
true;
2108 bool tmpBool =
true;
2112 tmpBool = (*it)->loadDAEdFdx ();
2113 bsuccess = bsuccess && tmpBool;
2114 tmpBool = (*it)->loadDAEdQdx ();
2115 bsuccess = bsuccess && tmpBool;
2130 .registerDevice(
"min", 1)
2131 .registerModelType(
"min", 1)
2132 .registerModelType(
"core", 1);
const InstanceName & getName() const
std::vector< std::string > inductorNames
std::vector< double > couplingCoefficient
void varTypes(std::vector< char > &varTypeVec)
bool updateDependentParameters()
const DeviceOptions & deviceOptions_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
void registerStoreLIDs(const std::vector< int > &staLIDVecRef)
double * daeQVectorRawPtr
void addStateNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
const std::string & getSubcircuitName() const
Decodes the device name.
double pdt_
Previous delta time alpha/dt (Many devices)
Linear::Vector * currSolVectorPtr
Linear::Vector * nextSolVectorPtr
std::vector< int > devConMap
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
bool given(const std::string ¶meter_name) const
Pure virtual class to augment a linear system.
Devices and models are each named.
std::vector< double > dMirrp_dI
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
std::vector< Instance * > instanceContainer
bool processParams()
processParams
std::vector< double > inductorInductances
void setNumStoreVars(int num_store_vars)
InstanceVector::const_iterator getInstanceEnd() const
Returns an iterator to the ending of the vector of all instances created for this device...
std::vector< std::vector< double > > LO
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
std::vector< double > LOI
std::vector< double > inductorCurrents
double tnom
nominal temperature for device params.
int getNumStoreVars() const
InstanceVector::const_iterator getInstanceBegin() const
Returns an iterator to the beginning of the vector of all instances created for this device...
Teuchos::RCP< std::ofstream > outputFileStreamPtr
std::vector< Param > params
Parameters from the line.
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
double * daeFVectorRawPtr
std::vector< std::string > inductorsNode2
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
const DeviceOptions & getDeviceOptions() const
std::vector< double > ddelM_dI
std::vector< double > dP_dI
bool outputPlotFiles(bool force_final_output)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Linear::Vector * nextStaVectorPtr
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Linear::Matrix * dFdxMatrixPtr
bool includeMEquationGiven
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
The Device class is an interface for device implementations.
void updateInductanceMatrix()
bool updateIntermediateVars()
std::vector< double > inductanceVals
bool processInstanceParams()
processInstanceParams
void addStoreNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
std::vector< std::string > inductorsNode1
const SolverState & solverState_
Class Configuration contains device configuration data.
bool updatePrimaryState()
std::vector< int > mEquInductorOffsets
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.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
const SolverState & getSolverState() const
std::vector< int > inductorCurrentOffsets
Linear::Vector * nextStoVectorPtr
bool UseConstantDeltaVScaling
bool updateTemperature(const double &temp_tmp)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Iiter, const FactoryBlock &factory_block)
virtual std::ostream & printOutInstances(std::ostream &os) const
std::string spiceInternalName(const InstanceName &instance_name, const std::string &lead)
std::vector< double > dManp_dI
virtual bool updateSecondaryState(double *staDeriv, double *stoVec)
Updates the devices secondary state information.
const ExternData & extData
ModelBlock represents a .MODEL line from the netlist.
std::vector< std::string > couplingInductor
std::vector< std::vector< int > > jacStamp
Manages parameter binding for class C.
std::vector< double > dHe_dI
InstanceBlock represent a device instance line from the netlist.
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
std::vector< Param > params
Linear::Matrix * dQdxMatrixPtr
const std::vector< std::vector< int > > & jacobianStamp() const
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
std::vector< InductorInstanceData * > instanceData
bool updateSecondaryState()
Linear::Vector * nextStaDerivVectorPtr
void setModParams(const std::vector< Param > ¶ms)
static void loadModelParameters(ParametricData< Model > &model_parameters)
std::vector< int > rEquInductorOffsets