DSQSS
1.1
|
00001 00002 #ifndef ALGORITHM_H 00003 #define ALGORITHM_H 00004 00005 #include <iostream> 00006 #include <stdio.h> 00007 #include "name.h" 00008 #include "io.h" 00009 #include "array.h" 00010 #include "link.hpp" 00011 #include "xml.h" 00012 00013 //#include "objects.hpp" 00014 //####################################################################### 00015 00016 class Algorithm; 00017 class SiteProperty; 00018 class SiteInitialConfiguration; 00019 class InteractionProperty; 00020 class VertexProperty; 00021 class VertexInitialConfiguration; 00022 class ScatteringChannel; 00023 00024 //###################################################################### 00025 //#### Object Property Declarations 00026 //###################################################################### 00027 00028 class SiteInitialConfiguration { 00029 public: 00030 int State; 00031 int NCH; 00032 Array<ScatteringChannel> CH; 00033 SiteInitialConfiguration() { 00034 CH.setLabel("SiteInitialConfiguration::CH"); 00035 }; 00036 int id() { return State; }; 00037 void initialize(XML::Block& X); 00038 void dump(); 00039 }; 00040 00041 //####################################################################### 00042 00043 class SiteProperty { 00044 public: 00045 int STYPE; 00046 int VTYPE; 00047 VertexProperty* _VP; 00048 int NX; 00049 int NIC; 00050 Array<SiteInitialConfiguration> IC; 00051 SiteProperty() { 00052 IC.setLabel("SiteProperty::IC"); 00053 }; 00054 00055 int id() { return STYPE; }; 00056 void initialize(XML::Block& X); 00057 void setVertexProperty(VertexProperty& VP) { _VP = &VP; }; 00058 VertexProperty& getVertexProperty() { return *_VP; }; 00059 SiteInitialConfiguration& getInitialConfiguration(int x) { 00060 return IC[x]; 00061 } 00062 void dump(); 00063 }; 00064 00065 //####################################################################### 00066 00067 class ScatteringChannel { 00068 public: 00069 int OUT; 00070 int XOUT; 00071 double PROB; 00072 00073 void initialize(XML::Block& X); 00074 void dump(); 00075 }; 00076 00077 //####################################################################### 00078 00079 class InteractionProperty { 00080 public: 00081 int ITYPE; 00082 int VTYPE; 00083 int NBODY; 00084 int NXMAX; 00085 double EBASE; 00086 VertexProperty* _VP; 00087 Array<int> STYPE; 00088 Array<double> VertexDensity; 00089 Array<double> AverageInterval; 00090 00091 InteractionProperty() { 00092 STYPE.setLabel("InteractionProperty::STYPE"); 00093 VertexDensity.setLabel("InteractionProperty::VertexDensity"); 00094 AverageInterval.setLabel("InteractionProperty::AverageInterval"); 00095 }; 00096 00097 void setVertexProperty(VertexProperty& vp) { _VP = &vp; }; 00098 VertexProperty& getVertexProperty() { return *_VP; }; 00099 00100 int id() { return ITYPE; }; 00101 void initialize(XML::Block& X); 00102 void dump(); 00103 }; 00104 00105 //####################################################################### 00106 00107 class VertexProperty { 00108 private: 00109 public: 00110 int VTYPE; 00111 int VCAT; 00112 int NBODY; 00113 int NLEG; 00114 int NST; 00115 int NIC; 00116 int NHTYPE; 00117 int NXMAX; 00118 // === edit sakakura === 00119 int MIC; 00120 // === edit sakakura === 00121 Array<int> STYPE; 00122 Array<VertexInitialConfiguration> IC; 00123 Array<VertexInitialConfiguration*> _IC; 00124 Array<int> StateCode; 00125 Array<int> SCNK; // State Code for NON-KINK 00126 00127 VertexProperty() { 00128 STYPE.setLabel("VertexProperty::STYPE"); 00129 IC.setLabel("VertexProperty::IC"); 00130 _IC.setLabel("VertexProperty::_IC"); 00131 StateCode.setLabel("VertexProperty::StateCode"); 00132 SCNK.setLabel("VertexProperty::StateCode4NON-KINK"); 00133 }; 00134 00135 int id() { return VTYPE; }; 00136 00137 // == edit sakakura == 00138 void initialize(XML::Block& X,int i); 00139 //void initialize(XML::Block& X); 00140 // == edit sakakura == 00141 00142 int getSiteType(int out); 00143 bool isTerminal() { return VCAT == VCAT::TERM; }; 00144 VertexInitialConfiguration& getIC(int st, int inc, int xinc); 00145 00146 void dump(); 00147 }; 00148 00149 //####################################################################### 00150 00151 class VertexInitialConfiguration { 00152 private: 00153 00154 00155 public: 00156 int ID; 00157 00158 Array<ScatteringChannel> CH; 00159 00160 VertexInitialConfiguration() { 00161 ID = -1; 00162 CH.setLabel("VertexInitialConfiguration::CH"); 00163 }; 00164 00165 ~VertexInitialConfiguration() { 00166 if ( State != 0 ) delete [] State; 00167 }; 00168 00169 int NLEG; 00170 int* State; 00171 int INC; 00172 int XINC; 00173 int NCH; 00174 00175 // -- edit sakakura -- 00176 int MCH; //NCHの最大値 00177 // -- edit sakakura -- 00178 // 00179 double dRHO;// [vertex density] * [1-p1] 00180 void setID(int i) { ID = i; }; 00181 int id() { return ID; }; 00182 void initialize(XML::Block& X); 00183 00184 // edit sakakura 00185 void initialize(); 00186 // edit sakakura 00187 // 00188 ScatteringChannel& getScatteringChannel(); 00189 ScatteringChannel& getScatteringChannel(double drho); 00190 void dump(); 00191 00192 }; 00193 00194 //int VertexInitialConfiguration::LastID = 0; 00195 00196 //####################################################################### 00197 00198 class Algorithm { 00199 00200 private: 00201 00202 XML::Block X; 00203 Array<SiteProperty> SPROP; 00204 Array<InteractionProperty> IPROP; 00205 Array<VertexProperty> VPROP; 00206 00207 // --edit sakakrua -- 00208 int ix; 00209 // --edit sakakrua -- 00210 public: 00211 00212 Algorithm(char* FNAME); 00213 00214 // --edit sakakrua -- 00215 Algorithm();//no 00216 // --edit sakakrua -- 00217 00218 ~Algorithm(); 00219 00220 int NSTYPE; // Number of site types 00221 int NITYPE; // Number of interaction types 00222 int NVTYPE; // Number of bond types 00223 int NXMAX; // Maximum number of segment states 00224 double WDIAG; // Artifitial weight attached to the diagonal state 00225 // Used in relating the worm-head mean-path to the susceptibility 00226 00227 void read(); 00228 void initialize(); 00229 00230 // --edit sakakrua -- 00231 int MXNIC1; // Maximum number of Vertex InitialConfigureations 00232 void initializer(int i ); 00233 void set_i(int n) { ix=n; } 00234 void set_alg(int n) ; 00235 // --edit sakakrua -- 00236 00237 SiteProperty& getSiteProperty(int i) { return SPROP[i]; };//return val[i] 00238 InteractionProperty& getInteractionProperty(int i) { return IPROP[i]; }; 00239 VertexProperty& getVertexProperty(int i) { return VPROP[i]; }; 00240 00241 void dump() { X.dump(); }; 00242 // 00243 // void get_spid(){return id();}; 00244 00245 }; 00246 00247 //###################################################################### 00248 //########### Member Functions ####################################### 00249 //###################################################################### 00250 // 00251 // ============= edit sakakura ============ 00252 00253 inline Algorithm::Algorithm(char* FNAME) { 00254 SPROP.setLabel("Algorithm::SPROP"); 00255 IPROP.setLabel("Algorithm::IPROP"); 00256 VPROP.setLabel("Algorithm::VPROP"); 00257 00258 if (DEBUG) printf("\nAlgorithm::Algorithm> Start.\n"); 00259 X.initialize( FNAME ); //pass2 //xml::Block X 00260 00261 // == edit sakakura == 00262 int ixx = X["General"]["NXMAX" ].getInteger(); 00263 MXNIC1=24*(ixx-1)*(ixx-1); 00264 // == edit sakakura == 00265 00266 read(); 00267 initialize(); 00268 00269 if (DEBUG) printf("Algorithm::Algorithm> End.\n"); 00270 } 00271 00272 //====================================================================== 00273 // ============= edit sakakura ============ 00274 inline Algorithm::Algorithm() { 00275 } 00276 // ============= edit sakakura ============ 00277 void Algorithm::set_alg(int ix) { 00278 SPROP.setLabel("Algorithm::SPROP"); 00279 IPROP.setLabel("Algorithm::IPROP"); 00280 VPROP.setLabel("Algorithm::VPROP"); 00281 00282 // == edit sakakura == 00283 MXNIC1=0; 00284 // == edit sakakura == 00285 00286 //char* FNAME="algorithm.xml"; 00287 00288 stringstream ss; 00289 ss << ix << ".xml"; 00290 // char* xxx ; 00291 00292 // string zzz = ss.str(); 00293 00294 // 00295 // if (DEBUG) printf("\nAlgorithm::Algorithm> Start.\n"); 00296 // X.initialize( FNAME ); 00297 X.initialize(ss.str().c_str() ); 00298 read(); 00299 initialize(); 00300 00301 // if (DEBUG) printf("Algorithm::Algorithm> End.\n"); 00302 } 00303 // ============= edit sakakura ============ 00304 00305 00306 //====================================================================== 00307 00308 void Algorithm::read() { 00309 00310 // if (DEBUG) printf("Algorithm::read> Start.\n"); 00311 00312 NSTYPE = X["General"]["NSTYPE"].getInteger(); //1 []operator 00313 NITYPE = X["General"]["NITYPE"].getInteger(); //1 00314 NVTYPE = X["General"]["NVTYPE"].getInteger(); //2 00315 NXMAX = X["General"]["NXMAX" ].getInteger(); //2 00316 WDIAG = X["General"]["WDIAG" ].getDouble(); // 0.25 00317 00318 SPROP.init(1,NSTYPE); //1,SiteProperty 00319 IPROP.init(1,NITYPE); //1,InteractionProperty 00320 VPROP.init(1,NVTYPE); //2,VertexProperty 00321 00322 for (int i=0; i<NITYPE; i++) { //1 IPROP(i) : return val[i] 00323 IPROP(i).NXMAX = NXMAX; 00324 } 00325 00326 for (int i=0; i<NVTYPE; i++) { //2 00327 VPROP(i).NXMAX = NXMAX; 00328 } 00329 00330 for (int i=0; i<X.NumberOfBlocks(); i++) { //X.numberofblocks=6 00331 XML::Block& B = X[i]; 00332 const string& name = B.getName(); 00333 00334 if ( name == "Site" ) { 00335 int id = B["STYPE"].getInteger(); //id=0 00336 SPROP(id).initialize(B); //463行目 この時点でSitePropertyClass set完了 00337 //SPROP(0) は、SiteProperty& val[0]を返す。 00338 } 00339 00340 if ( name == "Interaction" ) { 00341 int id = B["ITYPE"].getInteger();//id=0 00342 IPROP(id).initialize(B);//son 00343 } 00344 00345 if ( name == "Vertex" ) { //riyo 00346 int id = B["VTYPE"].getInteger(); //id=0,1 00347 // -- edit sakakura -- 00348 VPROP(id).initialize(B,MXNIC1);//mayu 00349 // VPROP(id).initialize(B);//mayu 00350 // -- edit sakakura -- 00351 00352 } 00353 } 00354 } 00355 00356 00357 //= edit sakakura ======================================================= 00358 void Algorithm::initializer(int ix) { 00359 00360 for (int i=1; i<2; i++) { 00361 VertexProperty& VP = VPROP(i); 00362 00363 VP.NIC = ix; 00364 00365 // VP.initialize.StateCode.set_all(STATE::UNDEF); 00366 VP.StateCode.set_all(-1); 00367 VP._IC.set_all(0); 00368 VP.SCNK.set_all(STATE::UNDEF); //-1 //size=2,4 00369 // cout <<"VP.NIC = " <<VP.NIC << endl; 00370 // VP.dump(); 00371 // exit(31); 00372 00373 int nst = 0; 00374 00375 // --- edit sakakura --- 00376 for (int ic=0; ic<ix; ic++) { 00377 // int ic = ix; 00378 // cout <<"initializer ="<< ic << endl; 00379 // --- edit sakakura --- 00380 VertexInitialConfiguration& IC = VP.IC[ic]; //tomo 00381 00382 int nl = VP.NLEG; 00383 int* x = IC.State; 00384 int inc = IC.INC; 00385 int xinc = IC.XINC; 00386 int st; 00387 bool isKink = false; 00388 int* xx = new int[nl/2]; 00389 00390 for(int il = 0; il < nl ; il+=2){ 00391 if(x[il]!=x[il+1])isKink = true; 00392 else xx[il/2] = x[il]; 00393 } 00394 // printf ("ic=%d ( %d %d %d %d ) vps=%d\n",ic,x[0],x[1],x[2],x[3],VP.StateCode(x)); 00395 if ( VP.StateCode(x) == STATE::UNDEF ) { //operator return val(ID(x)) 00396 VP.StateCode(x) = nst; 00397 st = nst; 00398 if(!isKink) VP.SCNK(xx)=nst; 00399 nst++; 00400 } else { 00401 st = VP.StateCode(x); 00402 } 00403 // printf("ic=%d st=%d inc=%d xinc=%d\n",ic,st,inc,xinc) ; 00404 00405 // st = VP.StateCode(x); 00406 VP._IC( st, inc, xinc) = &IC; //st,inc,xincを利用してINDEX生成//rei 00407 delete [] xx; 00408 } //end VP.NICloop 00409 // VP.dump(); 00410 } 00411 // InteractionProperty の _VP を初期化 00412 for (int i=0; i<NITYPE; i++) { 00413 InteractionProperty& I = IPROP(i); 00414 I.setVertexProperty(VPROP(I.VTYPE)); 00415 } 00416 00417 return; 00418 00419 // 散乱確率の積算と ScatteringChannel::PROB の再々定義 00420 // NOT KINK のバーテックスに対してはPROB = [vertexdensity]*[probablity]とする 00421 for (int i=1; i<2; i++) { 00422 VertexProperty& VP = VPROP(i); 00423 // --- edit sakakura --- 00424 00425 for (int j=VP.NIC; j<VP.MIC; j++) { 00426 00427 VertexInitialConfiguration& IC = VP.IC[j]; 00428 00429 bool isKink = false; 00430 int* x = new int[VP.NBODY]; //edit sakakura 00431 // int x[VP.NBODY]; 00432 for(int ileg = 0; ileg<IC.NLEG; ileg+=2){ 00433 if(IC.State[ileg]!=IC.State[ileg+1]){isKink=true;} 00434 x[ileg/2]=IC.State[ileg]; 00435 } 00436 double p = 0.0; 00437 00438 bool isVertex = false;// false: kink or term , true: means interaction 00439 int i_type =0; 00440 for(i_type = 0; i_type<NITYPE; i_type++){ 00441 if(IPROP[i_type].VTYPE==i){isVertex = true; break;} 00442 }// If VTYPE is for Vertex (not for term or tail), there should be InteractionProperty with density of vertex. 00443 00444 if( isKink||(!isVertex )){ 00445 00446 IC.dRHO=1.0; 00447 for (int k=0; k<IC.NCH; k++) { 00448 ScatteringChannel& SC = IC.CH[k]; 00449 p += SC.PROB; 00450 SC.PROB = p; 00451 } 00452 00453 }else{ 00454 double Vdensity = IPROP[i_type].VertexDensity(x); 00455 int count_ch = 0; 00456 double dR = Vdensity; 00457 00458 for (int k=0; k<IC.NCH; k++) { 00459 00460 ScatteringChannel& SC = IC.CH[k]; 00461 if(SC.OUT == IC.INC + 1 - 2*(IC.INC%2)){ 00462 dR = (1.0-SC.PROB)*Vdensity; 00463 }else{ 00464 p += (SC.PROB * Vdensity); 00465 IC.CH[count_ch] = SC; 00466 IC.CH[count_ch].PROB = p; 00467 count_ch++; 00468 } 00469 00470 } 00471 IC.dRHO = dR; 00472 IC.NCH = count_ch; 00473 } 00474 if ( fabs(p-IC.dRHO) > EPS * 10.0 ) { 00475 printf("Algorithm::initialize> Error.\n"); 00476 printf(" The sum of probabilities is not equal to dRHO.\n"); 00477 VP.dump(); 00478 IC.dump(); 00479 exit(0); 00480 } 00481 00482 if(IC.NCH != 0){ IC.CH[ IC.NCH - 1 ].PROB = IC.dRHO + EPS; 00483 }else{ IC.dRHO = 0.0;} 00484 delete []x; 00485 } 00486 } 00487 00488 // if (DEBUG) printf("Algorithm::initialize> End.\n"); 00489 } 00490 00491 //= edit sakakura ======================================================= 00492 00493 //====================================================================== 00494 00495 void Algorithm::initialize() { 00496 00497 // if (DEBUG) printf("Algorithm::initialize> Start.\n"); 00498 // Site::_VP の初期化 00499 00500 for (int i=0; i<NSTYPE; i++) { //1 00501 int vt = SPROP(i).VTYPE;//2 00502 SPROP(i).setVertexProperty( VPROP(vt) ); //VPROP(vt) {return val} 00503 00504 //kota! setVertexProperty(VertexProperty& VP) { _VP = &VP; };// 00505 } 00506 // 散乱確率の積算と ScatteringChannel::PROB の再定義 //1.0にする 00507 00508 for (int i=0; i<NSTYPE; i++) {//1 00509 SiteProperty& SP = SPROP(i); 00510 // SP.dump(); 定義前 00511 for (int j=0; j<SP.NIC; j++) { //NIC=NX=Numberofstates 2 00512 SiteInitialConfiguration& IC = SP.IC[j]; //[]operator return val[i] 00513 double p = 0.0; 00514 00515 for (int k=0; k<IC.NCH; k++) { //numberofchannnels 00516 ScatteringChannel& SC = IC.CH[k]; 00517 p += SC.PROB; 00518 SC.PROB = p; 00519 } 00520 if ( fabs(p-1.0) > EPS ) { //EPS=1.d-14 00521 printf("Algorithm::initialize> Error.\n"); 00522 printf(" The sum of probabilities is not equal to 1.\n"); 00523 SP.dump(); 00524 IC.dump(); 00525 exit(0); 00526 } 00527 IC.CH[ IC.NCH - 1 ].PROB = 1.0; 00528 } 00529 } 00530 00531 // バーテックスのサイトタイプ情報の初期化 00532 00533 for (int i=0; i<NSTYPE; i++) { 00534 SiteProperty& S = SPROP(i); 00535 VertexProperty& V = VPROP(S.VTYPE); 00536 00537 int NLEG = 2; 00538 for (int l=0; l<NLEG; l++) { 00539 V.STYPE[l] = S.STYPE; 00540 } 00541 } 00542 for (int i=0; i<NITYPE; i++) { 00543 InteractionProperty& I = IPROP(i); 00544 VertexProperty& V = VPROP(I.VTYPE); 00545 int NLEG = 2 * I.NBODY; 00546 for (int l=0; l<NLEG; l++) { 00547 V.STYPE[l] = I.STYPE[l/2]; 00548 } 00549 } 00550 00551 // バーテックスプロパティーの _IC の初期化 00552 for (int i=0; i<NVTYPE; i++) { 00553 VertexProperty& VP = VPROP(i); 00554 00555 int nst = 0; 00556 00557 for (int ic=0; ic<VP.NIC; ic++) { 00558 00559 VertexInitialConfiguration& IC = VP.IC[ic]; //tomo 00560 00561 int nl = VP.NLEG; 00562 int* x = IC.State; 00563 int inc = IC.INC; 00564 int xinc = IC.XINC; 00565 int st; 00566 bool isKink = false; 00567 int* xx = new int[nl/2]; 00568 00569 for(int il = 0; il < nl ; il+=2){ 00570 if(x[il]!=x[il+1])isKink = true; 00571 else xx[il/2] = x[il]; 00572 } 00573 00574 if ( VP.StateCode(x) == STATE::UNDEF ) { //operator return val(ID(x)) 00575 VP.StateCode(x) = nst; 00576 st = nst; 00577 if(!isKink) VP.SCNK(xx)=nst; 00578 nst++; 00579 } else { 00580 st = VP.StateCode(x); 00581 } 00582 00583 // printf("ic=%d st=%d inc=%d xinc=%d\n",ic,st,inc,xinc) ; 00584 VP._IC( st, inc, xinc) = &IC; //st,inc,xincを利用してINDEX生成//rei 00585 delete [] xx; 00586 } //end VP.NICloop 00587 00588 } 00589 00590 // InteractionProperty の _VP を初期化 00591 for (int i=0; i<NITYPE; i++) { 00592 InteractionProperty& I = IPROP(i); 00593 I.setVertexProperty(VPROP(I.VTYPE)); 00594 } 00595 00596 // 散乱確率の積算と ScatteringChannel::PROB の再々定義 00597 // NOT KINK のバーテックスに対してはPROB = [vertexdensity]*[probablity]とする 00598 for (int i=0; i<NVTYPE; i++) { 00599 VertexProperty& VP = VPROP(i); 00600 // --- edit sakakura --- 00601 00602 for (int j=0; j<VP.NIC; j++) { 00603 00604 VertexInitialConfiguration& IC = VP.IC[j]; 00605 00606 bool isKink = false; 00607 int* x = new int[VP.NBODY]; //edit sakakura 00608 // int x[VP.NBODY]; 00609 for(int ileg = 0; ileg<IC.NLEG; ileg+=2){ 00610 if(IC.State[ileg]!=IC.State[ileg+1]){isKink=true;} 00611 x[ileg/2]=IC.State[ileg]; 00612 } 00613 double p = 0.0; 00614 00615 bool isVertex = false;// false: kink or term , true: means interaction 00616 int i_type =0; 00617 for(i_type = 0; i_type<NITYPE; i_type++){ 00618 if(IPROP[i_type].VTYPE==i){isVertex = true; break;} 00619 }// If VTYPE is for Vertex (not for term or tail), there should be InteractionProperty with density of vertex. 00620 00621 if( isKink||(!isVertex )){ 00622 // printf("i=%d j=%d iskink \n",i,j); 00623 IC.dRHO=1.0; 00624 for (int k=0; k<IC.NCH; k++) { 00625 ScatteringChannel& SC = IC.CH[k]; 00626 p += SC.PROB; 00627 SC.PROB = p; 00628 } 00629 00630 }else{ 00631 double Vdensity = IPROP[i_type].VertexDensity(x); 00632 int count_ch = 0; 00633 double dR = Vdensity; 00634 // printf("i=%d j=%d dR=%f \n",i,j,dR); 00635 00636 for (int k=0; k<IC.NCH; k++) { 00637 00638 ScatteringChannel& SC = IC.CH[k]; 00639 if(SC.OUT == IC.INC + 1 - 2*(IC.INC%2)){ 00640 dR = (1.0-SC.PROB)*Vdensity; 00641 }else{ 00642 p += (SC.PROB * Vdensity); 00643 IC.CH[count_ch] = SC; 00644 IC.CH[count_ch].PROB = p; 00645 count_ch++; 00646 } 00647 00648 } 00649 IC.dRHO = dR; 00650 IC.NCH = count_ch; 00651 } 00652 if ( fabs(p-IC.dRHO) > EPS * 10.0 ) { 00653 printf("Algorithm::initialize> Error.\n"); 00654 printf(" The sum of probabilities is not equal to dRHO.\n"); 00655 VP.dump(); 00656 IC.dump(); 00657 exit(0); 00658 } 00659 00660 if(IC.NCH != 0){ IC.CH[ IC.NCH - 1 ].PROB = IC.dRHO + EPS; 00661 }else{ IC.dRHO = 0.0;} 00662 delete []x; 00663 } 00664 } 00665 00667 00668 // if (DEBUG) printf("Algorithm::initialize> End.\n"); 00669 } 00670 00671 //====================================================================== 00672 00673 inline Algorithm::~Algorithm() { 00674 // printf("*** Destroying Algorithm\n"); 00675 } 00676 00677 //###################################################################### 00678 //###################################################################### 00679 //###################################################################### 00680 00681 void SiteProperty::initialize(XML::Block& X) { //<Site> 00682 00683 STYPE = X["STYPE"].getInteger(); 00684 NX = X["NumberOfStates"].getInteger(); 00685 VTYPE = X["VertexTypeOfSource"].getInteger(); 00686 NIC = NX; 00687 00688 IC.init(1,NIC); 00689 00690 for (int i=0; i<X.NumberOfBlocks(); i++) { 00691 XML::Block& B = X[i]; 00692 if ( B.getName() == "InitialConfiguration" ) { 00693 int st = B["State"].getInteger(); 00694 IC[st].initialize(B); 00695 } 00696 } 00697 } 00698 00699 //====================================================================== 00700 00701 void SiteProperty::dump() { 00702 printf("\n"); 00703 printf("<SiteProperty>\n"); 00704 printf(" STYPE= %d\n", STYPE); 00705 printf(" NX= %d\n", NX); 00706 printf(" VTYPE= %d\n", VTYPE); 00707 printf(" NIC= %d\n", NIC); 00708 for (int i=0; i<NIC; i++) IC[i].dump(); 00709 printf("</SiteProperty>\n"); 00710 } 00711 00712 //####################################################################### 00713 00714 void SiteInitialConfiguration::initialize(XML::Block& X) { 00715 00716 //printf("SiteInitialConfiguration::initialize> Start.\n"); 00717 00718 State = X["State"].getInteger(); 00719 NCH = X["NumberOfChannels"].getInteger(); 00720 CH.init("SCH",1,NCH); 00721 00722 int ch = 0; 00723 for (int i=0; i<X.NumberOfBlocks(); i++) { 00724 XML::Block& B = X[i]; 00725 if ( B.getName() == "Channel" ) CH[ch++].initialize(B); 00726 } 00727 00728 if ( ch != NCH ) { 00729 printf("SiteInitialConfiguration::initialize> Error.\n"); 00730 printf(" The actual number of channels (=%d)\n", ch); 00731 printf(" does not agree with NCH (=%d)\n", NCH); 00732 } 00733 00734 } 00735 00736 //====================================================================== 00737 00738 void SiteInitialConfiguration::dump() { 00739 printf("\n"); 00740 printf("<SiteInitialConfiguration>\n"); 00741 printf(" State= %d\n", State); 00742 printf(" NCH= %d\n", NCH); 00743 for (int i=0; i<NCH; i++) CH[i].dump(); 00744 printf("</SiteInitialConfiguration>\n"); 00745 } 00746 00747 //####################################################################### 00748 00749 void ScatteringChannel::initialize(XML::Block& X) { 00750 OUT = X.getInteger(0); 00751 XOUT = X.getInteger(1); 00752 PROB = X.getDouble(2); 00753 } 00754 00755 //====================================================================== 00756 00757 void ScatteringChannel::dump() { 00758 // printf(" CH= %2d", Code); 00759 printf(" OUT= %2d", OUT); 00760 printf(", XOUT= %2d", XOUT); 00761 printf(", P= %8.3f", PROB); 00762 printf("\n"); 00763 } 00764 00765 //####################################################################### 00766 00767 void InteractionProperty::initialize(XML::Block& X) { //<interaction> son 00768 ITYPE = X["ITYPE"].getInteger(); 00769 VTYPE = X["VTYPE"].getInteger(); 00770 NBODY = X["NBODY"].getInteger(); 00771 EBASE = X["EBASE"].getDouble(); 00772 STYPE.init( 1, NBODY); 00773 STYPE.set_all(STYPE::UNDEF); 00774 VertexDensity.init( NBODY, NXMAX, ARRAY::EOL); 00775 VertexDensity.set_all(0.0); 00776 AverageInterval.init( NBODY, NXMAX, ARRAY::EOL); 00777 AverageInterval.set_all(-1.0); 00778 00779 for (int i=0; i<X.NumberOfBlocks(); i++) { 00780 XML::Block& B = X[i]; 00781 if (B.getName() == "VertexDensity") { 00782 int*x = new int[NBODY]; //edit sakakura 00783 // int x[NBODY]; 00784 for (int ii=0; ii<NBODY; ii++) { 00785 x[ii] = B.getInteger(ii); 00786 } 00787 double d = B.getDouble(NBODY); 00788 // VertexDensity val[n] = d を格納(n:1-n) 00789 // AverageInterval val[n] = 1/d を格納(n:1-n) 00790 VertexDensity(x) = d; //x[0],x[1]分が処理される return C* val[id] 00791 AverageInterval(x) = 1.0/d; 00792 delete []x; 00793 } 00794 } 00795 // Numberofblocksは/Interaction の行数 00796 00797 } 00798 00799 //====================================================================== 00800 00801 inline void InteractionProperty::dump() { 00802 printf("\n"); 00803 printf("<InteractionProperty>\n"); 00804 printf(" ITYPE= %2d", ITYPE); 00805 printf(", VTYPE= %2d", VTYPE); 00806 printf(", NBODY= %2d", NBODY); 00807 printf(", NXMAX= %2d", NXMAX); 00808 printf(", EBASE= %24.16f\n", EBASE); 00809 IndexSystem& I = VertexDensity.index_system(); 00810 int* x = new int[I.dimension()]; 00811 00812 for (int i=0; i<I.size(); i++) { 00813 I.coord(i,x); 00814 printf(" ("); 00815 for (int j=0; j<I.dimension(); j++) { 00816 printf(" %1d", x[j]); 00817 } 00818 printf(") --> %8.3f, %8.3f\n", 00819 VertexDensity(x), AverageInterval(x) ); //kota averagei=1/vd 00820 } 00821 printf("</InteractionProperty>\n"); 00822 delete [] x; 00823 } 00824 00825 //####################################################################### 00826 00827 void VertexProperty::initialize( XML::Block& X,int mx) {//<vertex> //mayu 00828 VTYPE = X["VTYPE"].getInteger(); 00829 VCAT = X["VCATEGORY"].getInteger(); 00830 NBODY = X["NBODY"].getInteger(); 00831 NIC = X["NumberOfInitialConfigurations"].getInteger(); 00832 NLEG = 2 * NBODY; 00833 00834 STYPE.init(1,NLEG);//array(int) STYPE //size 2,4 00835 STYPE.set_all(STYPE::UNDEF); //val[i]に(size()個分)-1をセット 00836 00837 StateCode.init(NLEG,NXMAX,ARRAY::EOL); //array(int) StateCode -1をセット 00838 StateCode.set_all(STATE::UNDEF); //2^2,4^2 00839 00840 SCNK.init(NBODY,NXMAX,ARRAY::EOL); //array(int) scnk 00841 SCNK.set_all(STATE::UNDEF); //-1 //size=2,4 00842 00843 NST = StateCode.size(); //4,16 00844 _IC.init(3,NST,NLEG,NXMAX); //index用の数値用意[4,2,2],[16,4,2] 00845 _IC.set_all(0); //size 16,128 00846 00847 // === edit sakakura === 00848 // if ( RUNTYPE == 1 ) { 00849 int id = X["VTYPE"].getInteger(); //id=0,1 00850 00851 if (id == 0){ 00852 IC.init(1,NIC); 00853 }else{ 00854 MIC = NIC; 00855 00856 if (mx > NIC)MIC=mx; 00857 IC.init(1,MIC); 00858 } 00859 // } 00860 // === edit sakakura === 00861 00862 int ic = 0; 00863 for (int i=0; i<X.NumberOfBlocks(); i++) { //2番目のtag 00864 XML::Block& B = X[i]; 00865 if ( B.getName() == "InitialConfiguration" ) { 00866 IC[ic].setID(ic); 00867 IC[ic].NLEG = NLEG; 00868 IC[ic].initialize( B ); 00869 ic++; 00870 } 00871 } 00872 00873 // == edit sakakura == 00874 if (id==1) { 00875 for ( int i=NIC; i<MIC; i++){ 00876 IC[i].setID(i); 00877 IC[i].NLEG = NLEG;//NLEG; 00878 IC[i].initialize(); //mai 00879 } 00880 } 00881 // == edit sakakura == 00882 00883 } 00884 00885 //====================================================================== 00886 00887 inline int VertexProperty::getSiteType(int out) { 00888 #ifdef DEB 00889 if ( out < 0 || out >= NLEG ) { 00890 printf("VertexProperty::getSiteType> Error.\n"); 00891 printf(" The argument (= %d) is out of the bounds.\n", out); 00892 dump(); 00893 exit(0); 00894 } 00895 #endif 00896 return STYPE[out]; 00897 } 00898 00899 //====================================================================== 00900 00901 inline VertexInitialConfiguration& VertexProperty::getIC( int st, int inc, int xinc) { 00902 return *_IC(st, inc, xinc); 00903 } 00904 00905 //====================================================================== 00906 00907 void VertexProperty::dump() { 00908 printf("\n"); 00909 printf("<VertexProperty>\n"); 00910 printf(" VTYPE = %d\n", VTYPE); 00911 printf(" NBODY = %d\n", NBODY); 00912 printf(" NLEG = %d\n", NLEG); 00913 printf(" NST = %d\n", NST); 00914 printf(" NIC = %d\n", NIC); 00915 printf(" NXMAX = %d\n", NXMAX); 00916 printf(" STYPE = "); 00917 for (int i=0; i<NLEG; i++) printf(" %d", STYPE[i]); 00918 printf("\n"); 00919 int* x = new int[NLEG]; 00920 IndexSystem& I = StateCode.index_system(); 00921 for (int i=0; i<I.size(); i++) { 00922 I.coord(i,x); 00923 int sc = StateCode[i]; 00924 printf(" StateCode"); 00925 for (int j=0; j<I.dimension(); j++) { 00926 printf("[%1d]", x[j]); 00927 } 00928 printf(" = %d\n", sc); 00929 } 00930 IndexSystem& I2 = SCNK.index_system(); 00931 for (int i=0; i<I2.size(); i++) { 00932 I2.coord(i,x); 00933 int sc = SCNK[i]; 00934 printf(" StateCode4NON-KINK"); 00935 for (int j=0; j<I2.dimension(); j++) { 00936 printf("[%1d]", x[j]); 00937 } 00938 printf(" = %d\n", sc); 00939 } 00940 int y[3]; 00941 IndexSystem& J = _IC.index_system(); 00942 cout <<"J.size() = "<<J.size() << endl; 00943 for (int i=0; i<J.size(); i++) { 00944 J.coord(i,y); 00945 if ( _IC[i] != 0 ) { 00946 int icc = (*_IC[i]).id(); 00947 printf(" (_IC[%1d][%1d][%1d])->id() = %d\n", 00948 y[0],y[1],y[2],icc); 00949 } 00950 } 00951 for (int i=0; i<NIC; i++) IC[i].dump(); 00952 printf("</VertexProperty>\n"); 00953 delete [] x; 00954 } 00955 00956 //####################################################################### 00957 00958 void VertexInitialConfiguration::initialize(XML::Block& X) {//<initialconfig> 00959 00960 //printf("VertexInitialConfiguration::initialize> Start.\n"); 00961 00962 if (NLEG == 0) { 00963 printf("VertexInitialConfiguration::read> Error.\n"); 00964 printf(" ... NLEG has not been set.\n"); 00965 exit(0); 00966 } 00967 00968 State = new int [NLEG]; 00969 for (int i=0; i<NLEG; i++) { 00970 State[i] = X["State"].getInteger(i); 00971 } 00972 00973 INC = X["IncomingDirection"].getInteger(); 00974 XINC = X["NewState"].getInteger(); 00975 NCH = X["NumberOfChannels"].getInteger(); 00976 00977 // -- edit sakakura -- 00978 MCH = 4; 00979 CH.init("VCH",1,MCH); 00980 //CH.init("VCH",1,NCH);//org 00981 // -- edit sakakura -- 00982 00983 int ch = 0; 00984 for (int i=0; i<X.NumberOfBlocks(); i++) { 00985 XML::Block& B = X[i]; 00986 if (B.getName() == "Channel") CH[ch++].initialize(B); 00987 } 00988 00989 if ( ch != NCH ) { 00990 printf("SiteInitialConfiguration::initialize> Error.\n"); 00991 printf(" The actual number of channels (=%d)\n", ch); 00992 printf(" does not agree with NCH (=%d)\n", NCH); 00993 } 00994 } 00995 00996 //====================================================================== 00997 //###edit sakakura######################################################mai 00998 00999 void VertexInitialConfiguration::initialize() {//<initialconfig> 01000 01001 //printf("VertexInitialConfiguration::initialize> Start.\n"); 01002 01003 if (NLEG == 0) { 01004 printf("VertexInitialConfiguration::read> Error.\n"); 01005 printf(" ... NLEG has not been set.\n"); 01006 exit(0); 01007 } 01008 01009 State = new int [NLEG]; 01010 01011 NCH = 4; //X["NumberOfChannels"].getInteger(); 01012 CH.init("VCH",1,NCH); 01013 01014 } 01015 01016 //====edit sakakura======================================================== 01017 01018 01019 inline ScatteringChannel& VertexInitialConfiguration::getScatteringChannel() { 01020 double p; 01021 if ( NCH == 1 ) return CH[0]; 01022 int ch; 01023 double r = RND.Uniform(); 01024 for ( ch=0; ch<NCH; ch++) { 01025 p = CH[ch].PROB; 01026 if (r < p) break; 01027 } 01028 if ( ch == NCH ) { 01029 printf("ERROR! at Usual Vertex (KINK) \n"); 01030 dump(); 01031 printf("VertexInitialConfiguration::getScatteringChannel> Error.\n"); 01032 printf(" ... ch=%d exceeds the limit.\n",ch); 01033 exit(0); 01034 } 01035 return CH[ch]; 01036 } 01037 01038 //====================================================================== 01039 inline ScatteringChannel& VertexInitialConfiguration::getScatteringChannel(double drho) { 01040 if ( NCH == 1 ) return CH[0]; 01041 int ch; 01042 double p; 01043 for ( ch=0; ch<NCH; ch++) { 01044 p = CH[ch].PROB; 01045 if (drho < p) break; 01046 } 01047 if ( ch == NCH ) { 01048 printf("ERROR! at place Vertex (non-KINK)\n"); 01049 dump(); 01050 printf("VertexInitialConfiguration::getScatteringChannel> Error.\n"); 01051 printf(" ... ch=%d exceeds the limit.\n",ch); 01052 exit(0); 01053 } 01054 return CH[ch]; 01055 } 01056 01057 //====================================================================== 01058 01059 void VertexInitialConfiguration::dump() { 01060 printf("\n"); 01061 printf("<VertexInitialConfiguration> ID= %d\n", ID); 01062 printf(" NLEG= %d",NLEG); 01063 printf(", INC= %d",INC); 01064 printf(", XINC= %d",XINC); 01065 printf(", NCH= %d",NCH); 01066 printf(", dRHO= %f",dRHO); 01067 01068 printf(", X= ("); 01069 for (int i=0; i<NLEG; i++) printf(" %1d", State[i]); 01070 printf(")\n"); 01071 for (int i=0; i<NCH; i++) CH[i].dump(); 01072 printf("</VertexInitialConfiguration>\n"); 01073 } 01074 01075 #endif