Skip to content

Commit

Permalink
Merge pull request #138 from ehb54/Lukas-low-speed-convert
Browse files Browse the repository at this point in the history
low acceleration rate conversion
  • Loading branch information
doluk authored Nov 11, 2024
2 parents 2aff6a0 + 014528c commit b0cf8f1
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: Build
run: |
cp admin/codeql/docker/local.pri.mpi local.pri
git config --global --add safe.directory /__w/ultrascan3/ultrascan3
cd utils
qmake
make -j4
Expand Down
2 changes: 1 addition & 1 deletion programs/us_2dsa/us_2dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ DbgLv(1)<<"2dsa : timestate newly created. timestateobject = "
QString svalu = US_Settings::debug_value( "SetSpeedLowA" );
int lo_ss_acc = svalu.isEmpty() ? 250 : svalu.toInt();
int rspeed = dset.simparams.speed_step[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / accel1;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );
int accel2 = dset.simparams.sim_speed_prof[ 0 ].acceleration;
DbgLv(1)<<"2dsa : ssck: rspeed accel1 tf_aend tf_scan"
<< rspeed << accel1 << tf_aend << tf_scan
Expand Down
2 changes: 1 addition & 1 deletion programs/us_autoflow_analysis/us_autoflow_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ void US_Analysis_auto::simulateModel( )
QString svalu = US_Settings::debug_value( "SetSpeedLowA" );
int lo_ss_acc = svalu.isEmpty() ? 250 : svalu.toInt();
int rspeed = simparams.speed_step[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / accel1;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );

qDebug() << "SimMdl: ssck: rspeed accel1 lo_ss_acc"
<< rspeed << accel1 << lo_ss_acc << "tf_aend tf_scan"
Expand Down
2 changes: 1 addition & 1 deletion programs/us_convert/us_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ qDebug() << "CVT:Adj: t_acc rate" << t_acc << rate;
// omega^2t offset is based on the value at the new zone start.
double azdur = (double)qRound( speedsteps[ 0 ].rotorspeed / 400.0 );
double t_offs = t1 - azdur;
double azwrate = sq( rate * M_PI / 30.0 );
double azwrate = sq( speedsteps[ 0 ].rotorspeed * 0.5 * M_PI / 30.0 );
double w_offs = w2t - ( w2 * ( t2 - t1 ) ) - ( azwrate * azdur );
qDebug() << "CVT:Adj: azdur azwrate" << azdur << azwrate << "t_offs w_offs"
<< t_offs << w_offs;
Expand Down
2 changes: 1 addition & 1 deletion programs/us_convert/us_convert_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9785,7 +9785,7 @@ DbgLv(1) << "CGui:IOD: cSS nspeed" << speedsteps.size();
int tf_scan = speedsteps[ 0 ].time_first;
int accel1 = (int)qRound( rate );
int rspeed = speedsteps[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / accel1;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );

QString wmsg = tr( "The SpeedStep computed/used is likely bad:<br/>"
"The acceleration implied is %1 rpm/sec.<br/>"
Expand Down
1 change: 1 addition & 0 deletions programs/us_experiment/us_experiment_gui_optima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,7 @@ void US_ExperGuiSpeeds::adjustDelay( void )
double pspeed = ( curssx > 0 ) ? ssvals[ curssx - 1 ][ "speed" ] : 0.0;
double spdelta = fabs(cspeed - pspeed); // Speed delta <-- In case there is deceleration..
double accel = ssvals[ curssx ][ "accel" ]; // Acceleration
#warning "Check if this accel is guaranteed to be non-zero, inform user if it is zero?"
double delaylow = qCeil( spdelta / accel ); // Low seconds delay

//Uv-vis
Expand Down
2 changes: 1 addition & 1 deletion programs/us_fematch/us_fematch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ DbgLv(1) << "SimMdl: accel-calc: t1 t2 w2t t_acc speed rate"
QString svalu = US_Settings::debug_value( "SetSpeedLowA" );
int lo_ss_acc = svalu.isEmpty() ? 250 : svalu.toInt();
int rspeed = simparams.speed_step[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / accel1;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );
DbgLv(1) << "SimMdl: ssck: rspeed accel1 lo_ss_acc"
<< rspeed << accel1 << lo_ss_acc << "tf_aend tf_scan"
<< tf_aend << tf_scan;
Expand Down
37 changes: 37 additions & 0 deletions programs/us_mpi_analysis/us_mpi_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,43 @@ if ( my_rank == 0 ) {
}
}

// If debug text modifies SetSpeedLowA value, apply it
int lo_ss_acc = 250;
QStringList dbgtxt = US_Settings::debug_text();
for ( int ii = 0; ii < dbgtxt.count(); ii++ )
{
if ( dbgtxt[ ii ].startsWith( "SetSpeedLowA=" ) )
{
lo_ss_acc = QString( dbgtxt[ ii ] ).section( "=", 1, 1 ).toInt();
if ( my_rank == 0 ){
DbgLv(1) << "DSM: SetSpeedLowA: SetSpeedLowA" << lo_ss_acc;
}
}
}

// Check for low acceleration in every dataset
for ( int ee = 0; ee < data_sets.size(); ee++ )
{
US_SolveSim::DataSet* dset = data_sets[ ee ];
// Do a quick test of the speed step implied by TimeState
int tf_scan = dset->simparams.speed_step[ 0 ].time_first;
int accel1 = dset->simparams.speed_step[ 0 ].acceleration;
int rspeed = dset->simparams.speed_step[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );
int accel2 = dset->simparams.sim_speed_prof[ 0 ].acceleration;
if ( my_rank == 0 ){
DbgLv(1) << "DSM: ssck: rspeed accel1 tf_aend tf_scan"
<< rspeed << accel1 << tf_aend << tf_scan
<< "accel2" << accel2 << "lo_ss_acc" << lo_ss_acc;
}
if ( accel1 < lo_ss_acc || tf_aend > ( tf_scan - 3 ) )
{
DbgLv(0) << "rank: " << my_rank << " Dataset " << ee << " Name: " << dset->run_data.runID <<
" likely bad Timestate. Implied acceleration: " << accel1 <<
" accel end: " << tf_aend << "s. First scan: " << tf_scan << "s.";
}
}

double s_max = parameters[ "s_max" ].toDouble() * 1.0e-13;
double x_max = parameters[ "x_max" ].toDouble() * 1.0e-13;
s_max = ( s_max == 0.0 ) ? x_max : s_max;
Expand Down
2 changes: 1 addition & 1 deletion programs/us_mwl_species_sim/us_mwl_species_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void US_MwlSpeciesSim::set_parameters( void )
double tim_val = 0.0;
double w2t_val = 0.0;
double aspeed = 0.0;
double rpm_inc = rspeed / qCeil( rspeed / accel );
double rpm_inc = rspeed / qCeil( rspeed / ( accel == 0.0 ? 1.0 : accel ) );

while ( aspeed < rspeed )
{ // Walk time and omega2t through acceleration zone
Expand Down
2 changes: 1 addition & 1 deletion programs/us_reporter_gmp/us_reporter_gmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5100,7 +5100,7 @@ void US_ReporterGMP::simulateModel( QMap < QString, QString> & tripleInfo )
QString svalu = US_Settings::debug_value( "SetSpeedLowA" );
int lo_ss_acc = svalu.isEmpty() ? 250 : svalu.toInt();
int rspeed = simparams.speed_step[ 0 ].rotorspeed;
int tf_aend = ( rspeed + accel1 - 1 ) / accel1;
int tf_aend = ( rspeed + accel1 - 1 ) / ( accel1 == 0 ? 1 : accel1 );

qDebug() << "SimMdl: ssck: rspeed accel1 lo_ss_acc"
<< rspeed << accel1 << lo_ss_acc << "tf_aend tf_scan"
Expand Down
12 changes: 8 additions & 4 deletions utils/us_simparms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,14 @@ DbgLv(1) << "Sim parms:ssProf: accel-end ss_p ss_c" << ss_p << ss_c
ssp.w2t_e_accel = w2_p; // Accel end omega2t
ssp.time_e_accel = tm_p; // Accel end time
//qDebug()<<"accln times"<<ssp.time_e_accel<< ss_c<<ss_p<<rs_c<<rs_p ;
sum_accel -= accel_p; // Back off 1 second
double tmi_accel = naintvs > 1 // Accel time intervals minus 1
? (double)( naintvs - 1 )
: 1.0;
double tmi_accel = 1.0;
// only back off one time intervall if there are more than one time interval with acceleration
if ( naintvs > 1 )
{
// Back off 1 intervall of acceleration
sum_accel -= accel_p;
tmi_accel = (double)( naintvs - 1 );
}
ssp.acceleration = sum_accel // Average acceleration
/ tmi_accel;

Expand Down

0 comments on commit b0cf8f1

Please sign in to comment.