Author: gegorbet Date: 2019-08-15 16:42:34 +0000 (Thu, 15 Aug 2019) New Revision: 2816 Modified: trunk/programs/us_density_match/us_density_match.cpp trunk/programs/us_density_match/us_density_match.h trunk/programs/us_density_match/us_model_params.cpp Log: density_match: diffcoeff averaging options, ff0 calcs, tab order changes in ModelParms dialog Modified: trunk/programs/us_density_match/us_density_match.cpp =================================================================== --- trunk/programs/us_density_match/us_density_match.cpp 2019-08-15 02:51:53 UTC (rev 2815) +++ trunk/programs/us_density_match/us_density_match.cpp 2019-08-15 16:42:34 UTC (rev 2816) @@ -67,8 +67,8 @@ // Top banner QLabel* lb_info1 = us_banner( tr( "Model Selection Controls" ) ); - us_checkbox( tr( "Save Plot(s)" ), ck_savepl, false ); - us_checkbox( tr( "Local Save Only" ), ck_locsave, true ); +// us_checkbox( tr( "Save Plot(s)" ), ck_savepl, false ); +// us_checkbox( tr( "Local Save Only" ), ck_locsave, true ); // Distribution information text box te_distr_info = us_textedit(); @@ -102,6 +102,24 @@ connect( bg_x_axis, SIGNAL( buttonReleased( int ) ), this, SLOT ( select_x_axis ( int ) ) ); + // Diffusion-averaging radio buttons and button group + diff_avg = 1; + QLabel* lb_di_avg = us_label( tr( "Diffusion Coefficient Averaging:" ) ); + bg_di_avg = new QButtonGroup( this ); + QGridLayout* gl_da_n = us_radiobutton( tr( "none" ), rb_da_n, false ); + QGridLayout* gl_da_s = us_radiobutton( tr( "simple" ), rb_da_s, true ); + QGridLayout* gl_da_w = us_radiobutton( tr( "weighted" ), rb_da_w, false ); + bg_di_avg->addButton( rb_da_n, 0 ); + bg_di_avg->addButton( rb_da_s, 1 ); + bg_di_avg->addButton( rb_da_w, 2 ); + rb_da_n ->setToolTip( tr( "Perform NO Diffusion Coefficient Averaging" ) ); + rb_da_s ->setToolTip( tr( "Do a SIMPLE average of Diffusion Coefficients across distributions" ) ); + rb_da_w ->setToolTip( tr( "Do a WEIGHTED average of Diffusion Coefficients across distributions" ) ); + rb_da_s ->setChecked( true ); + connect( bg_di_avg, SIGNAL( buttonReleased( int ) ), + this, SLOT ( select_di_avg ( int ) ) ); + + // Various other GUI elements pb_refresh = us_pushbutton( tr( "Refresh Plot" ) ); pb_refresh->setEnabled( false ); connect( pb_refresh, SIGNAL( clicked() ), @@ -172,8 +190,12 @@ spec->addLayout( gl_x_mass, s_row, 2, 1, 2 ); spec->addLayout( gl_x_ff0, s_row, 4, 1, 2 ); spec->addLayout( gl_x_rh, s_row++, 6, 1, 2 ); - spec->addWidget( ck_savepl, s_row, 0, 1, 4 ); - spec->addWidget( ck_locsave, s_row++, 4, 1, 4 ); +// spec->addWidget( ck_savepl, s_row, 0, 1, 4 ); +// spec->addWidget( ck_locsave, s_row++, 4, 1, 4 ); + spec->addWidget( lb_di_avg, s_row++, 0, 1, 8 ); + spec->addLayout( gl_da_n, s_row, 2, 1, 2 ); + spec->addLayout( gl_da_s, s_row, 4, 1, 2 ); + spec->addLayout( gl_da_w, s_row++, 6, 1, 2 ); spec->addWidget( te_distr_info, s_row, 0, 2, 8 ); s_row += 2; // Set up analysis controls @@ -696,14 +718,14 @@ } curr_distr = alldis.size() - 1; - need_save = ck_savepl->isChecked() && !cont_loop; +// need_save = ck_savepl->isChecked() && !cont_loop; pb_rmvdist->setEnabled( models.count() > 0 ); // Notify user of need to set D2O-percent, label, density model values QString qmsg = tr( "%1 models are loaded.\n\nIn the dialog to follow,\n" "you must set D2O Percent values for each,\n" "then review and set Label and Density values for them.\n" - "Begin with the model with 0% D2O." ) + "Insure there is a model with 0% D2O." ) .arg( alldis.size() ); QMessageBox::warning( this, tr( "Model Parameters" ), qmsg ); @@ -1093,6 +1115,7 @@ void US_Density_Match::select_prefilt( void ) { QString pfmsg; + QString dinfo; int nruns = 0; pfilts.clear(); @@ -1107,17 +1130,31 @@ pfilts.clear(); if ( nruns == 0 ) - pfmsg = tr( "(no prefilter)" ); + { + pfmsg = tr( "(no prefilter)" ); + dinfo = pfmsg + "\n"; + } else if ( nruns > 1 ) - pfmsg = tr( "RunID prefilter - %1 runs: " ).arg( nruns ) - + QString( pfilts[ 0 ] ).left( 20 ) + "*, ..."; + { + pfmsg = tr( "RunID prefilter - %1 runs: " ).arg( nruns ) + + QString( pfilts[ 0 ] ).left( 20 ) + "*, ..."; + dinfo = tr( "RunID prefilter - %1 runs:\n" ).arg( nruns ); + for ( int ii = 0; ii < nruns; ii++ ) + { + dinfo += pfilts[ ii ] + "\n"; + } + } else - pfmsg = tr( "RunID prefilter - 1 run: " ) - + QString( pfilts[ 0 ] ).left( 20 ) + " ..."; + { + pfmsg = tr( "RunID prefilter - 1 run: " ) + + QString( pfilts[ 0 ] ).left( 20 ) + " ..."; + dinfo = tr( "RunID prefilter - 1 run:\n" ) + pfilts[ 0 ]; + } - le_prefilt->setText( pfmsg ); + le_prefilt ->setText( pfmsg ); + te_distr_info->setText( dinfo ); } @@ -1236,6 +1273,16 @@ plot_data(); // Plot data } +// Select diffusion coefficient averaging flag +void US_Density_Match::select_di_avg( int ival ) +{ +DbgLv(1) << "sel_da: ival" << ival; + diff_avg = ival; + build_bf_dists(); // Build the boundary fraction distributions + build_bf_vects(); // Build the boundary fraction vectors + plot_data(); // Plot data +} + // Generate the BF version of the current distribution void US_Density_Match::build_bf_distro( int modx ) { @@ -1308,15 +1355,14 @@ // Generate the BoundaryFraction version of all distributions void US_Density_Match::build_bf_dists() { - bool diff_avg = true; int ndists = alldis.size(); for ( int jj = 0; jj < ndists; jj++ ) { // Build bfrac distro for each model build_bf_distro( jj ); } - if ( diff_avg ) - { // Replace diffusion coefficients with weight averages + if ( diff_avg > 0 ) + { // Replace diffusion coefficients with simple or weighted averages int npoints = alldis[ 0 ].bf_distro.size(); for ( int jj = 0; jj < npoints; jj++ ) { @@ -1325,7 +1371,8 @@ for ( int ii = 0; ii < ndists; ii++ ) { // Accumulate (weighted) sum and sum of weights // double dwt = alldis[ ii ].bf_distro[ jj ].c; - double dwt = 1.0; + double dwt = ( diff_avg == 1 ) ? 1.0 + : alldis[ ii ].bf_distro[ jj ].c; dsum += ( alldis[ ii ].bf_distro[ jj ].d * dwt ); wsum += dwt; } @@ -1455,13 +1502,8 @@ v_hrads.reserve( npoints ); for ( int jj = 0; jj < npoints; jj++ ) { - // Mi*vbari/N = Volume of moleculei - // V=4/3 * pi*r_0^3 (3/(4*pi) *v)^1/3 = r_0 - // f_0i = 6 * pi * eta * r_0i // fi = RT/(N*Di) - // *** fi/f_0i // *** ri = fi/(6 * pi * eta) <-- hydrodynamic radius -// double difco = alldis[ 0 ].bf_distro[ jj ].d * 1.0e-7; double difco = v_difcs[ zx ][ jj ] * 1.0e-7; double frico = R_GC * K20 / ( difco * AVOGADRO ); double hyrad = frico / ( 6.0 * M_PI * VISC_20W ); @@ -1473,6 +1515,7 @@ // Compute frictional ratio values and build the vector const double a_third = ( 1.0 / 3.0 ); double vol_fac = ( 0.75 / M_PI ); + double spfac = 0.06 * M_PI * VISC_20W; v_frats.clear(); v_frats.reserve( npoints ); for ( int jj = 0; jj < npoints; jj++ ) @@ -1484,14 +1527,27 @@ // *** fi/f_0i // *** ri = fi/(6 * pi * eta) <-- hydrodynamic radius // double difco = alldis[ 0 ].bf_distro[ jj ].d * 1.0e-7; + double vbari = v_vbars[ jj ]; + double mmass = v_mmass[ jj ]; +#if 0 double difco = v_difcs[ zx ][ jj ] * 1.0e-7; - double vbari = v_vbars[ jj ]; // double rzero = pow( ( ( 0.75 / M_PI ) * vbari ), a_third ); - double volum = v_mmass[ jj ] * vbari / AVOGADRO; + double volum = mmass * vbari / AVOGADRO; double rzero = pow( ( vol_fac * volum ), a_third ); double fcoef = R_GC * K20 / ( difco * AVOGADRO ); - double fzero = 6.0 * M_PI * VISC_20W * rzero; - double frati = fcoef / fzero; +// double fzero = 6.0 * M_PI * VISC_20W * rzero; + double fzero = 0.06 * M_PI * VISC_20W * rzero; +#endif +#if 1 + double sedco = v_sedcs[ zx ][ jj ] * 1.0e-13; + double volum = mmass * vbari / AVOGADRO; + double rzero = pow( ( vol_fac * volum ), a_third ); +// rsph_fac = 0.06 * M_PI * VISC_20W; +// buoyancyb = 1.0 - vbar * DENS_20W; + double fcoef = mmass * ( 1.0 - vbari * DENS_20W ) / ( sedco * AVOGADRO ); + double fzero = spfac * rzero; +#endif + double frati = qAbs( fcoef / fzero ); v_frats << frati; } DbgLv(1) << "BldVc: fr 0 1 k n" << v_frats[0] << v_frats[1] Modified: trunk/programs/us_density_match/us_density_match.h =================================================================== --- trunk/programs/us_density_match/us_density_match.h 2019-08-15 02:51:53 UTC (rev 2815) +++ trunk/programs/us_density_match/us_density_match.h 2019-08-15 16:42:34 UTC (rev 2816) @@ -107,8 +107,12 @@ QRadioButton* rb_x_vbar; QRadioButton* rb_x_s; QRadioButton* rb_x_d; + QRadioButton* rb_da_n; + QRadioButton* rb_da_s; + QRadioButton* rb_da_w; QButtonGroup* bg_x_axis; + QButtonGroup* bg_di_avg; QVector< DisSys > alldis; // All distributions @@ -135,6 +139,7 @@ int curr_distr; int dbg_level; int plot_x; + int diff_avg; bool auto_sxy; bool auto_scz; @@ -176,6 +181,7 @@ void remove_distro ( void ); void set_mparms ( void ); void select_x_axis ( int ); + void select_di_avg ( int ); void build_bf_distro( int ); void build_bf_dists ( void ); void build_bf_vects ( void ); Modified: trunk/programs/us_density_match/us_model_params.cpp =================================================================== --- trunk/programs/us_density_match/us_model_params.cpp 2019-08-15 02:51:53 UTC (rev 2815) +++ trunk/programs/us_density_match/us_model_params.cpp 2019-08-15 16:42:34 UTC (rev 2816) @@ -71,6 +71,7 @@ mainLayout->addWidget( lb_hdr3, row, 2, 1, 1 ); mainLayout->addWidget( lb_hdr4, row, 3, 1, 2 ); mainLayout->addWidget( lb_hdr5, row++, 5, 1, 3 ); + QList< QLineEdit* > lneds; for ( int jj = 0; jj < nd_orig; jj++ ) { QString modelid = modelids[ jj ]; @@ -90,6 +91,10 @@ QLineEdit* le_mlab = us_lineedit( mlabel ); QLineEdit* le_mdsc = us_lineedit( mdesc ); us_setReadOnly( le_mdsc, true ); + lneds << le_d2op; + lneds << le_dens; + lneds << le_mlab; + lneds << le_mdsc; QString rowx = QString::number( jj ); le_d2op->setObjectName( "D2OP:" + rowx ); @@ -111,6 +116,28 @@ } DbgLv(1) << "MP:main: model rows populated"; + // Reset tab order of line edits in model table + // Tab down rows of each column, instead of + // across columns of each row. + for ( int ii = 0; ii < 4; ii++ ) + { // Adjust each column + int kk = ii; + int ll = kk; + for ( int jj = 1; jj < nd_orig; jj++ ) + { // Each box connected to next row's box + kk = ll; // This box index + ll = kk + 4; // Next row index +DbgLv(1) << "MP:main: sTO: kk ll" << kk << ll << " jj" << jj; + QWidget::setTabOrder( lneds[ kk ], lneds[ ll ] ); + } + if ( ii < 3 ) + { // Last row box connected to start of next column +DbgLv(1) << "MP:main: sTO: ll i1" << ll << ii+1; + QWidget::setTabOrder( lneds[ ll ], lneds[ ii + 1 ] ); + } + } + + mainLayout ->addWidget( pb_help, row, 0, 1, 1 ); mainLayout ->addWidget( pb_cancel, row, 1, 1, 2 ); mainLayout ->addWidget( pb_accept, row, 3, 1, 2 );