16 : QObject( parent ), system( model ), simparams( params )
32 double current_time = 0.0;
33 double current_om2t = 0.0;
35 double duration = 0.0;
38 int initial_npts = 1000;
39 int current_assoc = 0;
41 QVector< bool > reactVec( size_cv );
42 bool* reacting = reactVec.data();
47 #define TIMING_RA_INC 500
51 QDateTime calcStart = QDateTime::currentDateTime();
78 initial_npts = ( initial_npts < npts ) ? initial_npts : npts;
88 DbgLv(2) <<
"RSA: scan0size" << npts;
89 DbgLv(2) <<
"RSA: af_c0size" << initial_npts;
96 DbgLv(2) <<
"RSA: RG size" << nrg;
97 for(
int jr=0;jr<nrg;jr++)
99 int na=
rg[jr].association.size();
100 int ng=
rg[jr].GroupComponent.size();
101 DbgLv(2) <<
"RSA: RG" << jr <<
": na" << na <<
"ng" << ng;
102 for(
int ja=0;ja<na;ja++)
103 DbgLv(2) <<
"RSA: Assoc" << ja <<
":" <<
rg[jr].association[ja];
104 for(
int jg=0;jg<ng;jg++)
105 DbgLv(2) <<
"RSA: GrpComp" << jg <<
":" <<
rg[jr].GroupComponent[jg];
115 for (
int cc = 0; cc < size_cv; cc++ )
118 QDateTime clcSt1 = QDateTime::currentDateTime();
122 reacting[ cc ] =
false;
128 DbgLv(2) <<
"RSA: aa react.size" << aa << as->
rcomps.size();
130 for (
int jj = 0; jj < as->
rcomps.size(); jj++ )
132 if ( cc == (
int)as->
rcomps[ jj ] )
134 reacting[ cc ] =
true;
139 DbgLv(2) <<
"RSA: cc aa current_assoc" << cc << aa << current_assoc;
150 CT0.
radius .reserve( initial_npts );
154 ( initial_npts - 1 );
156 for (
int jj = 0; jj < initial_npts; jj++ )
196 if ( ! reacting[ cc ] )
201 DbgLv(2) <<
"RSA: s0 i_conc cc step lsc" << cc << 0 << 0 <<
": c0 cm cn"
213 totT1+=(clcSt1.msecsTo(QDateTime::currentDateTime()));
228 for (
int step = 0; step < nstep; step++ )
231 QDateTime clcSt2 = QDateTime::currentDateTime();
241 DbgLv(2) <<
"RSA:PO: STEP NSTEP" << step << nstep
242 <<
"ETIMEF ETIMEL" << ed->
scan[fscan].time << ed->
scan[lscan].time
259 DbgLv(2) <<
"RSA:PO: FSCAN TIME1" << fscan << time1 <<
"cc step" << cc << step
269 qAbs( step_speed - current_speed ) / sp->
acceleration );
276 DbgLv(2) <<
"RSA: AP during ACCELERATION";
286 DbgLv(2) <<
"RSA: scan0size" << npts;
287 DbgLv(2) <<
"RSA: af_c0size" << initial_npts;
289 delay = time1 - time0;
315 double drtm = delay - accel_time;
317 DbgLv(2) <<
"RSA:PO: time0 time1 omeg0 omeg1"
318 << time0 << time1 << omeg0 << omeg1 <<
"delay atime" << delay << accel_time;
321 double ddw1 = wfac *
sq( current_speed );
322 double ddw3 = wfac *
sq( step_speed );
323 int ndt2 = qRound( dt2 );
327 for (
int kk = 0; kk < ndt2; kk++ )
330 dw2 += ( wfac *
sq( crpm ) );
336 if ( current_speed == 0.0 )
338 double dt3 = ( omeg1 - dw2 ) / ddw3;
339 dt1 = (double)qFloor( time1 - dt3 - accel_time );
340 dt1 = ( dt1 < 0.0 ) ? 1.0 : dt1;
341 dw1 = wfac *
sq( rpmi );
346 dt1 = (double)qFloor(
347 ( omeg1 - omeg0 - dw2 - drtm * ddw3 )
351 DbgLv(2) <<
"RSA:PO: ddw1 ddw3" << ddw1 << ddw3 <<
"dt2 dw2" << dt2 << dw2
352 <<
"dt1 dw1" << dt1 << dw1;
356 int nradi = simdata.
radius.size();
357 DbgLv(2) <<
"RSA:PO: st_ time om2t"
361 DbgLv(2) <<
"RSA: S:cc step" << cc << step <<
": c0 cm cn"
368 if ( step > 0 && dt1 > 2.0 )
382 CT0, simdata,
false );
387 DbgLv(2) <<
"RSA:PO: Accel nradi" << nradi <<
"CT0size" << CT0.
radius.size();
396 CT0, simdata,
true );
398 qApp->processEvents();
407 qApp->processEvents();
414 current_time = time1;
415 current_om2t = omeg1;
418 QDateTime clcSt3 = QDateTime::currentDateTime();
419 totT2+=(clcSt2.msecsTo(clcSt3));
422 duration = time2 - current_time;
425 duration += (
double)( (int)( duration * 0.05 ) );
427 if ( accel_time > duration )
429 DbgErr() <<
"Attention: acceleration time exceeds duration - "
430 "please check initialization\n";
434 double omega = step_speed * M_PI / 30.0;
437 << omega << step_speed;
439 double lg_bm_rat = log(
452 DbgLv(1) <<
"RSA: ***CORRECTED dt: lg_bm_rat" << lg_bm_rat <<
"sc->s" << sc->
s
460 << duration <<
"** simpts set to 10000 **";
477 <<
"dt" <<
af_params.
dt <<
"rat fac" << lg_bm_rat << s_omg_fac;
479 QDateTime clcSt4 = QDateTime::currentDateTime();
480 totT3+=(clcSt3.msecsTo(clcSt4));
485 DbgLv(2) <<
"RSA: B:cc step" << cc << step <<
": c0 cm cn"
488 int nr1=ed->
radius.size();
489 DbgLv(2) <<
"RSA:(1) nr1" << nr1 <<
"r sme"
497 CT0, simdata,
false );
499 qApp->processEvents();
505 current_time = time2;
506 current_om2t = omeg2;
509 <<
"fscan lscan" << fscan << lscan <<
"dt" <<
af_params.
dt;
510 int mmm=simdata.
scan.size()-1;
512 DbgLv(2) <<
"RSA:T eomg1 eomg2" << ed->
scan[fscan].omega_s_t
513 << ed->
scan[lscan].omega_s_t <<
" somg1 somg2"
514 << simdata.
scan[0].omega_s_t << simdata.
scan[mmm].omega_s_t;
515 DbgLv(2) <<
"RSA:T etim1 etim2" << ed->
scan[fscan].time
516 << ed->
scan[lscan].time <<
" stim1 stim2"
517 << simdata.
scan[0].time << simdata.
scan[mmm].time << simdata.
scan[kkk].time
520 QDateTime clcSt5 = QDateTime::currentDateTime();
521 totT4+=(clcSt4.msecsTo(clcSt5));
527 int nr2=ed->
radius.size();
528 DbgLv(2) <<
"RSA:(2) nr2" << nr2 <<
"r sme"
537 DbgLv(2) <<
"RSA:T INTERP in step" << step;
539 int nr3=ed->
radius.size();
540 DbgLv(2) <<
"RSA:(3) nr3" << nr3 <<
"r sme"
548 simdata.
scan .clear();
553 current_speed = step_speed;
556 qApp->processEvents();
559 totT5+=(clcSt5.msecsTo(QDateTime::currentDateTime()));
566 DbgLv(2) <<
"RSA: E:cc step" << cc << step <<
": c0 cm cn"
574 qApp->processEvents();
579 QDateTime clcSt6 = QDateTime::currentDateTime();
587 for (
int group = 0; group <
rg.size(); group++ )
589 int num_comp =
rg[ group ].GroupComponent.size();
590 int num_rule =
rg[ group ].association.size();
592 DbgLv(2) <<
"RSA: group nrule ncomp" << group << num_rule << num_comp;
599 for (
int m = 0; m < num_rule; m++ )
605 for (
int jj = 0; jj < num_comp; jj++ )
607 int index =
rg[ group ].GroupComponent[ jj ];
608 DbgLv(2) <<
"RSA: jj index" << jj << index;
627 for (
int aa = 0; aa <
rg[ group ].association.size(); aa++ )
630 int rule =
rg[ group ].association[ aa ];
631 DbgLv(2) <<
"RSA: aa rule" << aa << rule;
634 for (
int rr = 0; rr < as->
rcomps.size(); rr++ )
636 DbgLv(2) <<
"RSA: rr af-index as-react" << rr
650 for (
int aa = 0; aa < num_rule; aa++ )
653 for (
int rr = 0; rr < as->
rcomps.size(); rr++ )
657 DbgLv(2) <<
"RSA: aa rr rcn" << aa << rr << as->
rcomps[rr];
671 ( initial_npts - 1 );
673 QVector< US_AstfemMath::MfemInitial > vC0Vec( num_comp );
676 for (
int jj = 0; jj < num_comp; jj++ )
680 CT0.
radius .reserve( initial_npts );
682 DbgLv(2) <<
"RSA: jj in_npts" << jj << initial_npts;
684 for (
int ii = 0; ii < initial_npts; ii++ )
695 DbgLv(2) <<
"RSA: decompose OUT";
697 QDateTime clcSt5 = QDateTime::currentDateTime();
709 int nr4=ed->
radius.size();
710 DbgLv(2) <<
"RSA:(4) nr4" << nr4 <<
"r sme"
715 for (
int step = 0; step < nstep; step++ )
742 ( qAbs( step_speed - current_speed ) / sp->
acceleration );
750 duration = time2 - time0;
751 current_time = time0;
755 vC0, simdata,
true );
756 int nr5=ed->
radius.size();
757 DbgLv(2) <<
"RSA:(5) nr5" << nr4 <<
"r sme"
764 current_time += accel_time;
768 qApp->processEvents();
771 qApp->processEvents();
775 duration = time2 - time0;
776 delay = time1 - time0;
781 duration += (
double)( (int)( duration * 0.05 ) );
783 if ( accel_time > duration )
785 DbgErr() <<
"Attention: acceleration time exceeds duration - "
786 "please check initialization\n";
791 duration -= accel_time;
795 for (
int mm = 1; mm <
af_params.
s.size(); mm++ )
796 s_max = qMax( s_max, qAbs(
af_params.
s[ mm ] ) );
800 << step_speed <<
"s.size s_max" <<
af_params.
s.size() << s_max;
821 << duration <<
"** simpts set to 10000 **";
832 int nr1=ed->
radius.size();
833 DbgLv(2) <<
"RSA:(1) nr1" << nr1 <<
"r sme"
839 calculate_ra2( step_speed, step_speed, vC0, simdata,
false );
846 current_time = time1;
849 DbgLv(2) <<
"RSA: current_time" << current_time <<
"fscan lscan"
850 << fscan << lscan <<
"speed" << step_speed;
855 int nr2=ed->
radius.size();
856 DbgLv(2) <<
"RSA:(2) nr2" << nr2 <<
"r sme"
867 int nr3=ed->
radius.size();
868 DbgLv(2) <<
"RSA:(3) nr3" << nr3 <<
"r sme"
876 simdata.
scan .clear();
881 current_speed = step_speed;
884 qApp->processEvents();
889 totT5+=(clcSt5.msecsTo(QDateTime::currentDateTime()));
892 DbgLv(2) <<
"RSA: Speed step OUT";
894 QDateTime clcSt7 = QDateTime::currentDateTime();
895 totT6+=(clcSt6.msecsTo(clcSt7));
900 qApp->processEvents();
904 int nr7=ed->
radius.size();
905 DbgLv(2) <<
"RSA:(7) nr7" << nr7 <<
"r sme"
912 double correction = 0.0;
915 for (
int step = 0; step < nstep; step++ )
920 int nscans = ed->
scan.size();
921 DbgLv(2) <<
"RSA: TimeCorr step" << step <<
"nscans" << nscans;
926 int lscan = nscans - 1;
927 DbgLv(2) <<
"RSA: TimeCorr nscans fscan lscan" << nscans << fscan << lscan;
929 <<
"etimef etimel" << ed->
scan[ fscan ].time << ed->
scan[ lscan ].time;
948 QVector< double > xtmpVec( nscans );
949 QVector< double > ytmpVec( nscans );
950 double* xtmp = xtmpVec.data();
951 double* ytmp = ytmpVec.data();
954 for (
int ii = 0; ii < nscans; ii++ )
956 xtmp[ ii ] = ed->
scan[ ii ].time;
957 ytmp[ ii ] = ed->
scan[ ii ].omega_s_t;
961 &correlation, nscans );
963 correction = -intercept / slope;
965 DbgLv(2) <<
"RSA: TimeCorr correction" << correction <<
"nscans" << nscans;
967 for (
int ii = 0; ii < nscans; ii++ )
968 ed->
scan[ ii ].time -= correction;
974 if ( correction > 0.0 )
978 DbgLv(2) <<
"RSA: Time Corr OUT";
980 QDateTime clcSt8 = QDateTime::currentDateTime();
981 totT7+=(clcSt7.msecsTo(clcSt8));
983 int nr9=ed->
radius.size();
984 DbgLv(2) <<
"RSA:(9) nr9" << nr9 <<
"r sme"
995 QDateTime clcSt9 = QDateTime::currentDateTime();
996 totT8+=(clcSt8.msecsTo(clcSt9));
997 int elapsedCalc = calcStart.msecsTo( clcSt9 );
1000 if((ncalls%TIMING_RA_INC)<1) {
1001 DbgLv(0) <<
" Elapsed fem-calc ms" << elapsedCalc <<
"nc totC" << ncalls << totTC <<
" size_cv" << size_cv;
1002 DbgLv(0) <<
" t1 t2 t3 t4 t5 t6 t7 t8"
1003 << totT1 << totT2 << totT3 << totT4 << totT5 << totT6 << totT7 << totT8;
1006 DbgLv(2) <<
"ASTFEM CALC DONE";
1016 int ncomp = as->
rcomps.size();
1017 int stoich1 = as->
stoichs[ 0 ];
1018 int stoich2 = as->
stoichs[ 1 ];
1019 DbgLv(2) <<
"AFRSA: ncomp st1 st2" << ncomp << stoich1 << stoich2;
1023 as->
stoichs[ 1 ] = stoich2 < 0 ? stoich2 : -stoich2;
1024 as->
stoichs[ 0 ] = stoich1 > 0 ? stoich1 : -stoich1;
1029 else if ( ncomp == 3 )
1031 int stoich3 = as->
stoichs[ 2 ];
1032 as->
stoichs[ 0 ] = stoich1 > 0 ? stoich1 : -stoich1;
1033 as->
stoichs[ 1 ] = stoich2 > 0 ? stoich2 : -stoich2;
1034 as->
stoichs[ 2 ] = stoich3 < 0 ? stoich3 : -stoich3;
1066 double speed = (double)rpm;
1067 return ( rotorcoeffs[ 0 ] * speed
1068 + rotorcoeffs[ 1 ] *
sq( speed ) );
1078 QVector< bool > reaction_used;
1079 reaction_used.clear();
1082 reaction_used.append(
false );
1098 if ( as->
rcomps.size() > 2 )
1101 reaction_used[ 0 ] =
true;
1106 rg .append( tmp_rg );
1125 ncomp = av->
rcomps.size();
1126 component1 = ( ncomp > 0 ) ? av->
rcomps[ 0 ] : -1;
1127 component2 = ( ncomp > 1 ) ? av->
rcomps[ 1 ] : -1;
1128 component3 = ( ncomp > 2 ) ? av->
rcomps[ 2 ] : -1;
1130 while ( reaction_used[ counter ] )
1162 reaction_used[ counter ] =
true;
1214 rg .append( tmp_rg );
1222 while ( reaction_used[ j ] )
1225 if ( j >= reaction_used.size() )
return;
1229 ncomp = avj->
rcomps.size();
1230 component1 = ( ncomp > 0 ) ? avj->
rcomps[ 0 ] : 0;
1231 component2 = ( ncomp > 1 ) ? avj->
rcomps[ 1 ] : 0;
1232 component3 = ( ncomp > 2 ) ? avj->
rcomps[ 2 ] : 0;
1244 reaction_used[ j ] =
true;
1250 rg .append( tmp_rg );
1259 bool noninteracting )
1261 DbgLv(2) <<
"RSA: init_conc() ENTER kk" << kk
1279 DbgLv(2) <<
"RSA: angle pathlen" << angl << plen;
1288 for (
int j = 0; j < nval; j++ )
1303 for (
int j = 0; j < nval; j++ )
1309 DbgLv(2) <<
"RSA: kk jmxc" << kk << jmxc <<
"max_conc" << mxct
1315 if ( noninteracting )
1323 CT0.
radius .reserve( nval );
1327 for (
int jj = 0; jj < nval; jj++ )
1341 C.
radius .reserve( nval );
1345 / (
double)( nval - 1 );
1348 for (
int j = 0; j < nval; j++ )
1357 for (
int j = 0; j < nval; j++ )
1371 static int Nsave = 0;
1372 static int Nsavea = 0;
1373 static double** CA = NULL;
1376 static double** CB = NULL;
1379 static double** CA1;
1380 static double** CA2;
1381 static double** CB1;
1382 static double** CB2;
1405 static int nccall=0;
1415 QDateTime clcSt0 = QDateTime::currentDateTime();
1416 QDateTime clcSt1 = clcSt0;
1417 QDateTime clcSt2 = clcSt0;
1418 QDateTime clcSt3 = clcSt0;
1419 QDateTime clcSt4 = clcSt0;
1420 QDateTime clcSt5 = clcSt0;
1421 QDateTime clcSt6 = clcSt0;
1422 QDateTime clcSt7 = clcSt0;
1423 QDateTime clcSt8 = clcSt0;
1424 QDateTime clcSt9 = clcSt0;
1428 simdata.
scan .clear();
1438 double sw2 =
af_params.
s[ 0 ] *
sq( rpm_stop * M_PI / 30 );
1439 QVector< double > nu;
1444 DbgLv(2) <<
"RSA: mesh_gen size" << nu.count() <<
"accel" << accel;
1462 for ( j = 0; j <
Nx - 3; j++ )
1463 if (
xA[ j ] > xc )
break;
1470 for ( j = 0; j <
Nx - 3; j++ )
1471 if (
xA[ Nx - j - 1 ] < xc )
break;
1480 simdata.
scan .clear();
1484 for (
int i = 0; i <
Nx; i++ )
1504 for (
int ii = 0; ii < 3; ii++ )
1506 for (
int jj = 0; jj <
Nx; jj++ )
1508 CA[ ii ][ jj ] = 0.0;
1509 CB[ ii ][ jj ] = 0.0;
1520 clcSt2 = QDateTime::currentDateTime();
1521 ttT1+=(clcSt1.msecsTo(clcSt2));
1563 for (
int ii = 0; ii < 3; ii++ )
1565 for (
int jj = 0; jj <
Nx; jj++ )
1567 CA1[ ii ][ jj ] = 0.0;
1568 CA2[ ii ][ jj ] = 0.0;
1569 CB1[ ii ][ jj ] = 0.0;
1570 CB2[ ii ][ jj ] = 0.0;
1588 clcSt3 = QDateTime::currentDateTime();
1589 ttT2+=(clcSt2.msecsTo(clcSt3));
1593 QVector< double > C0Vec( Nx );
1594 QVector< double > C1Vec( Nx );
1595 QVector< double > rhVec( Nx );
1605 double* right_hand_side = rhVec.data();
1607 ttT3+=(clcSt3.msecsTo(QDateTime::currentDateTime()));
1608 clcSt3 = QDateTime::currentDateTime();
1614 double rpm_inc = ( rpm_stop - rpm_start ) / time_dif;
1615 double rpm_current = rpm_start - rpm_inc;
1618 int nisteps = ntsteps + 3;
1620 int ltsteps = ntsteps;
1622 simdata.
scan .reserve( nisteps );
1625 for (
int ii = 0; ii < nisteps; ii++ )
1629 clcSt4 = QDateTime::currentDateTime();
1630 ttT3+=(clcSt3.msecsTo(clcSt4));
1633 if ( ii <= ntsteps )
1634 rpm_current += rpm_inc;
1643 double rpm_ratio =
sq( rpm_current / rpm_stop );
1645 for (
int j1 = 0; j1 < 3; j1++ )
1647 double* CAj = CA [ j1 ];
1648 double* CBj = CB [ j1 ];
1649 double* CA1j = CA1[ j1 ];
1650 double* CA2j = CA2[ j1 ];
1651 double* CB1j = CB1[ j1 ];
1652 double* CB2j = CB2[ j1 ];
1654 for (
int j2 = 0; j2 <
Nx; j2++ )
1656 CAj[ j2 ] = CA1j[ j2 ] + rpm_ratio * ( CA2j[ j2 ] - CA1j[ j2 ] );
1657 CBj[ j2 ] = CB1j[ j2 ] + rpm_ratio * ( CB2j[ j2 ] - CB1j[ j2 ] );
1663 simscan.
rpm = (int) rpm_current;
1667 sq( rpm_current * M_PI / 30.0 );
1668 if(ii<3||ii>ntsteps-2) {
1669 DbgLv(2) <<
"TMS:RSA:ni: iistep" << ii <<
"time ltime omg"
1677 <<
"rpm_c" << rpm_current <<
"step-scan" << simdata.
scan.size();
1679 simscan.
conc.clear();
1680 simscan.
conc.reserve( Nx );
1681 DbgLv(2) <<
"RSA: Nx C0size" << Nx << C0Vec.size() <<
"step-scan"
1684 for (
int jj = 0; jj <
Nx; jj++ )
1685 simscan.
conc.append( C0[ jj ] );
1689 simdata.
scan.append( simscan );
1691 if(ii==0)
DbgLv(2) <<
"TMS:RSA:ni: Scan Added";
1693 clcSt5 = QDateTime::currentDateTime();
1694 ttT4+=(clcSt4.msecsTo(clcSt5));
1700 if ( accel || fixedGrid )
1702 right_hand_side[ 0 ] = - CB[ 1 ][ 0 ] * C0[ 0 ]
1703 - CB[ 2 ][ 0 ] * C0[ 1 ];
1705 for (
int jj = 1; jj < Nx - 1; jj++ )
1707 right_hand_side[ jj ] = - CB[ 0 ][ jj ] * C0[ jj - 1 ]
1708 - CB[ 1 ][ jj ] * C0[ jj ]
1709 - CB[ 2 ][ jj ] * C0[ jj + 1 ];
1713 right_hand_side[ jj ] = - CB[ 0 ][ jj ] * C0[ jj - 1 ]
1714 - CB[ 1 ][ jj ] * C0[ jj ];
1720 right_hand_side[ 0 ] = - CB[ 2 ][ 0 ] * C0[ 0 ];
1721 right_hand_side[ 1 ] = - CB[ 1 ][ 1 ] * C0[ 0 ]
1722 - CB[ 2 ][ 1 ] * C0[ 1 ];
1724 for (
int jj = 2; jj <
Nx; jj++ )
1726 right_hand_side[ jj ] = - CB[ 0 ][ jj ] * C0[ jj - 2 ]
1727 - CB[ 1 ][ jj ] * C0[ jj - 1 ]
1728 - CB[ 2 ][ jj ] * C0[ jj ];
1733 for (
int jj = 0; jj < Nx - 2; jj++ )
1735 right_hand_side[ jj ] = - CB[ 0 ][ jj ] * C0[ jj ]
1736 - CB[ 1 ][ jj ] * C0[ jj + 1 ]
1737 - CB[ 2 ][ jj ] * C0[ jj + 2 ];
1741 right_hand_side[ jj ] = - CB[ 0 ][ jj ] * C0[ jj ]
1742 - CB[ 1 ][ jj ] * C0[ jj + 1 ];
1745 right_hand_side[ jj ] = -CB[ 0 ][ jj ] * C0[ jj ];
1751 clcSt6 = QDateTime::currentDateTime();
1752 ttT5+=(clcSt5.msecsTo(clcSt6));
1758 clcSt7 = QDateTime::currentDateTime();
1759 ttT6+=(clcSt6.msecsTo(clcSt7));
1763 for (
int jj = 0; jj <
Nx; jj++ ) C0[ jj ] = C1[ jj ];
1769 qApp->processEvents();
1774 qApp->processEvents();
1778 clcSt3 = QDateTime::currentDateTime();
1779 ttT7+=(clcSt7.msecsTo(clcSt3));
1783 if ( ii == ltsteps )
1787 C_init.
radius .reserve( Nx );
1789 for (
int jj = 0; jj <
Nx; jj++ )
1791 C_init.
radius .append(
x [ jj ] );
1798 clcSt8 = QDateTime::currentDateTime();
1803 qApp->processEvents();
1819 clcSt9 = QDateTime::currentDateTime();
1820 ttT8+=(clcSt8.msecsTo(clcSt9));
1821 int elapsCalc=clcSt0.msecsTo(clcSt9);
1824 if((nccall%1000)==0) {
1825 int totTK=ttT1+ttT2+ttT3+ttT4+ttT5+ttT6+ttT7+ttT8;
1826 qDebug() <<
" ++Elapsed calc-ni ms" << elapsCalc <<
" nc totC totK" << nccall
1827 << ttTC << totTK <<
" Nx" << Nx <<
" acc fixG" << accel << fixedGrid;
1828 qDebug() <<
" CN: t1 t2 t3 t4 t5 t6 t7 t8" << ttT1 << ttT2 << ttT3 << ttT4
1829 << ttT5 << ttT6 << ttT7 << ttT8;
1831 int p1=(ttT1*100+p0)/totTK;
1832 int p2=(ttT2*100+p0)/totTK;
1833 int p3=(ttT3*100+p0)/totTK;
1834 int p4=(ttT4*100+p0)/totTK;
1835 int p5=(ttT5*100+p0)/totTK;
1836 int p6=(ttT6*100+p0)/totTK;
1837 int p7=(ttT7*100+p0)/totTK;
1838 int p8=(ttT8*100+p0)/totTK;
1839 qDebug() <<
" CN: p1 p2 p3 p4 p5 p6 p7 p8" << p1 << p2 << p3 << p4
1840 << p5 << p6 << p7 << p8;
1843 DbgLv(2) <<
"RSA: CALC_NI END - simdata scans points rss"
1876 x.reserve( Np * 2 + 2 );
1891 else if ( nu[ nu.size() - 1 ] < 0 )
1897 double deltbm = ( b - m ) / (
double)( Np - 1 );
1899 for (
int i = 0; i < Np; i++ )
1910 for (
int i = 0; i < Np; i++ )
1911 x .append( m + ( b - m ) * i / ( Np - 1 ) );
1920 for (
int i = 1; i < Np - 1; i++ )
1921 x .append( m * pow( b / m, ( i - 0.5 ) / ( Np - 1 ) ) );
1931 if ( f.open( QIODevice::ReadOnly ) )
1933 QTextStream ts( &f );
1935 while ( ! ts.atEnd() )
x .append( ts.readLine().toDouble() );
1939 if ( qAbs(
x[ 0 ] - m ) > 1.0e7 )
1941 DbgErr() <<
"The meniscus from the mesh file does not"
1942 " match the set meniscus - using Claverie Mesh instead\n";
1945 if ( qAbs(
x[
x.size() - 1 ] - b ) > 1.0e7 )
1947 DbgErr() <<
"The cell bottom from the mesh file does not"
1948 " match the set cell bottom - using Claverie Mesh"
1954 DbgErr() <<
"Could not read the mesh file - "
1955 "using Claverie Mesh instead\n";
1958 x .append( m + ( b - m ) * i / ( Np - 1 ) );
1970 else if ( nu[ nu.size() - 1 ] < 0 )
1975 for (
int i = 0; i < Np; i++ )
1976 x .append( m + ( b - m ) * i / ( Np - 1 ) );
1981 qDebug() <<
"undefined mesh option\n";
2001 QVector< double > xc;
2002 QVector< double > Hstar;
2003 QVector< double > y;
2005 const double* nu = nuvec.data();
2019 double uth = 1.0 / Np;
2020 double bmsqdf = (
sq( bottom ) -
sq( meniscus ) ) / ( uth * 2.0 );
2021 double Npm1 = (double)( Np - 1 );
2022 double Npm2 = Npm1 - 1.0;
2023 double Npratio = Npm2 / Npm1;
2024 double bmratio = bottom / meniscus;
2025 double mbratio = meniscus / bottom;
2026 double bmrlog = log( bmratio );
2027 double k2log = log( 2.0 );
2028 double bmNpow = pow( bmratio, Npratio );
2029 double bmdiff = bottom - meniscus * bmNpow;
2030 const double PIhalf = M_PI / 2.0;
2031 DbgLv(2) <<
"RSA: msg_pos: nu0" << nu[0] <<
"nu1" << nu[1] <<
"Np" << Np <<
"uth" << uth;
2032 DbgLv(2) <<
"RSA: msg_pos: m " << meniscus <<
" b " << bottom <<
" bmsqdf" << bmsqdf;
2034 for (
int i = 0; i <
af_params.
s.size(); i++ )
2036 double tmp_xc = bottom - ( 1.0 / ( nu[ i ] * bottom ) )
2037 * log( nu[ i ] * bmsqdf );
2040 int tmp_Nf = (int) ( PIhalf * ( bottom - tmp_xc )
2041 * nu[ i ] * bottom / 2.0 + 0.5 ) + 1;
2044 tmp_Hstar = ( bottom - tmp_xc ) / tmp_Nf * PIhalf;
2046 DbgLv(2) <<
"RSA: msg_pos: i " << i <<
"txc" << tmp_xc <<
"tNf" << tmp_Nf <<
"tHs" << tmp_Hstar;
2047 if ( ( tmp_xc > meniscus ) && ( bmdiff > tmp_Hstar ) )
2049 xc .append( tmp_xc );
2050 Nf .append( tmp_Nf );
2051 Hstar .append( tmp_Hstar );
2056 xc .append( bottom );
2063 for (
int i = 0; i < IndLayer; i++ )
2065 double xci = xc[ i ];
2067 if ( i < IndLayer - 1 )
2069 double xcip = xc[ i + 1 ];
2070 double HL = Hstar[ i ];
2071 double HR = Hstar[ i + 1 ];
2072 int Mp = (int) ( ( xcip - xci ) * 2.0 / ( HL + HR ) );
2076 double beta = ( ( HR - HL ) / 2.0 ) * Mp;
2077 double alpha = xcip - xci - beta;
2079 for (
int j = 0; j <= Mp - 1; j++ )
2081 double xi = (double) j / (
double) Mp;
2082 y .append( xci + alpha * xi + beta *
sq( xi ) );
2089 double xcip = xc[ qMin( i + 1, xc.size() - 1 ) ];
2091 for (
int j = 0; j <= Nf[ i ] - 1; j++ )
2094 y .append( xci + ( bottom - xci ) *
2095 sin( j / ( Nf[ i ] - 1.0 ) * PIhalf ) );
2097 if ( y[ indp - 1 ] > xcip )
break;
2105 x .append( meniscus );
2108 for (
int k = 1; k < Np - 1 ; k++ )
2110 x .append( meniscus * pow( bmratio, (
double) k / Npm1 ) );
2113 x .append( bottom );
2119 DbgLv(2) <<
"RSA: msg_pos: IndL>0 x sz" <<
x.size();
2123 int kk = NfTotal - 1;
2124 double* yary = y.data();
2128 double ysav = yary[ jj ];
2129 yary[ jj++ ] = yary[ kk ];
2130 yary[ kk-- ] = ysav;
2135 double Hf = y[ NfTotal - 2 ] - y[ NfTotal - 1 ];
2138 int Nm = (int)( log( bottom / ( Npm1 * Hf ) * bmrlog ) / k2log ) + 1;
2140 double xa = y[ NfTotal - 1 ] - Hf * ( pow( 2.0, (
double)Nm ) - 1.0 );
2142 int Js = (int)( Npm1 * log( xa / meniscus ) / bmrlog );
2145 xa = meniscus * pow( bmratio, ( (
double)Js / (
double)Npm1 ) );
2147 double tmp_xc = y[ NfTotal - 1 ];
2148 double HL = xa * ( 1.0 - mbratio );
2149 double HR = y[ NfTotal - 2 ] - y[ NfTotal - 1 ];
2151 int Mp = (int)( ( tmp_xc - xa ) * 2.0 / ( HL + HR ) ) + 1;
2155 double beta = ( ( HR - HL ) / 2.0 ) * Mp;
2156 double alpha = ( tmp_xc - xa ) - beta;
2158 for (
int j = Mp - 1; j > 0; j-- )
2160 double xi = (double) j / Mp;
2161 y .append( xa + alpha * xi + beta *
sq( xi ) );
2166 DbgLv(2) <<
"RSA: msg_pos: IndL>0 Js" << Js <<
"NfTotal" << NfTotal <<
"Nm" << Nm;
2169 x .append( meniscus );
2172 for (
int j = 1; j <= Js; j++ )
2173 x .append( meniscus * pow( bmratio, ( (
double)j / (
double)Npm1 ) ) );
2175 for (
int j = NfTotal + Nm - 2; j >=0; j-- )
2176 x .append( yary[ j ] );
2177 DbgLv(2) <<
"RSA: msg_pos: IndL>0 y sz" << y.size() <<
"Mp" << Mp <<
"Nm" << Nm <<
"x sz" <<
x.size();
2183 DbgLv(2) <<
"RSA: mgs_pos: xA sme" <<
x[0] <<
x[1] <<
x[2]
2184 <<
x[mm-1] <<
x[mm] <<
x[mm+1] <<
x[mm+2] <<
x[ee-2] <<
x[ee-1] <<
x[ee];
2195 const double PIhalf = M_PI / 2.0;
2196 const double PIquar = M_PI / 4.0;
2197 const double k2log = log( 2.0 );
2199 double xc, xa, Hstar;
2200 QVector< double > yr, ys, yt;
2211 double uth = 1.0 / Np;
2212 double nu0 = qAbs( nu[ 0 ] );
2213 double bmrlog = log( b / m );
2214 double mbratio = m / b;
2215 double Npm1 = (double)( Np - 1 );
2222 xc = m + 1. / ( nu0 * m ) * log( (
sq( b ) -
sq( m ) ) * nu0 / ( 2. * uth ) );
2224 Nf = 1 + (int)( ( xc - m ) * nu0 * m * PIquar );
2226 Hstar = ( xc - m ) / Nf * PIhalf;
2228 Nm = 1 + (int)( log( m / ( Npm1 * Hstar ) * bmrlog ) / k2log );
2230 xa = xc + ( pow( 2.0, (
double) Nm ) - 1.0 ) * Hstar;
2232 Js = (int) ( Npm1 * log( b / xa ) / bmrlog + 0.5 );
2240 for( j = 1; j < Np; j++ )
2245 if ( b * ( pow( mbratio, ( Np - 3.5 ) / Npm1 )
2246 - pow( mbratio, ( Np - 2.5 ) / Npm1 ) ) < Hstar || Nf <= 2 )
2248 double* yrA = yr.data();
2251 for ( j = Np - 1; j >= 0; j-- )
2253 x .append( yrA[ j ] );
2258 DbgErr() <<
"Use exponential grid only!(1/10000 reported): Np Nf b m nu0"
2259 << Np << Nf << b << m << nu0;
2264 double xcm = xc - m;
2265 double Nfm1 = (double)( Nf - 1 );
2266 for ( j = 0; j < Nf - 1; j++ )
2267 ys .append( xc - xcm * sin( (
double)j / Nfm1 * PIhalf ) );
2271 for ( j = 0; j < Nm; j++ )
2272 yt .append( xc + ( pow( 2.0, (
double) j ) - 1.0 ) * Hstar );
2274 double* ysA = ys.data();
2275 double* ytA = yt.data();
2276 double* yrA = yr.data();
2279 for ( j = Nf - 1; j >= 0; j-- )
2280 x .append( ysA[ j ] );
2282 for ( j = 1; j < Nm; j++ )
2283 x .append( ytA[ j ] );
2285 for ( j = Js; j >= 0; j-- )
2286 x .append( yrA[ j ] );
2291 xA[ jj ] = (
xA[ jj - 1 ] +
xA[ jj + 1 ] ) / 2.0;
2292 xA[ jj + 1 ] = (
xA[ jj ] +
xA[ jj + 2 ] ) / 2.0;
2308 const double PIhalf = M_PI / 2.0;
2309 QVector< double > zz;
2313 zz.reserve(
x.size() );
2319 for (
int j = 0; j < M0; j++ )
2321 double tmp = (double) j / (
double)M0;
2322 tmp = 1.0 - cos( tmp * PIhalf );
2323 zz .append(
xA[ 0 ] * ( 1.0 - tmp ) +
xA[ N0 ] * tmp );
2328 for (
int j = N0; j <
x.size(); j++ )
2330 zz .append(
xA[ j ] );
2333 double xAval =
xA[
x.size() - 1 ];
2334 double xAinc = xAval -
xA[
x.size() - 2 ];
2335 zz << xAval + xAinc;
2336 zz << xAval + xAinc * 2.0;
2339 x.reserve( zz.size() );
2342 for (
int j = 0; j < zz.size(); j++ )
2343 x .append( zA[ j ] );
2347 for (
int j = 0; j <
x.size() - N0; j++ )
2348 zz .append(
xA[ j ] );
2351 int kk =
x.size() - 1;
2352 double x1 =
xA[ kk - N0 ];
2353 double x2 =
xA[ kk ];
2354 double tinc = PIhalf / (double)M0;
2357 for (
int j = 1; j <= M0; j++ )
2360 double tmp = sin( tval );
2361 zz .append( x1 * ( 1.0 - tmp ) + x2 * tmp );
2365 x.reserve( zz.size() );
2368 for (
int j = 0; j < zz.size(); j++ )
2369 x .append( zA[ j ] );
2372 DbgErr() <<
"No refinement at ends since sedimentation "
2373 "and floating mixed ...\n" ;
2379 DbgLv(2) <<
"RSA:mgR: Nx xA sme" <<
Nx <<
x[0] <<
x[1] <<
x[2]
2380 <<
x[mm-1] <<
x[mm] <<
x[mm+1] <<
x[mm+2] <<
x[ee-2] <<
x[ee-1] <<
x[ee];
2386 double D,
double sw2,
double** CA,
double** CB )
2388 if (
Nx !=
x.size() ||
Nx < 1 )
2389 DbgErr() <<
"***FixedMesh ERROR*** Nx x.size" <<
Nx <<
x.size()
2390 <<
" params.s[0] D sw2" <<
af_params.
s[0] << D << sw2;
2393 static int Nsave = 0;
2394 static double*** Stif = NULL;
2407 double*** Stif = NULL;
2411 double xd[ 4 ][ 2 ];
2413 for (
int k = 0; k <
Nx - 1; k++ )
2415 xd[ 0 ][ 0 ] =
xA[ k ];
2417 xd[ 1 ][ 0 ] =
xA[ k + 1 ];
2419 xd[ 2 ][ 0 ] =
xA[ k + 1 ];
2421 xd[ 3 ][ 0 ] =
xA[ k ];
2431 CA[ 1 ][ k ] = Stif[ k ][ 3 ][ 0 ] + Stif[ k ][ 3 ][ 3 ];
2432 CA[ 2 ][ k ] = Stif[ k ][ 2 ][ 0 ] + Stif[ k ][ 2 ][ 3 ];
2433 CB[ 1 ][ k ] = Stif[ k ][ 0 ][ 0 ] + Stif[ k ][ 0 ][ 3 ];
2434 CB[ 2 ][ k ] = Stif[ k ][ 1 ][ 0 ] + Stif[ k ][ 1 ][ 3 ];
2436 for ( k = 1, m = 0; k < Nx - 1; k++, m++ )
2439 CA[ 0 ][ k ] = Stif[ m ][ 3 ][ 1 ] + Stif[ m ][ 3 ][ 2 ];
2440 CA[ 1 ][ k ] = Stif[ m ][ 2 ][ 1 ] + Stif[ m ][ 2 ][ 2 ];
2441 CB[ 0 ][ k ] = Stif[ m ][ 0 ][ 1 ] + Stif[ m ][ 0 ][ 2 ];
2442 CB[ 1 ][ k ] = Stif[ m ][ 1 ][ 1 ] + Stif[ m ][ 1 ][ 2 ];
2445 CA[ 1 ][ k ] += Stif[ k ][ 3 ][ 0 ] + Stif[ k ][ 3 ][ 3 ];
2446 CA[ 2 ][ k ] = Stif[ k ][ 2 ][ 0 ] + Stif[ k ][ 2 ][ 3 ];
2447 CB[ 1 ][ k ] += Stif[ k ][ 0 ][ 0 ] + Stif[ k ][ 0 ][ 3 ];
2448 CB[ 2 ][ k ] = Stif[ k ][ 1 ][ 0 ] + Stif[ k ][ 1 ][ 3 ];
2454 CA[ 0 ][ k ] = Stif[ m ][ 3 ][ 1 ] + Stif[ m ][ 3 ][ 2 ];
2455 CA[ 1 ][ k ] = Stif[ m ][ 2 ][ 1 ] + Stif[ m ][ 2 ][ 2 ];
2456 CB[ 0 ][ k ] = Stif[ m ][ 0 ][ 1 ] + Stif[ m ][ 0 ][ 2 ];
2457 CB[ 1 ][ k ] = Stif[ m ][ 1 ][ 1 ] + Stif[ m ][ 1 ][ 2 ];
2463 DbgLv(2) <<
"RSA:CCMFM: CA0 sme" << CA[0][0] << CA[0][1] << CA[0][2]
2464 << CA[0][mm-1] << CA[0][mm] << CA[0][mm+1] << CA[0][mm+2]
2465 << CA[0][Nx-3] << CA[0][Nx-2] << CA[0][Nx-1];
2466 DbgLv(2) <<
"RSA:CCMFM: CA1 sme" << CA[1][0] << CA[1][1] << CA[1][2]
2467 << CA[1][mm-1] << CA[1][mm] << CA[1][mm+1] << CA[1][mm+2]
2468 << CA[1][Nx-3] << CA[1][Nx-2] << CA[1][Nx-1];
2469 DbgLv(2) <<
"RSA:CCMFM: CB0 sme" << CB[0][0] << CB[0][1] << CB[0][2]
2470 << CB[0][mm-1] << CB[0][mm] << CB[0][mm+1] << CB[0][mm+2]
2471 << CB[0][Nx-3] << CB[0][Nx-2] << CB[0][Nx-1];
2472 DbgLv(2) <<
"RSA:CCMFM: CB1 sme" << CB[1][0] << CB[1][1] << CB[1][2]
2473 << CB[1][mm-1] << CB[1][mm] << CB[1][mm+1] << CB[1][mm+2]
2474 << CB[1][Nx-3] << CB[1][Nx-2] << CB[1][Nx-1];
2478 double D,
double sw2,
double** CA,
double** CB )
2481 double xd[ 4 ][ 2 ];
2485 static int Nsave = 0;
2486 static double*** Stif = NULL;
2498 double*** Stif = NULL;
2503 xd[ 0 ][ 0 ] =
xA[ 0 ]; xd[ 0 ][ 1 ] = 0.;
2509 for (
int k = 1; k <
Nx - 1; k++ )
2511 xd[ 0 ][ 0 ] =
xA[ k - 1 ]; xd[ 0 ][ 1 ] = 0.0;
2512 xd[ 1 ][ 0 ] =
xA[ k ]; xd[ 1 ][ 1 ] = 0.0;
2519 xd[ 0 ][ 0 ] =
xA[ Nx - 2 ]; xd[ 0 ][ 1 ] = 0.0;
2520 xd[ 1 ][ 0 ] =
xA[ Nx - 1 ]; xd[ 1 ][ 1 ] = 0.0;
2528 CA[ 1 ][ k ] = Stif[ k ][ 2 ][ 2 ] ;
2529 CA[ 2 ][ k ] = Stif[ k ][ 1 ][ 2 ] ;
2530 CB[ 2 ][ k ] = Stif[ k ][ 0 ][ 2 ] ;
2533 CA[ 0 ][ k ] = Stif[ mm ][ 2 ][ 0 ] + Stif[ mm ][ 2 ][ 1 ];
2534 CA[ 1 ][ k ] = Stif[ mm ][ 1 ][ 0 ] + Stif[ mm ][ 1 ][ 1 ];
2535 CA[ 1 ][ k ] += Stif[ k ][ 3 ][ 0 ] + Stif[ k ][ 3 ][ 3 ];
2536 CA[ 2 ][ k ] = Stif[ k ][ 2 ][ 0 ] + Stif[ k ][ 2 ][ 3 ] ;
2538 CB[ 1 ][ k ] = Stif[ mm ][ 0 ][ 0 ] + Stif[ mm ][ 0 ][ 1 ];
2539 CB[ 1 ][ k ] += Stif[ k ][ 0 ][ 0 ] + Stif[ k ][ 0 ][ 3 ];
2540 CB[ 2 ][ k ] = Stif[ k ][ 1 ][ 0 ] + Stif[ k ][ 1 ][ 3 ];
2542 for( k = 2; k < Nx - 1; k++ )
2546 CA[ 0 ][ k ] = Stif[ mm ][ 3 ][ 1 ] + Stif[ mm ][ 3 ][ 2 ];
2547 CA[ 1 ][ k ] = Stif[ mm ][ 2 ][ 1 ] + Stif[ mm ][ 2 ][ 2 ];
2548 CB[ 0 ][ k ] = Stif[ mm ][ 0 ][ 1 ] + Stif[ mm ][ 0 ][ 2 ];
2549 CB[ 1 ][ k ] = Stif[ mm ][ 1 ][ 1 ] + Stif[ mm ][ 1 ][ 2 ];
2552 CA[ 1 ][ k ] += Stif[ k ][ 3 ][ 0 ] + Stif[ k ][ 3 ][ 3 ];
2553 CA[ 2 ][ k ] = Stif[ k ][ 2 ][ 0 ] + Stif[ k ][ 2 ][ 3 ];
2554 CB[ 1 ][ k ] += Stif[ k ][ 0 ][ 0 ] + Stif[ k ][ 0 ][ 3 ];
2555 CB[ 2 ][ k ] = Stif[ k ][ 1 ][ 0 ] + Stif[ k ][ 1 ][ 3 ];
2561 CA[ 0 ][ k ] = Stif[ mm ][3][1] + Stif[ mm ][3][2];
2562 CA[ 1 ][ k ] = Stif[ mm ][2][1] + Stif[ mm ][2][2];
2563 CB[ 0 ][ k ] = Stif[ mm ][0][1] + Stif[ mm ][0][2];
2564 CB[ 1 ][ k ] = Stif[ mm ][1][1] + Stif[ mm ][1][2];
2567 CA[ 1 ][ k ] += Stif[ k ][2][0] + Stif[ k ][2][1] + Stif[ k ][2][2];
2568 CB[ 1 ][ k ] += Stif[ k ][0][0] + Stif[ k ][0][1] + Stif[ k ][0][2];
2569 CB[ 2 ][ k ] = Stif[ k ][1][0] + Stif[ k ][1][1] + Stif[ k ][1][2];
2577 double D,
double sw2,
double** CA,
double** CB )
2584 static int Nsave = 0;
2585 static double*** Stif = NULL;
2596 double*** Stif = NULL;
2603 xd[1][0] =
xA[1]; xd[1][1] = 0.0;
2608 for (
int k = 1; k <
Nx - 1; k++ )
2610 xd[0][0] =
xA[k ]; xd[0][1] = 0.0;
2611 xd[1][0] =
xA[k+1]; xd[1][1] = 0.0;
2618 xd[0][0] =
xA[Nx-1]; xd[0][1] = 0.0;
2626 CA[1][0] = Stif[0][2][0] + Stif[0][2][1] + Stif[0][2][2];
2627 CB[0][0] = Stif[0][0][0] + Stif[0][0][1] + Stif[0][0][2] ;
2628 CB[1][0] = Stif[0][1][0] + Stif[0][1][1] + Stif[0][1][2] ;
2630 CA[1][0]+= Stif[1][3][0] + Stif[1][3][3] ;
2631 CA[2][0] = Stif[1][2][0] + Stif[1][2][3] ;
2632 CB[1][0]+= Stif[1][0][0] + Stif[1][0][3] ;
2633 CB[2][0] = Stif[1][1][0] + Stif[1][1][3] ;
2635 for (
int k = 1; k < Nx - 2; k++ )
2638 CA[0][k] = Stif[k ][3][1] + Stif[k ][3][2];
2639 CA[1][k] = Stif[k ][2][1] + Stif[k ][2][2];
2640 CB[0][k] = Stif[k ][0][1] + Stif[k ][0][2];
2641 CB[1][k] = Stif[k ][1][1] + Stif[k ][1][2];
2644 CA[1][k] += Stif[k+1][3][0] + Stif[k+1][3][3];
2645 CA[2][k] = Stif[k+1][2][0] + Stif[k+1][2][3];
2646 CB[1][k] += Stif[k+1][0][0] + Stif[k+1][0][3];
2647 CB[2][k] = Stif[k+1][1][0] + Stif[k+1][1][3];
2652 CA[0][k] = Stif[k ][3][1] + Stif[k ][3][2];
2653 CA[1][k] = Stif[k ][2][1] + Stif[k ][2][2];
2654 CB[0][k] = Stif[k ][0][1] + Stif[k ][0][2];
2655 CB[1][k] = Stif[k ][1][1] + Stif[k ][1][2];
2658 CA[1][k] += Stif[k+1][2][0] + Stif[k+1][2][2];
2659 CA[2][k] = Stif[k+1][1][0] + Stif[k+1][1][2];
2660 CB[1][k] += Stif[k+1][0][0] + Stif[k+1][0][2];
2664 CA[0][k] = Stif[k ][2][1] ;
2665 CA[1][k] = Stif[k ][1][1] ;
2666 CB[0][k] = Stif[k ][0][1] ;
2680 int Npts = C0[ 0 ].
radius.size();
2684 if ( num_comp == 2 )
2689 double k_assoc = ( k_d != 0.0 ) ? ( 1.0 / k_d ) : 0.0;
2694 DbgLv(2) <<
"RSA: decompose() ext_M" << ext_M <<
"k_assoc" << k_assoc;
2699 for (
int j = 0; j < Npts; j++ )
2705 if ( st0 == 2 && st1 == -1 )
2709 c1 = ( sqrt( 1.0 + 4.0 * k_assoc * ct ) - 1.0 ) / ( 2.0 * k_assoc );
2712 else if ( st0 == 3 && st1 == -1 )
2715 else if ( st0 > 3 && st1 == -1 )
2720 DbgErr() <<
"Warning: invalid stoichiometry in decompose()"
2721 <<
" st0 st1 c1" << st0 << st1 << c1;
2725 double c2 = k_assoc * pow( c1, (
double)st0 );
2727 DbgLv(2) <<
"RSA: decompose() j" << j <<
"c1 c2 ct Ka" << c1 << c2 << ct
2728 << k_assoc <<
"p_role0_st0" <<
af_params.
role[0].stoichs[0];
2743 qApp->processEvents();
2746 DbgLv(2) <<
"RSA: decompose NCOMP=2 return";
2757 for(
int i = 0; i < num_comp; i++ )
2759 for(
int j = 0; j < Npts; j++ )
2762 C2[ i ][ j ] = C1[ i ][ j ];
2769 double k_min = 1.0e12;
2777 k_min = qMin( k_min, 1.0e-12 );
2780 const int time_max = 100;
2781 double timeStepSize = - log( 1.0e-7 ) / ( k_min * time_max );
2782 DbgLv(2) <<
"RSA: decompose k_min time_max timeStepSize"
2783 << k_min << time_max << timeStepSize;
2791 for (
int ti = 0; ti < time_max; ti++ )
2798 qApp->processEvents();
2810 for (
int i = 0; i < num_comp; i++ )
2812 for (
int j = 0; j < Npts; j++ )
2814 diff += qAbs( C2[ i ][ j ] - C1[ i ][ j ] );
2815 ct += qAbs( C1[ i ][ j ] );
2816 C2[ i ][ j ] = C1[ i ][ j ];
2822 qApp->processEvents();
2825 if ( diff < 1.0e-5 * ct )
2840 qApp->processEvents();
2844 for (
int i = 0; i < num_comp; i++ )
2846 for (
int j = 0; j < Npts; j++ )
2847 C0[ i ].concentration[ j ] = C1[ i ][ j ];
2860 int Npts,
double** C1,
double timeStep )
2863 DbgLv(2) <<
"RSA:Eul: Npts timeStep" << Npts << timeStep
2864 <<
"num_comp" << num_comp;
2867 if ( num_comp == 2 )
2877 double k_assoc = ( k_d == 0.0 ) ? 0.0 : ( 1.0 / ( k_d * extn ) );
2879 DbgLv(2) <<
"RSA:Eul: rule" << rule <<
"st0 st1 k_assoc k_off"
2880 << st0 << st1 << k_assoc << k_off;
2882 for (
int j = 0; j < Npts; j++ )
2884 double ct = C1[ 0 ][ j ] + C1[ 1 ][ j ];
2885 double dva = timeStep * k_off * k_assoc;
2886 double dvb = timeStep * k_off + 2.;
2887 double dvc = timeStep * k_off * ct + 2.0 * C1[ 0 ][ j ];
2889 DbgLv(2) <<
"RSA:Eul: j ct" << j << ct <<
"dva dvb dvc" << dva << dvb << dvc;
2891 if ( st0 == 2 && st1 == (-1) )
2893 uhat = 2. * dvc / ( dvb + sqrt( dvb * dvb + 4. * dva * dvc ) );
2895 DbgLv(2) <<
"RSA:Eul: mono-dimer uhat" << uhat
2896 <<
"C1[0][j] C1[1][j]" << C1[0][j] << C1[1][j];
2899 else if ( st0 == 3 && st1 == (-1) )
2904 else if ( st0 > 3 && st1 == (-1) )
2911 DbgErr() <<
"Warning: invalid stoichiometry in decompose()";
2917 C1[ 0 ][ j ] = 2. * uhat - C1[ 0 ][ j ];
2918 C1[ 1 ][ j ] = ct - C1[ 0 ][ j ];
2924 C1[ 1 ][ j ] = 2. * uhat - C1[ 1 ][ j ];
2925 C1[ 0 ][ j ] = ct - C1[ 1 ][ j ];
2933 const int iter_max = 20;
2937 QVector< double > y0Vec( num_comp );
2938 QVector< double > dnVec( num_comp );
2939 QVector< double > bbVec( num_comp );
2940 QVector< double > y0rVc( num_comp );
2941 QVector< double > y1rVc( num_comp );
2942 y0rVc.fill( 0.0, num_comp );
2943 y1rVc.fill( 0.0, num_comp );
2944 double* y0 = y0Vec.data();
2945 double* delta_n = dnVec.data();
2946 double* b = bbVec.data();
2947 double* y0_ref = y0rVc.data();
2948 double* y1_ref = y1rVc.data();
2952 for (
int j = 0; j < Npts; j++ )
2955 double diff_ref = 0.0;
2957 for (
int i = 0; i < num_comp; i++ )
2959 y0[ i ] = C1[ i ][ j ];
2961 ct += qAbs( y0[ i ] );
2962 diff_ref += qAbs( y0_ref[ i ] - y0[ i ] );
2965 if ( diff_ref < ( ct * 1.e-7 ) || diff_ref < 1.e-9 )
2967 for (
int i = 0; i < num_comp; i++ )
2969 C1[ i ][ j ] = y1_ref[ i ];
2975 for (
int iter = 0; iter < iter_max; iter++ )
2979 for (
int i = 0; i < num_comp; i++ )
2981 y0[ i ] = C1[ i ][ j ] + delta_n[ i ];
2991 for (
int i = 0; i < num_comp; i++ )
2993 for (
int k = 0; k < num_comp; k++ )
2994 A[ i ][ k ] *= ( -timeStep );
2998 b[ i ] = b[ i ] * timeStep - delta_n[ i ] * 2.0;
3003 DbgErr() <<
"Matrix singular in Reaction_Euler_imp: model 12";
3010 for (
int i = 0; i < num_comp; i++ )
3012 delta_n[ i ] += b[ i ];
3013 diff += qAbs( delta_n[ i ] );
3017 if ( diff < ( 1.0e-7 * ct ) )
break;
3020 for (
int i = 0; i < num_comp; i++ )
3022 y0_ref[ i ] = C1[ i ][ j ];
3023 C1[ i ][ j ] += delta_n[ i ];
3024 y1_ref[ i ] = C1[ i ][ j ];
3043 QVector< double > qqVec( num_rule );
3044 double* Q = qqVec.data();
3046 for (
int m = 0; m < num_rule; m++ )
3049 double k_off = as->
k_off;
3050 double k_assoc = ( as->
k_d != 0.0 ) ? ( 1.0 / as->
k_d ) : 0.0;
3052 double k_on = k_assoc * k_off;
3053 double Q_reactant = 1.0;
3054 double Q_product = 1.0;
3057 for (
int n = 0; n < as->
rcomps.size(); n++ )
3060 int ind_cn = as->
rcomps[ n ] ;
3063 int kstoi = as->
stoichs[ n ] ;
3064 int react = ( kstoi < 0 ) ? -1 : 1;
3065 double rstoi = (double)qAbs( kstoi );
3075 Q_reactant *= pow( y0[ ind_cn ] / extn, rstoi );
3079 Q_product *= pow( y0[ ind_cn ] / extn, rstoi );
3083 Q[ m ] = k_on * Q_reactant - k_off * Q_product;
3086 for (
int i = 0; i < num_comp; i++ )
3091 for (
int m = 0; m < cr->
assocs.size(); m++ )
3093 yt[ i ] -= ( (double)cr->
stoichs[ m ] * Q[ cr->
assocs[ m ] ] );
3099 DbgLv(2) <<
"RSA:ReDydt: yt[0] yt[n]" << yt[0] << yt[num_comp-1];
3112 for (
int m = 0; m < num_rule; m++ )
3115 double k_off = as->
k_off;
3116 double k_assoc = ( as->
k_d != 0.0 ) ? ( 1.0 / as->
k_d ) : 0.0;
3118 double k_on = k_assoc * k_off;
3120 for (
int j = 0; j < num_comp; j++ )
3122 double Q_reactant = 1.0;
3123 double Q_product = 1.0;
3124 double deriv_r = 0.0;
3125 double deriv_p = 0.0;
3127 for(
int n = 0; n < as->
rcomps.size(); n++ )
3130 int ind_cn = as->
rcomps[ n ] ;
3133 int kstoi = as->
stoichs[ n ] ;
3134 int react = ( kstoi < 0 ) ? -1 : 1;
3135 double rstoi = (double)( kstoi * react );
3139 double yext = y0[ ind_cn ] / extn;
3142 if ( as->
rcomps[ n ] == j )
3145 deriv_r = rstoi / extn * pow( yext, rstoi - 1.0 );
3148 deriv_p = rstoi / extn * pow( yext, rstoi - 1.0 );
3154 Q_reactant *= pow( yext, rstoi );
3157 Q_product *= pow( yext, rstoi );
3161 QC[ m ][ j ] = k_on * Q_reactant * deriv_r
3162 - k_off * Q_product * deriv_p;
3166 for (
int i = 0; i < num_comp; i++ )
3170 for (
int j = 0; j < num_comp; j++ )
3172 dfdy[ i ][ j ] = 0.0;
3174 for (
int m = 0; m < cr->
assocs.size(); m++ )
3176 dfdy[ i ][ j ] -= ( (double)cr->
stoichs[ m ]
3177 * QC[ cr->
assocs[ m ] ][ j ] );
3199 QVector< double > nu;
3201 nu.reserve( Mcomp );
3203 for (
int i = 0; i < Mcomp; i++ )
3205 double sw2 =
af_params.
s[ i ] *
sq( rpm_stop * M_PI / 30 );
3212 simdata.
scan .clear();
3214 simdata.
scan .reserve(
Nx );
3216 DbgLv(2) <<
"RSA:_ra2: Mcomp Nx" << Mcomp <<
Nx <<
"x size" <<
x.size()
3234 DbgLv(2) <<
"RSA:_ra2:(2) Nx" <<
Nx <<
"x size" <<
x.size();
3239 double sw2 = s_max *
sq( rpm_stop * M_PI / 30. );
3242 for ( j = 0; j <
Nx - 3; j++ )
3244 if (
xA[ j ] > xc )
break;
3248 DbgLv(2) <<
"RSA:_ra2: s_min s_max" << s_min << s_max <<
"xc xAj"
3249 << xc <<
xA[j] <<
"j" << j <<
"N0 M0" << (j+1) << (j*4);
3251 else if ( s_max < 0.0 )
3255 double sw2 = s_min *
sq( rpm_stop * M_PI / 30. );
3258 for ( j =
Nx - 1; j > 1; j-- )
3260 if (
xA[ j ] < xc )
break;
3267 DbgErr() <<
"Multicomponent system with sedimentation and "
3268 "floating mixed, use uniform mesh";
3270 DbgLv(2) <<
"RSA:_ra2:(3) Nx" <<
Nx <<
"x size" <<
x.size();
3272 DbgLv(2) <<
"RSA:_ra2:(4) Nx" <<
Nx <<
"x size" <<
x.size();
3274 for (
int i = 0; i <
Nx; i++ )
3300 for(
int i = 0; i < Mcomp; i++ )
3308 DbgLv(2) <<
"RSA:_ra2:(5) Nx" << Nx <<
"x size" <<
x.size();
3315 for(
int i = 0; i < Mcomp; i++ )
3317 double sw2 =
af_params.
s[ i ] *
sq( rpm_stop * M_PI / 30 );
3326 double stop_fact =
sq( rpm_stop * M_PI / 30.0 );
3329 for (
int i = 0; i < Mcomp; i++ )
3334 DbgLv(2) <<
"RSA: smin>0:GlStf: i" << i <<
"Si Di sw2 sw2D sqb s_max"
3339 QVector< double > xbvec;
3341 xbvec.reserve( Nx );
3344 for (
int j = 1; j <
Nx; j++ )
3346 double dval = 0.1 * exp( sw2D * (
sq( 0.5 *
3347 (
xA[ j - 1 ] +
xA[ j ] ) ) - sqb ) );
3349 double alpha = s_rat * ( 1.0 - dval ) + dval;
3350 xbvec << ( pow(
xA[ j - 1 ], alpha ) *
3351 pow(
xA[ j ], ( 1.0 - alpha ) ) );
3353 if(j<4 || j==(Nx/2) || (j+4)>Nx)
3354 DbgLv(2) <<
"RSA: smin>0:GlStf: j" << j <<
"dval alpha xbj xAj"
3355 << dval << alpha << xbvec[j] <<
xA[j];
3358 double* xb = xbvec.data();
3361 DbgLv(2) <<
"RSA: smin>0:GlStf: CA[i]:" << CA[i][0][0] << CA[i][1][0]
3363 DbgLv(2) <<
"RSA: smin>0:GlStf: CB[i]:" << CB[i][0][0] << CB[i][1][0]
3368 else if ( s_max < 0)
3370 DbgErr() <<
"all components floating, not implemented yet";
3376 DbgErr() <<
"sedimentation and floating mixed, suppose use "
3387 DbgLv(2) <<
"RSA:_ra2:(6) Nx" << Nx <<
"x size" <<
x.size();
3394 for(
int ii = 0; ii < Mcomp; ii++ )
3401 DbgLv(2) <<
"RSA: newX3 Nx" << Nx <<
"C0[00] C0[m0] C0[0n] C0[mn]"
3402 << C0[0][0] << C0[Mcomp-1][0] << C0[0][Nx-1] << C0[Mcomp-1][Nx-1];
3403 QVector< double > CT0vec( Nx );
3404 QVector< double > CT1vec( Nx );
3405 QVector< double > rhVec ( Nx );
3406 double* CT0 = CT0vec.data();
3407 double* CT1 = CT1vec.data();
3409 for (
int jj = 0; jj <
Nx; jj++ )
3413 for (
int ii = 0; ii < Mcomp; ii++ )
3414 CT0[ jj ] += C0[ ii ][ jj ];
3416 CT1[ jj ] = CT0[ jj ];
3418 DbgLv(2) <<
"RSA: newX3 CT0 CTn" << CT1[0] << CT1[Nx-1];
3421 double* right_hand_side = rhVec.data();
3424 int stepmax = ( Nt + 2 ) / stepinc + 1;
3425 bool repprog = stepmax > 1;
3436 for (
int kkk = 0; kkk < Nt + 2; kkk += 2 )
3438 double rpm_current = rpm_start +
3439 ( rpm_stop - rpm_start ) * ( kkk + 0.5 ) / Nt;
3446 simscan.
rpm = (int) rpm_current;
3448 *
sq( rpm_current * M_PI / 30 ) );
3452 <<
"step-scan" << simdata.
scan.size();
3454 simscan.
conc.clear();
3455 simscan.
conc.reserve( Nx );
3456 DbgLv(2) <<
"RSA: Nx CT0size" << Nx << CT0vec.size() <<
"step-scan"
3459 for (
int jj = 0; jj <
Nx; jj++ )
3460 simscan.
conc.append( CT0[ jj ] );
3461 DbgLv(2) <<
"TMS:RSA:ra: kkk" << kkk <<
"CT0[0] CT0[n]"
3462 << CT0[0] << CT0[Nx-1] <<
"accel fixedGrid" << accel << fixedGrid;
3464 simdata.
scan .append( simscan );
3470 double dval =
sq( rpm_current / rpm_stop );
3472 for (
int i = 0; i < Mcomp; i++ )
3474 for (
int j1 = 0; j1 < 3; j1++ )
3476 for (
int j2 = 0; j2 <
Nx; j2++ )
3478 CA[ i ][ j1 ][ j2 ] = CA1[ i ][ j1 ][ j2 ] +
3479 dval * ( CA2[ i ][ j1 ][ j2 ] -
3480 CA1[ i ][ j1 ][ j2 ] );
3482 CB[ i ][ j1 ][ j2 ] = CB1[ i ][ j1 ][ j2 ] +
3483 dval * ( CB2[ i ][ j1 ][ j2 ] -
3484 CB1[ i ][ j1 ][ j2 ] );
3490 if ( accel || fixedGrid )
3492 for (
int i = 0; i < Mcomp; i++ )
3494 right_hand_side[ 0 ] = - CB[ i ][ 1 ][ 0 ] * C0[ i ][ 0 ]
3495 - CB[ i ][ 2 ][ 0 ] * C0[ i ][ 1 ];
3497 for (
int j = 1; j < Nx - 1; j++ )
3499 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 1 ]
3500 - CB[ i ][ 1 ][ j ] * C0[ i ][ j ]
3501 - CB[ i ][ 2 ][ j ] * C0[ i ][ j + 1 ];
3506 right_hand_side[ j ] = -CB[ i ][ 0 ][ j ] * C0[ i ][ j - 1 ]
3507 - CB[ i ][ 1 ][ j ] * C0[ i ][ j ];
3510 right_hand_side, C1[ i ], Nx );
3520 for (
int i = 0; i < Mcomp; i++ )
3523 right_hand_side[ 0 ] = - CB[ i ][ 2 ][ 0 ] * C0[ i ][ 0 ]
3524 - CB[ i ][ 3 ][ 0 ] * C0[ i ][ 1 ];
3526 right_hand_side[ 1 ] = - CB[ i ][ 1 ][ 1 ] * C0[ i ][ 0 ]
3527 - CB[ i ][ 2 ][ 1 ] * C0[ i ][ 1 ]
3528 - CB[ i ][ 3 ][ 1 ] * C0[ i ][ 2 ];
3530 for (
int j = 2; j < Nx - 1; j++ )
3532 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 2 ]
3533 - CB[ i ][ 1 ][ j ] * C0[ i ][ j - 1 ]
3534 - CB[ i ][ 2 ][ j ] * C0[ i ][ j ]
3535 - CB[ i ][ 3 ][ j ] * C0[ i ][ j + 1 ];
3539 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 2 ]
3540 - CB[ i ][ 1 ][ j ] * C0[ i ][ j - 1 ]
3541 - CB[ i ][ 2 ][ j ] * C0[ i ][ j ];
3543 DbgLv(2) <<
"TMS:RSA:ra: MovGrid: i" << i <<
"CB[0]" << CB[i][2][0]
3544 << CB[i][3][0] << CB[i][1][1] << CB[i][2][1] << CB[i][3][1];
3545 DbgLv(2) <<
"TMS:RSA:ra: MovGrid: i" << i <<
"CA[0]" << CA[i][0][0]
3546 << CA[i][1][0] << CA[i][0][0] << CA[i][1][0] << CA[i][2][0];
3548 CA[ i ][ 3 ], right_hand_side, C1[ i ],
3550 DbgLv(2) <<
"TMS:RSA:ra: MovGrid: i" << i <<
"C1[i]" << C1[i][0]
3551 << C1[i][Nx-4] << C1[i][Nx-3] << C1[i][Nx-2] << C1[i][Nx-1];
3552 DbgLv(2) <<
"TMS:RSA:ra: MovGrid: i" << i <<
"C0[i]" << C0[i][0]
3553 << C0[i][Nx-4] << C0[i][Nx-3] << C0[i][Nx-2] << C0[i][Nx-1];
3568 DbgLv(2) <<
"TMS:RSA:ra: C1[10] C1[11] C1[1k] C1[1n]"
3569 << C1[1][0] << C1[1][1] << C1[1][Nx-2] << C1[1][Nx-1];
3571 DbgLv(2) <<
"TMS:RSA:ra(2): C1[10] C1[11] C1[1k] C1[1n]"
3572 << C1[1][0] << C1[1][1] << C1[1][Nx-2] << C1[1][Nx-1];
3576 for (
int j = 0; j <
Nx; j++ )
3580 for (
int i = 0; i < Mcomp; i++ )
3582 CT1[ j ] += C1[ i ][ j ];
3583 C0[ i][ j ] = C1[ i ][ j ];
3586 CT0[ j ] = CT1[ j ];
3591 rpm_current = rpm_start + ( rpm_stop - rpm_start ) * ( kkk + 1.5 ) / Nt;
3595 double dval =
sq( rpm_current / rpm_stop );
3597 for (
int i = 0; i < Mcomp; i++ )
3599 for (
int j1 = 0; j1 < 3; j1++ )
3601 for (
int j2 = 0; j2 <
Nx; j2++ )
3603 CA[ i][ j1 ][ j2 ] = CA1[ i ][ j1 ][ j2 ] +
3604 dval * ( CA2[ i ][ j1 ][ j2 ] -
3605 CA1[ i ][ j1 ][ j2 ] );
3607 CB[ i][ j1 ][ j2 ] = CB1[ i ][ j1 ][ j2 ] +
3608 dval * ( CB2[ i ][ j1 ][ j2 ] -
3609 CB1[ i ][ j1 ][ j2 ] ) ;
3615 if ( accel || fixedGrid )
3617 for (
int i = 0; i < Mcomp; i++ )
3619 right_hand_side[ 0 ] = - CB[ i ][ 1 ][ 0 ] * C0[ i ][ 0 ]
3620 - CB[ i ][ 2 ][ 0 ] * C0[ i ][ 1 ];
3622 for (
int j = 1; j < Nx - 1; j++ )
3624 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 1 ]
3625 - CB[ i ][ 1 ][ j ] * C0[ i ][ j ]
3626 - CB[ i ][ 2 ][ j ] * C0[ i ][ j + 1 ];
3630 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 1 ]
3631 - CB[ i ][ 1 ][ j ] * C0[ i ][ j ];
3634 right_hand_side, C1[ i ], Nx );
3639 for (
int i = 0; i < Mcomp; i++ )
3642 right_hand_side[ 0 ] = - CB[ i ][ 2 ][ 0 ] * C0[ i ][ 0 ]
3643 - CB[ i ][ 3 ][ 0 ] * C0[ i ][ 1 ];
3645 right_hand_side[ 1 ] = - CB[ i ][ 1 ][ 1 ] * C0[ i ][ 0 ]
3646 - CB[ i ][ 2 ][ 1 ] * C0[ i ][ 1 ]
3647 - CB[ i ][ 3 ][ 1 ] * C0[ i ][ 2 ];
3649 for (
int j = 2; j < Nx - 1; j++ )
3651 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 2 ]
3652 - CB[ i ][ 1 ][ j ] * C0[ i ][ j - 1 ]
3653 - CB[ i ][ 2 ][ j ] * C0[ i ][ j ]
3654 - CB[ i ][ 3 ][ j ] * C0[ i ][ j + 1 ];
3658 right_hand_side[ j ] = - CB[ i ][ 0 ][ j ] * C0[ i ][ j - 2 ]
3659 - CB[ i ][ 1 ][ j ] * C0[ i ][ j - 1 ]
3660 - CB[ i ][ 2 ][ j ] * C0[ i ][ j ];
3663 CA[ i ][ 2 ], CA[ i ][ 3 ],
3664 right_hand_side, C1[ i ], Nx );
3674 for (
int j = 0; j <
Nx; j++ )
3678 for (
int i = 0; i < Mcomp; i++ )
3680 CT1[ j ] += C1[ i ][ j ];
3681 C0[ i ][ j ] = C1[ i ][ j ];
3684 CT0[ j ] = CT1[ j ];
3695 qApp->processEvents();
3698 if ( repprog && ( ( kkk + 1 ) & stepinc ) == 0 )
3708 qApp->processEvents();
3711 for (
int i = 0; i < Mcomp; i++ )
3713 C_init[ i ].
radius .clear();
3715 C_init[ i ].
radius .reserve( Nx );
3718 for (
int j = 0; j <
Nx; j++ )
3720 C_init[ i ].
radius .append(
xA[ j ] );
3742 double** cb,
double D,
double sw2 )
3748 double*** Stif = NULL;
3763 for (
int i = 1; i <
Nx - 2; i++ )
3765 vx[ 0 ] =
x [ i - 1 ];
3767 vx[ 2 ] =
x [ i + 1 ];
3769 vx[ 4 ] =
x [ i + 1 ];
3770 vx[ 5 ] =
x [ i + 2 ];
3772 vx[ 7 ] = xb[ i + 1 ];
3777 vx[ 0 ] =
x [ Nx - 3 ];
3778 vx[ 1 ] =
x [ Nx - 2 ];
3779 vx[ 2 ] =
x [ Nx - 1 ];
3780 vx[ 3 ] =
x [ Nx - 2 ];
3781 vx[ 4 ] =
x [ Nx - 1 ];
3782 vx[ 5 ] = xb[ Nx - 2 ];
3783 vx[ 6 ] = xb[ Nx - 1 ];
3788 vx[ 0 ] =
x [ Nx - 2 ];
3789 vx[ 1 ] =
x [ Nx - 1 ];
3790 vx[ 2 ] =
x [ Nx - 1 ];
3791 vx[ 3 ] = xb[ Nx - 1 ];
3796 ca[ 1 ][ 0 ] = Stif[ 0 ][ 2 ][ 0 ];
3797 ca[ 2 ][ 0 ] = Stif[ 0 ][ 3 ][ 0 ];
3798 ca[ 3 ][ 0 ] = Stif[ 0 ][ 4 ][ 0 ];
3802 cb[ 2 ][ 0 ] = Stif[ 0 ][ 0 ][ 0 ];
3803 cb[ 3 ][ 0 ] = Stif[ 0 ][ 1 ][ 0 ];
3806 ca[ 0 ][ 1 ] = Stif[ 0 ][ 2 ][ 1 ];
3807 ca[ 1 ][ 1 ] = Stif[ 0 ][ 3 ][ 1 ] + Stif[ 1 ][ 3 ][ 0 ];
3808 ca[ 2 ][ 1 ] = Stif[ 0 ][ 4 ][ 1 ] + Stif[ 1 ][ 4 ][ 0 ];
3809 ca[ 3 ][ 1 ] = Stif[ 1 ][ 5 ][ 0 ];
3812 cb[ 1 ][ 1 ] = Stif[ 0 ][ 0 ][ 1 ] + Stif[ 1 ][ 0 ][ 0 ];
3813 cb[ 2 ][ 1 ] = Stif[ 0 ][ 1 ][ 1 ] + Stif[ 1 ][ 1 ][ 0 ];
3814 cb[ 3 ][ 1 ] = Stif[ 1 ][ 2 ][ 0 ];
3817 for (
int i = 2; i < Nx - 2; i++ )
3819 ca[ 0 ][ i ] = Stif[ i - 1 ][ 3 ][ 1 ];
3820 ca[ 1 ][ i ] = Stif[ i - 1 ][ 4 ][ 1 ] + Stif[ i ][ 3 ][ 0 ];
3821 ca[ 2 ][ i ] = Stif[ i - 1 ][ 5 ][ 1 ] + Stif[ i ][ 4 ][ 0 ];
3822 ca[ 3 ][ i ] = Stif[ i ][ 5 ][ 0 ];
3824 cb[ 0 ][ i ] = Stif[ i - 1 ][ 0 ][ 1 ];
3825 cb[ 1 ][ i ] = Stif[ i - 1 ][ 1 ][ 1 ] + Stif[ i ][ 0 ][ 0 ];
3826 cb[ 2 ][ i ] = Stif[ i - 1 ][ 2 ][ 1 ] + Stif[ i ][ 1 ][ 0 ];
3827 cb[ 3 ][ i ] = Stif[ i ][ 2 ][ 0 ];
3832 ca[ 0 ][ i ] = Stif[ i - 1 ][ 3 ][ 1 ];
3833 ca[ 1 ][ i ] = Stif[ i - 1 ][ 4 ][ 1 ] + Stif[ i ][ 3 ][ 0 ];
3834 ca[ 2 ][ i ] = Stif[ i - 1 ][ 5 ][ 1 ] + Stif[ i ][ 4 ][ 0 ];
3837 cb[ 0 ][ i ] = Stif[ i - 1 ][ 0 ][ 1 ];
3838 cb[ 1 ][ i ] = Stif[ i - 1 ][ 1 ][ 1 ] + Stif[ i ][ 0 ][ 0 ];
3839 cb[ 2 ][ i ] = Stif[ i - 1 ][ 2 ][ 1 ] + Stif[ i ][ 1 ][ 0 ];
3840 cb[ 3 ][ i ] = Stif[ i ][ 2 ][ 0 ];
3844 ca[ 0 ][ i ] = Stif[ i - 1 ][ 3 ][ 1 ];
3845 ca[ 1 ][ i ] = Stif[ i - 1 ][ 4 ][ 1 ] + Stif[ i ][ 2 ][ 0 ];
3849 cb[ 0 ][ i ] = Stif[ i - 1 ][ 0 ][ 1 ];
3850 cb[ 1 ][ i ] = Stif[ i - 1 ][ 1 ][ 1 ] + Stif[ i ][ 0 ][ 0 ];
3851 cb[ 2 ][ i ] = Stif[ i - 1 ][ 2 ][ 1 ] + Stif[ i ][ 1 ][ 0 ];
3862 DbgLv(2) <<
"RSA:f nscan nconc" << nscan << nconc;
3866 fdata.
scan .resize( nscan );
3871 for (
int ii = 0; ii < nscan; ii++ )
3881 DbgLv(2) <<
"RSA:f ii c0 cn" << ii << fscan->
conc[0] << fscan->
conc[nconc-1]
3882 <<
"d0 dn" << edata.
scanData[ii].rvalues[0] << edata.
scanData[ii].rvalues[nconc-1];
3887 fscan->conc.resize( nconc );
3889 for (
int jj = 0; jj < nconc; jj++ )
3891 fscan->conc[ jj ] = edata.
value( ii, jj );
3895 for (
int jj = 0; jj < nconc; jj++ )
3897 fdata.radius[ jj ] = edata.radius( jj );
3900 DbgLv(2) <<
"RSA:f sc0 temp" << fdata.scan[0].temperature;
3901 DbgLv(2) <<
"RSA:e sc0 temp" << edata.scanData[0].temperature;
3907 int nscan = fdata.
scan.size();
3908 int nconc = fdata.
radius.size();
3911 DbgLv(2) <<
"RSA:st_md: nscan nconc" << nscan << nconc;
3912 DbgLv(2) <<
"RSA:st_md: escan econc" << escan << econc;
3914 if ( escan != nscan )
3921 for (
int ii = 0; ii < nscan; ii++ )
3934 DbgLv(2) <<
"RSA:o-f sc0 temp" << fdata.
scan[0].temperature;
3935 DbgLv(2) <<
"RSA:o-e sc0 temp" << edata.
scanData[0].temperature;