From bd50f717dbdf30e0dcfd2137197cff5894e2229a Mon Sep 17 00:00:00 2001 From: Saeed Date: Mon, 13 Jan 2025 12:43:53 -0700 Subject: [PATCH 01/10] us_model.cpp: calculate_coefficients() function change the vbar to 1/vbar of the sedimentation is negative and buoyancy is positive. --- utils/us_model.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/us_model.cpp b/utils/us_model.cpp index 53362605c..ed9aa4ee0 100644 --- a/utils/us_model.cpp +++ b/utils/us_model.cpp @@ -196,13 +196,13 @@ bool US_Model::calc_coefficients( SimulationComponent& component ) // Adjust buoyancy to be consistent with s-value. Negative s-values require negative buoyancy. // 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; - } + // 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 ) From 151d3fa3b52e734a334a6d7348b0213677f115cb Mon Sep 17 00:00:00 2001 From: samo38 Date: Tue, 14 Jan 2025 16:25:56 -0700 Subject: [PATCH 02/10] us_model.cpp: removed the comments on updating the vbar when the buoyancy>0 and s<0 --- utils/us_model.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/us_model.cpp b/utils/us_model.cpp index ed9aa4ee0..53362605c 100644 --- a/utils/us_model.cpp +++ b/utils/us_model.cpp @@ -196,13 +196,13 @@ bool US_Model::calc_coefficients( SimulationComponent& component ) // Adjust buoyancy to be consistent with s-value. Negative s-values require negative buoyancy. // 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; - // } + 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 ) From 0612f20df1c484105971ad6141f4ccf75c95da8b Mon Sep 17 00:00:00 2001 From: samo38 Date: Tue, 14 Jan 2025 16:27:04 -0700 Subject: [PATCH 03/10] us_fematch.cpp: force the code to use the vbar from the solution instead of the Model table --- programs/us_fematch/us_fematch.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/programs/us_fematch/us_fematch.cpp b/programs/us_fematch/us_fematch.cpp index 849f8e1aa..2e79feadc 100644 --- a/programs/us_fematch/us_fematch.cpp +++ b/programs/us_fematch/us_fematch.cpp @@ -1872,15 +1872,15 @@ void US_FeMatch::adjust_model() sd.manual = solution.manual; DbgLv(1) << "Fem:Adj: avgT" << avgTemp << "scorr dcorr" << scorrec << dcorrec; - if ( cnstvb && mc_vbar != sd.vbar20 && mc_vbar != 0.0 ) - { // Use vbar from the model component, instead of from the solution - sd.vbar20 = mc_vbar; - sd.vbar = US_Math2::adjust_vbar20( sd.vbar20, avgTemp ); - US_Math2::data_correction( avgTemp, sd ); - scorrec = sd.s20w_correction; - dcorrec = sd.D20w_correction; -DbgLv(1) << "Fem:Adj: cnstvb" << cnstvb << " scorr dcorr" << scorrec << dcorrec; - } +// if ( cnstvb && mc_vbar != sd.vbar20 && mc_vbar != 0.0 ) +// { // Use vbar from the model component, instead of from the solution +// sd.vbar20 = mc_vbar; +// sd.vbar = US_Math2::adjust_vbar20( sd.vbar20, avgTemp ); +// US_Math2::data_correction( avgTemp, sd ); +// scorrec = sd.s20w_correction; +// dcorrec = sd.D20w_correction; +// DbgLv(1) << "Fem:Adj: cnstvb" << cnstvb << " scorr dcorr" << scorrec << dcorrec; +// } DbgLv(1) << "Fem:Adj: avgT" << avgTemp << "vb20 vb" << sd.vbar20 << sd.vbar; // Convert to experiment space: adjust s,D based on solution,temperature From 5a005db9fc136bf692092f9acfde33412a2e2f3b Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 18 Jan 2025 09:57:57 -0700 Subject: [PATCH 04/10] us_model.cpp: comment out updating the vbar when ( s < 0 and buoyancy > 0 ) or ( s > 0 and buoyancy < 0 ). ALso, based on the Eq. 14, there is no f_f0 in the numerator under the square root. --- utils/us_model.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/utils/us_model.cpp b/utils/us_model.cpp index 53362605c..9159cbb93 100644 --- a/utils/us_model.cpp +++ b/utils/us_model.cpp @@ -197,12 +197,12 @@ 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; - } + // 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 ) @@ -215,7 +215,8 @@ 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 * 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 ); From b56ef21c1ae3163ec69ecf0e58999cb4a9e3cfd2 Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 18 Jan 2025 10:07:56 -0700 Subject: [PATCH 05/10] us_2dsa.cpp: comment out buoyancy checking here and move it to the 2dsa_ctrl --- programs/us_2dsa/us_2dsa.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/programs/us_2dsa/us_2dsa.cpp b/programs/us_2dsa/us_2dsa.cpp index d9062389d..26a5cf199 100644 --- a/programs/us_2dsa/us_2dsa.cpp +++ b/programs/us_2dsa/us_2dsa.cpp @@ -1028,20 +1028,20 @@ 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" - " 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; - } + // 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" + // " 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; From effa5ece50e9d576408a12683e777d66a3a4753b Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 18 Jan 2025 11:05:23 -0700 Subject: [PATCH 06/10] us_analysis_control_2d.cpp: check the buoyancy before starting the fitting. --- programs/us_2dsa/us_analysis_control_2d.cpp | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/programs/us_2dsa/us_analysis_control_2d.cpp b/programs/us_2dsa/us_analysis_control_2d.cpp index 238f7ba1b..93dda4e2a 100644 --- a/programs/us_2dsa/us_analysis_control_2d.cpp +++ b/programs/us_2dsa/us_analysis_control_2d.cpp @@ -565,6 +565,33 @@ DbgLv(1) << "AnaC: edata" << edata; } } + // 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; + } + // Insure that max RPM and S-value imply a reasonable grid size double s_max = ct_uplimits->value() * 1e-13; QString smsg; From 07abed88b6692c472ddfccc928135989abd4ae6b Mon Sep 17 00:00:00 2001 From: samo38 Date: Mon, 20 Jan 2025 12:54:42 -0700 Subject: [PATCH 07/10] us_fematch: taking back the lines that had been commented out to check vbar discrepancy between the model table and solution data --- programs/us_fematch/us_fematch.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/programs/us_fematch/us_fematch.cpp b/programs/us_fematch/us_fematch.cpp index 2e79feadc..849f8e1aa 100644 --- a/programs/us_fematch/us_fematch.cpp +++ b/programs/us_fematch/us_fematch.cpp @@ -1872,15 +1872,15 @@ void US_FeMatch::adjust_model() sd.manual = solution.manual; DbgLv(1) << "Fem:Adj: avgT" << avgTemp << "scorr dcorr" << scorrec << dcorrec; -// if ( cnstvb && mc_vbar != sd.vbar20 && mc_vbar != 0.0 ) -// { // Use vbar from the model component, instead of from the solution -// sd.vbar20 = mc_vbar; -// sd.vbar = US_Math2::adjust_vbar20( sd.vbar20, avgTemp ); -// US_Math2::data_correction( avgTemp, sd ); -// scorrec = sd.s20w_correction; -// dcorrec = sd.D20w_correction; -// DbgLv(1) << "Fem:Adj: cnstvb" << cnstvb << " scorr dcorr" << scorrec << dcorrec; -// } + if ( cnstvb && mc_vbar != sd.vbar20 && mc_vbar != 0.0 ) + { // Use vbar from the model component, instead of from the solution + sd.vbar20 = mc_vbar; + sd.vbar = US_Math2::adjust_vbar20( sd.vbar20, avgTemp ); + US_Math2::data_correction( avgTemp, sd ); + scorrec = sd.s20w_correction; + dcorrec = sd.D20w_correction; +DbgLv(1) << "Fem:Adj: cnstvb" << cnstvb << " scorr dcorr" << scorrec << dcorrec; + } DbgLv(1) << "Fem:Adj: avgT" << avgTemp << "vb20 vb" << sd.vbar20 << sd.vbar; // Convert to experiment space: adjust s,D based on solution,temperature From cd1079a1c06c73c607796408f586092e09ebeca3 Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 25 Jan 2025 14:53:40 -0700 Subject: [PATCH 08/10] us_analysis_control_2d: check buoyancy only if the UGRID is set --- programs/us_2dsa/us_analysis_control_2d.cpp | 81 +++++++++++---------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/programs/us_2dsa/us_analysis_control_2d.cpp b/programs/us_2dsa/us_analysis_control_2d.cpp index 93dda4e2a..2d61ac2a0 100644 --- a/programs/us_2dsa/us_analysis_control_2d.cpp +++ b/programs/us_2dsa/us_analysis_control_2d.cpp @@ -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 ) { + + // 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 ( ck_varvbar->isChecked() ) - msg = msg.replace( "f/f0", "vbar" ); + if ( ck_varvbar->isChecked() ) + msg = msg.replace( "f/f0", "vbar" ); - QMessageBox::critical( this, tr( "Limits Inconsistent!" ), msg ); - return; + 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 @@ -565,33 +595,6 @@ DbgLv(1) << "AnaC: edata" << edata; } } - // 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; - } - // Insure that max RPM and S-value imply a reasonable grid size double s_max = ct_uplimits->value() * 1e-13; QString smsg; From 4b74572abd9e36bdad7e58da099d31bf248398c3 Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 25 Jan 2025 15:02:32 -0700 Subject: [PATCH 09/10] us_model: delete vbar updating. correct the equation of calculation of D from f_f0. --- utils/us_model.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/utils/us_model.cpp b/utils/us_model.cpp index 9159cbb93..a05197d3d 100644 --- a/utils/us_model.cpp +++ b/utils/us_model.cpp @@ -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 ) @@ -215,7 +209,6 @@ 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; From 7f4ace505028bb6a92637f487fc7a270b8139d03 Mon Sep 17 00:00:00 2001 From: Saeed Date: Sat, 25 Jan 2025 15:06:01 -0700 Subject: [PATCH 10/10] us_2dsa: delete buoyancy checking and move it to us_analysis_control_2d.cpp --- programs/us_2dsa/us_2dsa.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/programs/us_2dsa/us_2dsa.cpp b/programs/us_2dsa/us_2dsa.cpp index 26a5cf199..98ad41e5f 100644 --- a/programs/us_2dsa/us_2dsa.cpp +++ b/programs/us_2dsa/us_2dsa.cpp @@ -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" - // " 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;