QCCommon.cpp

Go to the documentation of this file.
00001 //*****************************************************************************//
00002 //                                                                             //
00003 //   Copyright (c) 2001                                                        //
00004 //      INRIA                                                                  //
00005 //      54600 VILLERS LES NANCY                                                //
00006 //      France                                                                 //
00007 //                                                                             //
00008 //*****************************************************************************//
00009 //                                                                             //
00010 //               *** NOTICE OF PROPRIETARY INFORMATION ***                     //
00011 //                                                                             //
00012 // The information contained in this file is considered proprietary and the    //
00013 // exclusive property of  INRIA. This information may not be disclosed,        //
00014 // duplicated or used, in whole or in part, for  any purpose  whatsoever       //
00015 // without express written authorization from INRIA                            //
00016 //                                                                             //
00017 //*****************************************************************************//
00018 
00019 
00020 
00021 #include <time.h>
00022 #include <unistd.h>
00023 #include <limits.h>
00024 
00025 #include <sstream>
00026 
00027 #include "QCCommon.hpp"
00028 
00029 
00030 
00034 inline map<string, QCModelType>
00035 initModel (void) {
00036   map<string, QCModelType> model;
00037   model [QCCommon::MndoStr] = QC_MNDO_MODEL;
00038   model [QCCommon::Am1Str]  = QC_AM1_MODEL;
00039   model [QCCommon::Pm3Str]  = QC_PM3_MODEL;
00040   return model;
00041 }
00042 //
00043 const string QCCommon::MndoStr ("MNDO");
00044 const string QCCommon::Am1Str  ("AM1");
00045 const string QCCommon::Pm3Str  ("PM3");
00046 const map<string, QCModelType> QCCommon::modelTypes = initModel();
00047 
00048 
00049 
00050 
00054 inline map<string, QCParameterType>
00055 initParam (void) {
00056   map<string, QCParameterType> param;
00057   param [QCCommon::MndoParamStr] = QC_MNDO_PARAM;
00058   param [QCCommon::Am1ParamStr] =  QC_AM1_PARAM;
00059   param [QCCommon::Pm3ParamStr] =  QC_PM3_PARAM;
00060   return param;
00061 }
00062 //
00063 const string QCCommon::MndoParamStr ("MNDO_Param_Std");
00064 const string QCCommon::Am1ParamStr  ("AM1_Param_Std");
00065 const string QCCommon::Pm3ParamStr  ("PM3_Param_Std");
00066 const map<string, QCParameterType> QCCommon::paramTypes = initParam();
00067 
00068 
00069 
00070 
00074 inline map<string, QCComputation>
00075 initComputation (void) {
00076   map<string, QCComputation> comp;
00077   comp [QCCommon::EnergyStr]      = QC_ENERGY;
00078   comp [QCCommon::EnergyDerivStr] = QC_ENERGY_DERIV;
00079   comp [QCCommon::ToolsStr]       = QC_TOOLS;
00080   return comp;
00081 }
00082 //
00083 const string QCCommon::EnergyStr      ("Energy");
00084 const string QCCommon::EnergyDerivStr ("Energy_Derivative");  
00085 const string QCCommon::ToolsStr       ("Tools");  
00086 const map<string, QCComputation> QCCommon::computations = initComputation();
00087  
00088 
00089 
00090 
00094 inline map<string, QCMainAlgorithm>
00095 initMainAlgo (void) {
00096   map<string, QCMainAlgorithm> mainAlgo;
00097   mainAlgo [QCCommon::SCFStr]              = QC_SCF;
00098   mainAlgo [QCCommon::LevelShiftingStr]    = QC_LEVEL_SHIFTING;
00099   mainAlgo [QCCommon::OptimalDampingStr]   = QC_OPTIMAL_DAMPING;
00100   mainAlgo [QCCommon::DCSCFStr]            = QC_DC_SCF;
00101   mainAlgo [QCCommon::DCLevelShiftingStr]  = QC_DC_LEVEL_SHIFTING;
00102   mainAlgo [QCCommon::DCOptimalDampingStr] = QC_DC_OPTIMAL_DAMPING;
00103   return mainAlgo;
00104 }
00105 //
00106 const string QCCommon::SCFStr              ("SCF");
00107 const string QCCommon::LevelShiftingStr    ("Level_Shifting");
00108 const string QCCommon::OptimalDampingStr   ("Optimal_Damping");
00109 const string QCCommon::DCSCFStr            ("DC_SCF");
00110 const string QCCommon::DCLevelShiftingStr  ("DC_Level_Shifting");
00111 const string QCCommon::DCOptimalDampingStr ("DC_Optimal_Damping");
00112 const map<string, QCMainAlgorithm> QCCommon::mainAlgorithms = initMainAlgo();
00113   
00114 
00115 
00116 
00120 inline map<string, QCDiagoAlgorithm>
00121 initDiago (void) {
00122   map<string, QCDiagoAlgorithm> diago;
00123   diago [QCCommon::ClassicDiagoStr] = QC_CLASSIC_DIAGO;
00124   diago [QCCommon::DCDiagoStr]      = QC_DC_DIAGO;
00125   return diago;
00126 }
00127 //
00128 const string QCCommon::ClassicDiagoStr ("Classic_Diago");
00129 const string QCCommon::DCDiagoStr      ("DC_Diago");
00130 const map<string, QCDiagoAlgorithm> QCCommon::diagoAlgorithms = initDiago();
00131   
00132 
00133 
00134 
00138 inline map<string, QCIntgAcquisitionMethod>
00139 initIntgMethod (void) {
00140   map<string, QCIntgAcquisitionMethod> intg;
00141   intg [QCCommon::DirectComputationStr] = QC_DIRECT_COMPUTATION;
00142   intg [QCCommon::IndirectStorageStr]   = QC_INDIRECT_STORAGE;
00143   return intg;
00144 }
00145 //
00146 const string QCCommon::DirectComputationStr ("Direct_Calculation");
00147 const string QCCommon::IndirectStorageStr   ("Indirect_Storage");
00148 const map<string, QCIntgAcquisitionMethod> QCCommon::intgAcqMethods = initIntgMethod();
00149 //
00150 //
00151 //
00152 inline map<string, QCInitDensityMatrix>
00153 initDensityMethod (void) {
00154   map<string, QCInitDensityMatrix> initD;
00155   initD [QCCommon::initDiagStr]   = QC_DENSITY_DIAG;
00156   initD [QCCommon::initFileStr]   = QC_DENSITY_FROM_FILE;
00157   return initD;
00158 }
00159 const string  QCCommon::initDiagStr("Diagonalisation") ;
00160 const string  QCCommon::initFileStr("From_File");
00161 const map<string, QCInitDensityMatrix> QCCommon::initDensityMatrix = initDensityMethod();
00162 
00163 
00167 inline map<string, QCDerivationType>
00168 initDerivType (void) {
00169   map<string, QCDerivationType> deriv;
00170   deriv [QCCommon::NumericalDerivationStr]  = QC_NUMERICAL_DERIVATION;
00171   deriv [QCCommon::AnalyticalDerivationStr] = QC_ANALYTICAL_DERIVATION;
00172   return deriv;
00173 }
00174 //
00175 const string QCCommon::NumericalDerivationStr  ("Numerical_Derivation");
00176 const string QCCommon::AnalyticalDerivationStr ("Analytical_Derivation");
00177 const map<string, QCDerivationType> QCCommon::derivationTypes = initDerivType();
00178   
00179 
00180 
00181 
00185 inline map<string, QCDerivShiftBhvr>
00186 initDerivBhvr (void) {
00187   map<string, QCDerivShiftBhvr> bhvr;
00188   bhvr [QCCommon::ConstantStr] = QC_CONSTANT;
00189   bhvr [QCCommon::ComputedStr] = QC_COMPUTED;
00190   return bhvr;
00191 }
00192 //
00193 const string QCCommon::ConstantStr ("Constant");
00194 const string QCCommon::ComputedStr ("Computed");
00195 const map<string, QCDerivShiftBhvr> QCCommon::derivShiftBhvrs = initDerivBhvr();
00196 
00197 
00198 
00202 inline map<QCSubDomainZone, string>
00203 initZones (void) {
00204   map<QCSubDomainZone, string> zones;
00205   zones[QC_CORE]   = QCCommon::CoreZoneStr;
00206   zones[QC_SHELL1] = QCCommon::Shell1ZoneStr;
00207   zones[QC_SHELL2] = QCCommon::Shell2ZoneStr;
00208   return zones;
00209 }
00210 //
00211 const string QCCommon::CoreZoneStr   ("  CORE");
00212 const string QCCommon::Shell1ZoneStr ("SHELL1");
00213 const string QCCommon::Shell2ZoneStr ("SHELL2");
00214 const map<QCSubDomainZone, string> QCCommon::domainZones = initZones();
00215 
00216 
00217 
00221 inline map<string, QCPartitionType>
00222 initPartTypes (void) {
00223   map<string, QCPartitionType> types;
00224   types[QCCommon::StandardPartStr] = QC_STANDARD_PART;
00225   types[QCCommon::DixonPartStr]    = QC_DIXON_PART;
00226   return types;
00227 }
00228 //
00229 const string QCCommon::StandardPartStr ("QC_Standard_Part");
00230 const string QCCommon::DixonPartStr    ("QC_Dixon_Part");
00231 const map<string, QCPartitionType> QCCommon::partitionTypes = initPartTypes();
00232 
00233 
00234 
00238 inline map<string, QCPartitionerType>
00239 initPartitionerTypes (void) {
00240   map<string, QCPartitionerType> types;
00241   types[QCCommon::LinearStr] = QC_LINEAR;
00242   types[QCCommon::KimikaStr] = QC_KIMIKA;
00243   return types;
00244 }
00245 //
00246 const string QCCommon::LinearStr ("QC_Linear");
00247 const string QCCommon::KimikaStr ("QC_Kimika");
00248 const map<string, QCPartitionerType> QCCommon::partitionerTypes = initPartitionerTypes();
00249 
00250 
00251 
00255 const string QCCommon::YesStr ("YES");
00256 const string QCCommon::NoStr  ("NO");
00257 
00258 
00259 
00263 char * env = getenv("QCPPUSERDIR");
00264 const string QCCommon::UserDirName = ".." + PATH_SEPARATOR + "userdir";
00265 const string QCCommon::DataDirName("data");
00266 const string QCCommon::DataBaseDirName(QCPP_DATABASE_PATH_);
00267 const string QCCommon::OutDirName ("results");
00268 string       QCCommon::userdir    ((env)? env : UserDirName);
00269 string       QCCommon::datadir    (userdir + PATH_SEPARATOR + DataDirName);
00270 string       QCCommon::outdir     (userdir + PATH_SEPARATOR + OutDirName);
00271 
00272 
00273 
00277 const int    QCCommon::Pid = getpid();
00278 
00279 
00280 
00281 
00285 const string QCCommon::ErrorFile (outdir +
00286                                   PATH_SEPARATOR +
00287                                   "Error_" +
00288                                   getTimeStr() +
00289                                   "@" +
00290                                   getPidStr() +
00291                                   OUTPUT_SUFFIX);
00292 
00293 
00294 
00298 const string QCCommon::MemoryTmpFile ("MemoryTmpFile@" + 
00299                                       getPidStr() + 
00300                                       OUTPUT_SUFFIX);
00301 
00302 
00309 const string QCCommon::IntegralsTmpFile (PATH_SEPARATOR + 
00310                                          "tmp" +
00311                                          PATH_SEPARATOR +
00312                                          "IntegralsTmpFile@" + 
00313                                          getPidStr());
00314 
00315 
00316 
00317 
00318 
00319 
00320 
00321 
00322 
00327 string 
00328 QCCommon::getTimeStr (void) {
00329   time_t     timeForCurQC;
00330   struct tm* structTimeForCurQC;
00331   char       timeCStr[32];  
00332 
00333   // On recupere la date
00334   timeForCurQC = time(NULL);
00335 
00336   // On la met dans une structure
00337   structTimeForCurQC = localtime(&timeForCurQC);
00338 
00339   // On ecrit la date dans une chaine de caractere
00340   sprintf(timeCStr, 
00341           "%02d_%02d_%02d",
00342           // Attention, les annees sont numerotees a partir de 1900
00343           //structTimeForCurQC->tm_year + 1900, 
00344           // et les mois de 0 a 11.
00345           //structTimeForCurQC->tm_mon + 1,
00346           //structTimeForCurQC->tm_mday,
00347           structTimeForCurQC->tm_hour,
00348           structTimeForCurQC->tm_min,
00349           structTimeForCurQC->tm_sec);
00350 
00351   // Que l on renvoie sous forme de string.
00352   return string(timeCStr);
00353 }
00354 
00355 
00356 
00360 string 
00361 QCCommon::getPidStr (void) {
00362   ostringstream oss;
00363   oss << Pid;
00364   return oss.str();
00365 }

Generated on Sat Jan 28 21:07:25 2006 for QC++ by  doxygen 1.4.4