[us-commits] r2811 - trunk/programs/us_density_match
svn at svn.aucsolutions.com
svn at svn.aucsolutions.com
Wed Aug 14 08:48:41 MDT 2019
Author: gegorbet
Date: 2019-08-14 14:48:40 +0000 (Wed, 14 Aug 2019)
New Revision: 2811
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
trunk/programs/us_density_match/us_model_params.h
Log:
density_match functionality close to complete, tho mmass,rh,ff0 magnitudes seem wrong
Modified: trunk/programs/us_density_match/us_density_match.cpp
===================================================================
--- trunk/programs/us_density_match/us_density_match.cpp 2019-08-13 22:54:23 UTC (rev 2810)
+++ trunk/programs/us_density_match/us_density_match.cpp 2019-08-14 14:48:40 UTC (rev 2811)
@@ -80,24 +80,24 @@
plot_x = 0;
QLabel* lb_x_axis = us_label( tr( "Plot X:" ) );
bg_x_axis = new QButtonGroup( this );
+ QGridLayout* gl_x_s = us_radiobutton( tr( "s" ), rb_x_s, false );
+ QGridLayout* gl_x_d = us_radiobutton( tr( "D" ), rb_x_d, false );
+ QGridLayout* gl_x_vbar = us_radiobutton( tr( "vbar"), rb_x_vbar, false );
QGridLayout* gl_x_mass = us_radiobutton( tr( "m.mass" ), rb_x_mass, true );
QGridLayout* gl_x_ff0 = us_radiobutton( tr( "ff0" ), rb_x_ff0, false );
QGridLayout* gl_x_rh = us_radiobutton( tr( "Rh" ), rb_x_rh, false );
- QGridLayout* gl_x_vbar = us_radiobutton( tr( "vbar"), rb_x_vbar, false );
- QGridLayout* gl_x_s = us_radiobutton( tr( "s" ), rb_x_s, false );
- QGridLayout* gl_x_d = us_radiobutton( tr( "D" ), rb_x_d, false );
+ bg_x_axis->addButton( rb_x_s, ATTR_S );
+ bg_x_axis->addButton( rb_x_d, ATTR_D );
+ bg_x_axis->addButton( rb_x_vbar, ATTR_V );
bg_x_axis->addButton( rb_x_mass, ATTR_W );
bg_x_axis->addButton( rb_x_ff0, ATTR_K );
bg_x_axis->addButton( rb_x_rh, ATTR_R );
- bg_x_axis->addButton( rb_x_vbar, ATTR_V );
- bg_x_axis->addButton( rb_x_s, ATTR_S );
- bg_x_axis->addButton( rb_x_d, ATTR_D );
+ rb_x_s ->setToolTip( tr( "Set X axis to Sedimentation Coefficient" ) );
+ rb_x_d ->setToolTip( tr( "Set X axis to Diffusion Coefficient" ) );
+ rb_x_vbar->setToolTip( tr( "Set X axis to Partial Specific Volume" ) );
rb_x_mass->setToolTip( tr( "Set X axis to Molar Mass" ) );
rb_x_ff0 ->setToolTip( tr( "Set X axis to Frictional Ratio" ) );
rb_x_rh ->setToolTip( tr( "Set X axis to Hydrodynamic Radius" ) );
- rb_x_vbar->setToolTip( tr( "Set X axis to Partial Specific Volume" ) );
- rb_x_s ->setToolTip( tr( "Set X axis to Sedimentation Coefficient" ) );
- rb_x_d ->setToolTip( tr( "Set X axis to Diffusion Coefficient" ) );
rb_x_s ->setChecked( true );
connect( bg_x_axis, SIGNAL( buttonReleased( int ) ),
this, SLOT ( select_x_axis ( int ) ) );
@@ -166,12 +166,12 @@
spec->addWidget( pb_mdlpars, s_row, 0, 1, 4 );
spec->addWidget( pb_save, s_row++, 4, 1, 4 );
spec->addWidget( lb_x_axis, s_row, 0, 1, 2 );
+ spec->addLayout( gl_x_s, s_row, 2, 1, 2 );
+ spec->addLayout( gl_x_d, s_row, 4, 1, 2 );
+ spec->addLayout( gl_x_vbar, s_row++, 6, 1, 2 );
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->addLayout( gl_x_vbar, s_row, 2, 1, 2 );
- spec->addLayout( gl_x_s, s_row, 4, 1, 2 );
- spec->addLayout( gl_x_d, 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( te_distr_info, s_row, 0, 2, 8 ); s_row += 2;
@@ -206,6 +206,8 @@
this, SLOT( update_divis( double ) ) );
connect( ct_boundaryPos, SIGNAL( valueChanged( double ) ),
this, SLOT( update_divis( double ) ) );
+ connect( ct_smoothing, SIGNAL( valueChanged( double ) ),
+ this, SLOT( update_divis( double ) ) );
spec->addWidget( lb_analysis , s_row++, 0, 1, 8 );
spec->addWidget( lb_division , s_row, 0, 1, 4 );
@@ -398,14 +400,14 @@
else if ( plot_x == ATTR_W )
{
xx = v_mmass.data();
- curvtitl = tr( "Mmass_curve" );
+ curvtitl = tr( "mmass_curve" );
tstr += tr( "Molar Mass" );
}
else if ( plot_x == ATTR_V )
{
xx = v_vbars.data();
DbgLv(1) << "DaPl: v_vbars" << v_vbars;
- curvtitl = tr( "Vbar_curve" );
+ curvtitl = tr( "vbar_curve" );
tstr += tr( "Partial Specific Density" );
}
else if ( plot_x == ATTR_D )
@@ -424,7 +426,7 @@
else if ( plot_x == ATTR_K )
{
xx = v_frats.data();
- curvtitl = tr( "Ff0_curve" );
+ curvtitl = tr( "ff0_curve" );
tstr += tr( "Frictional Ratio" );
}
DbgLv(1) << "DaPl: (3)tstr" << tstr;
@@ -1059,7 +1061,7 @@
{ // Redo text box summarizing models; calculate vectors
QString mdesc = mdescs[ 0 ].section( mdescs[ 0 ].left( 1 ), 1, 1 );
mdesc = QString( mdesc ).left( 50 );
- QString dinfo = tr( "Run:\n " ) + mdesc + "...\n\n"
+ QString dinfo = alldis[ 0 ].run_name.section( ".", 0, -2 ) + "\n\n"
+ tr( " D2O Percent Density Label MDescr.\n" );
for ( int jj = 0; jj < alldis.size(); jj++ )
@@ -1205,7 +1207,7 @@
DbgLv(1) << "BldBf: nsolbo nsolbf" << nsolbo << nsolbf;
}
-// Generate the BF version of all distributions
+// Generate the BoundaryFraction version of all distributions
void US_Density_Match::build_bf_dists()
{
bool diff_avg = true;
@@ -1238,7 +1240,7 @@
}
}
-// Generate the BF vectors
+// Generate the BoundaryFraction-associated vectors
void US_Density_Match::build_bf_vects()
{
int nsmoo = (int)( ct_smoothing->value() );
@@ -1277,7 +1279,7 @@
// Build vectors of s and D for this model
for ( int jj = 0; jj < npoints; jj++ )
- { // Build s,D vectors for this model
+ { // Append s,D values for each bf-point for this model
v_sedcs[ ii ] << alldis[ ii ].bf_distro[ jj ].s;
v_difcs[ ii ] << alldis[ ii ].bf_distro[ jj ].d;
}
@@ -1285,6 +1287,12 @@
<< v_sedcs[ii][npoints-2] << v_sedcs[ii][npoints-1];
DbgLv(1) << "BldVc: di 0 1 k n" << v_difcs[ii][0] << v_difcs[ii][1]
<< v_difcs[ii][npoints-2] << v_difcs[ii][npoints-1];
+
+ if ( nsmoo > 1 )
+ { // Apply gaussian smoothing to s and D vectors
+ US_Math2::gaussian_smoothing( v_sedcs[ ii ], nsmoo );
+ US_Math2::gaussian_smoothing( v_difcs[ ii ], nsmoo );
+ }
}
DbgLv(1) << "BldVc: vdens" << v_dens;
@@ -1296,7 +1304,7 @@
v_seds.clear();
for ( int ii = 0; ii < ndists; ii++ )
{ // Build sed coeffs vector across models
- v_seds << alldis[ ii ].bf_distro[ jj ].s;
+ v_seds << v_sedcs[ ii ][ jj ];
}
double* xx = v_seds.data(); // X is sed coeffs
double* yy = v_dens.data(); // Y is densities
@@ -1320,6 +1328,7 @@
v_mmass.reserve( npoints );
for ( int jj = 0; jj < npoints; jj++ )
{
+ // *** Mi = si*R*T/(Di_avg*(1-vbari*rho))
double sedco = alldis[ 0 ].bf_distro[ jj ].s * 1.0e-13;
double difco = alldis[ 0 ].bf_distro[ jj ].d * 1.0e-7;
double vbari = v_vbars[ jj ];
@@ -1335,26 +1344,45 @@
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 frico = R_GC * K20 / ( difco * AVOGADRO );
double hyrad = frico / ( 6.0 * M_PI * VISC_20W );
v_hrads << hyrad;
}
+DbgLv(1) << "BldVc: hr 0 1 k n" << v_hrads[0] << v_hrads[1]
+ << v_hrads[npoints-2] << v_hrads[npoints-1];
// Compute frictional ratio values and build the vector
const double a_third = ( 1.0 / 3.0 );
+ double vol_fac = ( 0.75 / M_PI );
v_frats.clear();
v_frats.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 vbari = v_vbars[ jj ];
- double rzero = pow( ( ( 0.75 / M_PI ) * vbari ), a_third );
- double frico = R_GC * K20 / ( difco * AVOGADRO );
+// double rzero = pow( ( ( 0.75 / M_PI ) * vbari ), a_third );
+ double volum = v_mmass[ jj ] * 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 frrat = frico / fzero;
- v_frats << frrat;
+ double frati = fcoef / fzero;
+ v_frats << frati;
}
+DbgLv(1) << "BldVc: fr 0 1 k n" << v_frats[0] << v_frats[1]
+ << v_frats[npoints-2] << v_frats[npoints-1];
#if 0
@@ -1411,11 +1439,35 @@
return a_title;
}
-// Update structures and plot after division change
+// Set plot-type text suffix for a plot index
+QString US_Density_Match::ptype_text( int pltndx )
+{
+ QString t_text;
+
+ if ( pltndx == ATTR_S )
+ t_text = "s";
+ else if ( pltndx == ATTR_K )
+ t_text = "ff0";
+ else if ( pltndx == ATTR_W )
+ t_text = "mmass";
+ else if ( pltndx == ATTR_V )
+ t_text = "vbar";
+ else if ( pltndx == ATTR_D )
+ t_text = "d";
+ else if ( pltndx == ATTR_R )
+ t_text = "rh";
+ else if ( pltndx == ATTR_F )
+ t_text = "bf";
+
+ return t_text;
+}
+
+// Update structures and plot after division/percent/position change
void US_Density_Match::update_divis( double dval )
{
DbgLv(1) << "UpdDiv:" << dval;
- build_bf_dists();
- build_bf_vects();
+ build_bf_dists(); // (Re-)build boundary fraction distributions
+ build_bf_vects(); // (Re-)build boundary fraction vectors
+ plot_data(); // Plot data
}
Modified: trunk/programs/us_density_match/us_density_match.h
===================================================================
--- trunk/programs/us_density_match/us_density_match.h 2019-08-13 22:54:23 UTC (rev 2810)
+++ trunk/programs/us_density_match/us_density_match.h 2019-08-14 14:48:40 UTC (rev 2811)
@@ -181,6 +181,7 @@
void build_bf_vects ( void );
int plot_x_select ( void );
QString anno_title ( int );
+ QString ptype_text ( int );
void help ( void )
{ showHelp.show_help( "dens_match.html" ); };
Modified: trunk/programs/us_density_match/us_model_params.cpp
===================================================================
--- trunk/programs/us_density_match/us_model_params.cpp 2019-08-13 22:54:23 UTC (rev 2810)
+++ trunk/programs/us_density_match/us_model_params.cpp 2019-08-14 14:48:40 UTC (rev 2811)
@@ -2,11 +2,15 @@
#include "us_model_params.h"
#include "us_gui_settings.h"
+#include "us_settings.h"
+#define DbgLv(a) if(dbg_level>=a)qDebug()
// Constructor: remove-distributions dialog widget
US_ModelParams::US_ModelParams( QVector< DisSys >& adistros,
QWidget* p ) : US_WidgetsDialog( p, 0 ), distros( adistros )
{
+ dbg_level = US_Settings::us_debug();
+ mainLayout = new QGridLayout( this );
setObjectName( "US_ModelParams" );
setPalette( US_GuiSettings::frameColor() );
setFont( QFont( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() ) );
@@ -14,8 +18,6 @@
// Lay out the GUI
setWindowTitle( tr( "Distribution Parameters" ) );
- mainLayout = new QGridLayout( this );
-
mainLayout->setSpacing ( 2 );
mainLayout->setContentsMargins( 2, 2, 2, 2 );
@@ -26,8 +28,9 @@
pb_cancel = us_pushbutton( tr( "Cancel" ) );
pb_accept = us_pushbutton( tr( "Accept" ) );
pb_compute = us_pushbutton( tr( "Compute Densities" ) );
+ pb_accept ->setEnabled( false );
+ pb_compute->setEnabled( false );
-
// Build lists of model parameters
nd_orig = distros.count();
int maxdlen = 0;
@@ -98,7 +101,15 @@
mainLayout->addWidget( le_dens, row, 2, 1, 1 );
mainLayout->addWidget( le_mlab, row, 3, 1, 2 );
mainLayout->addWidget( le_mdsc, row++, 5, 1, 3 );
+
+ connect( le_d2op, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( lnedChanged( const QString& ) ) );
+ connect( le_dens, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( lnedChanged( const QString& ) ) );
+ connect( le_mlab, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( lnedChanged( const QString& ) ) );
}
+DbgLv(1) << "MP:main: model rows populated";
mainLayout ->addWidget( pb_help, row, 0, 1, 1 );
mainLayout ->addWidget( pb_cancel, row, 1, 1, 2 );
@@ -129,59 +140,20 @@
// int lhigh = fhigh * 10 + 12;
int fwide = fm.width( QChar( '6' ) );
int lwide = fwide * ( maxdlen + 2 );
+DbgLv(1) << "MP:main: fwide lwide" << fwide << lwide;
adjustSize();
int wwide = qMax( 500, lwide );
int whigh = size().height();
resize( wwide, whigh );
qApp->processEvents();
+DbgLv(1) << "MP:main: wwide whigh" << wwide << whigh;
}
-// Private slot to react to a change in selections
-void US_ModelParams::d2opctChanged( int sel )
-{
-DbgLv(1) << "d2opctChanged: sel" << sel;
- bool can_accept = false;
- // Enable buttons according to the present state of selection/removal
- pb_accept ->setEnabled( can_accept );
-}
-
-// Private slot to react to a change in selections
-void US_ModelParams::labelChanged( int sel )
-{
-DbgLv(1) << "labelChanged: sel" << sel;
-}
-
-
// Private slot to do the actual removal of distributions and close
void US_ModelParams::accepted()
{
DbgLv(1) << "accepted";
-#if 0
- if ( nd_selected > 0 )
- { // Accept attempt with selections and no Remove clicked
- if ( QMessageBox::Yes == QMessageBox::warning( this,
- tr( "Outstanding Selections" ),
- tr( "You have selected distributions,\n"
- "but did not click on the Remove button.\n"
- "Do you want to remove the selected distributions?" ),
- QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes ) )
- { // If "Yes" to above, add current selections to the remove list
- remove();
- }
- }
-
- for ( int jj = nd_orig - 1; jj >= 0; jj-- )
- { // Remove all entries in the original that are not in the current list
- QString mdesc = mdesc_orig[ jj ];
-
- if ( ! mdesc_list.contains( mdesc ) )
- { // This original list item is to be removed from the passed list
- distros.removeAt( jj );
- }
- }
-#endif
-
QList< QObject* > ochilds = this->children();
DbgLv(1) << " acc: ochilds size" << ochilds.size();
for ( int jj = 0; jj < ochilds.size(); jj++ )
@@ -271,3 +243,141 @@
DbgLv(1) << " cdn: misspc" << misspc;
}
+bool US_ModelParams::values_filled()
+{
+ QList< QObject* > ochilds = this->children();
+ int nzd2pc = 0;
+ int nad2pc = 0;
+ int nadens = 0;
+ int nalabs = 0;
+ QList< double > allden;
+DbgLv(1) << " vlf: ochilds size" << ochilds.size();
+
+ for ( int jj = 0; jj < ochilds.size(); jj++ )
+ {
+ QObject* ochild = ochilds[ jj ];
+ QString cname = ochild->objectName();
+ if ( cname.isEmpty() ) continue;
+
+ QLineEdit* lned = (QLineEdit*) ochild;
+ QString pname = cname.section( ":", 0, 0 );
+ QString etext = lned->text();
+DbgLv(1) << " vlf: jj" << jj << "etext" << etext << "pname" << pname;
+
+ if ( pname == "D2OP" )
+ { // Count D2O percent values given
+ if ( !etext.isEmpty() )
+ {
+ int pctval = etext.toInt();
+ if ( etext == "0" )
+ { // Zero percent: bump counts
+ nzd2pc++;
+ nad2pc++;
+DbgLv(1) << " vlf: pctval" << pctval << "nzd2pc nad2pc" << nzd2pc << nad2pc;
+ }
+ else if ( pctval != 0 )
+ { // Non-zero numeric: bump percent count
+ nad2pc++;
+DbgLv(1) << " vlf: pctval" << pctval << "nad2pc" << nad2pc;
+ }
+ }
+ }
+ else if ( pname == "DENS" )
+ { // Count densities given
+ if ( !etext.isEmpty() )
+ {
+ double density = etext.toDouble();
+ if ( density > 0.0 )
+ { // Bump if non-empty, numeric; save unique values
+ nadens++;
+ if ( !allden.contains( density ) )
+ allden << density;
+DbgLv(1) << " vlf: density" << density << "nadens" << nadens;
+ }
+ }
+ }
+ else if ( pname == "MLAB" )
+ { // Count labels given
+ if ( !etext.isEmpty() )
+ nalabs++;
+DbgLv(1) << " vlf: nalabs" << nalabs;
+ }
+ }
+DbgLv(1) << " vlf: nzd2pc nad2pc nadens nalabs" << nzd2pc << nad2pc << nadens << nalabs
+ << "allden size" << allden.size();
+
+ // All model parameters are given if
+ // at least one zero-percent is given;
+ // percent,density,label counts equal row count;
+ // and number of unique densities equals row count.
+ bool filled = ( ( nzd2pc > 0 ) &&
+ ( nad2pc == nd_orig ) &&
+ ( nadens == nd_orig ) &&
+ ( nalabs == nd_orig ) &&
+ ( allden.size() == nadens ) );
+DbgLv(1) << " vlf: FILLED" << filled;
+ pb_accept ->setEnabled( filled ); // If all filled, enable Accept button
+
+ return filled;
+}
+
+// Return flag of whether all D2O percents have been given
+bool US_ModelParams::all_percents()
+{
+ QList< QObject* > ochilds = this->children();
+ int nzd2pc = 0;
+ int nad2pc = 0;
+DbgLv(1) << " apc: ochilds size" << ochilds.size();
+
+ for ( int jj = 0; jj < ochilds.size(); jj++ )
+ { // Examine any D2O percent texts
+ QObject* ochild = ochilds[ jj ];
+ QString cname = ochild->objectName();
+ if ( cname.isEmpty() ) continue;
+
+ QString pname = cname.section( ":", 0, 0 );
+ QLineEdit* lned = (QLineEdit*) ochild;
+ QString etext = lned->text();
+
+ if ( pname == "D2OP" )
+ {
+ if ( !etext.isEmpty() )
+ {
+ int pctval = etext.toInt();
+ if ( etext == "0" )
+ { // Count 0 percent and total percent
+ nzd2pc++;
+ nad2pc++;
+ }
+ else if ( pctval != 0 )
+ { // Count total non-empty percent values given
+ nad2pc++;
+ }
+ }
+ }
+ }
+DbgLv(1) << " apc: nzd2pc nad2pc" << nzd2pc << nad2pc;
+
+ // We have all needed if 0-percent exists and all percents given
+ bool all_pc = ( ( nzd2pc > 0 ) &&
+ ( nad2pc == nd_orig ) );
+DbgLv(1) << " apc: ALL-PC" << all_pc;
+
+ // If all percents given, enable Compute Densities button
+ pb_compute->setEnabled( all_pc );
+
+ return all_pc;
+}
+
+// Slot to handle change in lineEdit value in model rows
+void US_ModelParams::lnedChanged( const QString& /*text*/ )
+{
+DbgLv(1) << " lnedChanged IN";
+ // Determine if all boxes filled or all percents given
+ // and possibly enable "Accept" or "Compute Densities"
+ bool filled = values_filled();
+ bool all_pc = all_percents();
+DbgLv(1) << " lnedChanged filled all_pc" << filled << all_pc;
+ return;
+}
+
Modified: trunk/programs/us_density_match/us_model_params.h
===================================================================
--- trunk/programs/us_density_match/us_model_params.h 2019-08-13 22:54:23 UTC (rev 2810)
+++ trunk/programs/us_density_match/us_model_params.h 2019-08-14 14:48:40 UTC (rev 2811)
@@ -47,11 +47,12 @@
private slots:
- void d2opctChanged ( int );
- void labelChanged ( int );
void canceled ( void );
void accepted ( void );
void compute_densities( void );
+ bool values_filled ( void );
+ bool all_percents ( void );
+ void lnedChanged ( const QString& );
void help ( void )
{ showHelp.show_help( "dens_match_mparam.html" ); };
};
More information about the us-commits
mailing list