15 QVector< US_DataIO::EditedData >& dataList,
16 QVector< ScanEdit >& scedits,
17 QVector< EqScanFit >& scanfits,
20 dataList ( dataList ),
22 scanfits ( scanfits ),
31 QList< double >& ds_vbar20s, QList< double >&aud_pars )
38 for (
int ii = 0; ii <
scanfits.size(); ii++ )
40 if (
scanfits[ ii ].scanFit && jdx < 0 )
47 DbgLv(1) <<
"EM:IP: jdx" << jdx <<
"modelx" <<
modelx <<
"update_mw" << update_mw;
48 if ( jdx < 0 )
return;
51 double portion = molecwt;
87 for (
int ii = 0; ii <
scanfits.size(); ii++ )
89 if ( !
scanfits[ ii ].scanFit )
continue;
91 portion = exp(
scanfits[ ii ].amp_vals[ 0 ] ) * 0.5;
92 scanfits[ ii ].amp_vals[ 0 ] = log( portion * 0.7 );
93 scanfits[ ii ].amp_vals[ 1 ] = log( portion * 0.3 );
128 DbgLv(1) <<
"EM:IP: C2: total" << total;
129 for (
int ii = 0; ii <
scanfits.size(); ii++ )
131 if ( !
scanfits[ ii ].scanFit )
continue;
133 portion = exp(
scanfits[ ii ].amp_vals[ 0 ] ) / 3.0;
134 scanfits[ ii ].amp_vals[ 0 ] = log( portion * 0.6 );
135 scanfits[ ii ].amp_vals[ 1 ] = log( portion * 0.3 );
136 scanfits[ ii ].amp_vals[ 2 ] = log( portion * 0.1 );
144 mwll = aud_pars[ 1 ];
145 mwul = aud_pars[ 2 ];
146 uvbar = aud_pars[ 3 ];
147 uvbar = uvbar > 0.0 ? uvbar : ds_vbar20s[ jdx ];
149 mwinc = ( mwul - mwll ) / ( dnumc - 1.0 );
150 tempa = log( 1.0e-7 / dnumc );
152 for (
int ii = 0; ii <
scanfits.size(); ii++ )
154 if ( !
scanfits[ ii ].scanFit )
continue;
158 scanfits[ ii ].amp_vals[ jj ] = tempa;
160 scanfits[ ii ].amp_vals[ jj ] * 0.2;
210 for (
int ii = 0; ii <
scanfits.size(); ii++ )
212 if ( !
scanfits[ ii ].scanFit )
continue;
214 portion = exp(
scanfits[ ii ].amp_vals[ 0 ] ) / 2.0;
215 scanfits[ ii ].amp_vals[ 0 ] = log( portion );
246 for (
int ii = 0; ii <
scanfits.size(); ii++ )
248 if ( !
scanfits[ ii ].scanFit )
continue;
250 portion = exp(
scanfits[ ii ].amp_vals[ 0 ] ) / 2.0;
251 scanfits[ ii ].amp_vals[ 0 ] = log( portion );
268 for (
int ii = 0; ii <
scanfits.size(); ii++ )
270 if ( !
scanfits[ ii ].scanFit )
continue;
272 scanfits[ ii ].amp_vals[ 1 ] = -1.0e4;
273 scanfits[ ii ].amp_rngs[ 1 ] = 1.0e-3;
287 for (
int ii = 0; ii <
scanfits.size(); ii++ )
289 if ( !
scanfits[ ii ].scanFit )
continue;
291 scanfits[ ii ].amp_vals[ 1 ] = -1.0e4;
292 scanfits[ ii ].amp_rngs[ 1 ] = 1.0e-3;
304 for (
int ii = 0; ii <
scanfits.size(); ii++ )
306 if ( !
scanfits[ ii ].scanFit )
continue;
308 portion = exp(
scanfits[ ii ].amp_vals[ 0 ] ) / 2.0;
309 scanfits[ ii ].amp_vals[ 0 ] = log( portion * 0.7 );
310 scanfits[ ii ].amp_vals[ 1 ] = log( portion * 0.3 );
326 for (
int ii = 0; ii <
scanfits.size(); ii++ )
328 if ( !
scanfits[ ii ].scanFit )
continue;
330 scanfits[ ii ].amp_vals[ 1 ] = -1.0e4;
331 scanfits[ ii ].amp_rngs[ 1 ] = 1.0e-3;
336 double aaa[ 12 ];
double ppp[ 16 ];
337 for (
int ii=0;ii<12;ii++ ) aaa[ii]=(
double)( ii+1 );
338 for (
int ii=0;ii<16;ii++ ) ppp[ii]=0.0;
339 double* aa[3];
double* pp[4];
340 aa[0]=aaa;aa[1]=aaa+4;aa[2]=aaa+8;
341 pp[0]=ppp;pp[1]=ppp+4;pp[2]=ppp+8;pp[3]=ppp+12;
342 DbgLv(2) <<
"AA: " << aaa[0] << aaa[1] << aaa[2] << aaa[3];
343 DbgLv(2) <<
"AA: " << aaa[4] << aaa[5] << aaa[6] << aaa[7];
344 DbgLv(2) <<
"AA: " << aaa[8] << aaa[9] << aaa[10] << aaa[11];
346 DbgLv(2) <<
"==US_Matrix::tmm( aa, pp, 4, 3, false )==";
347 DbgLv(2) <<
" PP: " << ppp[0] << ppp[1] << ppp[2] << ppp[3];
348 DbgLv(2) <<
" PP: " << ppp[4] << ppp[5] << ppp[6] << ppp[7];
349 DbgLv(2) <<
" PP: " << ppp[8] << ppp[9] << ppp[10] << ppp[11];
350 DbgLv(2) <<
" PP: " << ppp[12] << ppp[13] << ppp[14] << ppp[15];
352 DbgLv(2) <<
"==US_Matrix::tmm( aa, pp, 4, 3, true )==";
353 DbgLv(2) <<
" PP: " << ppp[0] << ppp[1] << ppp[2] << ppp[3];
354 DbgLv(2) <<
" PP: " << ppp[4] << ppp[5] << ppp[6] << ppp[7];
355 DbgLv(2) <<
" PP: " << ppp[8] << ppp[9] << ppp[10] << ppp[11];
356 DbgLv(2) <<
" PP: " << ppp[12] << ppp[13] << ppp[14] << ppp[15];
379 for (
int ii = 0; ii <
scanfits.size(); ii++ )
381 if ( !
scanfits[ ii ].scanFit )
continue;
409 for (
int ii = 0; ii <
scanfits.size(); ii++ )
411 if ( !
scanfits[ ii ].scanFit )
continue;
433 v_BB .fill( 0.0, nfpars );
438 m_info .fill( 0, nfpars );
445 int nfpsq = nfpars *
nfpars;
447 v_info .fill( 0.0, nfpsq );
459 for (
int ii = 0; ii <
scanfits.size(); ii++ )
461 if ( !
scanfits[ ii ].scanFit )
continue;
475 for (
int jj = 0; jj <
nspts; jj++ )
478 DbgLv(1) <<
"EM:IF: matr fill 1 complete";
482 DbgLv(1) <<
"EM:IF: g map Forw complete";
489 for (
int ii = 0; ii <
ntpts; ii++ )
494 DbgLv(1) <<
"EM:IF: jacobi fill complete";
496 for (
int ii = 0; ii <
nfpars; ii++ )
503 DbgLv(1) <<
"EM:IF: inf/trns fill complete";
585 for (
int ii = 0; ii <
scanfits.size(); ii++ )
587 if ( !
scanfits[ ii ].scanFit )
continue;
596 vguess[ jpx ] = scnf->
amp_vals[ jj ];
617 DbgLv(1) <<
"EM:gmF: jpx" << jpx;
637 for (
int ii = 0; ii <
scanfits.size(); ii++ )
639 if ( !
scanfits[ ii ].scanFit )
continue;
646 scnf->
amp_vals[ jj ] = vguess[ jpx++ ];
665 if ( ! scnf->
scanFit )
continue;
679 int mcomp =
max( ncomps, 4 );
682 QVector< double > v_ufunc( mcomp );
683 QVector< double > v_vbar ( mcomp );
684 QVector< double > v_buoy ( mcomp );
694 for (
int ii = 0; ii <
scanfits.size(); ii++ )
698 if ( ! scnf->
scanFit )
continue;
701 double xm_sq =
sq( scnf->
xvs[ jstx ] );
702 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
703 double tempera = scnf->
tempera;
704 double density = scnf->
density;
705 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
707 for (
int kk = 0; kk < ncomps; kk++ )
711 v_buoy[ kk ] = ( 1.0 - v_vbar[ kk ] * density );
714 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
716 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
718 for (
int kk = 0; kk < ncomps; kk++ )
720 double buoy = v_buoy[ kk ];
723 double ufunc = exp( ampv + dconst * mwv * buoy * xv );
724 v_ufunc[ kk ] = ufunc;
728 = dconst * xv * buoy * ufunc;
732 = (-1.0 ) * dconst * mwv * xv * ufunc * density;
755 double stoich1 = (double)(
modelx - 2 );
756 double stoiexp = stoich1 - 1.0;
759 for (
int ii = 0; ii <
scanfits.size(); ii++ )
763 if ( ! scnf->
scanFit )
continue;
766 double xm_sq =
sq( scnf->
xvs[ jstx ] );
767 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
768 double tempera = scnf->
tempera;
769 double density = scnf->
density;
770 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
771 double ODcorrec = log( stoich1 / pow( scnf->
extincts[ 0 ]
775 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
776 double buoy = v_buoy[ 0 ];
778 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
780 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
783 double ufunc0 = exp( ampv + dconst * mwv * buoy * xv );
785 ODcorrec + dconst * stoich1 * mwv * buoy * ufunc0 );
786 v_ufunc[ 0 ] = ufunc0;
787 v_ufunc[ 1 ] = ufunc1;
788 double dcoeff = dconst * xv * buoy;
792 = dcoeff * ufunc0 + dcoeff * ufunc1 * stoich1;
794 dcoeff = dconst * mwv * xv * density;
798 = (-1.0 ) * dcoeff * ufunc0 - dcoeff * ufunc1 * stoich1;
802 = ufunc0 + ufunc1 * stoich1;
821 double stoich1 = 2.0;
822 double stoich2 = (double)(
modelx - 8 );
825 double stoiexp = stoich1 - 1.0;
826 double stoiex2 = stoich2 - 1.0;
828 for (
int ii = 0; ii <
scanfits.size(); ii++ )
832 if ( ! scnf->
scanFit )
continue;
835 double xm_sq =
sq( scnf->
xvs[ jstx ] );
836 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
837 double tempera = scnf->
tempera;
838 double density = scnf->
density;
839 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
840 double ODcorec1 = log( stoich1 / pow( scnf->
extincts[ 0 ]
842 double ODcorec2 = log( stoich2 / pow( scnf->
extincts[ 0 ]
846 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
847 double buoy = v_buoy[ 0 ];
849 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
851 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
854 double ufunc0 = exp( ampv + dconst * mwv * buoy * xv );
856 ODcorec1 + dconst * stoich1 * mwv * buoy * xv );
858 ODcorec2 + dconst * stoich2 * mwv * buoy * xv );
859 v_ufunc[ 0 ] = ufunc0;
860 v_ufunc[ 1 ] = ufunc1;
861 v_ufunc[ 2 ] = ufunc2;
862 double dcoeff = dconst * xv * buoy;
866 = dcoeff * ufunc0 * + dcoeff * ufunc1 * stoich1
867 + dcoeff * ufunc2 * stoich2;
869 dcoeff = dconst * mwv * xv * density;
873 = (-1.0 ) * dcoeff * ufunc0 - dcoeff * ufunc1 * stoich1
874 - dcoeff * ufunc2 * stoich2;
878 = ufunc0 + ufunc1 * stoich1 + ufunc2 * stoich2;
900 double mw_ab = mwv0 + mwv1;
902 for (
int ii = 0; ii <
scanfits.size(); ii++ )
906 if ( ! scnf->
scanFit )
continue;
909 double xm_sq =
sq( scnf->
xvs[ jstx ] );
910 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
911 double tempera = scnf->
tempera;
912 double density = scnf->
density;
913 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
914 double extinc0 = scnf->
extincts[ 0 ];
915 double extinc1 = scnf->
extincts[ 1 ];
916 double ODcorrec = log( ( extinc0 + extinc1 ) /
917 ( scnf->
pathlen * extinc0 * extinc1 ) );
922 v_vbar[ 2 ] = ( v_vbar[ 0 ] * mwv0 + v_vbar[ 1 ] * mwv1 )
924 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
925 v_buoy[ 1 ] = ( 1.0 - v_vbar[ 1 ] * density );
926 v_buoy[ 2 ] = ( 1.0 - v_vbar[ 2 ] * density );
927 double buoy0 = v_buoy[ 0 ];
928 double buoy1 = v_buoy[ 1 ];
929 double buoy2 = v_buoy[ 2 ];
931 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
933 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
936 double constx = dconst * xv;
937 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
938 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
940 ODcorrec + constx * mw_ab * buoy2 );
941 v_ufunc[ 0 ] = ufunc0;
942 v_ufunc[ 1 ] = ufunc1;
943 v_ufunc[ 2 ] = ufunc2;
947 = constx * buoy0 * ufunc0 +
949 constx * ( v_vbar[ 2 ] * density -
950 v_vbar[ 0 ] * density ) + ufunc2;
954 = (-1.0 ) * constx * mwv1 * density * ufunc1
955 - constx * mwv1 * density * ufunc2;
977 double mw_ab = mwv0 + mwv1;
979 double stoiexp = stoich1 - 1.0;
981 for (
int ii = 0; ii <
scanfits.size(); ii++ )
985 if ( ! scnf->
scanFit )
continue;
988 double xm_sq =
sq( scnf->
xvs[ jstx ] );
989 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
990 double tempera = scnf->
tempera;
991 double density = scnf->
density;
992 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
993 double extinc0 = scnf->
extincts[ 0 ];
994 double extinc1 = scnf->
extincts[ 1 ];
995 double ODcorec1 = log( ( extinc0 + extinc0 ) /
996 ( scnf->
pathlen * extinc0 * extinc1 ) );
997 double ODcorec2 = log( stoich1 /
998 pow( scnf->
pathlen * extinc0, stoiexp ) );
1003 v_vbar[ 2 ] = ( v_vbar[ 0 ] * mwv0 + v_vbar[ 1 ] * mwv1 )
1005 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
1006 v_buoy[ 1 ] = ( 1.0 - v_vbar[ 1 ] * density );
1007 v_buoy[ 2 ] = ( 1.0 - v_vbar[ 2 ] * density );
1008 double buoy0 = v_buoy[ 0 ];
1009 double buoy1 = v_buoy[ 1 ];
1010 double buoy2 = v_buoy[ 2 ];
1012 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1014 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1015 double ampv0 = scnf->
amp_vals[ 0 ];
1016 double ampv1 = scnf->
amp_vals[ 1 ];
1017 double constx = dconst * xv;
1018 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1019 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
1021 ODcorec1 + constx * mw_ab * buoy2 );
1022 double ufunc3 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
1023 ODcorec2 + constx * stoich1 * mw_ab * buoy0 );
1024 v_ufunc[ 0 ] = ufunc0;
1025 v_ufunc[ 1 ] = ufunc1;
1026 v_ufunc[ 2 ] = ufunc2;
1027 v_ufunc[ 3 ] = ufunc3;
1031 = constx * buoy0 * ufunc0 +
1033 constx * ( v_vbar[ 2 ] * density -
1034 v_vbar[ 0 ] * density ) +
1035 constx * buoy0 * ufunc3 * stoich1 + ufunc2;
1039 = constx * buoy1 * ufunc1 +
1041 constx * ( v_vbar[ 2 ] * density -
1042 v_vbar[ 1 ] * density ) + ufunc2;
1046 = (-1.0 ) * constx * mwv0 * density * ufunc0
1047 - constx * mwv0 * density * ufunc3 * stoich1
1048 - constx * mwv0 * density * ufunc2;
1052 = (-1.0 ) * constx * mwv1 * density * ufunc1
1053 - constx * mwv1 * density * ufunc2;
1057 = ufunc0 + ufunc3 * stoich1 + ufunc2;
1083 double stoiexp = stoich1 - 1.0;
1085 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1089 if ( ! scnf->
scanFit )
continue;
1092 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1093 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1094 double tempera = scnf->
tempera;
1095 double density = scnf->
density;
1096 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1097 double extinc0 = scnf->
extincts[ 0 ];
1098 double ODcorec1 = log( stoich1 /
1099 pow( extinc0 * scnf->
pathlen, stoiexp ) );
1102 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
1103 double buoy0 = v_buoy[ 0 ];
1105 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1107 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1108 double ampv0 = scnf->
amp_vals[ 0 ];
1109 double ampv1 = scnf->
amp_vals[ 1 ];
1110 double constx = dconst * xv;
1111 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1112 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
1113 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
1114 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
1115 v_ufunc[ 0 ] = ufunc0;
1116 v_ufunc[ 1 ] = ufunc1;
1117 v_ufunc[ 2 ] = ufunc2;
1121 = constx * buoy0 * ufunc0 +
1122 constx * buoy0 * ufunc1 +
1123 constx * buoy0 * ufunc2 * stoich1;
1127 = (-1.0 ) * constx * mwv0 * density * ufunc0
1128 - constx * mwv0 * density * ufunc1
1129 - constx * mwv0 * density * ufunc2 * stoich1;
1133 = ufunc0 + stoich1 * ufunc2;
1156 double stoiexp = stoich1 - 1.0;
1158 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1162 if ( ! scnf->
scanFit )
continue;
1165 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1166 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1167 double tempera = scnf->
tempera;
1168 double density = scnf->
density;
1169 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1170 double extinc0 = scnf->
extincts[ 0 ];
1171 double ODcorec1 = log( stoich1 /
1172 pow( scnf->
pathlen * extinc0, stoiexp ) );
1175 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
1176 double buoy0 = v_buoy[ 0 ];
1178 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1180 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1181 double ampv0 = scnf->
amp_vals[ 0 ];
1182 double ampv1 = scnf->
amp_vals[ 1 ];
1183 double constx = dconst * xv;
1184 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1185 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
1186 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
1187 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
1188 v_ufunc[ 0 ] = ufunc0;
1189 v_ufunc[ 1 ] = ufunc1;
1190 v_ufunc[ 2 ] = ufunc2;
1194 = constx * buoy0 * ufunc0 +
1195 constx * buoy0 * ufunc1 * stoich1 +
1196 constx * buoy0 * ufunc2 * stoich1;
1200 = (-1.0 ) * constx * mwv0 * density * ufunc0
1201 - constx * mwv0 * density * ufunc1 * stoich1
1202 - constx * mwv0 * density * ufunc2 * stoich1;
1206 = ufunc0 + ufunc2 * stoich1;
1228 double mwv1 = mwv0 * stoich1;
1230 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1234 if ( ! scnf->
scanFit )
continue;
1237 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1238 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1239 double tempera = scnf->
tempera;
1240 double density = scnf->
density;
1241 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1244 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
1245 double buoy0 = v_buoy[ 0 ];
1246 double ampv0 = scnf->
amp_vals[ 0 ];
1247 double ampv1 = scnf->
amp_vals[ 1 ];
1249 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1251 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1252 double constx = dconst * xv;
1253 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1254 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
1255 v_ufunc[ 0 ] = ufunc0;
1256 v_ufunc[ 1 ] = ufunc1;
1260 = constx * buoy0 * ufunc0 +
1261 constx * buoy0 * ufunc1 * stoich1;
1265 = (-1.0 ) * constx * mwv0 * density * ufunc0
1266 - constx * mwv0 * density * ufunc1 * stoich1;
1289 double stoiexp = stoich1 - 1.0;
1291 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1295 if ( ! scnf->
scanFit )
continue;
1298 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1299 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1300 double tempera = scnf->
tempera;
1301 double density = scnf->
density;
1302 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1303 double extinc0 = scnf->
extincts[ 0 ];
1304 double ODcorec1 = log( stoich1 /
1305 pow( scnf->
pathlen * extinc0, stoiexp ) );
1310 v_buoy[ 0 ] = ( 1.0 - v_vbar[ 0 ] * density );
1311 v_buoy[ 1 ] = ( 1.0 - v_vbar[ 1 ] * density );
1312 double buoy0 = v_buoy[ 0 ];
1313 double buoy1 = v_buoy[ 1 ];
1314 double ampv0 = scnf->
amp_vals[ 0 ];
1315 double ampv1 = scnf->
amp_vals[ 1 ];
1317 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1319 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1320 double constx = dconst * xv;
1321 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1322 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
1323 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
1324 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
1325 v_ufunc[ 0 ] = ufunc0;
1326 v_ufunc[ 1 ] = ufunc1;
1327 v_ufunc[ 2 ] = ufunc2;
1331 = constx * buoy0 * ufunc0 +
1332 constx * buoy0 * ufunc2 * stoich1;
1336 = constx * buoy1 * ufunc1;
1340 = (-1.0 ) * constx * mwv0 * density * ufunc0
1341 - constx * mwv0 * density * ufunc2;
1345 = ufunc0 + ufunc2 * stoich1;
1373 double chi_sq = 0.0;
1374 double x_temp = 0.0;
1381 QVector< double* > mmat;
1382 QVector< double > mvec;
1383 QVector< double > yrvec;
1384 QVector< double > covec;
1385 QVector< QPointF > xyvec;
1388 for (
int jes = 0; jes <
scanfits.size(); jes++ )
1389 points =
max( points,
scanfits[ jes ].xvs.size() );
1391 DbgLv(1) <<
"ctPar: max points" << points;
1392 mmat .fill( NULL, points );
1393 mvec .fill( 0.0, points * 2 );
1394 yrvec.fill( 0.0, points );
1395 covec.fill( 0.0, 2 );
1396 xyvec.fill( QPointF( 0.0, 0.0 ), points );
1398 for (
int jes = 0; jes <
scanfits.size(); jes++ )
1407 int stopn = stopx + 1;
1408 double fstemp = scnf->
tempera;
1409 double fsdens = scnf->
density;
1411 double fsrpm = scnf->
rpm;
1416 solution.
vbar = fsvbar;
1417 solution.
vbar20 = fsvbar;
1423 omega_s =
sq( fsrpm * M_PI / 30.0 );
1424 dconst = ( buoyancy_tb * omega_s ) / ( 2.0 *
R * (
K0 + fstemp ) );
1425 x_temp = scnf->
xvs[ strtx ];
1426 x_temp =
sq( x_temp );
1430 for (
int jxy = strtx; jxy < stopn; jxy++ )
1432 x_val = scnf->
xvs[ jxy ];
1433 y_val = scnf->
yvs[ jxy ];
1434 x_val = dconst * (
sq( x_val ) - x_temp );
1435 xyvec[ points++ ] = QPointF( x_val, y_val );
1438 double** MM = mmat .data();
1439 double* yraw = yrvec.data();
1440 double* mvls = mvec .data();
1441 double* coeffs = covec.data();
1444 for (
int ii = 0; ii < points; ii++ )
1446 x_val = xyvec[ ii ].x();
1447 y_val = xyvec[ ii ].y();
1450 mmat[ ii ] = mvls + kk;
1452 mvec[ kk++ ] = exp( mwval * x_val );
1454 yrvec[ ii ] = y_val;
1465 for (
int ii = 0; ii < points; ii++ )
1467 double chi = yrvec[ ii ] - ( coeffs[ 0 ] +
1468 coeffs[ 1 ] * exp( mwval * xyvec[ ii ].x() ) );
1469 chi_sq +=
sq( chi );
1478 DbgLv(1) <<
"ctPar: ** jes" << jes <<
"coeffs1 " << covec[1];
1484 scnf->
amp_vals[ 0 ] = log( coeffs[ 1 ] );
1489 DbgLv(1) <<
"ctPar: coeffs 0 1 " << covec[0] << covec[1];
1490 DbgLv(1) <<
"ctPar:chi_sq" << chi_sq;
1503 double residm = 0.0;
1504 double old_f0 = 0.0;
1505 double old_f1 = 0.0;
1506 double old_f2 = 0.0;
1509 double x2 = 10000.0;
1511 double toler = 100.0;
1520 DbgLv(1) <<
"MinRes:iter" << iter <<
" f0 f1 f2" << f0 << f1 << f2;
1523 if (
dataList[ 0 ].dataType ==
"RA" )
1529 while ( f0 >= errmx || f0 < 0.0 ||
1530 f1 >= errmx || f1 < 0.0 ||
1531 f2 >= errmx || f2 < 0.0 )
1542 DbgLv(1) <<
" x1 x2" << x1 << x2 <<
" f1 f2" << f1 << f2 <<
"errmx" << errmx;
1544 bool check_flag =
true;
1546 while ( check_flag )
1553 if ( ( qAbs( f2 - old_f2 ) <
dflt_min ) &&
1554 ( qAbs( f1 - old_f1 ) <
dflt_min ) &&
1555 ( qAbs( f0 - old_f0 ) <
dflt_min ) )
1561 DbgLv(1) <<
" old f0 f1 f2" << f0 << f1 << f2;
1563 DbgLv(1) <<
" test-0a";
1564 bool t1 = ( qAbs( f2 - f0 ) <
dflt_min );
1565 bool t2 = ( qAbs( f1 - f0 ) <
dflt_min );
1566 bool t3 = ( f0 > f1 );
1567 bool t4 = ( qAbs( f2 - f1 ) <
dflt_min );
1568 bool t12 = t1 && t2;
1569 bool t34 = t3 && t4;
1570 DbgLv(1) <<
" t-0a t1-4" << t1 << t2 << t3 << t4 <<
"t12,34" << t12 << t34;
1571 if ( ( ( qAbs( f2 - f0 ) <
dflt_min ) &&
1572 ( qAbs( f1 - f0 ) <
dflt_min ) ) ||
1577 DbgLv(1) <<
" test-0b";
1583 DbgLv(1) <<
" test-0c";
1584 if ( ( ( qAbs( f0 - f1 ) <
dflt_min ) &&
1585 ( qAbs( f1 - f2 ) <
dflt_min ) ) ||
1590 DbgLv(1) <<
" test-0 x0 x1 x2" << x0 << x1 << x2;
1591 if ( ( f0 > f1 ) && ( f2 > f1 ) )
1593 DbgLv(1) <<
" update-0 f0 f1 f2" << f0 << f1 << f2;
1598 if ( ( f2 > f1 && f1 > f0 ) ||
1599 ( f1 > f0 && f1 > f2 ) ||
1600 ( f1 == f2 && f1 > f0 ) )
1604 x1 = ( x2 + x1 ) * 0.5;
1606 DbgLv(1) <<
" update-1 f0 f1 f2" << f0 << f1 << f2;
1609 else if ( ( f0 > f1 ) && ( f1 > f2 ) )
1615 x2 = x2 + ( ( pow( 2.0, (
double)( iter + 2 ) ) ) + hh );
1617 DbgLv(1) <<
" update-2 f0 f1 f2" << f0 << f1 << f2;
1621 DbgLv(1) <<
"MinRes: iter" << iter <<
" f0 f1 f2" << f0 << f1 << f2;
1624 DbgLv(1) <<
"MinRes: iter" << iter <<
" f0 f1 f2" << f0 << f1 << f2;
1625 x1 = ( x0 + x2 ) * 0.5;
1651 if ( qAbs( f0 - ( f1 * 2.0 ) + f2 ) <
dflt_min )
1657 xmin = x1 + ( hh * ( f0 - f2 ) ) / ( 2.0 * ( f0 - f1 * 2.0 + f2 ) );
1679 DbgLv(1) <<
" update-9 x0 x2 f0 f2" << x0 << x2 << f0 << f2;
1695 double residual = 0.0;
1697 for (
int ii = 0; ii <
ntpts; ii++ )
1702 residual +=
sq( delta );
1709 residual /= (double)ntpts;
1712 qDebug() <<
"CalcResid: resid" << residual <<
"delta 0,1,m,n"
1729 int mcomp =
max( ncomps, 4 );
1730 QVector< double > v_vbar ( mcomp );
1731 QVector< double > v_buoy ( mcomp );
1741 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1745 if ( ! scnf->
scanFit )
continue;
1748 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1749 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1750 double tempera = scnf->
tempera;
1751 double density = scnf->
density;
1752 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1754 for (
int kk = 0; kk < ncomps; kk++ )
1758 v_buoy[ kk ] = ( 1.0 - v_vbar[ kk ] * density );
1763 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1765 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1766 double cguess = 0.0;
1768 for (
int kk = 0; kk < ncomps; kk++ )
1770 double buoy = v_buoy[ kk ];
1772 double ampv = scnf->
amp_vals[ kk ];
1773 double ufunc = exp( ampv + dconst * mwv * buoy * xv );
1781 lncr2[ jdx ][ jlx++ ] = log( cguess );
1799 double stoich1 = (double)(
modelx - 2 );
1800 double stoiexp = stoich1 - 1.0;
1803 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1807 if ( ! scnf->
scanFit )
continue;
1810 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1811 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1812 double tempera = scnf->
tempera;
1813 double density = scnf->
density;
1814 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1815 double ODcorrec = log( stoich1 / pow( scnf->
extincts[ 0 ]
1816 * scnf->
pathlen , stoiexp ) );
1819 double buoy = ( 1.0 - v_vbar[ 0 ] * density );
1822 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1824 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1827 double ufunc0 = exp( ampv + dconst * mwv * buoy * xv );
1829 ODcorrec + dconst * stoich1 * mwv * buoy * ufunc0 );
1830 double cguess = ufunc0 + ufunc1;
1836 lncr2[ jdx ][ jlx++ ] = log( cguess );
1851 double stoich1 = 2.0;
1852 double stoich2 = (double)(
modelx - 8 );
1855 double stoiexp = stoich1 - 1.0;
1856 double stoiex2 = stoich2 - 1.0;
1858 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1862 if ( ! scnf->
scanFit )
continue;
1865 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1866 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1867 double tempera = scnf->
tempera;
1868 double density = scnf->
density;
1869 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1870 double ODcorec1 = log( stoich1 / pow( scnf->
extincts[ 0 ]
1871 * scnf->
pathlen , stoiexp ) );
1872 double ODcorec2 = log( stoich2 / pow( scnf->
extincts[ 0 ]
1873 * scnf->
pathlen , stoiex2 ) );
1876 double buoy = ( 1.0 - v_vbar[ 0 ] * density );
1879 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1881 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1884 double ufunc0 = exp( ampv + dconst * mwv * buoy * xv );
1886 ODcorec1 + dconst * stoich1 * mwv * buoy * xv );
1888 ODcorec2 + dconst * stoich2 * mwv * buoy * xv );
1889 double cguess = ufunc0 + ufunc1 + ufunc2;
1895 lncr2[ jdx ][ jlx++ ] = log( cguess );
1910 double mw_ab = mwv0 + mwv1;
1912 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1916 if ( ! scnf->
scanFit )
continue;
1919 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1920 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1921 double tempera = scnf->
tempera;
1922 double density = scnf->
density;
1923 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1924 double extinc0 = scnf->
extincts[ 0 ];
1925 double extinc1 = scnf->
extincts[ 1 ];
1926 double ODcorrec = log( ( extinc0 + extinc1 ) /
1927 ( scnf->
pathlen * extinc0 * extinc1 ) );
1932 v_vbar[ 2 ] = ( v_vbar[ 0 ] * mwv0 + v_vbar[ 1 ] * mwv1 )
1934 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
1935 double buoy1 = ( 1.0 - v_vbar[ 1 ] * density );
1936 double buoy2 = ( 1.0 - v_vbar[ 2 ] * density );
1939 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
1941 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
1942 double ampv0 = scnf->
amp_vals[ 0 ];
1943 double ampv1 = scnf->
amp_vals[ 1 ];
1944 double constx = dconst * xv;
1945 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
1946 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
1948 ODcorrec + constx * mw_ab * buoy2 );
1949 double cguess = ufunc0 + ufunc1 + ufunc2;
1955 lncr2[ jdx ][ jlx++ ] = log( cguess );
1970 double mw_ab = mwv0 + mwv1;
1972 double stoiexp = stoich1 - 1.0;
1974 for (
int ii = 0; ii <
scanfits.size(); ii++ )
1978 if ( ! scnf->
scanFit )
continue;
1981 double xm_sq =
sq( scnf->
xvs[ jstx ] );
1982 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
1983 double tempera = scnf->
tempera;
1984 double density = scnf->
density;
1985 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
1986 double extinc0 = scnf->
extincts[ 0 ];
1987 double extinc1 = scnf->
extincts[ 1 ];
1988 double ODcorec1 = log( ( extinc0 + extinc0 ) /
1989 ( scnf->
pathlen * extinc0 * extinc1 ) );
1990 double ODcorec2 = log( stoich1 /
1991 pow( scnf->
pathlen * extinc0, stoiexp ) );
1996 v_vbar[ 2 ] = ( v_vbar[ 0 ] * mwv0 + v_vbar[ 1 ] * mwv1 )
1998 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
1999 double buoy1 = ( 1.0 - v_vbar[ 1 ] * density );
2000 double buoy2 = ( 1.0 - v_vbar[ 2 ] * density );
2003 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
2005 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
2006 double ampv0 = scnf->
amp_vals[ 0 ];
2007 double ampv1 = scnf->
amp_vals[ 1 ];
2008 double constx = dconst * xv;
2009 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
2010 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
2012 ODcorec1 + constx * mw_ab * buoy2 );
2013 double ufunc3 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
2014 ODcorec2 + constx * stoich1 * mw_ab * buoy0 );
2015 double cguess = ufunc0 + ufunc1 + ufunc2 + ufunc3;
2020 lncr2[ jdx ][ jlx++ ] = log( cguess );
2035 double stoiexp = stoich1 - 1.0;
2037 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2041 if ( ! scnf->
scanFit )
continue;
2044 double xm_sq =
sq( scnf->
xvs[ jstx ] );
2045 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2046 double tempera = scnf->
tempera;
2047 double density = scnf->
density;
2048 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2049 double extinc0 = scnf->
extincts[ 0 ];
2050 double ODcorec1 = log( stoich1 /
2051 pow( extinc0 * scnf->
pathlen, stoiexp ) );
2054 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
2057 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
2059 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
2060 double ampv0 = scnf->
amp_vals[ 0 ];
2061 double ampv1 = scnf->
amp_vals[ 1 ];
2062 double constx = dconst * xv;
2063 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
2064 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
2065 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
2066 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
2067 double cguess = ufunc0 + ufunc1 + ufunc2;
2072 lncr2[ jdx ][ jlx++ ] = log( cguess );
2087 double stoiexp = stoich1 - 1.0;
2089 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2093 if ( ! scnf->
scanFit )
continue;
2096 double xm_sq =
sq( scnf->
xvs[ jstx ] );
2097 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2098 double tempera = scnf->
tempera;
2099 double density = scnf->
density;
2100 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2101 double extinc0 = scnf->
extincts[ 0 ];
2102 double ODcorec1 = log( stoich1 /
2103 pow( scnf->
pathlen * extinc0, stoiexp ) );
2106 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
2109 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
2111 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
2112 double ampv0 = scnf->
amp_vals[ 0 ];
2113 double ampv1 = scnf->
amp_vals[ 1 ];
2114 double constx = dconst * xv;
2115 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
2116 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
2117 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
2118 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
2119 double cguess = ufunc0 + ufunc1 + ufunc2;
2124 lncr2[ jdx ][ jlx++ ] = log( cguess );
2138 double mwv1 = mwv0 * stoich1;
2140 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2144 if ( ! scnf->
scanFit )
continue;
2147 double xm_sq =
sq( scnf->
xvs[ jstx ] );
2148 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2149 double tempera = scnf->
tempera;
2150 double density = scnf->
density;
2151 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2154 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
2155 double ampv0 = scnf->
amp_vals[ 0 ];
2156 double ampv1 = scnf->
amp_vals[ 1 ];
2159 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
2161 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
2162 double constx = dconst * xv;
2163 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
2164 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy0 );
2165 double cguess = ufunc0 + ufunc1;
2170 lncr2[ jdx ][ jlx++ ] = log( cguess );
2185 double stoiexp = stoich1 - 1.0;
2187 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2191 if ( ! scnf->
scanFit )
continue;
2194 double xm_sq =
sq( scnf->
xvs[ jstx ] );
2195 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2196 double tempera = scnf->
tempera;
2197 double density = scnf->
density;
2198 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2199 double extinc0 = scnf->
extincts[ 0 ];
2200 double ODcorec1 = log( stoich1 /
2201 pow( scnf->
pathlen * extinc0, stoiexp ) );
2206 double buoy0 = ( 1.0 - v_vbar[ 0 ] * density );
2207 double buoy1 = ( 1.0 - v_vbar[ 1 ] * density );
2208 double ampv0 = scnf->
amp_vals[ 0 ];
2209 double ampv1 = scnf->
amp_vals[ 1 ];
2212 for (
int jj = jstx; jj < jstx +
v_setpts[ jdx ]; jj++ )
2214 double xv =
sq( scnf->
xvs[ jj ] ) - xm_sq;
2215 double constx = dconst * xv;
2216 double ufunc0 = exp( ampv0 + constx * mwv0 * buoy0 );
2217 double ufunc1 = exp( ampv1 + constx * mwv1 * buoy1 );
2218 double ufunc2 = exp( stoich1 * ampv0 +
runfit.
eq_vals[ 0 ] +
2219 ODcorec1 + constx * stoich1 * mwv0 * buoy0 );
2220 double cguess = ufunc0 + ufunc1 + ufunc2;
2225 lncr2[ jdx ][ jlx++ ] = log( cguess );
2241 double* y_raw,
double** coeff )
2247 aa[ 0 ] = (
double*)a0;
2248 aa[ 1 ] = (
double*)a1;
2254 for (
int ii = 0; ii < 2; ii++ )
2256 for (
int jj = 0; jj <= ii; jj++ )
2260 for (
int kk = 0; kk < points; kk++ )
2261 dotp += ( MM[ kk ][ ii ] * MM[ kk ][ jj ] );
2263 aa[ ii ][ jj ] = dotp;
2267 for (
int jj = 0; jj < 2; jj++ )
2271 for (
int kk = 0; kk < points; kk++ )
2272 dotp += ( y_raw[ kk ] * MM[ kk ][ jj ] );
2282 (*coeff)[ 0 ] = bb[ 0 ];
2283 (*coeff)[ 1 ] = bb[ 1 ];
2290 DbgLv(1) <<
"LS2:CDec a00 a10 a11" << aa[0][0] << aa[1][0] << aa[1][1];
2291 aa[ 0 ][ 0 ] = sqrt( aa[ 0 ][ 0 ] );
2292 aa[ 1 ][ 0 ] = aa[ 1 ][ 0 ] / aa[ 0 ][ 0 ];
2294 double sum =
sq( aa[ 1 ][ 0 ] );
2295 double diff = aa[ 1 ][ 1 ] - sum;
2296 DbgLv(1) <<
"LS2:CDec sum diff" << sum << diff;
2298 if ( diff <= 0.0 )
return false;
2300 aa[ 1 ][ 1 ] = sqrt( diff );
2302 DbgLv(1) <<
"LS2:CDec a00 a10 a11" << aa[0][0] << aa[1][0] << aa[1][1];
2312 bb[ 0 ] = bb[ 0 ] / LL[ 0 ][ 0 ];
2313 bb[ 1 ] = bb[ 1 ] - LL[ 1 ][ 0 ] * bb[ 0 ];
2314 bb[ 1 ] = bb[ 1 ] / LL[ 1 ][ 1 ];
2318 bb[ 1 ] = bb[ 1 ] / LL[ 1 ][ 1 ];
2319 bb[ 0 ] = bb[ 0 ] - LL[ 1 ][ 0 ] * bb[ 1 ];
2320 bb[ 0 ] = bb[ 0 ] / LL[ 0 ][ 0 ];
2328 if ( value != value )
2331 double avalue = qAbs( value );
2333 if ( avalue < dflt_min || avalue >
dflt_max )
2346 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2350 if ( ! scnf->
scanFit )
continue;
2357 for (
int jj = scnf->
start_ndx; jj < scnf->stop_ndx + 1; jj++ )
2359 bool thispos = (
y_guess[ jptx++ ] > scnf->
yvs[ jj ] );
2364 if ( ! lastpos ) scnf->
runs++;
2370 if ( lastpos ) scnf->
runs++;
2390 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2394 if ( ! scnf->
scanFit )
continue;
2398 double deltr = ( bottom - scnf->
meniscus ) / 5000.0;
2400 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2401 double tempera = scnf->
tempera;
2402 double density = scnf->
density;
2403 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2405 for (
int kk = 0; kk < ncomps; kk++ )
2409 double buoy = ( 1.0 - vbar * density );
2411 double amplv = scnf->
amp_vals[ kk ];
2412 double ampl2 = exp( amplv );
2416 for (
int mm = 0; mm < 4999; mm++ )
2419 double xvsq =
sq( xval ) - xm_sq;
2420 double ampl1 = ampl2;
2421 ampl2 = exp( amplv + mwfac * xvsq );
2422 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2430 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2434 if ( ! scnf->
scanFit )
continue;
2438 double deltr = ( bottom - scnf->
meniscus ) / 5000.0;
2440 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2441 double tempera = scnf->
tempera;
2442 double density = scnf->
density;
2443 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2445 for (
int kk = 0; kk < ncomps; kk++ )
2449 double buoy = ( 1.0 - vbar * density );
2451 double amplv = scnf->
amp_vals[ kk ];
2452 double ampl2 = exp( amplv );
2456 for (
int mm = 0; mm < 4999; mm++ )
2459 double xvsq =
sq( xval ) - xm_sq;
2460 double ampl1 = ampl2;
2461 ampl2 = exp( amplv + mwfac * xvsq );
2462 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2477 double stoich1 = (double)(
modelx - 2 );
2478 double stoiexp = stoich1 - 1.0;
2482 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2486 if ( ! scnf->
scanFit )
continue;
2490 double deltr = ( bottom - scnf->
meniscus ) / 5000.0;
2492 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2493 double tempera = scnf->
tempera;
2494 double density = scnf->
density;
2495 double ODcorrec = log( stoich1 / pow( scnf->
extincts[ 0 ]
2496 * scnf->
pathlen , stoiexp ) ) + eqval0;
2497 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2501 double buoy = ( 1.0 - vbar * density );
2503 double amplv = scnf->
amp_vals[ 0 ];
2504 double ampl2 = exp( amplv );
2508 for (
int mm = 0; mm < 4999; mm++ )
2511 double xvsq =
sq( xval ) - xm_sq;
2512 double ampl1 = ampl2;
2513 ampl2 = exp( amplv + mwfac * xvsq );
2514 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2521 amplv = scnf->
amp_vals[ 0 ] * stoich1;
2522 ampl2 = exp( amplv + ODcorrec );
2525 for (
int mm = 0; mm < 4999; mm++ )
2528 double xvsq =
sq( xval ) - xm_sq;
2529 double ampl1 = ampl2;
2530 ampl2 = exp( amplv + ODcorrec + mwfac * xvsq );
2531 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2542 double stoich1 = 2.0;
2543 double stoich2 = (double)(
modelx - 8 );
2548 double stoiexp = stoich1;
2549 double stoiex2 = stoich2;
2553 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2557 if ( ! scnf->
scanFit )
continue;
2561 double deltr = ( bottom - scnf->
meniscus ) / 5000.0;
2563 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2564 double tempera = scnf->
tempera;
2565 double density = scnf->
density;
2566 double ODcorre1 = log( stoich1 / pow( scnf->
extincts[ 0 ]
2567 * scnf->
pathlen , stoiexp ) ) + eqval0;
2568 double ODcorre2 = log( stoich2 / pow( scnf->
extincts[ 0 ]
2569 * scnf->
pathlen , stoiex2 ) ) + eqval1;
2570 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2574 double buoy = ( 1.0 - vbar * density );
2576 double amplv = scnf->
amp_vals[ 0 ];
2577 double ampl2 = exp( amplv );
2581 for (
int mm = 0; mm < 4999; mm++ )
2584 double xvsq =
sq( xval ) - xm_sq;
2585 double ampl1 = ampl2;
2586 ampl2 = exp( amplv + mwfac * xvsq );
2587 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2593 amplv = scnf->
amp_vals[ 0 ] * stoich1;
2594 ampl2 = exp( amplv + ODcorre1 );
2598 for (
int mm = 0; mm < 4999; mm++ )
2601 double xvsq =
sq( xval ) - xm_sq;
2602 double ampl1 = ampl2;
2603 ampl2 = exp( amplv + ODcorre1 + mwfac * xvsq );
2604 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2610 amplv = scnf->
amp_vals[ 0 ] * stoich2;
2611 ampl2 = exp( amplv + ODcorre2 );
2615 for (
int mm = 0; mm < 4999; mm++ )
2618 double xvsq =
sq( xval ) - xm_sq;
2619 double ampl1 = ampl2;
2620 ampl2 = exp( amplv + ODcorre1 + mwfac * xvsq );
2621 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2634 double mw_ab = mwv0 + mwv2;
2637 for (
int ii = 0; ii <
scanfits.size(); ii++ )
2641 if ( ! scnf->
scanFit )
continue;
2645 double deltr = ( bottom - scnf->
meniscus ) / 5000.0;
2647 double omega_sq =
sq( M_PI * scnf->
rpm / 30.0 );
2648 double tempera = scnf->
tempera;
2649 double density = scnf->
density;
2650 double dconst = omega_sq / ( 2.0 *
R * (
K0 + tempera ) );
2656 double vbar2 = ( vbar0 * mwv0 + vbar1 * mwv1 ) / mw_ab;
2657 double buoy0 = ( 1.0 - vbar0 * density );
2658 double buoy1 = ( 1.0 - vbar1 * density );
2659 double buoy2 = ( 1.0 - vbar2 * density );
2662 double amplv = scnf->
amp_vals[ 0 ];
2663 double ampl2 = exp( amplv );
2664 double mwfac = mwv0 * dconst * buoy0;
2667 for (
int mm = 0; mm < 4999; mm++ )
2670 double xvsq =
sq( xval ) - xm_sq;
2671 double ampl1 = ampl2;
2672 ampl2 = exp( amplv + mwfac * xvsq );
2673 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2680 ampl2 = exp( amplv );
2681 mwfac = mwv1 * dconst * buoy1;
2684 for (
int mm = 0; mm < 4999; mm++ )
2687 double xvsq =
sq( xval ) - xm_sq;
2688 double ampl1 = ampl2;
2689 ampl2 = exp( amplv + mwfac * xvsq );
2690 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );
2695 double extinc0 = scnf->
extincts[ 0 ];
2696 double extinc1 = scnf->
extincts[ 1 ];
2697 double extin_ab = extinc0 + extinc1;
2698 double ODcorrec = log( extin_ab
2699 / ( extinc0 * extinc1 * scnf->
pathlen ) )
2703 ampl2 = exp( amplv + ODcorrec );
2704 mwfac = mw_ab * dconst * buoy2;
2707 for (
int mm = 0; mm < 4999; mm++ )
2710 double xvsq =
sq( xval ) - xm_sq;
2711 double ampl1 = ampl2;
2712 ampl2 = exp( amplv + ODcorrec + mwfac * xvsq );
2713 sumi += ( deltr * ( ampl1 + ampl2 ) / 2.0 );