DSQSS  1.1
dla_alg.h
説明を見る。
00001 //
00002 //     Algorithm File Generator for dla.cc
00003 //
00004 //                   Copy Right 2005, Naoki Kawashima 
00005 //
00006 
00007 #include <math.h>
00008 #include <vector>
00009 #include "array.h"
00010 #include "io.h"
00011 #include "name.h"
00012 #include "xml.h"
00013 
00014 class InitialConfiguration;
00015 class InitialConfigurationGroup;
00016 class GENERAL;
00017 class SITE;
00018 class SOURCE;
00019 class INTERACTION;
00020 class VERTEX;
00021 class QUANTITY;
00022 
00023 using namespace std;
00024 
00025 //######################################################################
00026 
00027 void SolveWeightEquation(int N, Array<double>& V, Array<double>& W);
00028 bool testKink(int ist);
00029 bool testForbidden(int ist);
00030 void bubble_sort(int N, Array<double>& V, Array<int>& I);
00031 
00032 //######################################################################
00033 
00034 class GENERAL {
00035 public:
00036   string comment;
00037   // "WeightDiagonal"
00038   // the artificial weight attached to the diagonal state
00039   // in solving the weight equation for the worm creation/annihilation
00040   // ( the same as 1/(N_{box} \eta^2) )
00041   double WeightDiagonal; 
00042   GENERAL(XML::Block& X);
00043   void write();
00044 };
00045 
00046 //######################################################################
00047 
00048 class SITE {
00049 public:
00050   int ID;
00051   int TTYPE; // the SOURCE type of the worm tail
00052   int VTYPE; // the VERTEX type of the worm tail
00053   int NX;
00054   int* NumberOfChannels;
00055   SOURCE* _T;
00056   SOURCE& T() { return *_T; };
00057   VERTEX& V();
00058   Array<int> WormCreationNewState;
00059   Array<int> WormCreationDirection;
00060   Array<double> WormCreationProbability;
00061 
00062   SITE() {
00063     _T = 0;
00064     ID = STYPE::UNDEF;
00065     TTYPE = TTYPE::UNDEF;
00066     VTYPE = VTYPE::UNDEF;
00067     NX = 0;
00068     NumberOfChannels = 0;
00069   };
00070 
00071   ~SITE() {
00072     if ( NumberOfChannels != 0 ) delete [] NumberOfChannels;
00073     WormCreationNewState.reset();
00074     WormCreationDirection.reset();
00075     WormCreationProbability.reset();
00076   };
00077 
00078   void load(XML::Block& X);
00079   void SetInitialHeadTypeProbability();
00080   void write();
00081   void dump();
00082 
00083 };
00084 
00085 //######################################################################
00086 
00087 class VERTEX {
00088 private:
00089   IndexSystem* _INDX;
00090 
00091 public:
00092 
00093   int ID;
00094   vector<InitialConfigurationGroup*> icg;
00095   InitialConfigurationGroup& ICG(int i) { return *(icg[i]); };
00096   void add_ICG( InitialConfigurationGroup& x ) { icg.push_back( &x ); };
00097 
00098   int NBODY;     // the number of sites interacting
00099   int NLEG;
00100   int NICG;      // number of initial configuration group
00101   int NICV;      // total number of initial configurations
00102   int NST;       // the number of initial states (not including worm type or direction)
00103   int CATEGORY;  // =0 (TERM), =1 (WORM), =2 (INTERACTION)
00104   double EBASE;
00105   Array<double> Weight;
00106   Array<int> SiteTypeOfLeg;
00107   Array<int> checked;
00108 
00109   void setINDX( IndexSystem& I ) { _INDX = &I; };
00110   IndexSystem& INDX() { return *_INDX; };
00111 
00112   VERTEX() { 
00113     ID = VTYPE::UNDEF; 
00114     NBODY = 0;
00115     NLEG = 0;
00116     NICG = 0;
00117     NICV = 0;
00118     NST = 0;
00119     CATEGORY = VCAT::UNDEF;
00120     EBASE = 0.0;
00121   };
00122 
00123   ~VERTEX() {
00124   };
00125 
00126   bool isTerm() { return CATEGORY == VCAT::TERM; };
00127   bool isWorm() { return CATEGORY == VCAT::WORM; };
00128   bool isInteraction() { return CATEGORY == VCAT::INT; };
00129   void Grouping();
00130   double ComputeEBASE();
00131   void ComputeScatteringProbability();
00132   void dump();
00133   void load(XML::Block& X);
00134   void write();
00135   int NumberOfValidInitialConfigurations();
00136   bool testKink(int ist);
00137   bool testForbidden(int ist);
00138 
00139 };
00140 
00141 //######################################################################
00142 
00143 class SOURCE {
00144 public:
00145   int ID;
00146   int STYPE;
00147   int VTYPE;
00148   VERTEX *_V;
00149   SOURCE() { 
00150     ID = TTYPE::UNDEF; STYPE = STYPE::UNDEF; VTYPE = VTYPE::UNDEF; _V = 0; 
00151   };
00152   VERTEX& V() { 
00153     if ( _V == 0 ) {
00154       printf("SOURCE::V> Error. _V is not defined.\n"); 
00155       exit(0);
00156     }
00157     return *_V; 
00158   };
00159   double Weight(int x0, int x1) { 
00160     return V().Weight( x0 , x1 ); 
00161   };
00162   void load(XML::Block& X);
00163   void dump();
00164 };
00165 
00166 //######################################################################
00167 
00168 class INTERACTION {
00169 public:
00170   int ID;
00171   int VTYPE;
00172   int NBODY;
00173   VERTEX* _V;
00174   VERTEX& V() { return *_V; };
00175   Array<double> VertexDensity;
00176   INTERACTION() { ID = ITYPE::UNDEF; VTYPE = VTYPE::UNDEF; NBODY = 0; };
00177   ~INTERACTION() { VertexDensity.reset(); };
00178   int STYPE(int i);
00179   void SetVertexDensity();
00180   void load(XML::Block& X);
00181   void write();
00182   void dump();
00183 };
00184 
00185 //######################################################################
00186 
00187 class InitialConfiguration {
00188 
00189 private:
00190 
00191   static int LastID;
00192   int ID;
00193 
00194 public:
00195 
00196   friend class InitialConfigurationGroup;
00197 
00198   int NBODY;
00199   int NLEG;
00200   int NCH;
00201   int STI;
00202   int XINC;
00203   int INC;
00204 
00205   int* State;
00206   int* FinalState;
00207   int* FinalDirection;
00208   double* ScatteringProbability;
00209   VERTEX* _V;
00210 
00211   InitialConfiguration() { 
00212     ID = LastID; 
00213     LastID++; 
00214     State = 0;
00215     FinalState = 0;
00216     FinalDirection = 0;
00217     ScatteringProbability = 0;
00218   };
00219 
00220   ~InitialConfiguration() {
00221     if ( State != 0 ) delete [] State;
00222     if ( ScatteringProbability != 0 ) delete [] ScatteringProbability;
00223     if ( FinalState != 0 ) delete [] FinalState;
00224     if ( FinalDirection != 0 ) delete [] FinalDirection;
00225   };
00226 
00227   bool isValid();
00228   void setV(VERTEX& V0) { _V = &V0; };
00229   VERTEX& V() { return *_V; };
00230   void init( VERTEX& V, int sti , int inc, int xinc, int NICmax );
00231   bool isKink();
00232   int& id() { return ID; }
00233   double weight();
00234   double vertex_weight();
00235   double worm_weight();
00236   void dump();
00237   void write();
00238 
00239 };
00240 
00241 int InitialConfiguration::LastID = 0;
00242 
00243 //######################################################################
00244 
00245 class InitialConfigurationGroup {
00246 
00247 private:
00248   static int LastID;
00249   int ID;
00250   
00251 public:
00252   int NIC;
00253   int NDIAG;
00254   Array<double> U;
00255   //  Array<double> W;
00256   //  Array<double> P;
00257   VERTEX* _V;
00258   Array<InitialConfiguration> IC;
00259   int NBODY;
00260   int NLEG;
00261 
00262   InitialConfigurationGroup() { 
00263     ID = LastID;
00264     LastID++;
00265     _V = 0;
00266   };
00267 
00268   ~InitialConfigurationGroup() {
00269     IC.reset();
00270   };
00271 
00272   void setV(VERTEX& V0) { _V = &V0; };
00273 
00274   VERTEX& V() { 
00275     if ( _V == 0 ) {
00276       printf("VERTEX::V> Error. _V has not been defined.\n");
00277       exit(0);
00278     }
00279     return *_V; 
00280   };
00281 
00282   int NumberOfValidInitialConfigurations();
00283 
00284   //  void init_w( int nbody , int sti );
00285   void init( VERTEX& v, int nbody , int sti, int inc , int xinc );
00286   int number_of_diagonal_states();
00287   int number_of_offdiagonal_states();
00288   double minimum_diagonal_weight();
00289   double maximum_diagonal_weight();
00290   double maximum_offdiagonal_weight();
00291   double sum_of_all_weights();
00292   double ebase(); // the maximum base energy to make
00293                   // all diagonal weights positive
00294   void add_to_diagonal_element(double E);
00295   void numbering(int& ICNF);
00296   void ScatteringProbability();
00297   void ResetWeight();
00298 
00299   void dump();
00300   void write();
00301   
00302 };
00303 
00304 int InitialConfigurationGroup::LastID = 0;
00305 
00306 //######################################################################
00307 
00308 class QUANTITY {
00309 private:
00310   int ID;
00311   string NAME;
00312 public:
00313   Array<double> Value;
00314   Array<bool> isDefined;
00315   int getID() { return ID; };
00316   void setID(int i) { ID = i; };
00317   const string& getName() { return NAME; };
00318   void setName(const string& s) { NAME = s; };
00319   void load(XML::Block& X);
00320   //  void dump();
00321   void write();
00322 };
00323 
00324 //######################################################################
00325 
00326 int INTERACTION::STYPE(int i) { return _V->SiteTypeOfLeg(2*i); }
00327 
00328 //######################################################################
00329 
00330 VERTEX& SITE::V() { 
00331   if ( _T == 0 ) {
00332     printf("SITE::V> Error. _T is not defined.\n"); 
00333     exit(0);
00334   }
00335   return T().V(); 
00336 }
00337 
00338 //######################################################################
00339 
00340 char* HFILE; // file name of the hamiltonian and the worm
00341 char* AFILE; // file name of algorithm data file
00342 FileReader H;
00343 FILE* FALG;
00344 
00345 SITE* Site;
00346 SOURCE* Source;
00347 INTERACTION* Interaction;
00348 VERTEX* Vertex;
00349 QUANTITY* Quantity;
00350 
00351 bool isKink(int st);
00352 
00353 int NVTYPE;
00354 int NSTYPE; // the number of site types
00355 int NITYPE; // the number of interaction types
00356 int NHTYPE; // the number of worm head types
00357 int NQTYPE; // the number of observable types
00358 int NXMAX;
00359 
00360 bool MON = false; // true for monitoring
00361 
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型の値 フレンド マクロ定義