|
AvogadroLibs 2.1.0-20261111
|
Worker object that runs EnergyCalculator computations on a dedicated QThread. More...
#include <avogadro/qtgui/calcworker.h>
Public Slots | |
| void | initCalculator (Avogadro::Calc::EnergyCalculator *calculator, Avogadro::Core::Molecule molSnapshot, Eigen::VectorXd mask, std::vector< Avogadro::Core::Constraint > constraints) |
| void | runOptimizeChunk (Eigen::VectorXd positions, Avogadro::Calc::OptimizationOptions options) |
| void | runEvaluate (Eigen::VectorXd positions, bool computeGradient) |
| void | runGradient (Eigen::VectorXd positions) |
| void | runEvaluateBatch (std::vector< Eigen::VectorXd > coordsList, bool computeGradient, int chunkSize) |
| void | cancel () |
Signals | |
| void | optimizeFinished (Eigen::VectorXd positions, Eigen::VectorXd gradient, double energy, bool converged) |
| void | evaluateFinished (Eigen::VectorXd gradient, double energy) |
| void | batchProgress (int done, int total) |
| void | evaluateBatchFinished (std::vector< double > energies, std::vector< Eigen::VectorXd > gradients) |
| void | calculatorReady () |
Public Member Functions | |
| CalcWorker (QObject *parent=nullptr) | |
The worker owns a cloned EnergyCalculator and a Core::Molecule snapshot. All heavy computation (energy, gradient, optimization steps) happens on the worker thread; results are delivered back to the main thread via queued signal/slot connections.
Typical usage:
|
signal |
Emitted after each optimization chunk completes.
| positions | The updated coordinate vector. |
| gradient | The gradient at the new positions. |
| energy | The energy at the new positions. |
| converged | True if optimization could not continue. |
|
signal |
Emitted after a one-shot energy/gradient evaluation.
| gradient | The gradient vector (empty if not requested). |
| energy | The computed energy. |
|
signal |
Emitted after each chunk of a batch evaluation completes.
| done | Number of coordinate sets evaluated so far. |
| total | Total number of coordinate sets in the batch. |
|
signal |
Emitted after a batch energy/gradient evaluation completes (or is cancelled, in which case the vectors hold the partial results computed before cancellation).
| energies | One energy per coordinate set. |
| gradients | One gradient per coordinate set (empty if not requested). |
|
signal |
Emitted when the calculator has been initialized on the worker thread.
|
slot |
Initialize the calculator on the worker thread. This MUST be called via queued connection so that setMolecule() runs on the worker thread (required for QProcess affinity in ScriptEnergy/OBMMEnergy).
Takes ownership of calculator.
|
slot |
Run a chunk of optimization iterations.
|
slot |
Run a one-shot energy and optionally gradient evaluation.
|
slot |
Run a one-shot gradient evaluation.
|
slot |
Evaluate energy (and optionally gradient) for many coordinate sets.
The batch is split into chunks of chunkSize frames so a large trajectory never builds one giant wire buffer / model batch and so progress can be reported and cancellation honored between chunks.
| coordsList | One coordinate vector per set (each 3 * atomCount long). |
| computeGradient | Request gradients in addition to energies. |
| chunkSize | Frames per chunk; <= 0 selects a memory-bounded default. |
|
slot |
Request cancellation of the current computation. Thread-safe: can be called from any thread.