Skip to content

Commit

Permalink
Merge pull request #173 from samo38/issue_405_2dsa
Browse files Browse the repository at this point in the history
2DSA s,D correct griding
  • Loading branch information
demeler authored Jan 26, 2025
2 parents ad0bbfd + 7f4ace5 commit e1242ca
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
13 changes: 0 additions & 13 deletions programs/us_2dsa/us_2dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,20 +1028,7 @@ void US_2dsa::open_fitcntl()
double avTemp = edata->average_temperature();
double vbar20 = US_Math2::calcCommonVbar( solution_rec, 20.0 );
double vbartb = US_Math2::calcCommonVbar( solution_rec, avTemp );
double buoy = 1.0 - vbar20 * DENS_20W;

if ( buoy <= 0.0 )
{
QMessageBox::critical( this, tr( "Negative Buoyancy Implied" ),
tr( "The current vbar20 value (%1) implies a buoyancy\n"
"value (%2) that is non-positive.\n\n"
"2DSA cannot proceed with this value. Click on the\n"
"<Solution> button and change the vbar20 value.\n"
"Note that the Solution may be accepted without being saved.\n"
"Include negative values in the sedimentation coefficient\n"
"range to represent floating data." ).arg( vbar20 ).arg( buoy ) );
return;
}
US_Math2::SolutionData sd;
sd.density = density;
sd.viscosity = viscosity;
Expand Down
54 changes: 42 additions & 12 deletions programs/us_2dsa/us_analysis_control_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,20 +528,50 @@ DbgLv(1) << "AnaC: edata scans, baserss" << edata->scanData.size() << baserss;
DbgLv(1) << "AnaC: edata" << edata;
}

// Make sure that ranges are reasonable
if ( ( ct_uplimits->value() - ct_lolimits->value() ) < 0.0 ||
( ct_uplimitk->value() - ct_lolimitk->value() ) < 0.0 )
{
QString msg =
tr( "The \"s\" or \"f/f0\" ranges are inconsistent.\n"
"Please re-check the limits and correct them\n"
"before again clicking \"Start Fit\"." );
if ( grtype == US_2dsaProcess::UGRID ) {

if ( ck_varvbar->isChecked() )
msg = msg.replace( "f/f0", "vbar" );
// Make sure that ranges are reasonable
if ( ( ct_uplimits->value() - ct_lolimits->value() ) < 0.0 ||
( ct_uplimitk->value() - ct_lolimitk->value() ) < 0.0 )
{
QString msg =
tr( "The \"s\" or \"f/f0\" ranges are inconsistent.\n"
"Please re-check the limits and correct them\n"
"before again clicking \"Start Fit\"." );

QMessageBox::critical( this, tr( "Limits Inconsistent!" ), msg );
return;
if ( ck_varvbar->isChecked() )
msg = msg.replace( "f/f0", "vbar" );

QMessageBox::critical( this, tr( "Limits Inconsistent!" ), msg );
return;
}

// Check buoyancy
double vbar = dsets[0]->vbar20;
double buoy = 1.0 - vbar * DENS_20W;
if (buoy == 0) {
QMessageBox::critical( this, tr( "Zero Buoyancy Implied" ),
tr( "The current vbar20 value (%1) implies a zero buoyancy\n"
"value (%2). Please adjust the vbar20!" ).
arg( vbar ).arg( buoy ).arg( 1 / vbar) );
return;
} else if ( buoy > 0 && ct_lolimits->value() < 0) {
QMessageBox::critical( this, tr( "Positive Buoyancy Implied" ),
tr( "The current vbar20 value (%1) implies a positive buoyancy\n"
"value (%2), while the selected sedimentation values are negative.\n\n"
"Please adjust the sedimentation range or "
"increase the vbar20 to (%3 mL/g) or higher." ).
arg( vbar ).arg( buoy ).arg( 1 / vbar) );
return;
} else if ( buoy < 0 && ct_lolimits->value() > 0) {
QMessageBox::critical( this, tr( "Negative Buoyancy Implied" ),
tr( "The current vbar20 value (%1) implies a negative buoyancy\n"
"value (%2), while the selected sedimentation values are postive.\n\n"
"Please adjust the sedimentation range or "
"reduce the vbar20 to (%3 mL/g) or less." ).
arg( vbar ).arg( buoy ).arg( 1 / vbar) );
return;
}
}

// Make sure that any fit-meniscus is reasonable
Expand Down
8 changes: 1 addition & 7 deletions utils/us_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,6 @@ bool US_Model::calc_coefficients( SimulationComponent& component )
// Unless custom grid is used, we set the vbar to the reciprocal of the positive s-value vbar.

buoyancyb = 1.0 - ( vbar * DENS_20W );
if ( ( s < 0.0 && buoyancyb > 0.0 ) ||
( s > 0.0 && buoyancyb < 0.0 ) )
{
buoyancyb = 1.0 - ( DENS_20W / vbar );
vbar = 1.0 / vbar;
}

// Start with already calculated s if possible
if ( s != 0.0 )
Expand All @@ -215,7 +209,7 @@ bool US_Model::calc_coefficients( SimulationComponent& component )
{ ///////////////
// Please see calc_coefficient_documentation.pdf in this directory,
// equation 14, with adjustments for units in poise.
double numer = 0.02 * vbar * s * VISC_20W * f_f0;
double numer = 0.02 * vbar * s * VISC_20W;
f0 = 0.09 * VISC_20W * M_PI * sqrt( numer / buoyancyb );
fv = f_f0 * f0;
D = RT / ( AVOGADRO * fv );
Expand Down

0 comments on commit e1242ca

Please sign in to comment.