@@ -297,17 +297,30 @@ void Forcefield::optimize()
297
297
qDebug () << " maxSteps" << m_maxSteps << " steps "
298
298
<< m_maxSteps / crit.iterations ;
299
299
300
+ QProgressDialog progress (tr (" Optimize Geometry" ), " Cancel" , 0 ,
301
+ m_maxSteps / crit.iterations );
302
+ progress.setWindowModality (Qt::WindowModal);
303
+ progress.setMinimumDuration (0 );
304
+ progress.setAutoClose (true );
305
+ progress.show ();
306
+
300
307
Real currentEnergy = 0.0 ;
301
308
for (unsigned int i = 0 ; i < m_maxSteps / crit.iterations ; ++i) {
302
309
solver.minimize (*m_method, positions);
310
+ // update the progress dialog
311
+ progress.setValue (i);
303
312
304
313
qApp->processEvents (QEventLoop::AllEvents, 500 );
305
314
306
315
currentEnergy = m_method->value (positions);
316
+ progress.setLabelText (
317
+ tr (" Energy: %L1" , " force field energy" ).arg (currentEnergy, 0 , ' f' , 3 ));
307
318
// get the current gradient for force visualization
308
319
m_method->gradient (positions, gradient);
320
+ #ifndef NDEBUG
309
321
qDebug () << " optimize " << i << currentEnergy
310
322
<< " gradNorm: " << gradient.norm ();
323
+ #endif
311
324
312
325
// update coordinates
313
326
bool isFinite = std::isfinite (currentEnergy);
@@ -352,6 +365,9 @@ void Forcefield::optimize()
352
365
353
366
energy = currentEnergy;
354
367
}
368
+
369
+ if (progress.wasCanceled ())
370
+ break ;
355
371
}
356
372
357
373
m_molecule->undoMolecule ()->setInteractive (isInteractive);
0 commit comments