33 x =
new double [
Nv ];
38 for ( i = 0; i <
Nv; i++ )
40 x[ i ] = xl + (double)i / (
double)
Ne * ( xr - xl );
43 for ( i = 0; i <
Ne; i += 2 )
Eid[ i ] = 1 ;
44 for ( i = 1; i <
Ne; i += 2 )
Eid[ i ] = 4 ;
45 for ( i = 0; i <
Ne; i++ )
RefLev[ i ] = 0;
74 double* D20 =
new double [ Ne ];
75 double* D21 =
new double [ Ne ];
76 double* D30 =
new double [ Nv ];
77 double* D31 =
new double [ Nv ];
79 for ( i = 0; i < Ne; i++ )
81 h = ( x[ i + 1 ] - x[ i ] ) / 2;
83 D20[ i ] = ( u0[ i2 + 2 ] - 2 * u0[ i2 + 1 ] + u0[ i2 ] ) / ( h * h );
84 D21[ i ] = ( u1[ i2 + 2 ] - 2 * u1[ i2 + 1 ] + u1[ i2 ] ) / ( h * h );
88 for ( i = 1; i < Nv - 1; i++ )
90 h = ( x[ i + 1 ] - x[ i - 1 ] ) / 2;
91 D30[ i ] = ( D20[ i ] - D20[ i - 1 ] ) / h;
92 D31[ i ] = ( D21[ i ] - D21[ i - 1 ] ) / h;
97 for ( i = 1; i < Ne - 1; i++ )
99 D20[ i ] = ( D30[ i + 1 ] + D30[ i ] ) / 2;
100 D21[ i ] = ( D31[ i + 1 ] + D31[ i ] ) / 2;
105 D20[ Ne - 1 ] = D20[ Ne - 2 ];
106 D21[ Ne - 1 ] = D21[ Ne - 2 ];
109 for ( i = 0; i < Ne; i++ )
111 MeshDen[ i ] = pow( 1 + MonScale
112 * ( fabs( D20[ i ] ) + fabs( D21[ i ] ) ), 0.33333 );
114 if ( MeshDen[ i ] > MonCutoff ) MeshDen[ i ] = MonCutoff;
117 Smoothing( Ne, MeshDen, SmoothingWt, SmoothingCyl );
142 for ( s = 0; s < Cycle; s++ )
148 y[ 0 ] = Wt * y3 + Wt1 * y2;
150 for ( i = 1; i < n - 1; i++ )
156 y[ i ] = Wt * y2 + Wt2 * ( y1 + y3 );
159 y[ n - 1 ] = Wt * y2 + Wt1 * y3;
182 for ( i = 0; i < Ne; i++ ) Mark[ i ] = 0;
186 for ( i = 0; i < Ne - 1; i++ )
188 if ( RefLev[ i ] == RefLev[ i + 1 ] &&
189 ( Eid[ i ] / 2 ) == ( Eid[ i + 1 ] / 2 ) &&
190 ( x[ i + 1 ] - x[ i ] ) * MeshDen[ i ] < alpha &&
191 ( x[ i + 2 ] - x[ i + 1 ] ) * MeshDen[ i + 1 ] < alpha )
200 if ( Ne1 == Ne )
return;
204 Eid1 =
new int [ Ne1 ];
205 RefLev1 =
new int [ Ne1 ];
206 MeshDen1 =
new double [ Ne1 ];
207 x1 =
new double [ Nv1 ];
213 for ( i = 0; i < Ne; i++ )
215 if ( Mark[ i ] == 1 && Mark[ i + 1 ] == 1 )
217 x1[ i1 + 1 ] = x[ i + 2 ];
218 Eid1[ i1 ] = Eid[ i ] / 2;
219 RefLev1[ i1 ] = RefLev[ i ] - 1;
220 MeshDen1[ i1 ] = ( MeshDen[ i ] + MeshDen[ i + 1 ] ) / 2;
227 x1[ i1 + 1 ] = x[ i + 1 ];
228 Eid1[ i1 ] = Eid[ i ];
229 RefLev1[ i1 ] = RefLev[ i ];
230 MeshDen1[ i1 ] = MeshDen[ i ];
248 Mark =
new int [ Ne1 ];
275 for ( k = 0; k < Ne; k++ )
277 if ( ( x[ k + 1 ] - x[ k ] ) * MeshDen[ k ] > beta &&
278 RefLev[ k ] < MaxRefLev )
285 for ( k = 0; k < Ne - 1; k++ )
287 int rldiff = RefLev[ k ] - RefLev[ k + 1 ];
292 else if ( rldiff > 1 )
298 for ( k = 0; k < Ne; k++ )
299 if ( Mark[ k ] == 1 ) Ne1++;
301 if ( Ne1 == Ne )
return;
305 x1 =
new double [ Nv1 ];
306 Eid1 =
new int [ Ne1 ];
307 RefLev1 =
new int [ Ne1 ];
308 MeshDen1 =
new double [ Ne1 ];
313 for ( k = 0; k < Ne; k++ )
315 if ( Mark[ k ] == 0 )
317 x1[ ke + 1 ] = x[ k + 1 ];
318 Eid1[ ke ] = Eid[ k ];
319 RefLev1[ ke ] = RefLev[ k ];
320 MeshDen1[ ke ] = MeshDen[ k ];
326 x1[ ke + 1 ] = ( x[ k ] + x[ k + 1 ] ) / 2;
327 Eid1[ ke ] = Eid[ k ] * 2;
328 RefLev1[ ke ] = RefLev[ k ] + 1;
329 MeshDen1[ ke ] = MeshDen[ k ];
331 x1[ ke + 2 ] = x[ k + 1 ];
332 Eid1[ ke + 1 ] = Eid1[ ke ] + 1;
333 RefLev1[ ke + 1 ] = RefLev1[ ke ];
334 MeshDen1[ ke + 1 ] = MeshDen[ k ];
351 Mark =
new int [ Ne1 ];
362 const double sqrt3 = sqrt( 3.0 );
363 const double onethird = 1.0 / 3.0;
367 double beta = 6.0 * pow( ErrTol / sqrt3, onethird );
370 double alpha = beta / 4;
373 ComputeMeshDen_D3( u0, u1 );
374 Smoothing ( Ne, MeshDen, 0.7, 4 );
402 m2 = x[ 0 ] * x[ 0 ];
403 b2 = x[ Ne ] * x[ Ne ];
408 for ( t = 0; t < 1; t = t + 0.1 )
410 u0 =
new double [ 2 * Nv - 1 ];
411 u1 =
new double [ 2 * Nv - 1 ];
413 nu = pow( nu1, t ) * pow( nu0, 1 - t );
415 for ( j = 0; j < Nv; j++ )
417 x2 = x[ j ] * x[ j ];
418 u0[ 2 * j ] = exp( nu * ( m2 - x2 ) ) * ( nu * nu * m2 );
419 u1[ 2 * j ] = exp( nu * ( x2 - b2 ) ) * ( nu * nu * b2 );
422 for ( j = 0; j < Ne; j++ )
424 x2 = ( x[ j ] + x[ j + 1 ] ) / 2;
426 u0[ 2 * j + 1 ] = exp( nu * ( m2 - x2 ) ) * ( nu * nu * m2 );
427 u1[ 2 * j + 1 ] = exp( nu * ( x2 - b2 ) ) * ( nu * nu * b2 );
430 RefineMesh( u0, u1, 1.e-4 );
445 sa_data = *asim_data;
446 DbgLv(2) <<
"SaltD: sa_data avg.temp." << sa_data.average_temperature();
449 Nt = sa_data.scanCount();
450 Nx = sa_data.pointCount();
457 conc0 = ( conc0 < 0.01 ) ?
459 conc0 = ( conc0 < 0.01 ) ? 2.5 : conc0;
466 simparms.radial_resolution =
467 ( sa_data.radius( Nx - 1 ) - sa_data.radius( 0 ) ) / (
double)( Nx - 1 );
468 simparms.firstScanIsConcentration =
false;
469 DbgLv(2) <<
"SaltD: Nx" << Nx <<
"r0 rn ri" << sa_data.radius( 0 )
470 << sa_data.radius( Nx - 1 ) << simparms.radial_resolution;
478 for (
int ii = 0; ii < Nt; ii++ )
479 for (
int jj = 0; jj < Nx; jj++ )
480 sa_data.setValue( ii, jj, 0.0 );
486 DbgLv(2) <<
"SaltD:fem: m b s D rpm" << simparms.meniscus << simparms.bottom
488 << simparms.speed_step[0].rotorspeed;
489 DbgLv(2) <<
"SaltD: (0)Nt Nx" << Nt << Nx <<
"temperature" << sa_data.scanData[0].temperature;
491 qDebug() <<
"SaltD: model";
493 qDebug() <<
"SaltD: simparms:";
498 DbgLv(2) <<
"SaltD: (2)Nx" << Nx <<
"r0 r1 rm rn" << sa_data.radius(0)
499 << sa_data.radius(1) << sa_data.radius(Nx-2) << sa_data.radius(Nx-1);
503 Nt = sa_data.scanCount();
504 Nx = sa_data.pointCount();
506 DbgLv(2) <<
"SaltD: (3)Nx" << Nx <<
"r0 r1 rm rn" << sa_data.radius(0)
507 << sa_data.radius(1) << sa_data.radius(Nx-2) << sa_data.radius(Nx-1);
508 DbgLv(2) <<
"SaltD: Nt Nx" << Nt << Nx <<
"temp" << sa_data.scanData[0].temperature;
509 DbgLv(2) <<
"SaltD: sa sc0 sec omg" << sa_data.scanData[0].seconds
510 << sa_data.scanData[0].omega2t;
512 const double maxsalt = 1e100;
513 const double minsalt = -9e99;
514 const double minsala = 1e-100;
515 const double minsaln = -1e-100;
517 for (
int ii = 0; ii < Nt; ii++ )
519 for (
int jj = 0; jj < Nx; jj++ )
521 double saltv = sa_data.value( ii, jj );
522 double salta = qAbs( saltv );
523 if(ii<2 && (jj+3)>Nx)
524 DbgLv(2) <<
"SaltD: ii jj" << ii << jj <<
"saltv salta" << saltv << salta;
526 if ( saltv != saltv )
531 saltv = sa_data.value( ii, jj - 1 );
535 saltv = saltv > 0 ? maxsalt : minsalt;
537 sa_data.setValue( ii, jj, saltv );
538 DbgLv(2) <<
"SaltD: salt *NaN* ii jj adj-saltv" << ii << jj << saltv;
541 else if ( salta > maxsalt || saltv < minsalt )
544 salta = qMin( maxsalt, qMax( minsalt, salta ) );
545 saltv = saltv > 0 ? salta : -salta;
546 sa_data.setValue( ii, jj, saltv );
549 else if ( salta < minsala )
552 saltv = saltv > 0 ? minsala : minsaln;
553 sa_data.setValue( ii, jj, saltv );
557 DbgLv(2) <<
"SaltD: salt ampl limit changes" << nchg;
562 xsVec .fill( 0.0, Nx );
563 Cs0Vec.fill( 0.0, Nx );
564 Cs1Vec.fill( 0.0, Nx );
574 dir.mkpath( safile );
575 safile = safile +
"/salt_data.RA.1.S.260.auc";
581 for (
int jj = 0; jj < Nx; jj++ )
583 xs[ jj ] = sa_data.radius( jj );
585 DbgLv(2) <<
"SaltD: Nx" << Nx <<
"xs sme" << xs[0] << xs[1] << xs[2]
586 << xs[Nx/2-1] << xs[Nx/2] << xs[Nx-2+1] << xs[Nx-3] << xs[Nx-2] << xs[Nx-1];
601 t0 = sa_data.scanData[ 0 ].seconds;
602 t1 = sa_data.scanData[ 1 ].seconds;
604 Nt = sa_data.scanCount() - 2;
606 for (
int j = 0; j < Nx; j++ )
608 Cs0[ j ] = sa_data.value( 0, j );
609 Cs1[ j ] = sa_data.value( 1, j );
613 DbgLv(2) <<
"initSalt: t0 t1" << t0 << t1;
614 DbgLv(2) <<
"initSalt: xs Cs0 Cs1 j" << xs[0] << Cs0[0] << Cs1[0] << 0;
615 DbgLv(2) <<
"initSalt: xs Cs0 Cs1 j" << xs[k] << Cs0[k] << Cs1[k] << k;
616 DbgLv(2) <<
"initSalt: xs Cs0 Cs1 j" << xs[n] << Cs0[n] << Cs1[n] << n;
623 DbgLv(2) <<
"SaltD:ntrp: N t t1 Nt Nx" << N << t << t1 << Nt << Nx
624 <<
"Cs0N Cs1N" << Cs0[Nx-1] << Cs1[Nx-1];
626 while ( ( t1 < t ) && ( Nt > 0 ) )
633 t1 = sa_data.scanData[ scn ].seconds;
635 for (
int j = 0; j < Nx; j++ )
636 Cs1[ j ] = sa_data.value( scn, j );
640 DbgLv(3) <<
"SaltD:ntrp: 0 t 1" << t0 << t << t1 <<
" N s" << Nt << scn;
642 DbgLv(2) <<
"SaltD:ntrp: t0 t t1" << t0 << t << t1 <<
" Nt scn" << Nt << scn;
645 double et1 = ( t - t0 ) / ( t1 - t0 );
646 et1 = ( et1 > 1.0 ) ? 1.0 : et1;
647 et1 = ( et1 < 0.0 ) ? 0.0 : et1;
648 double et0 = 1.0 - et1;
655 for (
int j = 0; j < N; j++ )
658 while ( xj > xs[ k ] && k < Lx ) k++;
662 double xik = ( xj - xs[ m ] ) / ( xs[ k ] - xs[ m ] );
663 xik = ( xik > 1.0 ) ? 1.0 : xik;
664 xik = ( xik < 0.0 ) ? 0.0 : xik;
665 double xim = 1.0 - xik;
667 Csalt[ j ] = et0 * ( xim * Cs0[ m ] + xik * Cs0[ k ] )
668 + et1 * ( xim * Cs1[ m ] + xik * Cs1[ k ] );
674 DbgLv(2) <<
"SaltD:ntrp: j,k,xj,xsm,xsk" << j << k << xj << xs[m] << xs[k]
675 <<
"xim xik" << xim << xik <<
"Csaltj" << Csalt[j] << csj;
680 DbgLv(2) <<
"SaltD:ntrp: scn" << scn <<
"N Nx" << N << Nx
681 <<
"Csalt0 CsaltM CsaltN" << Csalt[0] << Csalt[N/2] << Csalt[N-1];
682 DbgLv(2) <<
"SaltD:ntrp: Cs00 Cs0M Cs0N" << Cs0[0] << Cs0[Nx/2] << Cs0[Nx-1];
683 DbgLv(2) <<
"SaltD:ntrp: Cs10 Cs1M Cs1N" << Cs1[0] << Cs1[Nx/2] << Cs1[Nx-1];
700 double stretch = coefs[ 0 ] * speed + coefs[ 1 ] *
sq( speed );
720 for (
int ii = 1; ii < 6; ii++ )
756 qApp->processEvents();
770 qApp->processEvents();
798 double dt = log(
param_b / param_m )
801 int ntcc = (int)( total_t / dt ) + 1;
813 int ntc = (int)( solut_t / dt ) + 1;
815 QVector< double > conc0;
816 QVector< double > conc1;
817 QVector< double > rads;
821 qApp->processEvents();
832 ntc = (int)( solut_t / dt ) + 1;
836 <<
" ntcc ntc nts ncs nicase" << ntcc << ntc << nts << ncs <<
NonIdealCaseNo;
837 DbgLv(2) <<
"LAsc: tot_t dt sol_t" << total_t << dt << solut_t;
840 if ( NonIdealCaseNo == 2 )
846 DbgLv(2) <<
"NonIdeal2: new saltdata comp_x" <<
comp_x;
871 if ( NonIdealCaseNo == 1 )
879 else if ( NonIdealCaseNo == 2 )
884 else if ( NonIdealCaseNo == 3 )
912 x0 =
new double [ N0 ];
913 u0 =
new double [ N0u ];
916 x1 =
new double [ N1 ];
917 u1 =
new double [ N1u ];
919 for (
int jj = 0; jj < N0; jj++ )
923 x0[ jj ] = msh->
x[ jj ];
925 u0[ kk ] = msh->
x[ jj ] * sig_conc;
929 for (
int kk = 1; kk < N0u - 1; kk+=2 )
931 u0[ kk ] = ( u0[ kk - 1 ] + u0[ kk + 1 ] ) * 0.5;
934 DbgLv(2) <<
"LAsc: u0 0,1,2...,N" << u0[0] << u0[1] << u0[2]
935 << u0[N0u-3] << u0[N0u-2] << u0[N0u-1];
937 for (
int jj = 0; jj < ncs; jj++ )
941 DbgLv(2) <<
"LAsc: r0 rn ncs rsiz" << rads[0] << rads[ncs-1]
944 const double u0max = 1e+100;
945 const double u0min = -u0max;
947 for (
int jj = 0; jj < N0u; jj++ )
949 u0[ jj ] = qMin( u0max, qMax( u0min, u0[ jj ] ) );
950 u1[ jj ] = qMin( u0max, qMax( u0min, u1[ jj ] ) );
952 DbgLv(2) <<
"LAsc: u0 0,1,2...,N" << u0[0] << u0[1] << u0[2]
953 << u0[N0u-3] << u0[N0u-2] << u0[N0u-1];
958 ktinc = qMax( 2, ( ( nts + 5000 ) / 10000 ) );
961 DbgLv(2) <<
"LAsc: nts ktinc" << nts << ktinc;
969 if ( ! dir.exists( tmpDir ) ) dir.mkpath( tmpDir );
971 QFile ftto( tmpDir +
"/tt0-ufvm" );
974 if ( ! ftto.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
975 qDebug() <<
"*ERROR* Unable to open tt0-ufvm";
977 QTextStream tso( &ftto );
983 for ( jt = 0, kt = 0; jt < ntc; jt++ )
986 t0 = dt * (double)jt;
990 if (
dbg_level > 0 && ( ( jt / 10 ) * 10 ) == jt )
992 u_ttl =
IntQs( x0, u0, 0, -1, N0-2, 1 );
993 DbgLv(2) <<
"LAsc: jt,kt,t0=" << jt << kt << t0 <<
" Nv=" << N0
994 <<
"u_ttl=" << u_ttl;
995 DbgLv(2) <<
"LAsc: u0 0,1,2...,N" << u0[0] << u0[1] << u0[2]
996 << u0[N0u-3] << u0[N0u-2] << u0[N0u-1];
997 tso << QString().sprintf(
"%12.5e %d %12.5e\n", t0, N0, u_ttl );
998 for (
int j=0; j<N0; j++ )
999 tso << QString().sprintf(
"%10.6e \n", x0[j] );
1000 tso << QString().sprintf(
"\n" );
1001 for (
int j=0; j<N0u; j++ )
1002 tso << QString().sprintf(
"%15.7e \n", u0[j] );
1003 tso << QString().sprintf(
"\n\n" );
1005 ktime1+=timer.restart();
1007 u1p0 =
new double [ N0u ];
1009 ktime2+=timer.restart();
1015 ktime3+=timer.restart();
1019 u1p =
new double [ N1u ];
1022 x1 =
new double [ N1 ];
1024 for (
int jj = 0; jj < N1; jj++ )
1025 x1[ jj ] = msh->
x[ jj ];
1027 ProjectQ( N0-1, x0, u1p0, N1-1, x1, u1p );
1030 u1 =
new double [ N1u ];
1032 ktime4+=timer.restart();
1040 ktime4+=timer.restart();
1044 ktime5+=timer.restart();
1047 if ( ts >= t0 && ts <= t1 )
1049 double f0 = ( t1 - ts ) / ( t1 - t0 );
1050 double f1 = ( ts - t0 ) / ( t1 - t0 );
1052 DbgLv(2) <<
"LAsc: call qI t0 ts t1" << t0 << ts << t1;
1058 DbgLv(2) <<
"LAsc: x0[0] x0[H] x0[N]" << x0[0] << x0[N0/2] << x0[N0-1];
1059 DbgLv(2) <<
"LAsc: x1[0] x1[H] x1[N]" << x1[0] << x1[N1/2] << x1[N1-1];
1060 DbgLv(2) <<
"LAsc: r[0] r[H] r[N]" << rads[0] << rads[ncs/2] << rads[ncs-1];
1061 DbgLv(2) <<
"LAsc: u0[0] u0[H] u0[N]" << u0[0] << u0[N0u/2] << u0[N1u-1];
1062 DbgLv(2) <<
"LAsc: u1[0] u1[H] u1[N]" << u1[0] << u1[N1u/2] << u1[N1u-1];
1063 DbgLv(2) <<
"LAsc: c0[0] c0[H] c0[N]"
1064 << conc0[0] << conc0[ncs/2] << conc0[ncs-1];
1065 DbgLv(2) <<
"LAsc: c1[0] c1[H] c1[N]"
1066 << conc1[0] << conc1[ncs/2] << conc1[ncs-1];
1067 double utt0 =
IntQs( x0, u0, 0, -1, N0-2, 1 );
1068 double utt1 =
IntQs( x1, u1, 0, -1, N1-2, 1 );
1069 DbgLv(2) <<
"LAsc: utt0 utt1" << utt0 << utt1;
1076 for (
int jj = 0; jj < ncs; jj++ )
1078 af_data.
scan[ kt ].conc[ jj ] += ( conc0[ jj ] * f0 +
1087 DbgLv(2) <<
"LAsc: t=" << ts <<
"Cmax=" << cmax <<
" r=" << rmax;
1094 if ( ( ( kt / ktinc ) * ktinc ) == kt || ( kt + 1 ) == nts )
1097 DbgLv(2) <<
"LAsc: istep" << istep;
1098 qApp->processEvents();
1108 qApp->processEvents();
1114 qApp->processEvents();
1123 qApp->processEvents();
1141 double cimn = 9e+14;
1146 for (
int ii = 0; ii <
af_data.
scan.size(); ii++ )
1151 for (
int jj = 1; jj <
af_data.
scan[ ii ].conc.size(); jj++ )
1154 csum += ( ( cval + pval ) * dltr );
1160 DbgLv(2) <<
"Scan" << ii + 1 <<
" Integral" << csum;
1161 cimn = ( cimn < csum ) ? cimn : csum;
1162 cimx = ( cimx > csum ) ? cimx : csum;
1167 double cidf = cimx - cimn;
1168 double cidp = (double)( qRound( 10000.0 * cidf / ciav ) ) / 100.0;
1169 DbgLv(2) <<
" Integral Min Max Mean" << cimn << cimx << ciav;
1170 DbgLv(2) <<
" ( range of" << cidf <<
"=" << cidp <<
" percent of mean )";
1178 ktime6+=timer.elapsed();
1180 << ktime1 << ktime2 << ktime3 << ktime4 << ktime5 << ktime6;
1206 DbgLv(2) <<
"NonIdeal2: create saltdata";
1211 DbgLv(2) <<
"NonIdeal2: initSalt comp_x" <<
comp_x;
1245 double *x0,
double *u0,
double *u1 )
1267 double *x0,
double *u0,
int M1,
double *x1,
double *u1p,
double *u1 )
1270 int* ke =
new int [ Ng ];
1271 double* MemDouble =
new double [ 12 * Ng + 15 ];
1272 double* flux_p[ 3 ];
1274 double dt2 = dt * 0.5;
1275 double* xt = MemDouble;
1276 double* xi = xt + Ng;
1277 double* xg0 = xi + Ng;
1278 double* xg1 = xg0 + Ng;
1279 double* ug0 = xg1 + Ng;
1280 double* ug1 = ug0 + Ng;
1281 double* Sv = ug1 + Ng;
1282 double* Dv = Sv + Ng;
1283 double* flux_u = Dv + Ng;
1284 flux_p[ 0 ] = flux_u + Ng;
1285 flux_p[ 1 ] = flux_p[ 0 ] + Ng;
1286 flux_p[ 2 ] = flux_p[ 1 ] + Ng;
1287 double* phi = flux_p[ 2 ] + Ng;
1288 double* phiL = phi + 3;
1289 double* phiR = phiL + 6;
1302 for (
int j = 0; j < Ng; j += 2 )
1305 xg1[ j ] = x1[ j2 ] * 0.75 + x1[ j2 + 1 ] * 0.25;
1306 xg1[ j + 1 ] = x1[ j2 ] * 0.25 + x1[ j2 + 1 ] * 0.75;
1307 ug1[ j ] = ( 3. * u1p[ j ] + 6. * u1p[ j + 1 ] - u1p[ j + 2 ] ) / 8.;
1308 ug1[ j + 1 ] = ( 3. * u1p[ j + 2 ] + 6. * u1p[ j + 1 ] - u1p[ j ] ) / 8.;
1311 AdjustSD( t + dt, Ng, xg1, ug1, Sv, Dv );
1312 ktim1+=timer.restart();
1313 DbgLv(2) <<
" xg1 0 1 M Nm N" << xg1[0] << xg1[1] << xg1[Ng/2]
1314 << xg1[Ng-2] << xg1[Ng-1];
1315 DbgLv(2) <<
" Sv 0 1 M Nm N" << Sv[0] << Sv[1] << Sv[Ng/2]
1316 << Sv[Ng-2] << Sv[Ng-1];
1319 for (
int j = 0; j < Ng; j++ )
1323 * exp( -qAbs( sw2 ) * dt / 2 );
1327 xt[ j ] = ( xg1[ j ] - xg0[ j ] ) / dt;
1329 DbgLv(2) <<
" xg0 0 1 M Nm N" << xg0[0] << xg0[1] << xg0[Ng/2]
1330 << xg0[Ng-2] << xg0[Ng-1] <<
"Ng" << Ng;
1335 for (
int j = 0; j < Ng; j++ )
1339 while ( xg0[ j ] < bl && ( j + 1 ) < Ng )
1345 double br = qMin( xg0[ j ],
param_b );
1347 for (
int jm = 0; jm < cnt; jm++ )
1349 xg0[ j - jm ] = br - (double)jm / (
double)cnt * ( br - bl );
1350 xt[ j - jm ] = ( xg1[ j - jm ] - xg0[ j - jm ] ) / dt;
1355 DbgLv(2) <<
" xg0 0 1 M Nm N" << xg0[0] << xg0[1] << xg0[Ng/2]
1356 << xg0[Ng-2] << xg0[Ng-1] <<
"Ng" << Ng;
1357 ktim2+=timer.restart();
1363 for (
int j = 0; j < Ng; j++ )
1366 double h = 0.5 * ( x1[ j2 + 1 ] - x1[ j2 ] );
1368 for (
int jm = 0; jm < 3; jm++ )
1370 flux_p[ jm ][ j ] = ( xt[ j ] - Sv[ j ] *
param_w2 * xg1[ j ]
1371 - Dv[ j ] / xg1[ j ] ) * phiL[ jm ]
1372 + Dv[ j ] * phiL[ jm + 3 ] / h;
1376 for (
int jm = 0; jm < 3; jm++ )
1378 flux_p[ jm ][ j ] = ( xt[ j ] - Sv[ j ] *
param_w2 * xg1[ j ]
1379 - Dv[ j ] / xg1[ j ] ) * phiR[ jm ]
1380 + Dv[ j ] * phiR[ jm + 3 ] / h;
1389 for (
int j = 0; j < Ng; j++ )
1393 int j2 = 2 * ke[ j ];
1394 ug0[ j ] = u0[ j2 ] * phi[ 0 ]
1395 + u0[ j2 + 1 ] * phi[ 1 ]
1396 + u0[ j2 + 2 ] * phi[ 2 ];
1400 ktim3+=timer.restart();
1401 AdjustSD( t, Ng, xg0, ug0, Sv, Dv );
1402 ktim4+=timer.restart();
1407 double* ux =
new double [ M0 + 1 ];
1409 for (
int j = 1; j < M0; j++ )
1412 ux[ j ] = ( ( u0[ j2 - 2 ] - 4. * u0[ j2 - 1 ] + 3. * u0[ j2 ] )
1413 / ( x0[ j ] - x0[ j - 1 ] )
1414 - ( 3. * u0[ j2 ] - 4. * u0[ j2 + 1 ] + u0[ j2 + 2 ] )
1415 / ( x0[ j + 1 ] - x0[ j ] ) ) / 2.;
1419 ux[ 0 ] = -( 3. * u0[ 0 ] - 4. * u0[ 1 ] + u0[ 2 ] )
1420 / ( x0[ 1 ] - x0[ 0 ] ) / 2.;
1421 ux[ M0 ] = ( u0[ j2 - 2 ] - 4. * u0[ j2 - 1 ] + 3. * u0[ j2 ] )
1422 / ( x0[ M0 ] - x0[ M0 - 1 ] ) / 2.;
1425 for (
int j = 0; j < Ng; j++ )
1427 double wt = ( 1. - xi[ j ] ) / 2.;
1428 double uxs = ux[ ke[ j ] ] * wt
1429 + ux[ ke[ j ] + 1 ] * ( 1. - wt );
1431 if ( ( xg0[ j ] <= (
param_m + 1.e-14 ) ) ||
1432 ( xg0[ j ] >= (
param_b - 1.e-14 ) ) )
1439 flux_u[ j ] = -( Sv[ j ] *
param_w2 * xg0[ j ] + Dv[ j ] / xg0[ j ] )
1440 * ug0[ j ] + Dv[ j ] * uxs + xt[ j ] * ug0[ j ];
1449 double** Mtx =
new double* [ Ng + 1 ];
1450 double* rhs =
new double [ Ng + 1 ];
1451 for (
int i = 0; i <= Ng; i++ )
1452 Mtx[ i ] =
new double [ 5 ];
1454 ktim5+=timer.restart();
1456 for (
int i = 1; i < Ng; i += 2 )
1458 int k = ( i - 1 ) / 2;
1459 double h = 0.5 * ( x1[ k + 1 ] - x1[ k ] );
1461 Mtx[ i ][ 1 ] = h / 24.
1462 + dt2 * ( flux_p[ 0 ][ i - 1 ] - flux_p[ 0 ][ i ] );
1463 Mtx[ i ][ 2 ] = h * 22. / 24.
1464 + dt2 * ( flux_p[ 1 ][ i - 1 ] - flux_p[ 1 ][ i ] );
1465 Mtx[ i ][ 3 ] = h / 24.
1466 + dt2 * ( flux_p[ 2 ][ i - 1 ] - flux_p[ 2 ][ i ] );
1470 for (
int i = 2; i < Ng; i += 2 )
1474 double h = 0.5 * ( x1[ k ] - x1[ k - 1 ] );
1475 Mtx[ i ][ 0 ] =-h / 24. + dt2 * flux_p[ 0 ][ i - 1 ];
1476 Mtx[ i ][ 1 ] = h * 5. / 24. + dt2 * flux_p[ 1 ][ i - 1 ];
1477 Mtx[ i ][ 2 ] = h * 8. / 24. + dt2 * flux_p[ 2 ][ i - 1 ];
1479 h = 0.5 * ( x1[ k + 1 ] - x1[ k ] );
1480 Mtx[ i ][ 2 ] += h * 8. / 24. - dt2 * flux_p[ 0 ][ i ];
1481 Mtx[ i ][ 3 ] = h * 5. / 24. - dt2 * flux_p[ 1 ][ i ];
1482 Mtx[ i ][ 4 ] =-h / 24. - dt2 * flux_p[ 2 ][ i ];
1486 double h = 0.5 * ( x1[ 1 ] - x1[ 0 ] );
1487 Mtx[ i ][ 2 ] = h * 8. / 24. - dt2 * flux_p[ 0 ][ 0 ];
1488 Mtx[ i ][ 3 ] = h * 5. / 24. - dt2 * flux_p[ 1 ][ 0 ];
1489 Mtx[ i ][ 4 ] =-h / 24. - dt2 * flux_p[ 2 ][ 0 ];
1492 h = 0.5 * ( x1[ M1 ] - x1[ M1 - 1 ] );
1493 Mtx[ i ][ 0 ] =-h / 24. + dt2 * flux_p[ 0 ][ i - 1 ];
1494 Mtx[ i ][ 1 ] = h * 5. / 24. + dt2 * flux_p[ 1 ][ i - 1 ];
1495 Mtx[ i ][ 2 ] = h * 8. / 24. + dt2 * flux_p[ 2 ][ i - 1 ];
1497 ktim6+=timer.restart();
1501 rhs[ i ] =
IntQs( x0, u0, 0, -1., ke[ i ], xi[ i ] )
1502 + dt2 * flux_u[ i ];
1504 for (
int i = 1; i < Ng; i++ )
1506 rhs[i] =
IntQs( x0, u0, ke[ i - 1 ], xi[ i - 1 ], ke[ i ], xi[ i ] )
1507 + dt2 * ( flux_u[ i ] - flux_u[i - 1 ] );
1511 rhs[ i ] =
IntQs( x0, u0, ke[ i - 1 ], xi[ i - 1 ], M0 - 1, 1. )
1512 + dt2 * ( - flux_u[ i - 1 ] );
1514 ktim7+=timer.restart();
1516 ktim8+=timer.restart();
1518 for (
int i = 0; i <= Ng; i++ )
1526 delete [] MemDouble;
1527 DbgLv(2) <<
" Diff_C times 1-8" << ktim1 << ktim2 << ktim3 << ktim4
1528 << ktim5 << ktim6 << ktim7 << ktim8;
1545 int *ke,
double *xi )
1549 for (
int j = 0; j < Ns; j++ )
1551 while ( xs[ j ] > x0[ eix ] && eix < ( N0 - 1 ) ) eix ++;
1554 xi[ j ] = ( xs[ j ] - x0[ eix - 1 ] )
1555 / ( x0[ eix ] - x0[ eix - 1 ] ) * 2. - 1.;
1567 double *s_adj,
double *D_adj )
1569 const double Tempt = 293.15;
1570 const double vbar_w = 0.72;
1571 const double rho_w = 0.998234;
1573 QVector< double > CsaltVec( Nv );
1590 for ( jj = 0; jj < Nv; jj++ )
1598 for ( jj = 0; jj < Nv; jj++ )
1600 s_adj[ jj ] =
param_s / ( 1. +
sigma * u[ jj ] / x[ jj ] );
1601 D_adj[ jj ] =
param_D / ( 1. +
delta * u[ jj ] / x[ jj ] );
1609 CsaltVec.resize( Nv );
1610 Csalt = CsaltVec.data();
1612 DbgLv(2) <<
"NonIdeal2: ntrp Salt";
1614 kst1+=timer.restart();
1625 double sA =
param_s * 1.00194 / ( 1.0 - vbar * rho_w );
1626 double dA =
param_D * Tempt * 1.00194 / 293.15;
1632 for ( jj = 0; jj < Nv; jj++ )
1663 visc = qAbs( visc );
1665 s_adj[ jj ] = sA * ( 1.0 - vbar * rho ) / visc;
1667 D_adj[ jj ] = dA / visc;
1670 if(jj==0){rho0=rho;vis0=visc;cms0=Cm;}
1671 if(jj==Nv/2){rhom=rho;vism=visc;cmsm=Cm;}
1672 if(jj==Nv-1){rhoe=rho;vise=visc;cmse=Cm;}
1674 DbgLv(2) <<
"AdjSD: Csalt0 CsaltN Cm" << Csalt[0] << Csalt[Nv-1] << Cm;
1675 DbgLv(2) <<
"AdjSD: sadj 0 m n" << s_adj[0] << s_adj[Nv/2] << s_adj[Nv-1];
1676 DbgLv(2) <<
"AdjSD: Dadj 0 m n" << D_adj[0] << D_adj[Nv/2] << D_adj[Nv-1];
1677 DbgLv(2) <<
"AdjSD: rho 0,m,e" << rho0 << rhom << rhoe;
1678 DbgLv(2) <<
"AdjSD: visc 0,m,e" << vis0 << vism << vise;
1679 DbgLv(2) <<
"AdjSD: Cm 0,m,e" << cms0 << cmsm << cmse;
1680 DbgLv(2) <<
"AdjSD: vbar vbar_w rho_w" << vbar << vbar_w << rho_w;
1681 DbgLv(2) <<
"AdjSD: cmrt cm^2 cm^3 cm^4" << Cmrt << Cmsq << Cmcu << Cmqu;
1682 DbgLv(2) <<
"AdjSD: d_coeff[0] rho" <<
d_coeff[0] << rhoe;
1683 DbgLv(2) <<
"AdjSD: v_coeff[0] vis" <<
v_coeff[0] << vise;
1686 kst2+=timer.restart();
1687 DbgLv(3) <<
"AdjSD: times 1 2" << kst1 << kst2;
1696 double sA = 1.0 - vbar * rho_w;
1698 for (
int jj = 0; jj < Nv; jj++ )
1701 / ( 1.0 - factn * ( x[ jj ] * x[ jj ] - msq ) );
1702 double beta = ( 1.0 - phip * rho ) / sA;
1703 s_adj[ jj ] =
param_s * alpha * beta;
1704 D_adj[ jj ] =
param_D * alpha;
1706 DbgLv(3) <<
"AdjSD: compr dens" << compressib <<
density;
1707 DbgLv(3) <<
"AdjSD: factn msq sa" << factn << msq << sA;
1708 DbgLv(3) <<
"AdjSD: sadj 0 m n" << s_adj[0] << s_adj[Nv/2] << s_adj[Nv-1];
1709 DbgLv(3) <<
"AdjSD: Dadj 0 m n" << D_adj[0] << D_adj[Nv/2] << D_adj[Nv-1];
1714 qDebug(
"invalid case number for non-ideal sedimentation" );
1736 y[ 0 ] = 0.5 * ( x2 - x );
1738 y[ 2 ] = 0.5 * ( x2 + x );
1745 y[ 0 ] = 0.5 * ( x2 - x );
1747 y[ 2 ] = 0.5 * ( x2 + x );
1758 double x3 = x * x2 / 6.0;
1761 y[ 1 ] = x - x3 * 2.0;
1781 intgrl = ( x[ 1 ] - x[ 0 ] ) / 2. * (
1782 u[ 0 ] * ( phib[ 0 ] - phia[ 0 ] ) +
1783 u[ 1 ] * ( phib[ 1 ] - phia[ 1 ] ) +
1784 u[ 2 ] * ( phib[ 2 ] - phia[ 2 ] ) );
1796 int ka,
double xia,
int kb,
double xib )
1802 intgrl =
IntQ( x + ka, u + 2 * ka, xia, xib );
1807 intgrl =
IntQ( x + ka, u + 2 * ka, xia, 1. );
1808 intgrl +=
IntQ( x + kb, u + 2 * kb, -1., xib );
1810 for (
int k = ka + 1; k <= kb - 1; k++ )
1813 intgrl += ( x[ k + 1 ] - x[ k ] )
1814 * ( u[ k2 ] + u[ k2 + 2 ] + 4. * u[ k2 + 1 ] ) / 6.;
1830 int M1,
double *x1,
double *u1 )
1835 int* ke =
new int [ M1 + 1 ];
1836 double* xi =
new double [ M1 + 1 ];
1838 LocateStar( M0 + 1, x0, M1 + 1, x1, ke, xi );
1841 for (
int j = 0; j <= M1; j++ )
1845 int idx = 2 * ke[ j ];
1846 u1[ 2 * j ] = phi[ 0 ] * u0[ idx ]
1847 + phi[ 1 ] * u0[ idx + 1 ]
1848 + phi[ 2 ] * u0[ idx + 2 ];
1851 for (
int j = 0; j < M1; j++ )
1855 intgrl =
IntQs( x0, u0, ke[ j ], xi[ j ], ke[ j + 1 ], xi[ j + 1 ] );
1857 u1[ j2 + 1 ] = 1.5 * intgrl / ( x1[ j + 1 ] - x1[ j ] )
1858 - 0.25 * ( u1[ j2 ] + u1[ j2 + 2 ] );
1877 for (
int j = 0; j < m - 1; j += 2 )
1882 double multi = -A[ j1 ][ 1 ] / A[ j ][ 2 ];
1883 A[ j1 ][ 2 ] += multi * A[ j ][ 3 ];
1884 A[ j1 ][ 3 ] += multi * A[ j ][ 4 ];
1885 b[ j1 ] += multi * b[ j ];
1887 multi = -A[ j2 ][ 0 ] / A[ j ][ 2 ];
1888 A[ j2 ][ 1 ] += multi * A[ j ][ 3 ];
1889 A[ j2 ][ 2 ] += multi * A[ j ][ 4 ];
1890 b[ j2 ] += multi * b[ j ];
1892 multi = -A[ j2 ][ 1 ] / A[ j1 ][ 2 ];
1893 A[ j2 ][ 2 ] += multi * A[ j1 ][ 3 ];
1894 b[ j2 ] += multi * b[ j1 ];
1898 x[ m ] = b[ m ] / A[ m ][ 2 ];
1900 for (
int j = m - 1; j > 0; j -= 2 )
1905 x[ j ] = ( b[ j ] - A[ j ][ 3 ] * x[ jp ] )
1908 x[ jm ] = ( b[ jm ] - A[ jm ][ 3 ] * x[ j ]
1909 - A[ jm ][ 4 ] * x[ jp ] )
1952 QVector< double >& xout, QVector< double >& cout )
1954 int nout = xout.size();
1956 double xv = xout[ 0 ];
1961 double x1 = x0[ 0 ];
1962 double x3 = x0[ 1 ];
1963 double x2 = ( x1 + x3 ) * 0.5;
1964 double y1 = u0[ 0 ];
1965 double y2 = u0[ 1 ];
1966 double y3 = u0[ 2 ];
1968 cout.resize( nout );
1974 while ( xv > x3 && ii < N0 )
1983 x2 = ( x1 + x3 ) * 0.5;
1990 (( ( xv - x2 ) * ( xv - x3 ) ) / ( ( x1 - x2 ) * ( x1 - x3 ) )) * y1 +
1991 (( ( xv - x1 ) * ( xv - x3 ) ) / ( ( x2 - x1 ) * ( x2 - x3 ) )) * y2 +
1992 (( ( xv - x1 ) * ( xv - x2 ) ) / ( ( x3 - x1 ) * ( x3 - x2 ) )) * y3;
1998 cout[ kk++ ] = yv / xv;
2011 int nconc = edata.
xvalues.size();
2014 fdata.
scan .resize( nscan );
2015 fdata.
radius.resize( nconc );
2017 for (
int ii = 0; ii < nscan; ii++ )
2026 fscan->
conc.resize( nconc );
2030 fscan->
conc.fill( 0.0 );
2035 for (
int jj = 0; jj < nconc; jj++ )
2037 fscan->
conc[ ii ] = edata.
value( ii, jj );
2042 for (
int jj = 0; jj < nconc; jj++ )
2049 fscan->conc.fill( 0.0, nconc );
2052 fscan->conc = edata.
scanData[ ii ].rvalues;
2054 fdata.radius = edata.xvalues;
2055 int nn=fdata.radius.size() - 1;
2057 DbgLv(2) <<
"LdDa: n r0 rm rn" << nn << fdata.radius[0] << fdata.radius[mm] << fdata.radius[nn];
2065 int nscan = fdata.
scan.size();
2066 int nconc = fdata.
radius.size();
2073 for (
int ii = 0; ii < nscan; ii++ )
2090 qApp->processEvents();
2097 qApp->processEvents();