00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020
00021 #ifndef CALCULATION_H
00022 #define CALCULATION_H
00023
00025
00026
00027 #include <list>
00028 #include <vector>
00029
00030
00031 class QDomElement;
00032 class QProcess;
00033 #include <qstringlist.h>
00034 class QWidget;
00035
00036
00037 class AtomSet;
00038
00039
00040 #include <qobject.h>
00041
00043 class Calculation : public QObject
00044 {
00045 Q_OBJECT
00046
00047 public:
00048
00049 Calculation(AtomSet* atomset, QWidget* parent = 0, const char* name = 0);
00050 ~Calculation();
00051
00052
00053 enum Errors{NoError, UndefinedError, NoConvergence, CloseNuclei, MaxCyclesExceeded, ManualStop};
00054
00055
00056 bool start();
00057 bool pause();
00058 bool stop();
00059
00060
00061 void setModified(const bool status = true);
00062 void setBraboInput(const QStringList stdInput, const QStringList basissets, const QString startVector, const bool preferStartVector, const unsigned int startVectorSize1, const unsigned int startVectorSize2);
00063 void setStockInput(const QStringList stin, const QString atdens = QString::null);
00064 void setRelaxInput(const QStringList aff, const QStringList maff, const unsigned int updateFreq, const unsigned int maxSteps, const std::vector<unsigned int>& steps, const std::vector<double>& factors);
00065 void setCalculationType(const unsigned int type, const unsigned int buur);
00066 void setParameters(const QString name, const QString dir, const bool format);
00067 void setBackup(const unsigned int freq, const bool brabo = false, const bool stock = false, const bool relax = false, const bool aff = false, const bool crd = false);
00068 void setContinuable(const bool status);
00069
00070
00071 bool isRunning() const;
00072 bool isPaused() const;
00073 void getRefinementParameters(bool& largestCart, bool& magnCart, bool& largestInt, bool& magnInt, bool& largestShift);
00074 void getAvailableOutputs(std::vector<unsigned int>& cycles, std::vector<bool>& brabo, std::vector<bool>& stock, std::vector<bool>& relax, std::vector<bool>& aff);
00075 QStringList braboOutput(const unsigned int step = 0);
00076 QStringList stockOutput(const unsigned int step = 0);
00077 QStringList relaxOutput(const unsigned int step = 0);
00078 QStringList affOutput(const unsigned int step = 0);
00079
00080
00081 void loadCML(const QDomElement* root);
00082 void saveCML(QDomElement* root);
00083 void writeInput();
00084 void clean();
00085
00086 signals:
00087 void newIteration(unsigned int, double);
00088 void newCycle(unsigned int);
00089 void updated();
00090 void finished(unsigned int error);
00091 void modified();
00092
00093 private slots:
00094 void finishBrabo();
00095 void readStdOutBrabo();
00096 void finishStock();
00097 void finishMAFF();
00098 void finishCnvrtAFF();
00099 void finishRelax();
00100 void readStdOutAll();
00101
00102 private:
00103
00104 enum CalculationStep{NEW_CYCLE, ACHAR, BRABO, BUUR, CNVRTAFF, DISTOR, FORKON, MAFF, RELAX, STOCK, UPDATE};
00105
00106
00107 bool checkBasissets();
00108 bool checkExecutables();
00109 bool makeDirCurrent(const QString dir, const QString title);
00110 bool copyStartVector();
00111 void doNextStep();
00112 void runBrabo();
00113 void runStock();
00114 void runMAFF();
00115 void runCnvrtAFF();
00116 void runRelax();
00117 void runCleanup();
00118 void runUpdate();
00119 double scaleFactor(const unsigned int step);
00120 void backupOutputs();
00121 bool copyFile(const QString source, const QString destination);
00122 QStringList output(const QString extension, const unsigned int step = 0);
00123 std::vector<double> loadFromPunch(const QString code, const unsigned int numValues, const unsigned int fieldSize, const unsigned int fieldsPerLine);
00124
00125
00126 AtomSet* atoms;
00127 QWidget* parentWidget;
00128 QStringList braboInput;
00129 QStringList stockInput;
00130 QStringList relaxInput;
00131 QStringList maffInput;
00132 QStringList basissetList;
00133 QString startVectorFile;
00134 QString atdensFile;
00135 unsigned int affUpdateFreq;
00136 unsigned int calculationType;
00137 unsigned int crystalType;
00138 bool updateBraboInput;
00139 bool updateStockInput;
00140 bool updateRelaxInput;
00141 bool doBasissetCheck;
00142 bool copyAtdens;
00143 bool calcRunning;
00144 bool calcPaused;
00145 QString calcName;
00146 QString calcDir;
00147 QProcess* calcProcess;
00148 unsigned int calcMaxCycle;
00149 bool calcXF;
00150 unsigned int currentCycle;
00151 bool calcSuccess;
00152 std::list<CalculationStep> calculationSteps;
00153 std::vector<unsigned int> scaleSteps;
00154 std::vector<double> scaleFactors;
00155 bool stopRequested;
00156 unsigned int backupFrequency;
00157 bool backupBrabo;
00158 bool backupStock;
00159 bool backupRelax;
00160 bool backupAFF;
00161 bool backupCRD;
00162 bool calcModified;
00163 unsigned int calcError;
00164 bool calcContinuable;
00165 };
00166
00167 #endif
00168