47 #include <Xyce_config.h>
51 #include <N_UTL_Misc.h>
65 #include <N_ERH_ErrorMgr.h>
67 #include <N_LAS_Vector.h>
68 #include <N_LAS_Matrix.h>
69 #include <N_LAS_BlockVector.h>
70 #include <N_LAS_System.h>
72 #include <N_PDS_Comm.h>
73 #include <N_PDS_Manager.h>
92 timeStepForHistory2_(0.0)
95 sec.maxOrder_=(Xycemin(2,tiaParams.maxOrder));
96 sec.minOrder_=(Xycemax(1,tiaParams.minOrder));
98 if (sec.minOrder_ > sec.maxOrder_)
100 sec.minOrder_ = sec.maxOrder_;
134 #ifdef Xyce_DEBUG_TIME
135 Xyce::dout().width(21); Xyce::dout().precision(13); Xyce::dout().setf(std::ios::scientific);
139 Xyce::dout() << std::endl;
140 Xyce::dout() << Xyce::section_divider << std::endl;
142 " N_TIA_OneStep::obtainPredictor" << std::endl;
144 Xyce::dout() <<
"\n sec.nscsco_: " <<
sec.
nscsco_ << std::endl;
146 Xyce::dout() <<
"\n sec.beta_[" << i <<
"] = " <<
sec.
beta_[i] <<
"\n" << std::endl;
149 Xyce::dout() <<
"\n xHistory["<< i <<
"]: \n" << std::endl;
150 (
ds.
xHistory[i])->printPetraObject(Xyce::dout());
151 Xyce::dout() << std::endl;
155 Xyce::dout() <<
"\n qHistory["<< i <<
"]: \n" << std::endl;
156 (
ds.
qHistory[i])->printPetraObject(Xyce::dout());
157 Xyce::dout() << std::endl;
161 Xyce::dout() <<
"\n sHistory["<< i <<
"]: \n" << std::endl;
162 (
ds.
sHistory[i])->printPetraObject(Xyce::dout());
163 Xyce::dout() << std::endl;
167 Xyce::dout() <<
"\n stoHistory["<< i <<
"]: \n" << std::endl;
169 Xyce::dout() << std::endl;
173 Xyce::dout() <<
"\n stoLeadCurrQCompHistory["<< i <<
"]: \n" << std::endl;
175 Xyce::dout() << std::endl;
177 Xyce::dout() <<
"\n xn0: \n" << std::endl;
178 ds.
xn0Ptr->printPetraObject(Xyce::dout());
179 Xyce::dout() << std::endl;
180 Xyce::dout() <<
"\n qn0: \n" << std::endl;
181 ds.
qn0Ptr->printPetraObject(Xyce::dout());
182 Xyce::dout() << std::endl;
183 Xyce::dout() <<
"\n qpn0: \n" << std::endl;
184 ds.
qpn0Ptr->printPetraObject(Xyce::dout());
185 Xyce::dout() << std::endl;
186 Xyce::dout() <<
"\n sn0: \n" << std::endl;
187 ds.
sn0Ptr->printPetraObject(Xyce::dout());
188 Xyce::dout() << std::endl;
189 Xyce::dout() <<
"\n spn0: \n" << std::endl;
190 ds.
spn0Ptr->printPetraObject(Xyce::dout());
191 Xyce::dout() << std::endl;
192 Xyce::dout() <<
"\n stoQCn0Ptr: \n" << std::endl;
194 Xyce::dout() << std::endl;
195 Xyce::dout() <<
"\n stoQCpn0Ptr: \n" << std::endl;
197 Xyce::dout() << std::endl;
198 Xyce::dout() << Xyce::section_divider << std::endl;
200 #endif // Xyce_DEBUG_TIME
221 #ifdef Xyce_DEBUG_TIME
224 Xyce::dout() << std::endl;
225 Xyce::dout() << Xyce::section_divider << std::endl;
227 " N_TIA_OneStep::obtainResidual" << std::endl;
228 Xyce::dout() <<
"\n t = " <<
sec.
nextTime <<
"\n" << std::endl;
229 Xyce::dout() <<
"\n solution: \n" << std::endl;
231 Xyce::dout() <<
"\n daeQVector: \n" << std::endl;
233 Xyce::dout() <<
"\n qn0: \n" << std::endl;
234 ds.
qn0Ptr->printPetraObject(Xyce::dout());
235 Xyce::dout() <<
"\n qpn0: \n" << std::endl;
236 ds.
qpn0Ptr->printPetraObject(Xyce::dout());
238 Xyce::dout() <<
"\n daeFVector: \n" << std::endl;
241 Xyce::dout() <<
"\n dQdt-vector: \n" << std::endl;
243 Xyce::dout() << std::endl;
276 #ifdef Xyce_DEBUG_TIME
279 Xyce::dout() <<
"\n Residual-vector: \n" << std::endl;
280 Xyce::dout() <<
"-(qpn0-(sec.alpha_s/h)*(Q-qn0)+F-B) \n" << std::endl;
282 Xyce::dout() << Xyce::section_divider << std::endl;
283 Xyce::dout() << std::endl;
300 #ifdef Xyce_DEBUG_TIME
303 Xyce::dout() << std::endl;
304 Xyce::dout() << Xyce::section_divider << std::endl;
306 " N_TIA_OneStep::obtainJacobian" << std::endl;
325 Jac.linearCombo( qscalar, dQdx, fscalar, dFdx );
327 #ifdef Xyce_DEBUG_TIME
330 Xyce::dout() <<
"\n dFdx:" <<std::endl;
331 dFdx.printPetraObject(Xyce::dout());
332 Xyce::dout() <<
"\n Total Jacobian:" <<std::endl;
333 Jac.printPetraObject(Xyce::dout());
339 Xyce::dout() << Xyce::section_divider << std::endl;
340 Xyce::dout() << std::endl;
354 N_LAS_Vector * tmpSolVectorPtr, std::vector<N_LAS_Vector*> & historyVec)
360 *tmpSolVectorPtr = *(historyVec[0]);
362 if( -dtr < 100 * N_UTL_MachineDependentParams::MachinePrecision() )
372 tmpSolVectorPtr->linearCombo(1.0,*tmpSolVectorPtr,dtr,*(historyVec[1]));
380 tmpSolVectorPtr->linearCombo(1.0,*tmpSolVectorPtr,dtr_step,*(historyVec[1]));
382 tmpSolVectorPtr->linearCombo(1.0,*tmpSolVectorPtr,dtr_step,*(historyVec[2]));
405 N_LAS_Vector * tmpSolVectorPtr)
416 N_LAS_BlockVector * blockTempSolVectorPtr =
417 dynamic_cast<N_LAS_BlockVector*
>(tmpSolVectorPtr);
418 if (blockTempSolVectorPtr == NULL)
420 std::string msg =
"N_TIA_OneStep::interpolateMPDESolution: ";
421 msg +=
"N_LAS_Vector tmpSolVectorPtr is not of type N_LAS_BlockVector";
422 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
428 int numblocks = timepoint.size();
429 int blockCount = blockTempSolVectorPtr->blockCount();
430 if (numblocks > blockCount)
432 std::string msg =
"N_TIA_OneStep::interpolateMPDESolution: ";
433 msg +=
"Number of time points requested is greater than number of fast time points in MPDE block vector";
434 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
447 tfuzz = 100 * uround * (tn + hh);
448 tp = tn - hused - tfuzz;
449 for (
int i=0; i<numblocks ; ++i)
451 if ( (timepoint[i] - tp)*hh < 0.0 )
457 N_LAS_Vector * solVectorPtr;
458 N_LAS_Vector * xHistoryVectorPtr;
460 for (
int i=0; i < numblocks ; ++i)
462 if ((kused == 0) || (timepoint[i] == tn)) { kord = 1; }
463 else { kord = kused; }
464 solVectorPtr = &(blockTempSolVectorPtr->block(i));
466 delt = timepoint[i] - tn;
468 for (
int j=1 ; j <= kord ; ++j)
472 N_LAS_BlockVector * blockXHistoryVectorPtr =
473 dynamic_cast<N_LAS_BlockVector*>(
ds.
xHistory[j]);
474 if (blockXHistoryVectorPtr == NULL)
476 Xyce::Report::DevelFatal0().in(
"N_TIA_OneStep::interpolateMPDESolution") <<
"N_LAS_Vector ds.xHistory[j] is not of type N_LAS_BlockVector\n j = " << j;
479 xHistoryVectorPtr = &(blockXHistoryVectorPtr->block(i));
480 solVectorPtr->linearCombo(1.0,*solVectorPtr,c,*xHistoryVectorPtr);
495 RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
497 N_LAS_Vector * solnVecPtr,
498 const std::vector<double> & fastTimes )
500 #ifdef Xyce_DEBUG_TIME
503 Xyce::dout() << std::endl;
504 Xyce::dout() << Xyce::section_divider << std::endl;
506 " N_TIA_OneStep::printMPDEOutputSolution" << std::endl;
508 #endif // Xyce_DEBUG_TIME
513 double beg_of_output_time_interval = lasttime;
514 double end_of_output_time_interval = tn;
515 double start_time = max(lasttime,beg_of_output_time_interval);
516 double stop_time = min(tn,end_of_output_time_interval);
517 #ifdef Xyce_DEBUG_TIME
520 Xyce::dout() <<
"timestep = " << timestep << std::endl;
521 Xyce::dout() <<
"lasttime = " << lasttime << std::endl;
522 Xyce::dout() <<
"tn = " << tn << std::endl;
523 Xyce::dout() <<
"beg_of_output_time_interval = " << beg_of_output_time_interval << std::endl;
524 Xyce::dout() <<
"end_of_output_time_interval = " << end_of_output_time_interval << std::endl;
525 Xyce::dout() <<
"start_time = " << start_time << std::endl;
526 Xyce::dout() <<
"stop_time = " << stop_time << std::endl;
528 #endif // Xyce_DEBUG_TIME
531 N_LAS_BlockVector * blockTmpSolVectorPtr =
533 if (blockTmpSolVectorPtr == NULL)
535 std::string msg =
"N_TIA_OneStep::printMPDEOutputSolution: ";
536 msg +=
"N_LAS_Vector ds.tmpSolVectorPtr is not of type N_LAS_BlockVector";
537 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
540 int blockCount = blockTmpSolVectorPtr->blockCount();
543 double T2 = fastTimes.back();
545 double charcross = fmod(start_time,T2);
549 for (
int i=0 ; i<=blockCount ; ++i)
551 if (fastTimes[i] >= charcross)
559 std::string msg =
"N_TIA_OneStep::printMPDEOutputSolution: ";
560 msg +=
"Cannot find where characteristic curve crosses fast time slice at start_time";
561 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
564 std::vector<double> h2(blockCount,0);
565 for (
int j=0 ; j < blockCount ; ++j)
567 h2[j] = fastTimes[j+1] - fastTimes[j];
569 std::vector<double> ti;
571 double first_interp = start_time - charcross + fastTimes[s_ind_0];
572 #ifdef Xyce_DEBUG_TIME
575 Xyce::dout() <<
"first_interp = " << first_interp << std::endl;
577 #endif // Xyce_DEBUG_TIME
578 if (s_ind_0 == blockCount) { s_ind_0 = 0; };
580 double eps = fabs(start_time)*1.0e-6;
581 if ( fabs(first_interp-
timept_) <= eps )
583 first_interp += h2[s_ind_0];
585 if (s_ind_0 == blockCount) { s_ind_0 = 0; };
586 #ifdef Xyce_DEBUG_TIME
589 Xyce::dout() <<
"Moving first_interp forward to avoid duplicate outputs: " << first_interp << std::endl;
591 #endif // Xyce_DEBUG_TIME
594 double t = first_interp;
595 while (t <= stop_time)
600 if (sn >= blockCount) { sn = 0; }
602 #ifdef Xyce_DEBUG_TIME
605 Xyce::dout() <<
"T2 = " << T2 << std::endl;
606 Xyce::dout() <<
"charcross = " << charcross << std::endl;
607 Xyce::dout() <<
"s_ind_0 = " << s_ind_0 << std::endl;
608 Xyce::dout() <<
"Expecting to interpolate the following points:" << std::endl;
609 unsigned int numinterp = ti.size();
610 for (
unsigned int i=0 ; i < numinterp ; ++i)
612 Xyce::dout() << ti[i] << std::endl;
614 Xyce::dout() <<
"Total of " << numinterp <<
" points" << std::endl;
616 #endif // Xyce_DEBUG_TIME
618 unsigned int tinum = ti.size();
619 int total_interp = 0;
620 std::vector<double> timepoint_vec(blockCount,stop_time);
621 int num_interp_this_cycle = 0;
623 for (
unsigned int i=0; i < tinum ; ++i)
625 timepoint_vec[s_ind] = ti[i];
626 num_interp_this_cycle++;
628 if (s_ind >= blockCount) { s_ind = 0; };
630 if ((s_ind == s_ind_0) || (i == tinum-1))
635 for (
int j=0 ; j < num_interp_this_cycle ; ++j)
638 outputMgrAdapterRCPtr->tranOutput(
639 timept_, blockTmpSolVectorPtr->block(s),
645 if (s >= blockCount) { s = 0; }
646 #ifdef Xyce_DEBUG_TIME
647 Xyce::dout() <<
"Interpolated to t = " <<
timept_ << std::endl;
648 #endif // Xyce_DEBUG_TIME
650 num_interp_this_cycle = 0;
653 #ifdef Xyce_DEBUG_TIME
654 Xyce::dout() <<
"Total of " << total_interp <<
" points" << std::endl;
655 #endif // Xyce_DEBUG_TIME
658 eps = fabs(stop_time)*1.0e-8;
660 if (fabs(
timept_ - stop_time) >= eps)
662 #ifdef Xyce_DEBUG_TIME
665 Xyce::dout() <<
"Previous timept = " <<
timept_ << std::endl;
666 Xyce::dout() <<
"Expecting to interpolate the following point: " << stop_time << std::endl;
668 #endif // Xyce_DEBUG_TIME
669 N_LAS_Vector* tmpSolnVecPtr = solnVecPtr;
676 N_LAS_BlockVector * blockTmpSolnVecPtr =
677 dynamic_cast<N_LAS_BlockVector*
>(tmpSolnVecPtr);
678 N_LAS_BlockVector * blockTmpVecPtr =
679 dynamic_cast<N_LAS_BlockVector*
>(tmpVecPtr);
680 if (blockTmpSolnVecPtr == NULL)
682 std::string msg =
"N_TIA_OneStep::printMPDEOutputSolution: ";
683 msg +=
"N_LAS_Vector tmpSolnVecPtr is not of type N_LAS_BlockVector";
684 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
687 if (blockTmpVecPtr == NULL)
689 std::string msg =
"N_TIA_OneStep::printMPDEOutputSolution: ";
690 msg +=
"N_LAS_Vector tmpVecPtr is not of type N_LAS_BlockVector";
691 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
696 charcross = fmod(stop_time,T2);
699 if( charcross < fastTimes[0] )
702 s_ind_1 = blockCount-1;
706 for (
int i=blockCount-1 ; i>=0 ; --i)
708 if (fastTimes[i] <= charcross)
717 std::string msg =
"N_TIA_OneStep::printMPDEOutputSolution: ";
718 msg +=
"Cannot find where characteristic curve crosses fast time slice at stop_time";
719 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
724 double coeff_sm = fastTimes[sp]-charcross;
725 double coeff_sp = charcross-fastTimes[sm];
726 if (sp == blockCount) { sp = 0; }
727 double dt = h2[s_ind_1];
729 #ifdef Xyce_DEBUG_TIME
730 Xyce::dout() <<
"charcross = " << charcross << std::endl;
731 Xyce::dout() <<
"s_ind_1 = " << s_ind_1 << std::endl;
732 Xyce::dout() <<
"sp = " << sp << std::endl;
733 Xyce::dout() <<
"sm = " << sm << std::endl;
734 Xyce::dout() <<
"dt = " << dt << std::endl;
735 Xyce::dout() <<
"timept = " <<
timept_ << std::endl;
736 Xyce::dout() <<
"coeff_sm = " << coeff_sm << std::endl;
737 Xyce::dout() <<
"coeff_sp = " << coeff_sp << std::endl;
738 #endif // Xyce_DEBUG_TIME
739 blockTmpVecPtr->block(0).linearCombo(
740 coeff_sm/dt, blockTmpSolnVecPtr->block(sm),
741 coeff_sp/dt, blockTmpSolnVecPtr->block(sp)
743 outputMgrAdapterRCPtr->tranOutput(
timept_, blockTmpVecPtr->block(0),
747 #ifdef Xyce_DEBUG_TIME
748 Xyce::dout() <<
"Interpolated to t = " <<
timept_ << std::endl;
749 #endif // Xyce_DEBUG_TIME
751 #ifdef Xyce_DEBUG_TIME
756 Xyce::dout() <<
"No further interpolation required." << std::endl;
759 #endif // Xyce_DEBUG_TIME
761 #ifdef Xyce_DEBUG_TIME
762 Xyce::dout() << Xyce::section_divider << std::endl;
763 #endif // Xyce_DEBUG_TIME
777 RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
779 N_LAS_Vector * solnVecPtr,
780 const std::vector<double> & fastTimes,
783 #ifdef Xyce_DEBUG_TIME
786 Xyce::dout() << std::endl;
787 Xyce::dout() << Xyce::section_divider << std::endl;
789 " N_TIA_OneStep::printWaMPDEOutputSolution" << std::endl;
791 #endif // Xyce_DEBUG_TIME
796 double beg_of_output_time_interval = lasttime;
797 double end_of_output_time_interval = tn;
798 double start_time = max(lasttime,beg_of_output_time_interval);
799 double stop_time = min(tn,end_of_output_time_interval);
800 #ifdef Xyce_DEBUG_TIME
803 Xyce::dout() <<
"start_time = " << start_time << std::endl;
804 Xyce::dout() <<
"stop_time = " << stop_time << std::endl;
806 #endif // Xyce_DEBUG_TIME
830 N_LAS_BlockVector * blockTmpSolVectorPtr =
832 N_LAS_BlockVector * blockTmpXn0APtr =
834 N_LAS_BlockVector * blockTmpXn0BPtr =
836 if (blockTmpSolVectorPtr == NULL)
838 std::string msg =
"N_TIA_OneStep::printWaMPDEOutputSolution: ";
839 msg +=
"N_LAS_Vector ds.tmpSolVectorPtr is not of type N_LAS_BlockVector";
840 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
843 if (blockTmpXn0APtr == NULL)
845 std::string msg =
"N_TIA_OneStep::printWaMPDEOutputSolution: ";
846 msg +=
"N_LAS_Vector ds.tmpXn0APtr is not of type N_LAS_BlockVector";
847 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
850 if (blockTmpXn0BPtr == NULL)
852 std::string msg =
"N_TIA_OneStep::printWaMPDEOutputSolution: ";
853 msg +=
"N_LAS_Vector ds.tmpXn0BPtr is not of type N_LAS_BlockVector";
854 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
857 int phiLID = blockTmpSolVectorPtr->pmap()->globalToLocalIndex(phiGID);
861 #ifdef Xyce_DEBUG_TIME
864 Xyce::dout() <<
" sec.usedOrder_ = " <<
sec.
usedOrder_ << std::endl;
865 Xyce::dout() <<
" sec.currentTime_ = " <<
sec.
currentTime << std::endl;
866 Xyce::dout() <<
" lasttime = " << lasttime << std::endl;
868 #endif // Xyce_DEBUG_TIME
875 timeA = lasttime + hh*i;
879 std::string msg =
"interpolateSolution returned false!";
880 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0,msg);
889 timeB = lasttime + hh*(i+1);
891 #ifdef Xyce_DEBUG_TIME
894 Xyce::dout() <<
"Interpolating in [ " << timeA <<
", " << timeB <<
" ]" << std::endl;
895 Xyce::dout() <<
"timeA = " << timeA << std::endl;
896 Xyce::dout() <<
"timeB = " << timeB << std::endl;
898 #endif // Xyce_DEBUG_TIME
901 std::vector<double> t1vals;
902 double T2 = fastTimes.back();
903 int blockCount = blockTmpSolVectorPtr->blockCount();
904 double h2 = T2/blockCount;
905 double tval = timeA+h2;
906 while (tval <= timeB)
908 t1vals.push_back(tval);
912 double eps = fabs(timeB)*1.0e-8;
913 if ( (t1vals.size() == 0) || (fabs(t1vals.back() - timeB) >= eps) )
915 t1vals.push_back(timeB);
917 std::vector<double> t2vals, phiAB(2);
918 std::vector<double> tmpPhiAB(2, 0.0);
924 blockTmpSolVectorPtr->pmap()->pdsComm()->sumAll( &tmpPhiAB[0], &phiAB[0], 2 );
926 double phiA = phiAB[0], phiB = phiAB[1];
927 for (
unsigned int j=0 ; j<t1vals.size() ; ++j)
929 double phi = (1/(timeB-timeA))*(phiA*(timeB-t1vals[j])+phiB*(t1vals[j]-timeA));
930 t2vals.push_back(fmod(phi,T2));
932 #ifdef Xyce_DEBUG_TIME
935 Xyce::dout() <<
"t1vals = " << std::endl;
936 for (
unsigned int j=0 ; j < t1vals.size() ; ++j)
938 Xyce::dout() << t1vals[j] << std::endl;
940 Xyce::dout() <<
"phi(" << timeA <<
") = " << phiA << std::endl;
941 Xyce::dout() <<
"phi(" << timeB <<
") = " << phiB << std::endl;
942 Xyce::dout() <<
"t2vals = " << std::endl;
943 for (
unsigned int j=0 ; j< t2vals.size() ; ++j)
945 Xyce::dout() << t2vals[j] << std::endl;
948 #endif // Xyce_DEBUG_TIME
953 double t = t1vals[0];
954 double s = t2vals[0];
958 for (
int j=0 ; j < blockCount ; ++j)
960 if ((fastTimes[j] <= s) && (s < fastTimes[j+1]))
966 if (b2 == blockCount)
970 double s1 = fastTimes[b1];
971 double s2 = fastTimes[b1+1];
972 if ((s < s1) || (s > s2))
974 std::string msg =
"N_TIA_OneStep::printWaMPDEOutputSolution: ";
975 msg +=
" Interpolator cannot find a fast time block containing the first point ";
976 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
978 #ifdef Xyce_DEBUG_TIME
979 Xyce::dout() <<
"Found s = " << s <<
" in block " << b1;
980 Xyce::dout() <<
" with boundary = [" << s1 <<
"," << s2 <<
"]" << std::endl;
981 #endif // Xyce_DEBUG_TIME
982 for (
unsigned int j=0 ; j < t1vals.size() ; ++j)
988 if ( (s < s1) || (s > s2) )
990 #ifdef Xyce_DEBUG_TIME
991 Xyce::dout() <<
"Incrementing fast time block for next interpolation." << std::endl;
992 #endif // Xyce_DEBUG_TIME
994 if (b1 == blockCount)
999 if (b2 == blockCount)
1004 s2 = fastTimes[b1+1];
1007 if ((s < s1) || (s > s2))
1009 #ifdef Xyce_DEBUG_TIME
1010 Xyce::dout() <<
"Searching for fast time block for next interpolation." << std::endl;
1011 #endif // Xyce_DEBUG_TIME
1013 for (
int j2=0 ; j2 < blockCount ; ++j2)
1015 if ((fastTimes[j2] <= s) && (s < fastTimes[j2+1]))
1021 if (b2 == blockCount)
1026 s2 = fastTimes[b1+1];
1029 if ((s < s1) || (s > s2))
1031 std::string msg =
"N_TIA_OneStep::printWaMPDEOutputSolution: ";
1032 msg +=
" Interpolator moved fast time block but new point is not in this block ";
1033 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
1044 #ifdef Xyce_DEBUG_TIME
1047 Xyce::dout() <<
"Interpolating in the block:" << std::endl;
1048 Xyce::dout() <<
"(t1,t2) = (" << t1 <<
"," << t2 <<
")" << std::endl;
1049 Xyce::dout() <<
"(s1,s2) = (" << s1 <<
"," << s2 <<
")" << std::endl;
1051 #endif // Xyce_DEBUG_TIME
1052 double denom = (t2-t1)*(s2-s1);
1053 double coeff0 = (t2-t)*(s2-s)/denom;
1054 double coeff1 = (t2-t)*(s-s1)/denom;
1055 double coeff2 = (t-t1)*(s2-s)/denom;
1056 double coeff3 = (t-t1)*(s-s1)/denom;
1057 (blockTmpSolVectorPtr->block(b1)).linearCombo(
1058 coeff0, blockTmpXn0APtr->block(b1),
1059 coeff1, blockTmpXn0APtr->block(b2),
1060 coeff2, blockTmpXn0BPtr->block(b1) );
1061 (blockTmpSolVectorPtr->block(b1)).update(
1062 coeff3, blockTmpXn0BPtr->block(b2), 1.0 );
1067 outputMgrAdapterRCPtr->tranOutput(t, blockTmpSolVectorPtr->block(b1),
1071 #ifdef Xyce_DEBUG_TIME
1072 Xyce::dout() <<
"Interpolated to (t,phi(t)) = (" << t <<
"," << s <<
")" << std::endl;
1073 #endif // Xyce_DEBUG_TIME
1078 #ifdef Xyce_DEBUG_TIME
1079 Xyce::dout() << Xyce::section_divider << std::endl;
1080 #endif // Xyce_DEBUG_TIME
1094 RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
1096 N_LAS_Vector * solnVecPtr,
1097 const bool doNotInterpolate,
1098 const std::vector<double> &outputInterpolationTimes,
1099 bool skipPrintLineOutput)
1101 #ifdef Xyce_DEBUG_TIME
1104 Xyce::dout() << std::endl;
1105 Xyce::dout() << Xyce::section_divider << std::endl;
1107 " N_TIA_OneStep::printOutputSolution" << std::endl;
1108 Xyce::dout() <<
"usedOrder_ = " <<
sec.
usedOrder_ << std::endl;
1110 #endif // Xyce_DEBUG_TIME
1113 bool dointerp =
true;
1126 if (doNotInterpolate)
1131 if (dointerp && !outputInterpolationTimes.empty())
1133 for (
unsigned int i=0;i<outputInterpolationTimes.size();++i)
1138 outputMgrAdapterRCPtr->tranOutput(outputInterpolationTimes[i], *
ds.
tmpSolVectorPtr,
1148 if (outputInterpolationTimes.empty() || doNotInterpolate)
1154 skipPrintLineOutput);
1157 #ifdef Xyce_DEBUG_TIME
1158 Xyce::dout() << Xyce::section_divider << std::endl;
1159 #endif // Xyce_DEBUG_TIME
1173 RefCountPtr< N_ANP_OutputMgrAdapter > outputMgrAdapterRCPtr,
1174 N_LAS_Vector * solnVecPtr,
1175 const double saveTime,
1176 const bool doNotInterpolate)
1178 #ifdef Xyce_DEBUG_TIME
1181 Xyce::dout() << std::endl;
1182 Xyce::dout() << Xyce::section_divider << std::endl;
1184 " N_TIA_BackwardDifferentiation15::saveOutputSolution" << std::endl;
1186 #endif // Xyce_DEBUG_TIME
1190 bool dointerp =
true;
1195 #ifdef Xyce_DEBUG_TIME
1196 Xyce::dout() << Xyce::section_divider << std::endl;
1197 #endif // Xyce_DEBUG_TIME
1212 #ifdef Xyce_DEBUG_TIME
1215 Xyce::dout() << std::endl;
1216 Xyce::dout() << Xyce::section_divider << std::endl;
1218 " N_TIA_OneStep::updateHistory" << std::endl;
1219 Xyce::dout() <<
"\n Before updates \n" << std::endl;
1222 Xyce::dout() <<
"\n xHistory["<< i <<
"]: \n" << std::endl;
1223 (
ds.
xHistory[i])->printPetraObject(Xyce::dout());
1224 Xyce::dout() << std::endl;
1228 Xyce::dout() <<
"\n qHistory["<< i <<
"]: \n" << std::endl;
1229 (
ds.
qHistory[i])->printPetraObject(Xyce::dout());
1230 Xyce::dout() << std::endl;
1234 Xyce::dout() <<
"\n sHistory["<< i <<
"]: \n" << std::endl;
1235 (
ds.
sHistory[i])->printPetraObject(Xyce::dout());
1236 Xyce::dout() << std::endl;
1238 Xyce::dout() << Xyce::section_divider << std::endl;
1240 #endif // Xyce_DEBUG_TIME
1263 #ifdef Xyce_DEBUG_TIME
1266 Xyce::dout() <<
"\n After updates \n" << std::endl;
1267 Xyce::dout() <<
"\n newtonCorrectionPtr: " << std::endl;
1269 Xyce::dout() <<
"\n qnewtonCorrectionPtr: " << std::endl;
1273 Xyce::dout() <<
"\n xHistory["<< i <<
"]: \n" << std::endl;
1274 (
ds.
xHistory[i])->printPetraObject(Xyce::dout());
1275 Xyce::dout() << std::endl;
1279 Xyce::dout() <<
"\n qHistory["<< i <<
"]: \n" << std::endl;
1280 (
ds.
qHistory[i])->printPetraObject(Xyce::dout());
1281 Xyce::dout() << std::endl;
1283 Xyce::dout() <<
"\n sNewtonCorrectionPtr: " << std::endl;
1285 Xyce::dout() << std::endl;
1286 Xyce::dout() <<
"\n nextStatePtr: " << std::endl;
1288 Xyce::dout() << std::endl;
1291 Xyce::dout() <<
"\n sHistory["<< i <<
"]: \n" << std::endl;
1292 (
ds.
sHistory[i])->printPetraObject(Xyce::dout());
1293 Xyce::dout() << std::endl;
1295 Xyce::dout() << Xyce::section_divider << std::endl;
1297 #endif // Xyce_DEBUG_TIME
1315 #ifdef Xyce_DEBUG_TIME
1318 Xyce::dout() << std::endl;
1319 Xyce::dout() << Xyce::section_divider << std::endl;
1321 " N_TIA_OneStep::restoreHistory" << std::endl;
1323 Xyce::dout() <<
"\n sec.psi_[i] = " <<
sec.
psi_[i] << std::endl;
1326 Xyce::dout() <<
"\n xHistory["<< i <<
"]: \n" << std::endl;
1327 (
ds.
xHistory[i])->printPetraObject(Xyce::dout());
1328 Xyce::dout() << std::endl;
1332 Xyce::dout() <<
"\n qHistory["<< i <<
"]: \n" << std::endl;
1333 (
ds.
qHistory[i])->printPetraObject(Xyce::dout());
1334 Xyce::dout() << std::endl;
1338 Xyce::dout() <<
"\n sHistory["<< i <<
"]: \n" << std::endl;
1339 (
ds.
sHistory[i])->printPetraObject(Xyce::dout());
1340 Xyce::dout() << std::endl;
1342 Xyce::dout() << Xyce::section_divider << std::endl;
1344 #endif // Xyce_DEBUG_TIME
1359 #ifdef Xyce_DEBUG_TIME
1362 Xyce::dout() << std::endl;
1363 Xyce::dout() << Xyce::section_divider << std::endl;
1366 " N_TIA_OneStep::updateCoeffs" << std::endl;
1376 " psi_[0] = " <<
sec.
psi_[0] << std::endl;
1398 sec.
beta_[1] = temp1/temp2 + (temp1/temp2)*(temp1/temp2)/2;
1408 #ifdef Xyce_DEBUG_TIME
1414 " beta_[0] = " <<
sec.
beta_[0] << std::endl;
1416 " beta_[1] = " <<
sec.
beta_[1] << std::endl;
1418 " beta_[2] = " <<
sec.
beta_[2] << std::endl;
1420 " beta_[3] = " <<
sec.
beta_[3] << std::endl;
1422 " beta_[4] = " <<
sec.
beta_[4] << std::endl;
1424 " alpha_[0] = " <<
sec.
alpha_[0] << std::endl;
1426 " alpha_[1] = " <<
sec.
alpha_[1] << std::endl;
1428 " alpha_[2] = " <<
sec.
alpha_[2] << std::endl;
1430 " alpha_[3] = " <<
sec.
alpha_[3] << std::endl;
1432 " alpha_[4] = " <<
sec.
alpha_[4] << std::endl;
1438 " gamma_[0] = " <<
sec.
gamma_[0] << std::endl;
1440 " gamma_[1] = " <<
sec.
gamma_[1] << std::endl;
1442 " gamma_[2] = " <<
sec.
gamma_[2] << std::endl;
1444 " gamma_[3] = " <<
sec.
gamma_[3] << std::endl;
1446 " gamma_[4] = " <<
sec.
gamma_[4] << std::endl;
1448 " psi_[0] = " <<
sec.
psi_[0] << std::endl;
1450 " psi_[1] = " <<
sec.
psi_[1] << std::endl;
1452 " psi_[2] = " <<
sec.
psi_[2] << std::endl;
1454 " psi_[3] = " <<
sec.
psi_[3] << std::endl;
1456 " psi_[4] = " <<
sec.
psi_[4] << std::endl;
1458 " sigma_[0] = " <<
sec.
sigma_[0] << std::endl;
1460 " sigma_[1] = " <<
sec.
sigma_[1] << std::endl;
1462 " sigma_[2] = " <<
sec.
sigma_[2] << std::endl;
1464 " sigma_[3] = " <<
sec.
sigma_[3] << std::endl;
1466 " sigma_[4] = " <<
sec.
sigma_[4] << std::endl;
1468 " ck_ = " <<
sec.
ck_ << std::endl;
1469 Xyce::dout() << Xyce::section_divider << std::endl;
1471 #endif // Xyce_DEBUG_TIME
1498 double currentTimeStep;
1504 currentTimeStep = 0.1 * time_to_stop;
1512 #ifdef Xyce_INCOMPLETE_2LEVEL_NORMS
1513 double dnorm_q = 0.0;
1537 if (rh>1.0) currentTimeStep = currentTimeStep/rh;
1562 #ifdef Xyce_VERBOSE_TIME
1565 Xyce::dout() <<
"ERROROPTION=1: DeltaT Grow = 2" <<
"\n" << std::endl;
1566 Xyce::dout() <<
"ERROROPTION=1: DeltaT Cut = 0.125" <<
"\n" << std::endl;
1567 Xyce::dout() <<
"ERROROPTION=1: NL MIN = " <<
tiaParams.
NLmin <<
"\n" << std::endl;
1568 Xyce::dout() <<
"ERROROPTION=1: NL MAX = " <<
tiaParams.
NLmax <<
"\n" << std::endl;
1569 Xyce::dout() <<
"ERROROPTION=1: DELMAX = " <<
sec.
maxTimeStep <<
"\n" << std::endl;
1571 #endif //Xyce_VERBOSE_TIME
1605 #ifdef Xyce_DEBUG_TIME
1608 Xyce::dout() << std::endl;
1609 Xyce::dout() << Xyce::section_divider << std::endl;
1611 " N_TIA_OneStep::initialize" << std::endl;
1612 Xyce::dout() <<
"\n xHistory: \n" << std::endl;
1613 (
ds.
xHistory[0])->printPetraObject(Xyce::dout());
1614 Xyce::dout() << std::endl;
1615 (
ds.
xHistory[1])->printPetraObject(Xyce::dout());
1616 Xyce::dout() << std::endl;
1617 Xyce::dout() <<
"\n qHistory: \n" << std::endl;
1618 (
ds.
qHistory[0])->printPetraObject(Xyce::dout());
1619 Xyce::dout() << std::endl;
1620 (
ds.
qHistory[1])->printPetraObject(Xyce::dout());
1621 Xyce::dout() << std::endl;
1622 Xyce::dout() <<
"\n sHistory: \n" << std::endl;
1623 (
ds.
sHistory[0])->printPetraObject(Xyce::dout());
1624 Xyce::dout() << std::endl;
1625 (
ds.
sHistory[1])->printPetraObject(Xyce::dout());
1626 Xyce::dout() << std::endl;
1627 Xyce::dout() <<
"\n" <<
"currentTimeStep = " << currentTimeStep <<
"\n" << std::endl;
1628 Xyce::dout() <<
"\n" <<
"time_to_stop = " << time_to_stop <<
"\n" << std::endl;
1629 Xyce::dout() << Xyce::section_divider << std::endl;
1631 #endif // Xyce_DEBUG_TIME
1646 double time_to_stop = sec.stopTime - sec.currentTime;
1650 *(ds.xHistory[0]) = *(ds.currSolutionPtr);
1651 (ds.xHistory[1])->putScalar(0.0);
1654 *(ds.qHistory[0]) = *(ds.daeQVectorPtr);
1655 *(ds.qHistory[1]) = *(ds.daeFVectorPtr);
1656 (ds.qHistory[1])->scale(-sec.currentTimeStep);
1659 *(ds.sHistory[0]) = *(ds.nextStatePtr);
1660 (ds.sHistory[1])->putScalar(0.0);
1665 sec.numberOfSteps_ = 0;
1667 sec.psi_[0] = sec.currentTimeStep;
1668 sec.cj_ = 1/sec.psi_[0];
1712 #ifdef Xyce_DEBUG_TIME
1716 Xyce::dout() << std::endl;
1717 Xyce::dout() << Xyce::section_divider << std::endl;
1720 " N_TIA_OneStep::rejectStep" << std::endl;
1749 std::string msg =
"N_TIA_OneStep::rejectStep: ";
1750 msg +=
" Maximum number of local error test failures. ";
1751 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
1774 #ifndef Xyce_USE_Q_NORM
1798 #ifdef Xyce_DEBUG_TIME
1810 " alpha_[0] = " <<
sec.
alpha_[0] << std::endl;
1812 " alpha_[1] = " <<
sec.
alpha_[1] << std::endl;
1814 " alpha_[2] = " <<
sec.
alpha_[2] << std::endl;
1816 " alpha_[3] = " <<
sec.
alpha_[3] << std::endl;
1818 " alpha_[4] = " <<
sec.
alpha_[4] << std::endl;
1820 " psi_[0] = " <<
sec.
psi_[0] << std::endl;
1822 " psi_[1] = " <<
sec.
psi_[1] << std::endl;
1824 " psi_[2] = " <<
sec.
psi_[2] << std::endl;
1826 " psi_[3] = " <<
sec.
psi_[3] << std::endl;
1828 " psi_[4] = " <<
sec.
psi_[4] << std::endl;
1830 " sigma_[0] = " <<
sec.
sigma_[0] << std::endl;
1832 " sigma_[1] = " <<
sec.
sigma_[1] << std::endl;
1834 " sigma_[2] = " <<
sec.
sigma_[2] << std::endl;
1836 " sigma_[3] = " <<
sec.
sigma_[3] << std::endl;
1838 " sigma_[4] = " <<
sec.
sigma_[4] << std::endl;
1840 " rr = " << rr << std::endl;
1846 " Est_ = " <<
sec.
Est_ << std::endl;
1848 " nef_ = " <<
sec.
nef_ << std::endl;
1857 " newTimeStep_ = " << newTimeStep_ << std::endl;
1859 #endif // Xyce_DEBUG_TIME
1864 std::string tmp =
" OneStep:rejectStep: Warning: Local error test failed with constant step-size.\n";
1865 Xyce::dout() << tmp << std::endl;
1888 #ifdef Xyce_DEBUG_TIME
1892 " newTimeStep_ = " << newTimeStep_ << std::endl;
1896 #endif // Xyce_DEBUG_TIME
1915 #ifdef Xyce_DEBUG_TIME
1918 Xyce::dout() << Xyce::section_divider << std::endl;
1920 #endif // Xyce_DEBUG_TIME
1956 #ifdef Xyce_DEBUG_TIME
1960 Xyce::dout() << std::endl;
1961 Xyce::dout() << Xyce::section_divider << std::endl;
1964 " N_TIA_OneStep::completeStep" << std::endl;
1990 #ifdef Xyce_DEBUG_TIME
1996 " rr = " << rr << std::endl;
2004 " newTimeStep_ = " << newTimeStep_ << std::endl;
2066 #ifdef Xyce_DEBUG_TIME
2080 " Est = " <<
sec.
Est_ << std::endl;
2082 " raw rr = " << rr << std::endl;
2136 #ifdef Xyce_DEBUG_TIME
2142 " newTimeStep_ = " << newTimeStep_ << std::endl;
2167 #ifdef Xyce_DEBUG_TIME
2170 Xyce::dout() << Xyce::section_divider << std::endl;
2205 #ifdef Xyce_DEBUG_TIME
2208 Xyce::dout() <<
"\n next state Ptr: \n" << std::endl;
2210 Xyce::dout() << std::endl;
2212 Xyce::dout() <<
"\n sn0: \n" << std::endl;
2213 ds.
sn0Ptr->printPetraObject(Xyce::dout());
2214 Xyce::dout() << std::endl;
2216 Xyce::dout() <<
"\n next State Deriv: \n" << std::endl;
2218 Xyce::dout() << std::endl;
2247 #ifdef Xyce_DEBUG_TIME
2250 Xyce::dout() <<
"\n next store Ptr: \n" << std::endl;
2252 Xyce::dout() << std::endl;
2289 #ifdef Xyce_DEBUG_TIME
2290 Xyce::dout() << tle;