00001
00002
00003
00004
00005
00006 #include <stdio.h>
00007 #include <string.h>
00008 #include <math.h>
00009 #include <stdlib.h>
00010 #include "cemhydmat.h"
00011 #include "homog.h"
00012
00013 #ifdef TRFEL_CEM
00014 #include "globalt.h"
00015 #endif
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 cemhydmat::cemhydmat(void){
00047
00048 #ifdef PRINTF
00049 printf("Calling constructor\n");
00050 fflush(stdout);
00051 #endif
00052
00053 constructor_init();
00054
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 cemhydmat::cemhydmat(cemhydmat *CemP)
00065 {
00066 int i,j,k;
00067
00068 constructor_init();
00069
00070 #ifdef TRFEL_CEM
00071 average_temp = 0.0;
00072 n_ipp = 0;
00073 init_material_time = 0.0;
00074 #endif
00075
00076
00077 if(CemP!=NULL){
00078 iseed=CemP->iseed;
00079 nseed=iseed;
00080 seed=(&nseed);
00081 SYSIZE = CemP->SYSIZE;
00082 for(k=0;k<SYSIZE;k++){
00083 for(j=0;j<SYSIZE;j++){
00084 for(i=0;i<SYSIZE;i++){
00085 micorig[i][j][k]=CemP->micorig[i][j][k];
00086 mic[i][j][k]=micorig[i][j][k];
00087 micpart[i][j][k]=CemP->micpart[i][j][k];
00088 }
00089 }
00090 }
00091
00092 sealed=CemP->sealed;
00093 ntimes=CemP->ntimes;
00094 pnucch=CemP->pnucch;
00095 pscalech=CemP->pscalech;
00096 pnucgyp=CemP->pnucgyp;
00097 pscalegyp=CemP->pscalegyp;
00098 pnuchg=CemP->pnuchg;
00099 pscalehg=CemP->pscalehg;
00100 pnucfh3=CemP->pnucfh3;
00101 pscalefh3=CemP->pscalefh3;
00102 burnfreq=CemP->burnfreq;
00103 setfreq=CemP->setfreq;
00104 phydfreq=CemP->phydfreq;
00105 outfreq=CemP->outfreq;
00106 ind_time=CemP->ind_time;
00107 U_coeff=CemP->U_coeff;
00108 E_act=CemP->E_act;
00109 E_act_pozz=CemP->E_act_pozz;
00110 E_act_slag=CemP->E_act_slag;
00111 beta=CemP->beta;
00112 mass_agg=CemP->mass_agg;
00113 cem_m3=CemP->cem_m3;
00114 Cp_agg=CemP->Cp_agg;
00115 Cp_cement=CemP->Cp_cement;
00116 csh2flag=CemP->csh2flag;
00117 chflag=CemP->chflag;
00118 resatcyc=CemP->resatcyc;
00119 cshgeom=CemP->cshgeom;
00120 pHactive=CemP->pHactive;
00121 }
00122 }
00123
00124
00125 cemhydmat::~cemhydmat(void){
00126
00127 #ifdef OUTFILES
00128 fclose(fileperc);
00129 fclose(disprobfile);
00130 fclose(percfile);
00131 fclose(heatfile);
00132 fclose(pHfile);
00133 fclose(phasfile);
00134 fclose(perc_phases);
00135 fclose(adiafile);
00136 fclose(elasfile);
00137 fclose(CSHfile);
00138
00139 #endif
00140 delete [] PhaseFrac;
00141 delete [] last_values;
00142 delete [] phase;
00143
00144 delete F;
00145 delete [] CSH_vicinity;
00146 delete [] molarvcsh;
00147 delete [] watercsh;
00148
00149 delete [] xsph;
00150 delete [] ysph;
00151 delete [] zsph;
00152 delete [] iv;
00153 delete [] discount;
00154 delete [] count;
00155 delete [] disprob;
00156 delete [] disbase;
00157 delete [] specgrav;
00158 delete [] molarv;
00159 delete [] heatf;
00160 delete [] waterc;
00161 delete [] pHeffect;
00162 delete [] soluble;
00163 delete [] creates;
00164
00165
00166 struct ants *curant;
00167
00168 if(headant!=NULL){
00169 while(headant->nextant!=NULL){
00170 curant = headant->nextant;
00171 free(headant);
00172 headant = curant;
00173 #ifdef PRINTF
00174 printf("Deallocating headant\n");
00175 #endif
00176 }
00177 }
00178
00179 if(tailant!=NULL){
00180 free(tailant);
00181 }
00182
00183 #ifdef PRINTF
00184 printf("Deallocating arrays\n");
00185 fflush(stdout);
00186 #endif
00187
00188 dealloc_char_3D(mic, SYSIZE);
00189 dealloc_int_3D(mic_CSH, SYSIZE);
00190 dealloc_char_3D(micorig, SYSIZE);
00191 dealloc_long_3D(micpart, SYSIZE);
00192 dealloc_int_3D(mask, SYSIZE+1);
00193 dealloc_int_3D(ArrPerc, SYSIZE);
00194 dealloc_int_3D(ConnNumbers, SYSIZE);
00195 dealloc_shortint_3D(cshage, SYSIZE);
00196 dealloc_shortint_3D(faces, SYSIZE);
00197 }
00198
00199
00200 void cemhydmat::constructor_init(void){
00201
00202 icyc=1;
00203 time_cur=0.0;
00204 heat_new=0.0;
00205 heat_cf=0.0;
00206
00207 xoff[0] = 1;
00208 xoff[1] = 0;
00209 xoff[2] = 0;
00210 xoff[3] = -1;
00211 xoff[4] = 0;
00212 xoff[5] = 0;
00213 xoff[6] = 1;
00214 xoff[7] = 1;
00215 xoff[8] = -1;
00216 xoff[9] = -1;
00217 xoff[10] = 0;
00218 xoff[11] = 0;
00219 xoff[12] = 0;
00220 xoff[13] = 0;
00221 xoff[14] = 1;
00222 xoff[15] = 1;
00223 xoff[16] = -1;
00224 xoff[17] = -1;
00225 xoff[18] = 1;
00226 xoff[19] = 1;
00227 xoff[20] = 1;
00228 xoff[21] = 1;
00229 xoff[22] = -1;
00230 xoff[23] = -1;
00231 xoff[24] = -1;
00232 xoff[25] = -1;
00233 xoff[26] = 0;
00234
00235 yoff[0] = 0;
00236 yoff[1] = 1;
00237 yoff[2] = 0;
00238 yoff[3] = 0;
00239 yoff[4] = -1;
00240 yoff[5] = 0;
00241 yoff[6] = 1;
00242 yoff[7] = -1;
00243 yoff[8] = 1;
00244 yoff[9] = -1;
00245 yoff[10] = 1;
00246 yoff[11] = -1;
00247 yoff[12] = 1;
00248 yoff[13] = -1;
00249 yoff[14] = 0;
00250 yoff[15] = 0;
00251 yoff[16] = 0;
00252 yoff[17] = 0;
00253 yoff[18] = 1;
00254 yoff[19] = -1;
00255 yoff[20] = 1;
00256 yoff[21] = -1;
00257 yoff[22] = 1;
00258 yoff[23] = 1;
00259 yoff[24] = -1;
00260 yoff[25] = -1;
00261 yoff[26] = 0;
00262
00263 zoff[0] = 0;
00264 zoff[1] = 0;
00265 zoff[2] = 1;
00266 zoff[3] = 0;
00267 zoff[4] = 0;
00268 zoff[5] = -1;
00269 zoff[6] = 0;
00270 zoff[7] = 0;
00271 zoff[8] = 0;
00272 zoff[9] = 0;
00273 zoff[10] = 1;
00274 zoff[11] = 1;
00275 zoff[12] = -1;
00276 zoff[13] = -1;
00277 zoff[14] = 1;
00278 zoff[15] = -1;
00279 zoff[16] = 1;
00280 zoff[17] = -1;
00281 zoff[18] = 1;
00282 zoff[19] = 1;
00283 zoff[20] = -1;
00284 zoff[21] = -1;
00285 zoff[22] = 1;
00286 zoff[23] = -1;
00287 zoff[24] = 1;
00288 zoff[25] = -1;
00289 zoff[26] = 0;
00290
00291 iy = 0;
00292 LastCallTime = -1.;
00293 alpha_cur = 0.0;
00294 alpha_last = 0.;
00295 TargTime_glob = 0.;
00296 TargDoHelas = 0.;
00297
00298
00299 CEM = 100;
00300 CEMID = 1;
00301 C2SID = 2;
00302 GYPID = 5;
00303 HEMIHYDRATE = 6;
00304 POZZID = 8;
00305 INERTID = 9;
00306 SLAGID = 10;
00307 AGG = 28;
00308 FLYASH = 30;
00309
00310 POROSITY = 0;
00311 C3S = 1;
00312 C2S = 2;
00313 C3A = 3;
00314 C4AF = 4;
00315 GYPSUM = 5;
00316 HEMIHYD = 6;
00317 ANHYDRITE = 7;
00318 POZZ = 8;
00319 INERT = 9;
00320 SLAG = 10;
00321 ASG = 11;
00322 CAS2 = 12;
00323 CH = 13;
00324 CSH = 14;
00325 C3AH6 = 15;
00326 ETTR = 16;
00327 ETTRC4AF = 17;
00328 AFM = 18;
00329 FH3 = 19;
00330 POZZCSH = 20;
00331 SLAGCSH = 21;
00332 CACL2 = 22;
00333 FREIDEL = 23;
00334 STRAT = 24;
00335 GYPSUMS = 25;
00336 CACO3 = 26;
00337 AFMC = 27;
00338 INERTAGG = 28;
00339 ABSGYP = 29;
00340 DIFFCSH = 30;
00341 DIFFCH = 31;
00342 DIFFGYP = 32;
00343 DIFFC3A = 33;
00344 DIFFC4A = 34;
00345 DIFFFH3 = 35;
00346 DIFFETTR = 36;
00347 DIFFCACO3 = 37;
00348 DIFFAS = 38;
00349 DIFFANH = 39;
00350 DIFFHEM = 40;
00351 DIFFCAS2 = 41;
00352 DIFFCACL2 = 42;
00353 EMPTYP = 45;
00354 HDCSH = 46;
00355 OFFSET = 50;
00356
00357 NEIGHBORS = 26;
00358 BoxSize = 1;
00359 SolidLimit = 27;
00360 MAXTRIES = 150000;
00361 MAXCYC_SEAL = 30000;
00362 NUMSIZES = 100;
00363 MAXSPH = 10000;
00364 PI = 3.141592653589793;
00365
00366 Cp_pozz = 0.75;
00367 Cp_CH = 0.75;
00368 Cp_h2o = 4.18;
00369 Cp_bh2o = 2.2;
00370 WN = 0.23;
00371 WCHSH = 0.06;
00372 CUBEMIN = 3;
00373
00374 DISBIAS = 30.0;
00375 DISMIN = 0.001;
00376 DISMIN2 = 0.00025;
00377 DISMINSLAG =0.0001;
00378 DISMINASG = 0.0005;
00379 DISMINCAS2 = 0.0005;
00380 DISMIN_C3A_0 = 0.002;
00381 DISMIN_C4AF_0= 0.0005;
00382
00383 C3AH6GROW = 0.01;
00384 CHGROW = 1.0;
00385 CHGROWAGG = 1.0;
00386 ETTRGROW = 0.002;
00387 C3AETTR = 0.001;
00388 C3AGYP = 0.001;
00389 SOLIDC3AGYP = 0.5;
00390 SOLIDC4AFGYP = 0.1;
00391 PPOZZ = 0.05;
00392 PCSH2CSH = 0.002;
00393 A0_CHSOL = 1.325;
00394 A1_CHSOL = 0.008162;
00395
00396 BURNT = 70;
00397 SIZE2D = 49000;
00398
00399 SIZESET = 100000;
00400 AGRATE = 0.25;
00401 VOLFACTOR = 0.00001;
00402 MASSFACTOR = 0.0001;
00403 MMNa = 22.9898;
00404 MMK = 39.102;
00405 MMNa2O = 61.979;
00406 MMK2O = 94.203;
00407 BNa = 0.00031;
00408 BK = 0.00020;
00409 BprimeNa = 0.0030;
00410 BprimeK = 0.0033;
00411 KspCH25C = 0.00000646;
00412 KspGypsum = 0.0000263;
00413 KspSyngenite = 0.00000010;
00414 SpecgravSyngenite = 2.607;
00415 KperSyn = 2.0;
00416 activeA0 = 0.0366;
00417 activeB0 = 0.01035;
00418 zCa = 2.;
00419 zSO4 = 2.;
00420 zOH = 1.;
00421 zNa = 1.;
00422 zK = 1.;
00423 aK = 1.33;
00424 aCa = 1.;
00425 aOH = 3.;
00426 aNa = 3.;
00427 aSO4 = 4.5;
00428 lambdaOH_0 = 198.0;
00429 lambdaNa_0 = 50.1;
00430 lambdaK_0 = 73.5;
00431 lambdaSO4_0 = 39.5;
00432 lambdaCa_0 = 29.5;
00433 GOH = 0.353;
00434 GK = 0.548;
00435 GNa = 0.733;
00436 GCa = 0.771;
00437 GSO4 = 0.877;
00438 cm2perL2m = 0.1;
00439 EPSS = 6.e-8;
00440 MAXIT = 100;
00441 EPSP = 2.0e-6;
00442 MAXM = 100;
00443
00444
00445 IA = 16807;
00446 IM = 2147483647;
00447 IQ = 127773;
00448 IR = 2836;
00449 NTAB = 32;
00450 EPS = 1.2E-07;
00451
00452 PhaseFrac = new double[34];
00453 last_values = new double[10];
00454 phase = new long int[51];
00455
00456 CSH_vicinity = new unsigned int[(2*BoxSize+1)*(2*BoxSize+1)*(2*BoxSize+1)+1];
00457 molarvcsh = new float[MAXCYC_SEAL];
00458 watercsh = new float[MAXCYC_SEAL];
00459 xsph = new int[MAXSPH];
00460 ysph = new int[MAXSPH];
00461 zsph = new int[MAXSPH];
00462
00463 iv = new int[NTAB];
00464
00465 discount = new long int[EMPTYP+1];
00466 count = new long int[HDCSH+1];
00467 disprob = new float [EMPTYP+1];
00468 disbase = new float [EMPTYP+1];
00469 specgrav = new float [EMPTYP+1];
00470 molarv = new float [EMPTYP+1];
00471 heatf = new float [EMPTYP+1];
00472 waterc = new float [EMPTYP+1];
00473 pHeffect = new float [EMPTYP+1];
00474
00475
00476 for(int i=0; i<=EMPTYP; i++){
00477 heatf[i]=0.;
00478 waterc[i]=0.;
00479 }
00480
00481 headant = NULL;
00482 tailant = NULL;
00483 soluble = new int [EMPTYP+1];
00484 creates = new int [EMPTYP+1];
00485
00486
00487 }
00488
00489 #ifdef TRFEL_CEM
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 void cemhydmat::matcond (matrix &d,long ri,long ci,long ipp)
00502 {
00503 long n;
00504 n = d.n;
00505
00506 switch (n){
00507 case 1:{
00508 matcond1d (d,ri,ci,ipp);
00509 break;
00510 }
00511 case 2:{
00512 matcond2d (d,ri,ci,ipp);
00513 break;
00514 }
00515 case 3:{
00516 matcond3d (d,ri,ci,ipp);
00517 break;
00518 }
00519 default:{
00520 fprintf (stderr,"\n unknown number of components of stress tensor is required");
00521 fprintf (stderr,"\n in function (%s, line %d).\n",__FILE__,__LINE__);
00522 }
00523 }
00524 }
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535 void cemhydmat::matcond1d (matrix &d,long,long,long)
00536 {
00537 double kk;
00538
00539 kk = get_k();
00540
00541 d[0][0] = kk;
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 void cemhydmat::matcond2d (matrix &d,long,long,long)
00553 {
00554 double kk;
00555
00556 kk = get_k();
00557
00558 fillm(0.0,d);
00559
00560 d[0][0] = kk; d[0][1] = 0.0;
00561 d[1][0] = 0.0; d[1][1] = kk;
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573 void cemhydmat::matcond3d (matrix &d,long,long,long)
00574 {
00575 double kk;
00576
00577 kk = get_k();
00578
00579 fillm(0.0,d);
00580
00581 d[0][0]=kk; d[0][1]=0.0; d[0][2]=0.0;
00582 d[1][0]=0.0; d[1][1]=kk; d[1][2]=0.0;
00583 d[2][0]=0.0; d[2][1]=0.0; d[2][2]=kk;
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 void cemhydmat::matcap (double &cc,long,long,long)
00596 {
00597 cc = 0.0;
00598
00599 cc = get_c();
00600 }
00601
00602
00603
00604
00605
00606
00607
00608 double cemhydmat::get_k()
00609 {
00610 return(conductivity);
00611 }
00612
00613
00614
00615
00616
00617
00618 double cemhydmat::get_c()
00619 {
00620 return(capacity);
00621 }
00622
00623
00624
00625
00626
00627
00628
00629 void cemhydmat::read (XFILE *in)
00630 {
00631 files = new char[1000];
00632
00633 xfscanf (in,"%lf %lf",&capacity,&conductivity);
00634 xfscanf(in, "%s", files);
00635 readcem (files);
00636 delete [] files;
00637 }
00638
00639
00640
00641
00642
00643
00644
00645 void cemhydmat::print (FILE *out)
00646 {
00647 fprintf (out," %e %e",capacity,conductivity);
00648 fprintf (out,"\n%s",files);
00649 }
00650
00651 void cemhydmat::updateval(long ipp,long,long ido){
00652
00653 double temp, nothing1, nothing2, nothing3, nothing4;
00654 double actual_time;
00655
00656 if(LastCallTime < 0.0)
00657 init_material_time = Tp->time;
00658
00659 actual_time = Tp->time - init_material_time;
00660
00661 temp = Tm->ip[ipp].other[0];
00662 temp = temp - 273.15;
00663
00664
00665 if(LastCallTime != actual_time){
00666 last_values[0] = GetHeat (temp,actual_time);
00667 last_values[1] = GetDoHActual();
00668 if(Calculate_elastic_homogenization){
00669 CreateHDCSH();
00670 PercolateForOutput();
00671 AnalyticHomogenizationPaste(last_values[2], last_values[3],0);
00672 AnalyticHomogenizationConcrete(last_values[2], last_values[3], ¬hing1, ¬hing2, ¬hing3, ¬hing4, last_values[4], last_values[5]);
00673 }
00674 }
00675
00676 Tm->ip[ipp].eqother[ido+0] = last_values[0];
00677 Tm->ip[ipp].eqother[ido+1] = last_values[1];
00678 Tm->ip[ipp].eqother[ido+2] = last_values[2];
00679 Tm->ip[ipp].eqother[ido+3] = last_values[3];
00680 Tm->ip[ipp].eqother[ido+4] = last_values[4];
00681 Tm->ip[ipp].eqother[ido+5] = last_values[5];
00682 }
00683
00684
00685 void cemhydmat::initvalues(long ipp,long,long ido)
00686 {
00687 Tm->ip[ipp].eqother[ido+0] = 0.0;
00688 Tm->ip[ipp].eqother[ido+1] = 0.0;
00689 Tm->ip[ipp].eqother[ido+2] = 0.0;
00690 Tm->ip[ipp].eqother[ido+3] = 0.5;
00691 Tm->ip[ipp].eqother[ido+4] = 0.0;
00692 Tm->ip[ipp].eqother[ido+5] = 0.5;
00693 }
00694
00695 double cemhydmat::get_source(long ipp,long,long ido){
00696
00697 return (Tm->ip[ipp].eqother[ido+0]);
00698 }
00699 #endif
00700
00701
00702
00703 void cemhydmat::alloc_char_3D(char***(&mic), long SYSIZE){
00704 mic = new char**[SYSIZE];
00705 for(int x=0; x<SYSIZE; x++){
00706 mic[x] = new char*[SYSIZE];
00707 for(int y=0; y<SYSIZE; y++){
00708 mic[x][y] = new char[SYSIZE];
00709 if(mic[x][y] == NULL){
00710 printf("Cannot allocate memory (file %s, line %d)\n", __FILE__, __LINE__);
00711 }
00712 }
00713 }
00714 }
00715
00716 void cemhydmat::dealloc_char_3D(char***(&mic), long SYSIZE){
00717 if(**mic!=NULL){
00718 for (int x=0;x<SYSIZE;x++){
00719 for (int y=0;y<SYSIZE;y++){
00720 delete [] mic[x][y];
00721 }
00722 delete [] mic[x];
00723 }
00724 delete [] mic;
00725 }
00726 }
00727
00728 void cemhydmat::alloc_long_3D(long***(&mic), long SYSIZE){
00729
00730 mic = new long**[SYSIZE];
00731 for(int x=0; x<SYSIZE; x++){
00732 mic[x] = new long*[SYSIZE];
00733 for(int y=0; y<SYSIZE; y++){
00734 mic[x][y] = new long[SYSIZE];
00735 if(mic[x][y] == NULL){
00736 printf("Cannot allocate memory (file %s, line %d)\n", __FILE__, __LINE__);
00737 }
00738 }
00739 }
00740 }
00741
00742
00743 void cemhydmat::dealloc_long_3D(long***(&mic), long SYSIZE){
00744 if(**mic!=NULL){
00745 for (int x=0;x<SYSIZE;x++){
00746 for (int y=0;y<SYSIZE;y++){
00747 delete [] mic[x][y];
00748 }
00749 delete [] mic[x];
00750 }
00751 delete [] mic;
00752 }
00753 }
00754
00755 void cemhydmat::alloc_int_3D(int ***(&mic), long SYSIZE){
00756
00757 mic = new int**[SYSIZE];
00758 for(int x=0; x<SYSIZE; x++){
00759 mic[x] = new int*[SYSIZE];
00760 for(int y=0; y<SYSIZE; y++){
00761 mic[x][y] = new int[SYSIZE];
00762 if(mic[x][y] == NULL){
00763 printf("Cannot allocate memory (file %s, line %d)\n", __FILE__, __LINE__);
00764 }
00765 }
00766 }
00767 }
00768
00769
00770 void cemhydmat::dealloc_int_3D(int***(&mic), long SYSIZE){
00771 if(**mic!=NULL){
00772 for (int x=0;x<SYSIZE;x++){
00773 for (int y=0;y<SYSIZE;y++){
00774 delete [] mic[x][y];
00775 }
00776 delete [] mic[x];
00777 }
00778 delete [] mic;
00779 }
00780 }
00781
00782 void cemhydmat::alloc_shortint_3D(short int ***(&mic), long SYSIZE){
00783
00784 mic = new short int**[SYSIZE];
00785 for(int x=0; x<SYSIZE; x++){
00786 mic[x] = new short int*[SYSIZE];
00787 for(int y=0; y<SYSIZE; y++){
00788 mic[x][y] = new short int[SYSIZE];
00789 if(mic[x][y] == NULL){
00790 printf("Cannot allocate memory (file %s, line %d)\n", __FILE__, __LINE__);
00791 }
00792 }
00793 }
00794 }
00795
00796
00797 void cemhydmat::dealloc_shortint_3D(short int ***(&mic), long SYSIZE){
00798 if(**mic!=NULL){
00799 for (int x=0;x<SYSIZE;x++){
00800 for (int y=0;y<SYSIZE;y++){
00801 delete [] mic[x][y];
00802 }
00803 delete [] mic[x];
00804 }
00805 delete [] mic;
00806 }
00807 }
00808
00809 void cemhydmat::alloc_double_3D(double ***(&mic), long SYSIZE){
00810
00811 mic = new double**[SYSIZE];
00812 for(int x=0; x<SYSIZE; x++){
00813 mic[x] = new double*[SYSIZE];
00814 for(int y=0; y<SYSIZE; y++){
00815 mic[x][y] = new double[SYSIZE];
00816 if(mic[x][y] == NULL){
00817 printf("Cannot allocate memory (file %s, line %d)\n", __FILE__, __LINE__);
00818 }
00819 }
00820 }
00821 }
00822
00823
00824 void cemhydmat::dealloc_double_3D(double ***(&mic), long SYSIZE){
00825 if(**mic!=NULL){
00826 for (int x=0;x<SYSIZE;x++){
00827 for (int y=0;y<SYSIZE;y++){
00828 delete [] mic[x][y];
00829 }
00830 delete [] mic[x];
00831 }
00832 delete [] mic;
00833 }
00834 }
00835
00836
00837
00838
00839
00840 int cemhydmat::readcem (char *inp)
00841 {
00842 int read_micr;
00843
00844 F = new cmlfile(inp);
00845
00846
00847 F->set_labels( 54 ) ;
00848 F->set_label_string( 0,"Rand_seed_num" ) ;
00849 F->set_label_string( 1,"Input_img_file" ) ;
00850 F->set_label_string( 2,"Input_id_file" ) ;
00851 F->set_label_string( 3,"Saturated_sealed" ) ;
00852 F->set_label_string( 4,"Induction_time" ) ;
00853 F->set_label_string( 5,"Ea_cement" ) ;
00854 F->set_label_string( 6,"Ea_pozz" ) ;
00855 F->set_label_string( 7,"Ea_slag" ) ;
00856 F->set_label_string( 8,"Beta" ) ;
00857 F->set_label_string( 9,"Mass_aggr_frac" ) ;
00858 F->set_label_string( 10,"Mass_cem" ) ;
00859 F->set_label_string( 11,"Cp_agg" ) ;
00860 F->set_label_string( 12,"Cp_cem" ) ;
00861 F->set_label_string( 13,"Given_microstructure" ) ;
00862 F->set_label_string( 14,"Output_initial_microstructure" ) ;
00863 F->set_label_string( 15,"Output_initial_microstructure_img_file" ) ;
00864 F->set_label_string( 16,"Output_initial_microstructure_id_file" ) ;
00865 F->set_label_string( 17,"Cycle_freq_perc_pore" ) ;
00866 F->set_label_string( 18,"Cycle_freq_perc_sol" ) ;
00867 F->set_label_string( 19,"Total_sodium" ) ;
00868 F->set_label_string( 20,"Total_potassium" ) ;
00869 F->set_label_string( 21,"Readily_soluble_sodium" ) ;
00870 F->set_label_string( 22,"Readily_soluble_potassium" ) ;
00871 F->set_label_string( 23,"Diffusion_steps_per_cycle" ) ;
00872 F->set_label_string( 24,"CH_nucleation_probability" ) ;
00873 F->set_label_string( 25,"CH_scale_factor" ) ;
00874 F->set_label_string( 26,"Gypsum_nucleation_probability" ) ;
00875 F->set_label_string( 27,"Gypsum_scale_factor" ) ;
00876 F->set_label_string( 28,"C3AH6_nucleation_probability" ) ;
00877 F->set_label_string( 29,"C3AH6_scale_factor" ) ;
00878 F->set_label_string( 30,"FH3_nucleation_probability" ) ;
00879 F->set_label_string( 31,"FH3_scale_factor" ) ;
00880 F->set_label_string( 32,"Microstructure_size" ) ;
00881 F->set_label_string( 33,"Adiabatic_conditions" ) ;
00882 F->set_label_string( 34,"Vol_cement_clinker_gypsum" );
00883 F->set_label_string( 35,"Vol_cement_SCM" );
00884 F->set_label_string( 36,"Vol_water" );
00885 F->set_label_string( 37,"Vol_FA" );
00886 F->set_label_string( 38,"Vol_CA" );
00887 F->set_label_string( 39,"Vol_inert_filler" );
00888 F->set_label_string( 40,"Vol_entrained_entrapped_air" );
00889 F->set_label_string( 41,"Grain_average_FA");
00890 F->set_label_string( 42,"Grain_average_CA");
00891 F->set_label_string( 43,"ITZ_thickness");
00892 F->set_label_string( 44,"ITZ_Young_red\n");
00893 F->set_label_string( 45,"Young_SCM");
00894 F->set_label_string( 46,"Poisson_SCM");
00895 F->set_label_string( 47,"Young_FA");
00896 F->set_label_string( 48,"Poisson_FA");
00897 F->set_label_string( 49,"Young_CA");
00898 F->set_label_string( 50,"Poisson_CA");
00899 F->set_label_string( 51,"Young_inert");
00900 F->set_label_string( 52,"Poisson_inert");
00901 F->set_label_string( 53,"Calculate_elastic_homogenization");
00902
00903
00904 F->require( 0 ) ;
00905
00906
00907 F->require( 3 ) ;
00908 F->require( 4 ) ;
00909 F->require( 5 ) ;
00910 F->require( 6 ) ;
00911 F->require( 7 ) ;
00912 F->require( 8 ) ;
00913 F->require( 9 ) ;
00914 F->require( 10 ) ;
00915 F->require( 11 ) ;
00916 F->require( 12 ) ;
00917 F->require( 13 ) ;
00918 F->require( 14 ) ;
00919 F->require( 17 ) ;
00920 F->require( 18 ) ;
00921 F->require( 19 ) ;
00922 F->require( 20 ) ;
00923 F->require( 21 ) ;
00924 F->require( 22 ) ;
00925 F->require( 23 ) ;
00926 F->require( 24 ) ;
00927 F->require( 27 ) ;
00928 F->require( 28 ) ;
00929 F->require( 29 ) ;
00930 F->require( 30 ) ;
00931 F->require( 31 ) ;
00932 F->require( 32 ) ;
00933 F->require( 33 ) ;
00934 F->require( 34 ) ;
00935 F->require( 35 ) ;
00936 F->require( 36 ) ;
00937 F->require( 37 ) ;
00938 F->require( 38 ) ;
00939 F->require( 39 ) ;
00940 F->require( 40 ) ;
00941 F->require( 41 ) ;
00942 F->require( 42 ) ;
00943 F->require( 43 ) ;
00944 F->require( 44 ) ;
00945 F->require( 45 ) ;
00946 F->require( 46 ) ;
00947 F->require( 47 ) ;
00948 F->require( 48 ) ;
00949 F->require( 49 ) ;
00950 F->require( 50 ) ;
00951 F->require( 51 ) ;
00952 F->require( 52 ) ;
00953 F->require( 53 ) ;
00954
00955 F->set_sections( 1 ) ;
00956 F->set_section_string( 0,"CEMHYD_generate_particles" ) ;
00957
00958
00959 F->check_requirements( );
00960
00961 if ( F->error_in_requirements()){
00962 printf( "Cemhyd input file %s is not complete (file %s, line %d)\n", inp, __FILE__, __LINE__ ) ;
00963 exit(0) ;
00964 }
00965
00966 F->get_value(0, (long &)iseed);
00967 nseed=iseed;
00968 seed=(&nseed);
00969
00970
00971
00972 F->get_value(32, (long &)SYSSIZE);
00973 if(SYSSIZE<10){
00974 printf("Can not run small microstructure %d (< 10 voxels a side), file %s, line %d)\n", SYSSIZE, __FILE__, __LINE__);
00975 exit(0);
00976 }
00977
00978 SYSIZE = SYSSIZE;
00979 SYSIZEM1 =(SYSIZE-1);
00980 SYSIZE_POW3 = (SYSIZE*SYSIZE*SYSIZE);
00981 NPARTC = (long)(700000 * (double)SYSIZE_POW3/1000000.);
00982 BURNTG = (NPARTC > 100 ? NPARTC : 100);
00983 CUBEMAX = (SYSIZE>6?7:3);
00984 DETTRMAX =(1200.*SYSIZE_POW3/1000000.);
00985 DGYPMAX =(2000.*SYSIZE_POW3/1000000.);
00986 DCACO3MAX =(1000*SYSIZE_POW3/1000000.);
00987 DCACL2MAX =(2000*SYSIZE_POW3/1000000.);
00988 DCAS2MAX =(2000*SYSIZE_POW3/1000000.);
00989 CHCRIT =(50.*SYSIZE_POW3/1000000.);
00990 C3AH6CRIT =(10.*SYSIZE_POW3/1000000.);
00991 CSHSCALE =(70000.*SYSIZE_POW3/1000000.);
00992 C3AH6_SCALE =(2000.*SYSIZE_POW3/1000000.);
00993
00994 alloc_char_3D(mic, SYSIZE);
00995 alloc_int_3D(mic_CSH, SYSIZE);
00996 alloc_char_3D(micorig, SYSIZE);
00997 alloc_long_3D(micpart, SYSIZE);
00998 alloc_int_3D(mask, SYSIZE+1);
00999 alloc_int_3D(ArrPerc, SYSIZE);
01000 alloc_int_3D(ConnNumbers, SYSIZE);
01001 alloc_shortint_3D(cshage, SYSIZE);
01002 alloc_shortint_3D(faces, SYSIZE);
01003
01004 F->get_value(13, (long &)read_micr);
01005
01006 if(!read_micr){
01007 if(genpartnew()==1){
01008 return 1;
01009 }
01010
01011
01012 #ifdef PRINTF
01013 printf ("MONOPHASE microstructure created\n");
01014 #endif
01015 distrib3d();
01016 }
01017
01018 readhydrparam();
01019
01020 return 0;
01021 }
01022
01023
01024
01025
01026
01027
01028 double cemhydmat::ran1(int *idum)
01029
01030
01031 {
01032 int j,k;
01033 NDIV = 1.0/(1.0+(IM-1.0)/NTAB);
01034 RNMX = (1.0-EPS);
01035 AM = (1.0/IM);
01036
01037 if ((*idum <= 0) || (iy == 0)) {
01038 *idum = (-*idum>*idum) ? -*idum : *idum;
01039 for(j=NTAB+7;j>=0;j--) {
01040 k = *idum/IQ;
01041 *idum = IA*(*idum-k*IQ)-IR*k;
01042 if(*idum < 0) *idum += IM;
01043 if(j < NTAB) iv[j] = *idum;
01044 }
01045 iy = iv[0];
01046 }
01047 k = *idum/IQ;
01048 *idum = IA*(*idum-k*IQ)-IR*k;
01049 if(*idum<0) *idum += IM;
01050 j = (int)(iy*NDIV);
01051 iy = iv[j];
01052 iv[j] = *idum;
01053 return AM*iy<RNMX ? AM*iy : RNMX;
01054 }
01055
01056
01057
01058 void cemhydmat::addagg(void)
01059
01060
01061 {
01062 int ix,iy,iz;
01063 int agglo,agghi;
01064
01065
01066 do{
01067 printf("Enter thickness of aggregate to place (an even integer) \n");
01068 F->get_next_line_in_section(0,(long &)aggsize);
01069
01070 #ifdef PRINTF
01071 printf("%d\n",aggsize);
01072 #endif
01073 } while (((aggsize%2)!=0)||(aggsize>(SYSSIZE-2)));
01074
01075 if(aggsize!=0){
01076 agglo=(SYSSIZE/2)-((aggsize-2)/2);
01077 agghi=(SYSSIZE/2)+(aggsize/2);
01078
01079
01080 for(ix=agglo;ix<=agghi;ix++){
01081 for(iy=1;iy<=SYSSIZE;iy++){
01082 for(iz=1;iz<=SYSSIZE;iz++){
01083
01084
01085 cement[ix][iy][iz]=AGG;
01086 cemreal[ix][iy][iz]=AGG;
01087 }
01088 }
01089 }
01090 }
01091 }
01092
01093
01094
01095
01096
01097
01098
01099
01100 int cemhydmat::chksph(int xin,int yin,int zin,int radd,int wflg,int phasein,int phase2)
01101
01102
01103 {
01104 int nofits,xp,yp,zp,i,j,k;
01105 float dist,xdist,ydist,zdist,ftmp;
01106
01107 nofits=0;
01108
01109 for(i=xin-radd;((i<=xin+radd)&&(nofits==0));i++){
01110 xp=i;
01111
01112 if(xp<1) {xp+=SYSSIZE;}
01113 else if(xp>SYSSIZE) {xp-=SYSSIZE;}
01114 ftmp=(float)(i-xin);
01115 xdist=ftmp*ftmp;
01116 for(j=yin-radd;((j<=yin+radd)&&(nofits==0));j++){
01117 yp=j;
01118
01119 if(yp<1) {yp+=SYSSIZE;}
01120 else if(yp>SYSSIZE) {yp-=SYSSIZE;}
01121 ftmp=(float)(j-yin);
01122 ydist=ftmp*ftmp;
01123 for(k=zin-radd;((k<=zin+radd)&&(nofits==0));k++){
01124 zp=k;
01125
01126 if(zp<1) {zp+=SYSSIZE;}
01127 else if(zp>SYSSIZE) {zp-=SYSSIZE;}
01128 ftmp=(float)(k-zin);
01129 zdist=ftmp*ftmp;
01130
01131
01132 dist=sqrt(xdist+ydist+zdist);
01133 if((dist-0.5)<=(float)radd){
01134
01135 if(wflg==2){
01136 cement [xp] [yp] [zp]=phasein;
01137 cemreal [xp][yp][zp]=phase2;
01138 }
01139
01140 else if((wflg==1)&&(cement [xp] [yp] [zp] !=POROSITY)){
01141 nofits=1;
01142 }
01143 }
01144
01145 if((wflg==1)&&((fabs(xp-((float)(SYSSIZE+1)/2.0)))<((float)aggsize/2.0))){
01146 nofits=1;
01147 }
01148 }
01149 }
01150 }
01151
01152
01153 return(nofits);
01154 }
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164 int cemhydmat::gsphere(int numgen,long int *numeach,int *sizeeach, int *pheach){
01165
01166
01167
01168 int count,x,y,z,radius,ig,tries,phnow;
01169 long int jg, i;
01170 float testgyp,typegyp;
01171
01172
01173 for(ig=0;ig<numgen;ig++){
01174
01175 phnow=pheach[ig];
01176 radius=sizeeach[ig];
01177
01178 for(jg=1;jg<=numeach[ig];jg++){
01179
01180 tries=0;
01181
01182 do{
01183 tries+=1;
01184
01185 x=(int)((float)SYSSIZE*ran1(seed))+1;
01186 y=(int)((float)SYSSIZE*ran1(seed))+1;
01187 z=(int)((float)SYSSIZE*ran1(seed))+1;
01188
01189
01190
01191 count=chksph(x,y,z,radius+dispdist,1,npart+CEM,0);
01192 if((tries>MAXTRIES)&&(dispdist==2)){
01193 tries=0;
01194 dispdist+=1;
01195 }
01196 if(tries>MAXTRIES){
01197 printf("Could not place sphere %d after %ld random attempts \n",npart,MAXTRIES);
01198 printf("Skipping this microstructure parameters\n");
01199 for(i=1;i<=npart;i++){
01200 free(clust[i]);
01201 }
01202 return(1);
01203 }
01204 } while(count!=0);
01205
01206
01207 npart+=1;
01208 if(npart>=NPARTC){
01209 printf("Too many spheres being generated \n");
01210 printf("User needs to increase value of NPARTC at top of C-code\n");
01211 printf("Skipping this microstructure parameters\n");
01212 return(1);
01213 }
01214
01215 clust[npart]=(struct cluster *)malloc(sizeof(struct cluster));
01216 clust[npart]->partid=npart;
01217 clust[npart]->clustid=npart;
01218
01219 clust[npart]->partphase=CEMID;
01220 clust[npart]->x=x;
01221 clust[npart]->y=y;
01222 clust[npart]->z=z;
01223 clust[npart]->r=radius;
01224 clusleft+=1;
01225 if(phnow==1){
01226 testgyp=ran1(seed);
01227
01228 if(((testgyp>probgyp)&&((target_sulfate-n_sulfate)<(target_total-n_total)))||(n_sulfate>target_sulfate)||(volpart[radius]>(target_sulfate-n_sulfate))||(numeach[ig]<=2)){
01229 count=chksph(x,y,z,radius,2,npart+CEM-1,CEMID);
01230 n_total+=volpart[radius];
01231 }
01232 else{
01233
01234 typegyp=ran1(seed);
01235 n_total+=volpart[radius];
01236 n_sulfate+=volpart[radius];
01237 if((probanh>=1.0)||((typegyp<probanh)&&(n_anhydrite<target_anhydrite)&&(volpart[radius]<=(target_anhydrite-n_anhydrite)))){
01238
01239 n_anhydrite+=volpart[radius];
01240 count=chksph(x,y,z,radius,2,npart+CEM-1,ANHYDRITE);
01241 clust[npart]->partphase=ANHYDRITE;
01242 }
01243 else if(((probanh+probhem)>=1.0)||((typegyp<(probanh+probhem))&&(n_hemi<target_hemi)&&(volpart[radius]<=(target_hemi-n_hemi)))){
01244
01245 n_hemi+=volpart[radius];
01246 count=chksph(x,y,z,radius,2,npart+CEM-1,HEMIHYDRATE);
01247 clust[npart]->partphase=HEMIHYDRATE;
01248 }
01249 else{
01250 count=chksph(x,y,z,radius,2,npart+CEM-1,GYPID);
01251
01252 clust[npart]->partphase=GYPID;
01253 }
01254 }
01255 }
01256
01257 else{
01258 count=chksph(x,y,z,radius,2,npart+CEM-1,phnow);
01259
01260 clust[npart]->partphase=phnow;
01261 }
01262 clust[npart]->nextpart=NULL;
01263 }
01264 }
01265
01266
01267 for(i=1;i<=npart;i++){
01268 free(clust[i]);
01269
01270 }
01271 return(0);
01272 }
01273
01274
01275
01276 int cemhydmat::create(void){
01277
01278
01279 int numsize;
01280 int *sphrad,*sphase;
01281 long int *sphnum;
01282 long int inval1;
01283 int isph,inval;
01284
01285 sphrad = new int[NUMSIZES];
01286 sphase = new int[NUMSIZES];
01287 sphnum = new long int[NUMSIZES];
01288
01289
01290 do{
01291 #ifdef PRINTF
01292 printf("Enter number of different size spheres to use(max. is %d) \n",NUMSIZES);
01293 #endif
01294 F->get_next_line_in_section(0,(long &)numsize);
01295
01296 #ifdef PRINTF
01297 printf("%d \n",numsize);
01298 #endif
01299 }while ((numsize>NUMSIZES)||(numsize<0));
01300 do{
01301 #ifdef PRINTF
01302 printf("Enter dispersion factor (separation distance in pixels) for spheres (0-2) \n");
01303 printf("0 corresponds to totally random placement \n");
01304 #endif
01305 F->get_next_line_in_section(0,(long &)dispdist);
01306
01307 #ifdef PRINTF
01308 printf("%d \n",dispdist);
01309 #endif
01310 }while ((dispdist<0)||(dispdist>2));
01311 do{
01312 #ifdef PRINTF
01313 printf("Enter probability for gypsum particles on a random particle basis (0.0-1.0) \n");
01314 #endif
01315 F->get_next_line_in_section(0,probgyp);
01316
01317 #ifdef PRINTF
01318 printf("%f \n",probgyp);
01319 #endif
01320 } while ((probgyp<0.0)||(probgyp>1.0));
01321 do{
01322 #ifdef PRINTF
01323 printf("Enter probabilities for hemihydrate and anhydrite forms of gypsum (0.0-1.0) \n");
01324 #endif
01325 F->get_next_line_in_section(0,probhem);
01326 F->get_next_line_in_section(0,probanh);
01327
01328 #ifdef PRINTF
01329 printf("%f %f\n",probhem,probanh);
01330 #endif
01331 } while ((probhem<0.0)||(probhem>1.0)||(probanh<0.0)||(probanh>1.0)||((probanh+probhem)>1.001));
01332
01333 if((numsize>0)&&(numsize<(NUMSIZES+1))){
01334 #ifdef PRINTF
01335 printf("Enter number, radius, and phase ID for each sphere class (largest radius 1st) \n");
01336 printf("Phases are %d- Cement and (random) calcium sulfate, %d- C2S, %d- Gypsum, %d- hemihydrate %d- anhydrite %d- Pozzolanic, %d- Inert, %d- Slag, %d- CaCO3 %d- Fly Ash \n",CEMID,C2SID,GYPID,HEMIHYDRATE,ANHYDRITE,POZZID,INERTID,SLAGID,CACO3,FLYASH);
01337 #endif
01338
01339 for(isph=0;isph<numsize;isph++){
01340 #ifdef PRINTF
01341 printf("Enter number of spheres of class %d \n",isph+1);
01342 #endif
01343 F->get_next_line_in_section(0, inval1);
01344
01345 #ifdef PRINTF
01346 printf("%ld \n",inval1);
01347 #endif
01348 sphnum[isph]=inval1;
01349
01350
01351 #ifdef PRINTF
01352 printf("Enter radius of spheres of class %d \n",isph+1);
01353 printf("(Integer <=%d please) \n",SYSSIZE/3);
01354 #endif
01355 F->get_next_line_in_section(0,(long &)inval);
01356
01357 if(inval>(SYSSIZE/3)){
01358 printf("Given radius %d exceeded maximum radius of %d, terminating\n",inval,SYSSIZE/3);
01359 exit(0);
01360 }
01361 #ifdef PRINTF
01362 printf("%d \n",inval);
01363 #endif
01364
01365
01366 sphrad[isph]=inval;
01367 do{
01368 #ifdef PRINTF
01369 printf("Enter phase of spheres of class %d \n",isph+1);
01370 #endif
01371 F->get_next_line_in_section(0,(long &)inval);
01372
01373 #ifdef PRINTF
01374 printf("%d \n",inval);
01375 #endif
01376 } while ((inval!=CEMID)&&(inval!=C2SID)&&(inval!=GYPID)&&(inval!=HEMIHYDRATE)&&(inval!=ANHYDRITE)&&(inval!=POZZID)&&(inval!=INERTID)&&(inval!=SLAGID)&&(inval!=FLYASH)&&(inval!=CACO3));
01377 sphase[isph]=inval;
01378 if(inval==CEMID){
01379 target_total+=sphnum[isph]*volpart[sphrad[isph]];
01380 }
01381
01382 }
01383
01384 target_sulfate=(int)((float)target_total*probgyp);
01385 target_anhydrite=(int)((float)target_total*probgyp*probanh);
01386 target_hemi=(int)((float)target_total*probgyp*probhem);
01387 if(gsphere(numsize,sphnum,sphrad,sphase)==1){
01388 delete [] sphrad;
01389 delete [] sphase;
01390 delete [] sphnum;
01391 return(1);
01392 }
01393 }
01394
01395 delete [] sphrad;
01396 delete [] sphase;
01397 delete [] sphnum;
01398
01399
01400 return(0);
01401 }
01402
01403
01404
01405
01406 void cemhydmat::drawfloc(int xin,int yin,int zin,int radd,int phasein,int phase2){
01407
01408
01409 int xp,yp,zp,i,j,k;
01410 float dist,xdist,ydist,zdist,ftmp;
01411
01412
01413 for(i=xin-radd;(i<=xin+radd);i++){
01414 xp=i;
01415
01416 if(xp<1) {xp+=SYSSIZE;}
01417 else if(xp>SYSSIZE) {xp-=SYSSIZE;}
01418 ftmp=(float)(i-xin);
01419 xdist=ftmp*ftmp;
01420 for(j=yin-radd;(j<=yin+radd);j++){
01421 yp=j;
01422
01423 if(yp<1) {yp+=SYSSIZE;}
01424 else if(yp>SYSSIZE) {yp-=SYSSIZE;}
01425 ftmp=(float)(j-yin);
01426 ydist=ftmp*ftmp;
01427 for(k=zin-radd;(k<=zin+radd);k++){
01428 zp=k;
01429
01430 if(zp<1) {zp+=SYSSIZE;}
01431 else if(zp>SYSSIZE) {zp-=SYSSIZE;}
01432 ftmp=(float)(k-zin);
01433 zdist=ftmp*ftmp;
01434
01435
01436 dist=sqrt(xdist+ydist+zdist);
01437 if((dist-0.5)<=(float)radd){
01438
01439 cement [xp] [yp] [zp]=phasein;
01440 cemreal [xp] [yp] [zp]=phase2;
01441 }
01442 }
01443 }
01444 }
01445 }
01446
01447
01448
01449
01450
01451 int cemhydmat::chkfloc(int xin,int yin,int zin,int radd){
01452
01453
01454 int nofits,xp,yp,zp,i,j,k;
01455 float dist,xdist,ydist,zdist,ftmp;
01456
01457 nofits=0;
01458
01459
01460 for(i=xin-radd;((i<=xin+radd)&&(nofits==0));i++){
01461 xp=i;
01462
01463 if(xp<1) {xp+=SYSSIZE;}
01464 else if(xp>SYSSIZE) {xp-=SYSSIZE;}
01465 ftmp=(float)(i-xin);
01466 xdist=ftmp*ftmp;
01467 for(j=yin-radd;((j<=yin+radd)&&(nofits==0));j++){
01468 yp=j;
01469
01470 if(yp<1) {yp+=SYSSIZE;}
01471 else if(yp>SYSSIZE) {yp-=SYSSIZE;}
01472 ftmp=(float)(j-yin);
01473 ydist=ftmp*ftmp;
01474 for(k=zin-radd;((k<=zin+radd)&&(nofits==0));k++){
01475 zp=k;
01476
01477 if(zp<1) {zp+=SYSSIZE;}
01478 else if(zp>SYSSIZE) {zp-=SYSSIZE;}
01479 ftmp=(float)(k-zin);
01480 zdist=ftmp*ftmp;
01481
01482
01483 dist=sqrt(xdist+ydist+zdist);
01484 if((dist-0.5)<=(float)radd){
01485 if((cement [xp] [yp] [zp] !=POROSITY)){
01486
01487 nofits=cement [xp] [yp] [zp];
01488 }
01489 }
01490
01491 if((fabs(xp-((float)(SYSSIZE+1)/2.0)))<((float)aggsize/2.0)){
01492 nofits=AGG;
01493 }
01494 }
01495 }
01496 }
01497
01498 return(nofits);
01499 }
01500
01501
01502
01503 void cemhydmat::makefloc(void)
01504
01505
01506 {
01507 int partdo,numfloc;
01508 int nstart;
01509 int nleft = 0,ckall;
01510 int xm,ym,zm,moveran;
01511 int xp,yp,zp,rp,clushit,valkeep;
01512 int iclus;
01513 int *cluspart;
01514 struct cluster *parttmp,*partpoint,*partkeep = NULL;
01515
01516 cluspart = new int[NPARTC];
01517
01518
01519 nstart=npart;
01520 for(iclus=1;iclus<=npart;iclus++){
01521 cluspart[iclus]=iclus;
01522 }
01523 do{
01524 #ifdef PRINTF
01525 printf("Enter number of flocs desired at end of routine (>0) \n");
01526 #endif
01527 F->get_next_line_in_section(0,(long &)numfloc);
01528
01529 #ifdef PRINTF
01530 printf("%d\n",numfloc);
01531 #endif
01532 } while (numfloc<=0);
01533
01534 while(nstart>numfloc){
01535 nleft=0;
01536
01537
01538 for(iclus=1;iclus<=npart;iclus++){
01539 if(clust[iclus]==NULL){
01540 nleft+=1;
01541 }
01542 else{
01543 xm=ym=zm=0;
01544
01545 moveran=(int)(6.*ran1(seed));
01546 switch(moveran){
01547 case 0:
01548 xm=1;
01549 break;
01550 case 1:
01551 xm=(-1);
01552 break;
01553 case 2:
01554 ym=1;
01555 break;
01556 case 3:
01557 ym=(-1);
01558 break;
01559 case 4:
01560 zm=1;
01561 break;
01562 case 5:
01563 zm=(-1);
01564 break;
01565 default:
01566 break;
01567 }
01568
01569
01570 partpoint=clust[iclus];
01571 while(partpoint!=NULL){
01572 xp=partpoint->x;
01573 yp=partpoint->y;
01574 zp=partpoint->z;
01575 rp=partpoint->r;
01576 drawfloc(xp,yp,zp,rp,0,0);
01577 partpoint=partpoint->nextpart;
01578 }
01579
01580 ckall=0;
01581
01582 partpoint=clust[iclus];
01583 while((partpoint!=NULL)&&(ckall==0)){
01584 xp=partpoint->x+xm;
01585 yp=partpoint->y+ym;
01586 zp=partpoint->z+zm;
01587 rp=partpoint->r;
01588 ckall=chkfloc(xp,yp,zp,rp);
01589 partpoint=partpoint->nextpart;
01590 }
01591
01592 if(ckall==0){
01593
01594 partpoint=clust[iclus];
01595 while(partpoint!=NULL){
01596 xp=partpoint->x+xm;
01597 yp=partpoint->y+ym;
01598 zp=partpoint->z+zm;
01599 rp=partpoint->r;
01600 valkeep=partpoint->partphase;
01601 partdo=partpoint->partid;
01602 drawfloc(xp,yp,zp,rp,partdo+CEM-1,valkeep);
01603
01604 partpoint->x=xp;
01605 partpoint->y=yp;
01606 partpoint->z=zp;
01607 partpoint=partpoint->nextpart;
01608 }
01609 }
01610 else{
01611
01612
01613 partpoint=clust[iclus];
01614
01615 while(partpoint!=NULL){
01616 xp=partpoint->x;
01617 yp=partpoint->y;
01618 zp=partpoint->z;
01619 rp=partpoint->r;
01620 valkeep=partpoint->partphase;
01621 partdo=partpoint->partid;
01622 drawfloc(xp,yp,zp,rp,partdo+CEM-1,valkeep);
01623 partkeep=partpoint;
01624 partpoint=partpoint->nextpart;
01625 }
01626
01627 if(ckall!=AGG){
01628 clushit=cluspart[ckall-CEM+1];
01629
01630 parttmp=clust[clushit];
01631
01632 partkeep->nextpart=parttmp;
01633 while(parttmp!=NULL){
01634 cluspart[parttmp->partid]=iclus;
01635
01636 parttmp->clustid=iclus;
01637 parttmp=parttmp->nextpart;
01638 }
01639
01640 clust[clushit]=NULL;
01641 nstart-=1;
01642 }
01643 }
01644 }
01645 }
01646 printf("Number left was %d but number of clusters is %d \n",nleft,nstart);
01647 }
01648 clusleft=nleft;
01649
01650 delete [] cluspart;
01651
01652 }
01653
01654
01655
01656 void cemhydmat::measure(void)
01657
01658
01659 {
01660 long int npor,nc2s,ngyp,ncem,nagg,npozz,ninert,nflyash,nanh,nhem,ncaco3,nslag;
01661 int i,j,k,valph;
01662
01663
01664 npor=0;
01665 ngyp=0;
01666 ncem=0;
01667 nagg=0;
01668 ninert=0;
01669 nslag=0;
01670 nc2s=0;
01671 npozz=0;
01672 nflyash=0;
01673 nanh=0;
01674 nhem=0;
01675 ncaco3=0;
01676
01677
01678 for(i=1;i<=SYSSIZE;i++){
01679 for(j=1;j<=SYSSIZE;j++){
01680 for(k=1;k<=SYSSIZE;k++){
01681 valph=cemreal [i] [j] [k];
01682 if(valph==POROSITY) {npor+=1;}
01683 else if(valph==CEMID){ncem+=1;}
01684 else if(valph==C2SID){nc2s+=1;}
01685 else if(valph==GYPID){ngyp+=1;}
01686 else if(valph==ANHYDRITE){nanh+=1;}
01687 else if(valph==HEMIHYDRATE){nhem+=1;}
01688 else if(valph==AGG) {nagg+=1;}
01689 else if(valph==POZZID) {npozz+=1;}
01690 else if(valph==SLAGID) {nslag+=1;}
01691 else if(valph==INERTID) {ninert+=1;}
01692 else if(valph==FLYASH) {nflyash+=1;}
01693 else if(valph==CACO3) {ncaco3+=1;}
01694 }
01695 }
01696 }
01697
01698
01699 printf("\n Phase counts are: \n");
01700 printf("Porosity= %ld \n",npor);
01701 printf("Cement= %ld \n",ncem);
01702 printf("C2S= %ld \n",nc2s);
01703 printf("Gypsum= %ld \n",ngyp);
01704 printf("Anhydrite= %ld \n",nanh);
01705 printf("Hemihydrate= %ld \n",nhem);
01706 printf("Pozzolan= %ld \n",npozz);
01707 printf("Inert= %ld \n",ninert);
01708 printf("Slag= %ld \n",nslag);
01709 printf("CaCO3= %ld \n",ncaco3);
01710 printf("Fly Ash= %ld \n",nflyash);
01711 printf("Aggregate= %ld \n",nagg);
01712 }
01713
01714
01715
01716
01717 void cemhydmat::measagg(void)
01718
01719
01720 {
01721 int phase [40],ptot;
01722 int icnt,ixlo,ixhi,iy,iz,phid,idist;
01723 FILE *aggfile;
01724
01725
01726 aggfile=fopen("agglist.out","w");
01727 printf("Distance Porosity Cement C2S Gypsum Anhydrite Hemihydrate Pozzolan Inert Slag CaCO3 Fly Ash\n");
01728 fprintf(aggfile,"Distance Porosity Cement C2S Gypsum Anhydrite Hemihydrate Pozzolan Inert Slag CaCO3 Fly Ash\n");
01729
01730
01731 for(idist=1;idist<=(SYSSIZE-aggsize)/2;idist++){
01732
01733 ixlo=((SYSSIZE-aggsize+2)/2)-idist;
01734
01735 ixhi=((SYSSIZE+aggsize)/2)+idist;
01736
01737
01738 for(icnt=0;icnt<39;icnt++){
01739 phase[icnt]=0;
01740 }
01741 ptot=0;
01742
01743
01744 for(iy=1;iy<=SYSSIZE;iy++){
01745 for(iz=1;iz<=SYSSIZE;iz++){
01746 phid=cemreal [ixlo] [iy] [iz];
01747 ptot+=1;
01748 if(phid<=FLYASH){
01749 phase[phid]+=1;
01750 }
01751 phid=cemreal [ixhi] [iy] [iz];
01752 ptot+=1;
01753 if(phid<=FLYASH){
01754 phase[phid]+=1;
01755 }
01756 }
01757 }
01758
01759
01760 printf("%d %d %d %d %d %d %d %d %d %d %d %d\n",idist,phase[0],phase[CEMID],phase[C2SID],phase[GYPID],phase[ANHYDRITE],phase[HEMIHYDRATE],phase[POZZID],phase[INERTID],phase[SLAGID],phase[CACO3],phase[FLYASH]);
01761 fprintf(aggfile,"%d %d %d %d %d %d %d %d %d %d %d %d\n",idist,phase[0],phase[CEMID],phase[C2SID],phase[GYPID],phase[ANHYDRITE],phase[HEMIHYDRATE],phase[POZZID],phase[INERTID],phase[SLAGID],phase[CACO3],phase[FLYASH]);
01762
01763
01764 }
01765 fclose(aggfile);
01766 }
01767
01768
01769
01770
01771
01772 void cemhydmat::connect(void)
01773
01774
01775 {
01776 long int inew,ntop,nthrough,ncur,nnew,ntot;
01777 int i,j,k,nmatx[29000],nmaty[29000],nmatz[29000];
01778 int xcn,ycn,zcn,npix,x1,y1,z1,igood,nnewx[29000],nnewy[29000],nnewz[29000];
01779 int jnew,icur;
01780
01781 do{
01782 printf("Enter phase to analyze 0) pores 1) Cement \n");
01783 F->get_next_line_in_section(0,(long &)npix);
01784
01785 printf("%d \n",npix);
01786 } while ((npix!=0)&&(npix!=1));
01787
01788
01789
01790 ntop=0;
01791 nthrough=0;
01792
01793
01794
01795 k=1;
01796 for(i=1;i<=SYSSIZE;i++){
01797 for(j=1;j<=SYSSIZE;j++){
01798 ncur=0;
01799 ntot=0;
01800 igood=0;
01801 if(((cement[i][j][k]==npix)&&((cement[i][j][SYSSIZE]==npix)||
01802 (cement[i][j][SYSSIZE]==(npix+BURNTG))))||
01803 ((cement [i] [j] [SYSSIZE]>=CEM)&&
01804 (cement [i] [j] [k]>=CEM)&&(cement [i] [j] [k]<BURNTG)&&(npix==1))){
01805
01806 cement [i] [j] [k]+=BURNTG;
01807 ntot+=1;
01808 ncur+=1;
01809
01810
01811 nmatx[ncur]=i;
01812 nmaty[ncur]=j;
01813 nmatz[ncur]=1;
01814
01815 do{
01816 nnew=0;
01817 for(inew=1;inew<=ncur;inew++){
01818 xcn=nmatx[inew];
01819 ycn=nmaty[inew];
01820 zcn=nmatz[inew];
01821
01822
01823 for(jnew=1;jnew<=6;jnew++){
01824 x1=xcn;
01825 y1=ycn;
01826 z1=zcn;
01827 if(jnew==1){
01828 x1-=1;
01829 if(x1<1){
01830 x1+=SYSSIZE;
01831 }
01832 }
01833 else if(jnew==2){
01834 x1+=1;
01835 if(x1>SYSSIZE){
01836 x1-=SYSSIZE;
01837 }
01838 }
01839 else if(jnew==3){
01840 y1-=1;
01841 if(y1<1){
01842 y1+=SYSSIZE;
01843 }
01844 }
01845 else if(jnew==4){
01846 y1+=1;
01847 if(y1>SYSSIZE){
01848 y1-=SYSSIZE;
01849 }
01850 }
01851 else if(jnew==5){
01852 z1-=1;
01853 }
01854 else if(jnew==6){
01855 z1+=1;
01856 }
01857
01858
01859 if((z1>=1)&&(z1<=SYSSIZE)){
01860 if((cement [x1] [y1] [z1]==npix)||((cement [x1] [y1] [z1]>=CEM)&&
01861 (cement [x1] [y1] [z1]<BURNTG)&&(npix==1))){
01862 ntot+=1;
01863 cement [x1] [y1] [z1]+=BURNTG;
01864 nnew+=1;
01865 if(nnew>=29000){
01866 printf("error in size of nnew \n");
01867 }
01868 nnewx[nnew]=x1;
01869 nnewy[nnew]=y1;
01870 nnewz[nnew]=z1;
01871
01872 if(z1==SYSSIZE){
01873 igood=1;
01874 }
01875 }
01876 }
01877 }
01878 }
01879 if(nnew>0){
01880 ncur=nnew;
01881
01882 for(icur=1;icur<=ncur;icur++){
01883 nmatx[icur]=nnewx[icur];
01884 nmaty[icur]=nnewy[icur];
01885 nmatz[icur]=nnewz[icur];
01886 }
01887 }
01888 }while (nnew>0);
01889
01890 ntop+=ntot;
01891 if(igood==1){
01892 nthrough+=ntot;
01893 }
01894 }
01895 }
01896 }
01897
01898 printf("Phase ID= %d \n",npix);
01899 printf("Number accessible from top= %ld \n",ntop);
01900 printf("Number contained in through pathways= %ld \n",nthrough);
01901
01902
01903 for(i=1;i<=SYSSIZE;i++){
01904 for(j=1;j<=SYSSIZE;j++){
01905 for(k=1;k<=SYSSIZE;k++){
01906 if(cement [i] [j] [k]>=BURNTG){
01907 cement [i] [j] [k]-=BURNTG;
01908 }
01909 }
01910 }
01911 }
01912 }
01913
01914
01915
01916 void cemhydmat::outmic(void)
01917
01918
01919 {
01920 FILE *outfile,*partfile;
01921 char filen[80],filepart[80];
01922 int ix,iy,iz,valout;
01923
01924 #ifdef PRINTF
01925 printf("Enter name of file to save microstructure to \n");
01926 #endif
01927
01928 F->get_next_line_in_section(0,filen);
01929
01930 printf("%s\n",filen);
01931
01932 outfile=fopen(filen,"w");
01933
01934 #ifdef PRINTF
01935 printf("Enter name of file to save particle IDs to \n");
01936 #endif
01937
01938 F->get_next_line_in_section(0,filepart);
01939
01940 #ifdef PRINTF
01941 printf("%s\n",filepart);
01942 #endif
01943
01944 partfile=fopen(filepart,"w");
01945
01946 for(iz=1;iz<=SYSSIZE;iz++){
01947 for(iy=1;iy<=SYSSIZE;iy++){
01948 for(ix=1;ix<=SYSSIZE;ix++){
01949 valout=cemreal[ix][iy][iz];
01950 fprintf(outfile,"%1d\n",valout);
01951 valout=cement[ix][iy][iz];
01952 if(valout<0){valout=0;}
01953 fprintf(partfile,"%d\n",valout);
01954 }
01955 }
01956 }
01957 fclose(outfile);
01958 fclose(partfile);
01959 }
01960
01961
01962 int cemhydmat::genpartnew(void){
01963 int userc;
01964 int ig,jg,kg;
01965
01966 n_sulfate=0;
01967 target_sulfate=0;
01968 n_total=0;
01969 target_total=0;
01970 n_anhydrite=0;
01971 target_anhydrite=0;
01972 n_hemi=0;
01973 target_hemi=0;
01974
01975 alloc_long_3D(cement, SYSIZE+1);
01976 alloc_long_3D(cemreal, SYSIZE+1);
01977
01978 clust = new cluster*[NPARTC];
01979
01980
01981 volpart[0]=1;
01982 volpart[1]=19;
01983 volpart[2]=81;
01984 volpart[3]=179;
01985 volpart[4]=389;
01986 volpart[5]=739;
01987 volpart[6]=1189;
01988 volpart[7]=1791;
01989 volpart[8]=2553;
01990 volpart[9]=3695;
01991 volpart[10]=4945;
01992 volpart[11]=6403;
01993 volpart[12]=8217;
01994 volpart[13]=10395;
01995 volpart[14]=12893;
01996 volpart[15]=15515;
01997 volpart[16]=18853;
01998 volpart[17]=22575;
01999 volpart[18]=26745;
02000 volpart[19]=31103;
02001 volpart[20]=36137;
02002 volpart[21]=41851;
02003 volpart[22]=47833;
02004 volpart[23]=54435;
02005 volpart[24]=61565;
02006 volpart[25]=69599;
02007 volpart[26]=78205;
02008 volpart[27]=87271;
02009 volpart[28]=97233;
02010 volpart[29]=107783;
02011 volpart[30]=119009;
02012 volpart[31]=131155;
02013 volpart[32]=143761;
02014 volpart[33]=157563;
02015 volpart[34]=172317;
02016 volpart[35]=187511;
02017 volpart[36]=203965;
02018
02019
02020
02021
02022 nseed=iseed;
02023 seed=&nseed;
02024
02025
02026 npart=0;
02027 aggsize=0;
02028 clusleft=0;
02029
02030
02031 for(ig=1;ig<=SYSSIZE;ig++){
02032 for(jg=1;jg<=SYSSIZE;jg++){
02033 for(kg=1;kg<=SYSSIZE;kg++){
02034 cement [ig] [jg] [kg]=POROSITY;
02035 cemreal [ig] [jg] [kg]=POROSITY;
02036 }
02037 }
02038 }
02039
02040
02041 do{
02042 #ifdef PRINTF
02043 printf(" \n Input User Choice \n");
02044 printf("1) Exit \n");
02045 printf("2) Add spherical particles (cement,gypsum, pozzolans, etc.) to microstructure \n");
02046 printf("3) Flocculate system by reducing number of particle clusters \n");
02047 printf("4) Measure global phase fractions \n");
02048 printf("5) Add an aggregate to the microstructure \n");
02049 printf("6) Measure single phase connectivity (pores or solids) \n");
02050 printf("7) Measure phase fractions vs. distance from aggregate surface \n");
02051 printf("8) Output current microstructure to file \n");
02052 #endif
02053
02054 F->get_next_line_in_section(0,(long &)userc);
02055
02056
02057 fflush(stdout);
02058
02059 switch (userc) {
02060 case 2:
02061 if(create()==1){
02062 delete [] clust;
02063 dealloc_long_3D(cement, SYSIZE+1);
02064 dealloc_long_3D(cemreal, SYSIZE+1);
02065 return(1);
02066 }
02067 break;
02068 case 3:
02069 makefloc();
02070 break;
02071 case 4:
02072 measure();
02073 break;
02074 case 5:
02075 addagg();
02076 break;
02077 case 6:
02078 connect();
02079 break;
02080 case 7:
02081 if(aggsize!=0){
02082 measagg();
02083 }
02084 else{
02085 printf("No aggregate present. \n");
02086 }
02087 break;
02088 case 8:
02089 outmic();
02090 break;
02091 default:
02092 break;
02093 }
02094 } while (userc!=1);
02095
02096
02097 for(ig=0;ig<SYSSIZE;ig++){
02098 for(jg=0;jg<SYSSIZE;jg++){
02099 for(kg=0;kg<SYSSIZE;kg++){
02100 micpart[ig][jg][kg]=cement[ig+1][jg+1][kg+1];
02101 }
02102 }
02103 }
02104
02105 dealloc_long_3D(cement, SYSIZE+1);
02106 delete [] clust;
02107 return(0);
02108 }
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119 int cemhydmat::maketemp(int size)
02120 {
02121 int icirc,xval,yval,zval;
02122 float xtmp,ytmp;
02123 float dist;
02124
02125
02126 icirc=0;
02127 for(xval=(-size);xval<=size;xval++){
02128 xtmp=(float)(xval*xval);
02129 for(yval=(-size);yval<=size;yval++){
02130 ytmp=(float)(yval*yval);
02131 for(zval=(-size);zval<=size;zval++){
02132 dist=sqrt(xtmp+ytmp+(float)(zval*zval));
02133 if(dist<=((float)size+0.5)){
02134 icirc+=1;
02135 if(icirc>=MAXSPH){
02136 printf("Too many elements in sphere \n");
02137 printf("Must change value of MAXSPH parameter \n");
02138 printf("Currently set at %ld \n",MAXSPH);
02139 exit(1);
02140 }
02141 xsph[icirc]=xval;
02142 ysph[icirc]=yval;
02143 zsph[icirc]=zval;
02144 }
02145 }
02146 }
02147 }
02148
02149
02150 return(icirc);
02151 }
02152
02153
02154
02155
02156 void cemhydmat::phcount(void){
02157 long int npore,nsolid [37];
02158 int ix,iy,iz;
02159
02160 npore=0;
02161 for(ix=1;ix<37;ix++){
02162 nsolid[ix]=0;
02163 }
02164
02165 for(ix=1;ix<=SYSSIZE;ix++){
02166 for(iy=1;iy<=SYSSIZE;iy++){
02167 for(iz=1;iz<=SYSSIZE;iz++){
02168 if(mask [ix] [iy] [iz]==0){
02169 npore+=1;
02170 }
02171 else{
02172 nsolid[mask [ix] [iy] [iz]]+=1;
02173 }
02174 }
02175 }
02176 }
02177
02178 printf("Pores are: %ld \n",npore);
02179 printf("Solids are: %ld %ld %ld %ld %ld %ld\n",nsolid[1],nsolid[2],
02180 nsolid[3],nsolid[4],nsolid[5],nsolid[6]);
02181 }
02182
02183
02184
02185
02186
02187 int cemhydmat::surfpix(int xin,int yin,int zin){
02188 int npix,ix1,iy1,iz1;
02189
02190 npix=0;
02191
02192
02193
02194 ix1=xin-1;
02195 if(ix1<1){ix1+=SYSSIZE;}
02196 if(mask[ix1][yin][zin]==0){
02197 npix+=1;
02198 }
02199 ix1=xin+1;
02200 if(ix1>SYSSIZE){ix1-=SYSSIZE;}
02201 if(mask[ix1][yin][zin]==0){
02202 npix+=1;
02203 }
02204 iy1=yin-1;
02205 if(iy1<1){iy1+=SYSSIZE;}
02206 if(mask[xin][iy1][zin]==0){
02207 npix+=1;
02208 }
02209 iy1=yin+1;
02210 if(iy1>SYSSIZE){iy1-=SYSSIZE;}
02211 if(mask[xin][iy1][zin]==0){
02212 npix+=1;
02213 }
02214 iz1=zin-1;
02215 if(iz1<1){iz1+=SYSSIZE;}
02216 if(mask[xin][yin][iz1]==0){
02217 npix+=1;
02218 }
02219 iz1=zin+1;
02220 if(iz1>SYSSIZE){iz1-=SYSSIZE;}
02221 if(mask[xin][yin][iz1]==0){
02222 npix+=1;
02223 }
02224 return(npix);
02225 }
02226
02227
02228
02229
02230 float cemhydmat::rhcalc(int phin){
02231 int ix,iy,iz;
02232 long int porc,surfc;
02233 float rhval;
02234
02235 porc=surfc=0;
02236
02237
02238 for(ix=1;ix<=SYSSIZE;ix++){
02239 for(iy=1;iy<=SYSSIZE;iy++){
02240 for(iz=1;iz<=SYSSIZE;iz++){
02241 if(mask [ix] [iy] [iz]==phin){
02242 porc+=1;
02243 surfc+=surfpix(ix,iy,iz);
02244 }
02245 }
02246 }
02247 }
02248
02249 printf("Phase area count is %ld \n",porc);
02250 printf("Phase surface count is %ld \n",surfc);
02251 rhval=(float)porc*6./(4.*(float)surfc);
02252 printf("Hydraulic radius is %f \n",rhval);
02253 return(rhval);
02254 }
02255
02256
02257
02258
02259
02260 int cemhydmat::countem(int xp,int yp,int zp,int phin){
02261 int xc,yc,zc;
02262 int cumnum,ic;
02263
02264 cumnum=0;
02265 for(ic=1;ic<=nsph;ic++){
02266 xc=xp+xsph[ic];
02267 yc=yp+ysph[ic];
02268 zc=zp+zsph[ic];
02269
02270 if(xc<1){xc+=SYSSIZE;}
02271 else if(xc>SYSSIZE){xc-=SYSSIZE;}
02272 if(yc<1){yc+=SYSSIZE;}
02273 else if(yc>SYSSIZE){yc-=SYSSIZE;}
02274 if(zc<1){zc+=SYSSIZE;}
02275 else if(zc>SYSSIZE){zc-=SYSSIZE;}
02276
02277 if((xc!=xp)||(yc!=yp)||(zc!=zp)){
02278
02279 if((mask [xc] [yc] [zc]==phin)||(mask [xc] [yc] [zc]==0)){
02280 cumnum+=1;
02281 }
02282 }
02283 }
02284 return(cumnum);
02285 }
02286
02287
02288
02289
02290
02291 void cemhydmat::sysinit(int ph1,int ph2){
02292 int count,xl,yl,zl;
02293
02294 count=0;
02295
02296 for(xl=1;xl<=SYSSIZE;xl++){
02297 for(yl=1;yl<=SYSSIZE;yl++){
02298 for(zl=1;zl<=SYSSIZE;zl++){
02299
02300
02301
02302
02303 if(mask [xl] [yl] [zl]==ph1){
02304 count=countem(xl,yl,zl,0);
02305 }
02306
02307
02308 if(mask [xl] [yl] [zl]==ph2){
02309 count=countem(xl,yl,zl,ph2);
02310 }
02311 if((count<0)||(count>=nsph)){
02312 printf("Error count is %d \n",count);
02313 printf("xl %d yl %d zl %d \n",xl,yl,zl);
02314 }
02315
02316
02317
02318 if((count>=0)&&(mask [xl] [yl] [zl]==ph1)){
02319
02320 curvature [xl] [yl] [zl]=count;
02321
02322 nsolid[count]+=1;
02323 }
02324
02325
02326 if((count>=0)&&(mask [xl] [yl] [zl]==ph2)){
02327
02328 curvature [xl] [yl] [zl]=count;
02329
02330 nair[count]+=1;
02331 }
02332
02333 }
02334 }
02335 }
02336 }
02337
02338
02339
02340
02341
02342 void cemhydmat::sysscan(int ph1,int ph2){
02343 int xd,yd,zd,curvval;
02344
02345
02346 for(xd=1;xd<=SYSSIZE;xd++){
02347 for(yd=1;yd<=SYSSIZE;yd++){
02348 for(zd=1;zd<=SYSSIZE;zd++){
02349
02350 curvval=curvature [xd] [yd] [zd];
02351
02352 if(mask [xd] [yd] [zd]==ph2){
02353 nair[curvval]+=1;
02354 }
02355 else if (mask [xd] [yd] [zd]==ph1){
02356 nsolid[curvval]+=1;
02357 }
02358 }
02359 }
02360 }
02361 }
02362
02363
02364
02365
02366
02367
02368 int cemhydmat::procsol(int nsearch){
02369 int valfound,i,stop;
02370 long int nsofar;
02371
02372
02373
02374 valfound=nsph-1;
02375 nsofar=0;
02376 stop=0;
02377 for(i=(nsph-1);((i>=0)&&(stop==0));i--){
02378 nsofar+=nsolid[i];
02379 if(nsofar>nsearch){
02380 valfound=i;
02381 stop=1;
02382 }
02383 }
02384 return(valfound);
02385 }
02386
02387
02388
02389
02390
02391
02392
02393 int cemhydmat::procair(int nsearch){
02394 int valfound,i,stop;
02395 long int nsofar;
02396
02397
02398
02399 valfound=0;
02400 nsofar=0;
02401 stop=0;
02402 for(i=0;((i<nsph)&&(stop==0));i++){
02403 nsofar+=nair[i];
02404 if(nsofar>nsearch){
02405 valfound=i;
02406 stop=1;
02407 }
02408 }
02409 return(valfound);
02410 }
02411
02412
02413
02414
02415
02416 int cemhydmat::movepix(int ntomove,int ph1,int ph2){
02417 int xloc[2100],yloc[2100],zloc[2100];
02418 int count1,count2,ntot,countc,i,xp,yp,zp;
02419 int cmin,cmax,cfg;
02420 int alldone;
02421 long int nsolc,nairc,nsum,nsolm,nairm,nst1,nst2,next1,next2;
02422 float pck,plsol,plair;
02423
02424 alldone=0;
02425
02426 count1=procsol(ntomove);
02427 nsum=0;
02428 cfg=0;
02429 cmax=count1;
02430 for(i=nsph;i>count1;i--){
02431 if((nsolid[i]>0)&&(cfg==0)){
02432 cfg=1;
02433 cmax=i;
02434 }
02435 nsum+=nsolid[i];
02436 }
02437
02438 plsol=(float)(ntomove-nsum)/(float)nsolid[count1];
02439 next1=ntomove-nsum;
02440 nst1=nsolid[count1];
02441
02442 count2=procair(ntomove);
02443 nsum=0;
02444 cmin=count2;
02445 cfg=0;
02446 for(i=0;i<count2;i++){
02447 if((nair[i]>0)&&(cfg==0)){
02448 cfg=1;
02449 cmin=i;
02450 }
02451 nsum+=nair[i];
02452 }
02453
02454 plair=(float)(ntomove-nsum)/(float)nair[count2];
02455 next2=ntomove-nsum;
02456 nst2=nair[count2];
02457
02458
02459
02460 if(cmin>=cmax){
02461 alldone=1;
02462 printf("Stopping - at equilibrium \n");
02463 printf("cmin- %d cmax- %d \n",cmin,cmax);
02464 return(alldone);
02465 }
02466
02467
02468 ntot=0;
02469 nsolc=0;
02470 nairc=0;
02471 nsolm=0;
02472 nairm=0;
02473
02474
02475 for(xp=1;xp<=SYSSIZE;xp++){
02476 for(yp=1;yp<=SYSSIZE;yp++){
02477 for(zp=1;zp<=SYSSIZE;zp++){
02478
02479 countc=curvature [xp] [yp] [zp];
02480
02481 if(mask [xp] [yp] [zp]==ph1){
02482 if(countc>count1){
02483
02484 mask [xp] [yp] [zp]=ph2;
02485
02486
02487 nsolid[countc]-=1;
02488 nair[countc]+=1;
02489
02490 ntot+=1;
02491 xloc[ntot]=xp;
02492 yloc[ntot]=yp;
02493 zloc[ntot]=zp;
02494 }
02495 if(countc==count1){
02496 nsolm+=1;
02497
02498 pck=ran1(seed);
02499 if((pck<0)||(pck>1.0)){pck=1.0;}
02500
02501 if(((pck<plsol)&&(nsolc<next1))||((nst1-nsolm)<(next1-nsolc))){
02502 nsolc+=1;
02503
02504 mask [xp] [yp] [zp]=ph2;
02505
02506
02507 nsolid[count1]-=1;
02508 nair[count1]+=1;
02509
02510 ntot+=1;
02511 xloc[ntot]=xp;
02512 yloc[ntot]=yp;
02513 zloc[ntot]=zp;
02514 }
02515 }
02516 }
02517
02518
02519 else if (mask [xp] [yp] [zp]==ph2){
02520 if(countc<count2){
02521
02522 mask [xp] [yp] [zp]=ph1;
02523
02524 nsolid[countc]+=1;
02525 nair[countc]-=1;
02526 ntot+=1;
02527 xloc[ntot]=xp;
02528 yloc[ntot]=yp;
02529 zloc[ntot]=zp;
02530 }
02531 if(countc==count2){
02532 nairm+=1;
02533 pck=ran1(seed);
02534 if((pck<0)||(pck>1.0)){pck=1.0;}
02535
02536 if(((pck<plair)&&(nairc<next2))||((nst2-nairm)<(next2-nairc))){
02537 nairc+=1;
02538
02539 mask [xp] [yp] [zp]=ph1;
02540
02541 nsolid[count2]+=1;
02542 nair[count2]-=1;
02543 ntot+=1;
02544 xloc[ntot]=xp;
02545 yloc[ntot]=yp;
02546 zloc[ntot]=zp;
02547 }
02548 }
02549 }
02550
02551 }
02552 }
02553 }
02554 printf("ntot is %d \n",ntot);
02555 return(alldone);
02556 }
02557
02558
02559
02560
02561 void cemhydmat::sinter3d(int ph1id,int ph2id,float rhtarget){
02562 int natonce,i,rade,j,rflag;
02563 int keepgo;
02564 long int curvsum1,curvsum2,pixsum1,pixsum2;
02565 float rhnow,avecurv1,avecurv2;
02566
02567
02568 for(i=0;i<=499;i++){
02569 nsolid[i]=0;
02570 nair[i]=0;
02571 }
02572
02573
02574 natonce=200;
02575 rade=3;
02576 rflag=0;
02577
02578 nsph=maketemp(rade);
02579 printf("nsph is %d \n",nsph);
02580 if(rflag==0){
02581 sysinit(ph1id,ph2id);
02582 }
02583 else{
02584 sysscan(ph1id,ph2id);
02585 }
02586 i=0;
02587 rhnow=rhcalc(ph1id);
02588 while((rhnow<rhtarget)&&(i<MAXCYC_SEAL)){
02589 printf("Now: %f Target: %f \n",rhnow,rhtarget);
02590 i+=1;
02591 #ifdef PRINTF
02592 printf("Cycle: %d \n",i);
02593 #endif
02594 keepgo=movepix(natonce,ph1id,ph2id);
02595
02596 if(keepgo==1){
02597 return;
02598 }
02599 curvsum1=0;
02600 curvsum2=0;
02601 pixsum1=0;
02602 pixsum2=0;
02603
02604 for(j=0;j<=nsph;j++){
02605 pixsum1+=nsolid[j];
02606 curvsum1+=(j*nsolid[j]);
02607 pixsum2+=nair[j];
02608 curvsum2+=(j*nair[j]);
02609 }
02610 avecurv1=(float)curvsum1/(float)pixsum1;
02611 avecurv2=(float)curvsum2/(float)pixsum2;
02612 printf("Ave. solid curvature: %f \n",avecurv1);
02613 printf("Ave. air curvature: %f \n",avecurv2);
02614 rhnow=rhcalc(ph1id);
02615 }
02616 }
02617
02618 void cemhydmat::stat3d(void){
02619 int valin,ix,iy,iz;
02620 int ix1,iy1,iz1,k;
02621 long int voltot,surftot;
02622
02623 for(ix=0;ix<=42;ix++){
02624 volume[ix]=surface[ix]=0;
02625 }
02626
02627
02628 for(iz=1;iz<=SYSIZE;iz++){
02629 for(iy=1;iy<=SYSIZE;iy++){
02630 for(ix=1;ix<=SYSIZE;ix++){
02631 valin=mask[ix][iy][iz];
02632 volume[valin]+=1;
02633 }
02634 }
02635 }
02636
02637
02638 for(iz=1;iz<=SYSIZE;iz++){
02639 for(iy=1;iy<=SYSIZE;iy++){
02640 for(ix=1;ix<=SYSIZE;ix++){
02641 if(mask [ix] [iy] [iz]!=0){
02642 valin=mask [ix] [iy] [iz];
02643
02644 for(k=1;k<=6;k++){
02645
02646 switch (k){
02647 case 1:
02648 ix1=ix-1;
02649 if(ix1<1){ix1+=SYSIZE;}
02650 iy1=iy;
02651 iz1=iz;
02652 break;
02653 case 2:
02654 ix1=ix+1;
02655 if(ix1>SYSIZE){ix1-=SYSIZE;}
02656 iy1=iy;
02657 iz1=iz;
02658 break;
02659 case 3:
02660 iy1=iy-1;
02661 if(iy1<1){iy1+=SYSIZE;}
02662 ix1=ix;
02663 iz1=iz;
02664 break;
02665 case 4:
02666 iy1=iy+1;
02667 if(iy1>SYSIZE){iy1-=SYSIZE;}
02668 ix1=ix;
02669 iz1=iz;
02670 break;
02671 case 5:
02672 iz1=iz-1;
02673 if(iz1<1){iz1+=SYSIZE;}
02674 iy1=iy;
02675 ix1=ix;
02676 break;
02677 case 6:
02678 iz1=iz+1;
02679 if(iz1>SYSIZE){iz1-=SYSIZE;}
02680 iy1=iy;
02681 ix1=ix;
02682 break;
02683 default:
02684 break;
02685 }
02686 if((ix1<1)||(iy1<1)||(iz1<1)||(ix1>SYSIZE)||(iy1>SYSIZE)||(iz1>SYSIZE)){
02687 printf("%d %d %d \n",ix1,iy1,iz1);
02688 exit(1);
02689 }
02690 if(mask[ix1] [iy1] [iz1]==0){
02691 surface[valin]+=1;
02692 }
02693 }
02694 }
02695 }
02696 }
02697 }
02698 #ifdef PRINTF
02699 printf("Phase Volume Surface Volume Surface \n");
02700 printf(" ID count count fraction fraction \n");
02701 #endif
02702
02703 surftot=surface[1]+surface[2]+surface[3]+surface[4];
02704 voltot=volume[1]+volume[2]+volume[3]+volume[4];
02705 k=0;
02706 #ifdef PRINTF
02707 printf(" %d %8ld %8ld \n",k,volume[0],surface[0]);
02708
02709 for(k=1;k<=4;k++){
02710 printf(" %d %8ld %8ld %.5f %.5f\n",k,volume[k],surface[k],
02711 (float)volume[k]/(float)voltot,(float)surface[k]/(float)surftot);
02712 }
02713 printf("Total %8ld %8ld\n\n\n",voltot,surftot);
02714
02715 for(k=5;k<=11;k++){
02716 printf(" %d %8ld %8ld\n",k,volume[k],surface[k]);
02717 }
02718 printf(" 20 %8ld %8ld\n",volume[20],surface[20]);
02719
02720 for(k=24;k<=27;k++){
02721 printf(" %d %8ld %8ld\n",k,volume[k],surface[k]);
02722 }
02723
02724 printf(" 28 %8ld %8ld\n",volume[28],surface[28]);
02725 #endif
02726 }
02727
02728 void cemhydmat::rand3d(int phasein,int phaseout, float xpt){
02729 int ires;
02730 float s2,ss,sdiff,xtmp,ytmp;
02731
02732
02733 double ***normm, ***res;
02734
02735 double ***filter;
02736 int done,r[61];
02737
02738 float *s, *xr, *sum;
02739 float val2;
02740 double t1,t2,x1,x2,u1,u2,xrad,resmax,resmin;
02741 float xtot,filval,radius,sect,sumtot,vcrit;
02742 int valin,r1,r2,i1,i2,i3,i,j,k,j1,k1;
02743 int ido,iii,jjj,ix,iy,iz,index;
02744 char tempstr[256];
02745
02746 alloc_double_3D(normm, SYSIZE+1);
02747 alloc_double_3D(res, SYSIZE+1);
02748 alloc_double_3D(filter,32);
02749
02750 s = new float[61];
02751 xr = new float[61];
02752 sum = new float[502];
02753
02754
02755 i1=i2=i3=1;
02756 for(i=1;i<=((SYSIZE*SYSIZE*SYSIZE)/2);i++){
02757 u1=ran1(seed);
02758 u2=ran1(seed);
02759 t1=2.*PI*u2;
02760 t2=sqrt(-2.*log(u1));
02761 x1=cos(t1)*t2;
02762 x2=sin(t1)*t2;
02763 normm[i1][i2][i3]=x1;
02764 i1+=1;
02765 if(i1>SYSIZE){
02766 i1=1;
02767 i2+=1;
02768 if(i2>SYSIZE){
02769 i2=1;
02770 i3+=1;
02771 }
02772 }
02773 normm[i1][i2][i3]=x2;
02774 i1+=1;
02775 if(i1>SYSIZE){
02776 i1=1;
02777 i2+=1;
02778 if(i2>SYSIZE){
02779 i2=1;
02780 i3+=1;
02781 }
02782 }
02783 }
02784
02785
02786 F->get_next_line_in_section(0,(long &)ido);
02787
02788
02789 #ifdef PRINTF
02790 printf("Number of points in correlation file is %d \n",ido);
02791 #endif
02792
02793 for(i=1;i<=ido;i++){
02794 F->get_next_line_in_section(0,tempstr);
02795 sscanf(tempstr, "%d %f", &valin,&val2);
02796
02797 r[i]=valin;
02798 s[i]=val2;
02799 xr[i]=(float)r[i];
02800 }
02801 ss=s[1];
02802 s2=ss*ss;
02803
02804 sdiff=ss-s2;
02805 for(i=0;i<31;i++){
02806 iii=i*i;
02807 for(j=0;j<31;j++){
02808 jjj=j*j;
02809 for(k=0;k<31;k++){
02810 xtmp=(float)(iii+jjj+k*k);
02811 radius=sqrt(xtmp);
02812 r1=(int)radius+1;
02813 r2=r1+1;
02814 if(s[r1]<0.0){
02815 printf("%d and %d %f and %f with xtmp of %f\n",r1,r2,s[r1],s[r2],xtmp);
02816 fflush(stdout);
02817 exit(1);
02818 }
02819 xrad=radius+1-r1;
02820 filval=s[r1]+(s[r2]-s[r1])*xrad;
02821 filter[i+1][j+1][k+1]=(filval-s2)/sdiff;
02822 }
02823 }
02824 }
02825
02826
02827 resmax=0.0;
02828 resmin=1.0;
02829 for(i=1;i<=SYSIZE;i++){
02830 for(j=1;j<=SYSIZE;j++){
02831 for(k=1;k<=SYSIZE;k++){
02832 res[i][j][k]=0.0;
02833 if((float)mask[i][j][k]==phasein){
02834 for(ix=1;ix<=31;ix++){
02835 i1=i+ix-1;
02836 while(i1<1) {
02837 i1+=SYSIZE;
02838 }
02839 while(i1>SYSIZE) {
02840 i1-=SYSIZE;
02841 }
02842 for(iy=1;iy<=31;iy++){
02843 j1=j+iy-1;
02844 while(j1<1) {
02845 j1+=SYSIZE;
02846 }
02847 while(j1>SYSIZE) {
02848 j1-=SYSIZE;
02849 }
02850 for(iz=1;iz<=31;iz++){
02851 k1=k+iz-1;
02852 while(k1<1) {
02853 k1+=SYSIZE;
02854 }
02855 while(k1>SYSIZE) {
02856 k1-=SYSIZE;
02857 }
02858 res[i][j][k]+=normm[i1][j1][k1]*filter[ix][iy][iz];
02859 }
02860 }
02861 }
02862 if(res[i][j][k]>resmax){resmax=res[i][j][k];}
02863 if(res[i][j][k]<resmin){resmin=res[i][j][k];}
02864 }
02865 }
02866 #ifdef PRINTF
02867 printf(".");
02868 #endif
02869 }
02870 #ifdef PRINTF
02871 printf("\n%d out of %d", i, SYSIZE);
02872 #endif
02873 }
02874 #ifdef PRINTF
02875 printf("\n");
02876 #endif
02877
02878 sect=(resmax-resmin)/500.;
02879 for(i=1;i<=500;i++){
02880 sum[i]=0.0;
02881 }
02882 xtot=0.0;
02883 for(i=1;i<=SYSIZE;i++){
02884 for(j=1;j<=SYSIZE;j++){
02885 for(k=1;k<=SYSIZE;k++){
02886 if((float)mask[i][j][k]==phasein){
02887 xtot+=1.0;
02888 index=1+(int)((res[i][j][k]-resmin)/sect);
02889 if(index>500){index=500;}
02890 sum[index]+=1.0;
02891 }
02892 }
02893 }
02894 }
02895
02896 sumtot=vcrit=0.0;
02897 done=0;
02898 for(i=1;((i<=500)&&(done==0));i++){
02899 sumtot+=sum[i]/xtot;
02900 if(sumtot>xpt){
02901 ytmp=(float)i;
02902 vcrit=resmin+(resmax-resmin)*(ytmp-0.5)/500.;
02903 done=1;
02904 }
02905 }
02906 #ifdef PRINTF
02907 printf("Critical volume fraction is %f\n",vcrit);
02908 #endif
02909 ires=0;
02910
02911 for(k=1;k<=SYSIZE;k++){
02912 for(j=1;j<=SYSIZE;j++){
02913 for(i=1;i<=SYSIZE;i++){
02914 if((float)mask[i][j][k]==phasein){
02915 if(res[i][j][k]>vcrit){
02916 mask[i][j][k]=phaseout;
02917 }
02918 }
02919 }
02920 }
02921 }
02922
02923 dealloc_double_3D(normm, SYSIZE+1);
02924 dealloc_double_3D(res, SYSIZE+1);
02925 dealloc_double_3D(filter,32);
02926
02927 delete [] s;
02928 delete [] xr;
02929 delete [] sum;
02930
02931 }
02932
02933
02934
02935 void cemhydmat::distrib3d(void)
02936 {
02937 int i,j,k,alumflag,alumval,alum2,valin;
02938 int output_img;
02939 double volin,volf[5],surff[5],rhtest,rdesire;
02940 char filen[80];
02941
02942 FILE *infile;
02943 FILE *outfile_img = NULL, *outfile_id = NULL;
02944
02945 alloc_int_3D(curvature, SYSIZE+1);
02946
02947
02948
02949
02950
02951 nseed=iseed;
02952 #ifdef PRINTF
02953 printf("%d\n",*seed);
02954 #endif
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970
02971
02972
02973
02974 alumflag=1;
02975 alumval=4;
02976
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986
02987
02988
02989
02990
02991
02992
02993 for(i=1;i<=4;i++){
02994 F->get_next_line_in_section(0,volin);
02995
02996 volf[i]=volin;
02997 #ifdef PRINTF
02998 printf("volume %f\n",volf[i]);
02999 #endif
03000
03001 surff[i]=volin;
03002 #ifdef PRINTF
03003 printf("surface %f\n",surff[i]);
03004 #endif
03005 }
03006
03007
03008 if((infile=fopen(filen,"r"))!=NULL){
03009 for(k=1;k<=SYSIZE;k++){
03010 for(j=1;j<=SYSIZE;j++){
03011 for(i=1;i<=SYSIZE;i++){
03012 fscanf(infile,"%d",&valin);
03013 mask[i][j][k]=valin;
03014 curvature[i][j][k]=0;
03015 }
03016 }
03017 }
03018 fclose(infile);
03019 }
03020 else{
03021 for(k=1;k<=SYSIZE;k++){
03022 for(j=1;j<=SYSIZE;j++){
03023 for(i=1;i<=SYSIZE;i++){
03024 mask[i][j][k]=cemreal[i][j][k];
03025 }
03026 }
03027 }
03028 }
03029
03030 stat3d();
03031
03032
03033 volin=volf[1]+volf[2];
03034 if(volin<1.0){
03035 rand3d(1,alumval,volin);
03036
03037
03038 stat3d();
03039 rdesire=(surff[1]+surff[2])*(float)(surface[1]+surface[alumval]);
03040 if(rdesire!=0.0){
03041 if((int)rdesire<surface[1]){
03042 rhtest=(6./4.)*(float)(volume[1])/rdesire;
03043
03044 }
03045 else{
03046 rdesire=(surff[3]+surff[4])*(float)(surface[1]+surface[alumval]);
03047 if(rdesire!=0.0){
03048 rhtest=(6./4.)*(float)(volume[alumval])/rdesire;
03049
03050 }
03051 }
03052 }
03053 }
03054
03055
03056 if((volf[1]+volf[2])>0.0){
03057 volin=volf[1]/(volf[1]+volf[2]);
03058 if(volin<1.0){
03059 rand3d(1,2,volin);
03060
03061
03062 stat3d();
03063 rdesire=(surff[1]/(surff[1]+surff[2]))*(float)(surface[1]+surface[2]);
03064 if(rdesire!=0.0){
03065 if((int)rdesire<surface[1]){
03066 rhtest=(6./4.)*(float)(volume[1])/rdesire;
03067
03068 }
03069 else{
03070 rdesire=(surff[2]/(surff[1]+surff[2]))*(float)(surface[1]+surface[2]);
03071 if(rdesire!=0.0){
03072 rhtest=(6./4.)*(float)(volume[2])/rdesire;
03073
03074 }
03075 }
03076 }
03077 }
03078 }
03079
03080
03081 if(alumval==4){
03082 volin=volf[4]/(volf[4]+volf[3]);
03083 alum2=3;
03084 }
03085 else{
03086 volin=volf[3]/(volf[4]+volf[3]);
03087 alum2=4;
03088 }
03089 if(volin<1.0){
03090 rand3d(alumval,alum2,volin);
03091
03092
03093 stat3d();
03094 if(alumval==4){
03095 rdesire=(surff[4]/(surff[3]+surff[4]))*(float)(surface[3]+surface[4]);
03096 if(rdesire!=0.0){
03097 if((int)rdesire<surface[4]){
03098 rhtest=(6./4.)*(float)(volume[4])/rdesire;
03099
03100 }
03101 else{
03102 rdesire=(surff[3]/(surff[3]+surff[4]))*(float)(surface[3]+surface[4]);
03103 if(rdesire!=0.0){
03104 rhtest=(6./4.)*(float)(volume[3])/rdesire;
03105
03106 }
03107 }
03108 }
03109 }
03110 else{
03111 rdesire=(surff[3]/(surff[3]+surff[4]))*(float)(surface[3]+surface[4]);
03112 if(rdesire!=0.0){
03113 if((int)rdesire<surface[3]){
03114 rhtest=(6./4.)*(float)(volume[3])/rdesire;
03115
03116 }
03117 else{
03118 rdesire=(surff[4]/(surff[3]+surff[4]))*(float)(surface[3]+surface[4]);
03119 if(rdesire!=0.0){
03120 rhtest=(6./4.)*(float)(volume[4])/rdesire;
03121
03122 }
03123 }
03124 }
03125 }
03126 }
03127
03128
03129
03130
03131 F->get_value(14, (long &)output_img);
03132 if (output_img){
03133
03134 F->get_value(15,filen);
03135 if((outfile_img=fopen(filen,"w"))==NULL){
03136 printf("Output img file %s can not be created (file %s, line %d)\n", filen, __FILE__, __LINE__);
03137 exit(1);
03138 }
03139
03140 F->get_value(16,filen);
03141 if((outfile_id=fopen(filen,"w"))==NULL){
03142 printf("Output id file %s can not be created (file %s, line %d)\n", filen, __FILE__, __LINE__);
03143 exit(1);
03144 }
03145 }
03146
03147 for(k=0;k<SYSIZE;k++){
03148 for(j=0;j<SYSIZE;j++){
03149 for(i=0;i<SYSIZE;i++){
03150 mic[i][j][k]=mask[i+1][j+1][k+1];
03151 micorig[i][j][k]=mic[i][j][k];
03152 if(output_img){
03153 fprintf(outfile_img, "%d\n", mic[i][j][k]);
03154 fprintf(outfile_id, "%ld\n", micpart[i][j][k]);
03155 }
03156 }
03157 }
03158 }
03159
03160 if(output_img){
03161 fclose(outfile_img);
03162 fclose(outfile_id);
03163 }
03164
03165
03166 dealloc_int_3D(curvature, SYSIZE+1);
03167
03168
03169 dealloc_long_3D(cemreal, SYSIZE+1);
03170
03171 }
03172
03173
03174
03175
03176
03177
03178 void cemhydmat::init(void)
03179 {
03180 int i;
03181 double slagin,CHperslag;
03182 FILE *slagfile;
03183
03184 for(i=0;i<=EMPTYP;i++){
03185 creates[i]=0;
03186 soluble[i]=0;
03187 disprob[i]=0.0;
03188 disbase[i]=0.0;
03189 pHeffect[i]=0.0;
03190 }
03191
03192
03193
03194 gypabsprob=0.01;
03195
03196
03197
03198 soluble[C4AF]=1;
03199 disprob[C4AF]=disbase[C4AF]=0.067/DISBIAS;
03200 creates[C4AF]=POROSITY;
03201 pHeffect[C4AF]=1.0;
03202 soluble[C3S]=0;
03203 disprob[C3S]=disbase[C3S]=0.7/DISBIAS;
03204 creates[C3S]=DIFFCSH;
03205 pHeffect[C3S]=1.0;
03206 soluble[C2S]=0;
03207 disprob[C2S]=disbase[C2S]=0.1/DISBIAS;
03208 creates[C2S]=DIFFCSH;
03209 pHeffect[C2S]=1.0;
03210 soluble[C3A]=1;
03211
03212 disprob[C3A]=disbase[C3A]=0.4/DISBIAS;
03213 creates[C3A]=POROSITY;
03214 pHeffect[C3A]=1.0;
03215 soluble[GYPSUM]=1;
03216
03217
03218
03219
03220
03221 disprob[GYPSUM]=disbase[GYPSUM]=0.025;
03222
03223 creates[GYPSUM]=POROSITY;
03224 soluble[GYPSUMS]=1;
03225 pHeffect[GYPSUM]=0.0;
03226
03227
03228
03229 disprob[GYPSUMS]=disbase[GYPSUMS]=disprob[GYPSUM];
03230 creates[GYPSUMS]=POROSITY;
03231 pHeffect[GYPSUMS]=0.0;
03232 soluble[ANHYDRITE]=1;
03233
03234
03235 disprob[ANHYDRITE]=disbase[ANHYDRITE]=0.8*disprob[GYPSUM];
03236
03237 creates[ANHYDRITE]=POROSITY;
03238 pHeffect[ANHYDRITE]=0.0;
03239 soluble[HEMIHYD]=1;
03240
03241
03242
03243 disprob[HEMIHYD]=disbase[HEMIHYD]=1.5*disprob[GYPSUM];
03244
03245 creates[HEMIHYD]=POROSITY;
03246 pHeffect[HEMIHYD]=0.0;
03247
03248 soluble[CH]=1;
03249 disprob[CH]=disbase[CH]=0.5/DISBIAS;
03250 creates[CH]=DIFFCH;
03251 pHeffect[CH]=0.0;
03252
03253 soluble[CACO3]=1;
03254 disprob[CACO3]=disbase[CACO3]=0.10/DISBIAS;
03255 creates[CACO3]=DIFFCACO3;
03256 pHeffect[CACO3]=0.0;
03257
03258 soluble[SLAG]=0;
03259 disprob[SLAG]=disbase[SLAG]=0.005/DISBIAS;
03260 creates[SLAG]=0;
03261 pHeffect[SLAG]=1.0;
03262 soluble[C3AH6]=1;
03263 disprob[C3AH6]=disbase[C3AH6]=0.01/DISBIAS;
03264 creates[C3AH6]=POROSITY;
03265 pHeffect[C3AH6]=0.0;
03266
03267 soluble[ETTR]=0;
03268
03269 disprob[ETTR]=disbase[ETTR]=0.008/DISBIAS;
03270 creates[ETTR]=DIFFETTR;
03271 pHeffect[ETTR]=0.0;
03272
03273 soluble[ETTRC4AF]=0;
03274 disprob[ETTRC4AF]=disbase[ETTRC4AF]=0.0;
03275 creates[ETTRC4AF]=ETTRC4AF;
03276 pHeffect[ETTRC4AF]=0.0;
03277
03278 soluble[CACL2]=1;
03279 disprob[CACL2]=disbase[CACL2]=0.1/DISBIAS;
03280 creates[CACL2]=DIFFCACL2;
03281 pHeffect[CACL2]=0.0;
03282
03283 soluble[ASG]=1;
03284 disprob[ASG]=disbase[ASG]=0.2/DISBIAS;
03285 creates[ASG]=DIFFAS;
03286 pHeffect[ASG]=1.0;
03287
03288 soluble[CAS2]=1;
03289 disprob[CAS2]=disbase[CAS2]=0.2/DISBIAS;
03290 creates[CAS2]=DIFFCAS2;
03291 pHeffect[CAS2]=1.0;
03292
03293
03294
03295
03296
03297
03298 molarv[POROSITY]=18.068;
03299 heatf[POROSITY]=(-285.83);
03300 waterc[POROSITY]=1.0;
03301 specgrav[POROSITY]=0.99707;
03302
03303 molarv[C3S]=71.129;
03304 heatf[C3S]=(-2927.82);
03305 waterc[C3S]=0.0;
03306 specgrav[C3S]=3.21;
03307
03308
03309 molarv[CSH]=108.;
03310 heatf[CSH]=(-3283.0);
03311 waterc[CSH]=4.0;
03312 specgrav[CSH]=2.11;
03313
03314 molarv[CH]=33.1;
03315 heatf[CH]=(-986.1);
03316 waterc[CH]=1.0;
03317 specgrav[CH]=2.24;
03318
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328
03329 molarv[CACO3]=36.93;
03330 waterc[CACO3]=0.0;
03331 specgrav[CACO3]=2.71;
03332 heatf[CACO3]=(-1206.92);
03333
03334 molarv[AFMC]=261.91;
03335 waterc[AFMC]=11.0;
03336 specgrav[AFMC]=2.17;
03337
03338 heatf[AFMC]=(0.0);
03339
03340 molarv[C2S]=52.513;
03341 heatf[C2S]=(-2311.6);
03342 waterc[C2S]=0.0;
03343 specgrav[C2S]=3.28;
03344
03345 molarv[C3A]=88.94;
03346 heatf[C3A]=(-3587.8);
03347 waterc[C3A]=0.0;
03348 specgrav[C3A]=3.038;
03349
03350 molarv[GYPSUM]=74.21;
03351 heatf[GYPSUM]=(-2022.6);
03352 waterc[GYPSUM]=0.0;
03353 specgrav[GYPSUM]=2.32;
03354 molarv[GYPSUMS]=74.21;
03355 heatf[GYPSUMS]=(-2022.6);
03356 waterc[GYPSUMS]=0.0;
03357 specgrav[GYPSUMS]=2.32;
03358
03359 molarv[ANHYDRITE]=52.16;
03360 heatf[ANHYDRITE]=(-1424.6);
03361 waterc[ANHYDRITE]=0.0;
03362 specgrav[ANHYDRITE]=2.61;
03363
03364 molarv[HEMIHYD]=52.973;
03365 heatf[HEMIHYD]=(-1574.65);
03366 waterc[HEMIHYD]=0.0;
03367 specgrav[HEMIHYD]=2.74;
03368
03369 molarv[C4AF]=130.29;
03370 heatf[C4AF]=(-5090.3);
03371 waterc[C4AF]=0.0;
03372 specgrav[C4AF]=3.73;
03373
03374 molarv[C3AH6]=150.12;
03375 heatf[C3AH6]=(-5548.);
03376 waterc[C3AH6]=6.0;
03377 specgrav[C3AH6]=2.52;
03378
03379
03380 molarv[FH3]=69.803;
03381 heatf[FH3]=(-823.9);
03382 waterc[FH3]=3.0;
03383 specgrav[FH3]=3.062;
03384
03385 molarv[ETTRC4AF]=735.01;
03386 heatf[ETTRC4AF]=(-17539.0);
03387 waterc[ETTRC4AF]=26.0;
03388 specgrav[ETTRC4AF]=1.7076;
03389
03390 molarv[ETTR]=735.01;
03391 heatf[ETTR]=(-17539.0);
03392 waterc[ETTR]=26.0;
03393 specgrav[ETTR]=1.7076;
03394
03395 molarv[AFM]=312.82;
03396 heatf[AFM]=(-8778.0);
03397
03398
03399
03400 waterc[AFM]=10.0;
03401 specgrav[AFM]=1.99;
03402
03403 molarv[CACL2]=51.62;
03404 heatf[CACL2]=(-795.8);
03405 waterc[CACL2]=0;
03406 specgrav[CACL2]=2.15;
03407
03408 molarv[FREIDEL]=296.662;
03409
03410 heatf[FREIDEL]=(0.0);
03411
03412 waterc[FREIDEL]=10.0;
03413 specgrav[FREIDEL]=1.892;
03414
03415
03416 molarv[ASG]=49.9;
03417
03418 heatf[ASG]=0.0;
03419 waterc[ASG]=0.0;
03420 specgrav[ASG]=3.247;
03421
03422 molarv[CAS2]=100.62;
03423
03424 heatf[CAS2]=0.0;
03425 waterc[CAS2]=0.0;
03426 specgrav[CAS2]=2.77;
03427
03428 molarv[STRAT]=215.63;
03429
03430 heatf[STRAT]=0.0;
03431
03432 waterc[STRAT]=8.0;
03433 specgrav[STRAT]=1.94;
03434
03435 molarv[POZZ]=27.0;
03436
03437
03438 heatf[POZZ]=-907.5;
03439 waterc[POZZ]=0.0;
03440 specgrav[POZZ]=2.22;
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451 molarv[POZZCSH]=101.81;
03452 waterc[POZZCSH]=3.9;
03453 specgrav[POZZCSH]=1.884;
03454 heatf[POZZCSH]=(-2299.1);
03455
03456
03457 molarv[INERT]=27.0;
03458 heatf[INERT]=0.0;
03459 waterc[INERT]=0.0;
03460 specgrav[INERT]=2.2;
03461
03462 molarv[ABSGYP]=74.21;
03463 heatf[ABSGYP]=(-2022.6);
03464 waterc[ABSGYP]=0.0;
03465 specgrav[ABSGYP]=2.32;
03466
03467 molarv[EMPTYP]=18.068;
03468 heatf[EMPTYP]=(-285.83);
03469 waterc[EMPTYP]=0.0;
03470 specgrav[EMPTYP]=0.99707;
03471
03472
03473
03474
03475
03476
03477
03478
03479 specgrav[SLAG]=2.87;
03480 specgrav[SLAGCSH]=2.35;
03481 molarv[SLAG]=945.72;
03482 molarv[SLAGCSH]=1717.53;
03483 slagcasi=1.433;
03484 slaghydcasi=1.35;
03485 siperslag=15.0;
03486 waterc[SLAGCSH]=5.533*siperslag;
03487 slagc3a=1.0;
03488 slagreact=1.0;
03489
03490 F->get_value(19,totsodium);
03491 F->get_value(20,totpotassium);
03492 F->get_value(21,rssodium);
03493 F->get_value(22,rspotassium);
03494
03495
03496
03497
03498
03499
03500
03501 totsodium/=100.;
03502 totpotassium/=100.;
03503 rssodium/=100.;
03504 rspotassium/=100.;
03505
03506
03507 if(pHactive){
03508
03509
03510
03511 if((slagfile=fopen("slagchar.dat","r"))==NULL){
03512 printf("Slag file can not be opened\n");
03513 exit(1);
03514 }
03515
03516
03517 fscanf(slagfile,"%lf",&slagin);
03518 fscanf(slagfile,"%lf",&slagin);
03519 fscanf(slagfile,"%lf",&slagin);
03520 specgrav[SLAG]=slagin;
03521 fscanf(slagfile,"%lf",&slagin);
03522 specgrav[SLAGCSH]=slagin;
03523 fscanf(slagfile,"%lf",&slagin);
03524 molarv[SLAG]=slagin;
03525 fscanf(slagfile,"%lf",&slagin);
03526 molarv[SLAGCSH]=slagin;
03527 fscanf(slagfile,"%lf",&slagcasi);
03528 fscanf(slagfile,"%lf",&slaghydcasi);
03529 fscanf(slagfile,"%lf",&siperslag);
03530 fscanf(slagfile,"%lf",&slagin);
03531 waterc[SLAGCSH]=slagin*siperslag;
03532 fscanf(slagfile,"%lf",&slagc3a);
03533 fscanf(slagfile,"%lf",&slagreact);
03534 waterc[SLAG]=0.0;
03535 heatf[SLAG]=0.0;
03536 heatf[SLAGCSH]=0.0;
03537 fclose(slagfile);
03538 }
03539
03540
03541 specgrav[SLAG]=2.87;
03542 specgrav[SLAGCSH]=2.35;
03543 molarv[SLAG]=945.72;
03544 molarv[SLAGCSH]=1717.53;
03545 slagcasi=1.4333;
03546 slaghydcasi=1.35;
03547 siperslag=15.0;
03548 waterc[SLAGCSH]=5.533*siperslag;
03549 slagc3a=1.0;
03550 slagreact=1.0;
03551
03552
03553 CHperslag=siperslag*(slaghydcasi-slagcasi)+3.*slagc3a;
03554 if(CHperslag<0.0){CHperslag=0.0;}
03555 p2slag=(molarv[SLAG]+molarv[CH]*CHperslag+molarv[POROSITY]*(waterc[SLAGCSH]-CHperslag+waterc[C3AH6]*slagc3a)-molarv[SLAGCSH]-molarv[C3AH6]*slagc3a)/molarv[SLAG];
03556 p1slag=1.0-p2slag;
03557 p3slag=(molarv[SLAGCSH]/molarv[SLAG])-p1slag;
03558 p4slag=CHperslag*molarv[CH]/molarv[SLAG];
03559 p5slag=slagc3a*molarv[C3A]/molarv[SLAG];
03560 if(p5slag>1.0){
03561 p5slag=1.0;
03562 printf("Error in range of C3A/slag value... reset to 1.0 \n");
03563 }
03564 }
03565
03566
03567
03568
03569
03570 int cemhydmat::chckedge(int xck,int yck,int zck){
03571 int edgeback,x2,y2,z2;
03572 int ip;
03573
03574 edgeback=0;
03575
03576
03577
03578 for(ip=0;((ip<NEIGHBORS)&&(edgeback==0));ip++){
03579
03580 x2=xck+xoff[ip];
03581 y2=yck+yoff[ip];
03582 z2=zck+zoff[ip];
03583 if(x2>=SYSIZE){x2=0;}
03584 if(x2<0){x2=SYSIZEM1;}
03585 if(y2>=SYSIZE){y2=0;}
03586 if(y2<0){y2=SYSIZEM1;}
03587 if(z2>=SYSIZE){z2=0;}
03588 if(z2<0){z2=SYSIZEM1;}
03589 if(mic [x2] [y2] [z2]==POROSITY){
03590 edgeback=1;
03591 }
03592 }
03593 return(edgeback);
03594 }
03595
03596
03597
03598
03599
03600 void cemhydmat::passone(int low,int high,int cycid,int cshexflag){
03601 int i,xid,yid,zid,phid,edgef,phread,cshcyc;
03602
03603
03604 if((low<=GYPSUM)&&(GYPSUM<=high)){
03605 gypready=0;
03606 }
03607
03608 for(i=low;i<=high;i++){
03609 count[i]=0;
03610 }
03611
03612 for(xid=0;xid<SYSIZE;xid++){
03613 for(yid=0;yid<SYSIZE;yid++){
03614 for(zid=0;zid<SYSIZE;zid++){
03615
03616 phread=mic[xid][yid][zid];
03617
03618 if((cshexflag==1)&&(phread==CSH)){
03619 cshcyc=cshage[xid][yid][zid];
03620 heatsum+=heatf[CSH]/molarvcsh[cshcyc];
03621 molesh2o+=watercsh[cshcyc]/molarvcsh[cshcyc];
03622 }
03623
03624 phid=60;
03625 for(i=low;((i<=high)&&(phid==60));i++){
03626
03627 if(mic [xid][yid][zid]==i){
03628 phid=i;
03629
03630 count[i]+=1;
03631 if((i==GYPSUM)||(i==GYPSUMS)){
03632 gypready+=1;
03633 }
03634
03635 if(cycid==1){
03636 if(i==POROSITY){porinit+=1;}
03637
03638
03639 else if(i==C3S){c3sinit+=1;}
03640 else if(i==C2S){c2sinit+=1;}
03641 else if(i==C3A){c3ainit+=1;}
03642 else if(i==C4AF){c4afinit+=1;}
03643 else if(i==GYPSUM){ncsbar+=1;}
03644 else if(i==GYPSUMS){ncsbar+=1;}
03645 else if(i==ANHYDRITE){anhinit+=1;}
03646 else if(i==HEMIHYD){heminit+=1;}
03647 else if(i==POZZ){nfill+=1;}
03648 else if(i==SLAG){slaginit+=1;}
03649 else if(i==ETTR){netbar+=1;}
03650 else if(i==ETTRC4AF){netbar+=1;}
03651 }
03652 }
03653 }
03654
03655 if(phid!=60){
03656
03657 if((cycid!=0)&&(soluble[phid]==1)){
03658 edgef=chckedge(xid,yid,zid);
03659 if(edgef==1){
03660
03661 mic [xid][yid][zid]+=OFFSET;
03662 }
03663 }
03664 }
03665 }
03666 }
03667 }
03668 }
03669
03670
03671
03672
03673
03674 int cemhydmat::loccsh(int xcur,int ycur,int zcur,int extent){
03675 int effort,tries,xmod,ymod,zmod;
03676 struct ants *antnew;
03677
03678 effort=0;
03679 tries=0;
03680
03681 while((effort==0)&&(tries<500)){
03682 tries+=1;
03683 xmod=(-extent)+(int)((2.*(float)extent+1.)*ran1(seed));
03684 ymod=(-extent)+(int)((2.*(float)extent+1.)*ran1(seed));
03685 zmod=(-extent)+(int)((2.*(float)extent+1.)*ran1(seed));
03686 if(xmod>extent){xmod=extent;}
03687 if(ymod>extent){ymod=extent;}
03688 if(zmod>extent){zmod=extent;}
03689 xmod+=xcur;
03690 ymod+=ycur;
03691 zmod+=zcur;
03692
03693 if(xmod>=SYSIZE){xmod-=SYSIZE;}
03694 else if(xmod<0){xmod+=SYSIZE;}
03695 if(zmod>=SYSIZE){zmod-=SYSIZE;}
03696 else if(zmod<0){zmod+=SYSIZE;}
03697 if(ymod<0){ymod+=SYSIZE;}
03698 else if(ymod>=SYSIZE){ymod-=SYSIZE;}
03699
03700 if(mic[xmod][ymod][zmod]==POROSITY){
03701 effort=1;
03702 mic[xmod][ymod][zmod]=DIFFCSH;
03703 nmade+=1;
03704 ngoing+=1;
03705
03706 antnew=(struct ants *)malloc(sizeof(struct ants));
03707 antnew->x=xmod;
03708 antnew->y=ymod;
03709 antnew->z=zmod;
03710 antnew->id=DIFFCSH;
03711 antnew->cycbirth=cyccnt;
03712
03713 antnew->prevant=tailant;
03714 tailant->nextant=antnew;
03715 antnew->nextant=NULL;
03716 tailant=antnew;
03717 }
03718 }
03719 return(effort);
03720 }
03721
03722
03723
03724
03725
03726 int cemhydmat::countbox(int boxsize,int qx,int qy,int qz){
03727 int nfound,ix,iy,iz,qxlo,qxhi,qylo,qyhi,qzlo,qzhi;
03728 int hx,hy,hz,boxhalf;
03729
03730 boxhalf=boxsize/2;
03731 nfound=0;
03732 qxlo=qx-boxhalf;
03733 qxhi=qx+boxhalf;
03734 qylo=qy-boxhalf;
03735 qyhi=qy+boxhalf;
03736 qzlo=qz-boxhalf;
03737 qzhi=qz+boxhalf;
03738
03739
03740 for(ix=qxlo;ix<=qxhi;ix++){
03741 hx=ix;
03742 if(hx<0){hx+=SYSIZE;}
03743 else if(hx>=SYSIZE){hx-=SYSIZE;}
03744 for(iy=qylo;iy<=qyhi;iy++){
03745 hy=iy;
03746 if(hy<0){hy+=SYSIZE;}
03747 else if(hy>=SYSIZE){hy-=SYSIZE;}
03748 for(iz=qzlo;iz<=qzhi;iz++){
03749 hz=iz;
03750 if(hz<0){hz+=SYSIZE;}
03751 else if(hz>=SYSIZE){hz-=SYSIZE;}
03752
03753 if((mic [hx] [hy] [hz]<C3S)||(mic[hx] [hy] [hz]>ABSGYP)){
03754 nfound+=1;
03755 }
03756 }
03757 }
03758 }
03759 return(nfound);
03760 }
03761
03762
03763
03764
03765
03766
03767
03768 int cemhydmat::countboxc(int boxsize,int qx,int qy,int qz){
03769 int nfound,ix,iy,iz,qxlo,qxhi,qylo,qyhi,qzlo,qzhi;
03770 int hx,hy,hz,boxhalf;
03771
03772 boxhalf=boxsize/2;
03773 nfound=0;
03774 qxlo=qx-boxhalf;
03775 qxhi=qx+boxhalf;
03776 qylo=qy-boxhalf;
03777 qyhi=qy+boxhalf;
03778 qzlo=qz-boxhalf;
03779 qzhi=qz+boxhalf;
03780
03781
03782 for(ix=qxlo;ix<=qxhi;ix++){
03783 hx=ix;
03784 if(hx<0){hx+=SYSIZE;}
03785 else if(hx>=SYSIZE){hx-=SYSIZE;}
03786 for(iy=qylo;iy<=qyhi;iy++){
03787 hy=iy;
03788 if(hy<0){hy+=SYSIZE;}
03789 else if(hy>=SYSIZE){hy-=SYSIZE;}
03790 for(iz=qzlo;iz<=qzhi;iz++){
03791 hz=iz;
03792 if(hz<0){hz+=SYSIZE;}
03793 else if(hz>=SYSIZE){hz-=SYSIZE;}
03794
03795 if((mic [hx] [hy] [hz]<C3S)||(mic[hx] [hy] [hz]>POZZ)){
03796 nfound+=1;
03797 }
03798 }
03799 }
03800 }
03801 return(nfound);
03802 }
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812 void cemhydmat::makeinert(long int ndesire){
03813 struct togo *headtogo,*tailtogo,*newtogo,*lasttogo,*onetogo;
03814 long int idesire;
03815 int px,py,pz,placed,cntpore,cntmax;
03816
03817
03818 headtogo=(struct togo *)malloc(sizeof(struct togo));
03819 headtogo->x=headtogo->y=headtogo->z=(-1);
03820 headtogo->npore=0;
03821 headtogo->nexttogo=NULL;
03822 headtogo->prevtogo=NULL;
03823 tailtogo=headtogo;
03824 cntmax=0;
03825
03826 #ifdef PRINTF
03827 printf("In makeinert with %ld needed elements \n",ndesire);
03828 #endif
03829
03830 fflush(stdout);
03831
03832 for(idesire=2;idesire<=ndesire;idesire++){
03833 newtogo=(struct togo *)malloc(sizeof(struct togo));
03834 newtogo->npore=0;
03835 newtogo->x=newtogo->y=newtogo->z=(-1);
03836 tailtogo->nexttogo=newtogo;
03837 newtogo->prevtogo=tailtogo;
03838 tailtogo=newtogo;
03839 }
03840
03841
03842 for(px=0;px<SYSIZE;px++){
03843 for(py=0;py<SYSIZE;py++){
03844 for(pz=0;pz<SYSIZE;pz++){
03845 if(mic[px][py][pz]==POROSITY){
03846 cntpore=countbox(cubesize,px,py,pz);
03847 if(cntpore>cntmax){cntmax=cntpore;}
03848
03849
03850 if(cntpore>(tailtogo->npore)){
03851 placed=0;
03852 lasttogo=tailtogo;
03853 while(placed==0){
03854 newtogo=lasttogo->prevtogo;
03855 if(newtogo==NULL){
03856 placed=2;
03857 }
03858 else{
03859 if(cntpore<=(newtogo->npore)){
03860 placed=1;
03861 }
03862 }
03863 if(placed==0){
03864 lasttogo=newtogo;
03865 }
03866 }
03867 onetogo=(struct togo *)malloc(sizeof(struct togo));
03868 onetogo->x=px;
03869 onetogo->y=py;
03870 onetogo->z=pz;
03871 onetogo->npore=cntpore;
03872
03873 if(placed==2){
03874 onetogo->prevtogo=NULL;
03875 onetogo->nexttogo=headtogo;
03876 headtogo->prevtogo=onetogo;
03877 headtogo=onetogo;
03878 }
03879 if(placed==1){
03880 onetogo->nexttogo=lasttogo;
03881 onetogo->prevtogo=newtogo;
03882 lasttogo->prevtogo=onetogo;
03883 newtogo->nexttogo=onetogo;
03884 }
03885
03886 lasttogo=tailtogo;
03887 tailtogo=tailtogo->prevtogo;
03888 tailtogo->nexttogo=NULL;
03889
03890 free(lasttogo);
03891 }
03892 }
03893 }
03894 }
03895 }
03896
03897
03898
03899
03900 for(idesire=1;idesire<=ndesire;idesire++){
03901 px=headtogo->x;
03902 py=headtogo->y;
03903 pz=headtogo->z;
03904 if(px!=(-1)){
03905 mic [px] [py] [pz]=EMPTYP;
03906 count[POROSITY]-=1;
03907 count[EMPTYP]+=1;
03908 }
03909 lasttogo=headtogo;
03910 headtogo=headtogo->nexttogo;
03911
03912 free(lasttogo);
03913 }
03914
03915
03916 if(cubesize>CUBEMIN){
03917 if((2*cntmax)<(cubesize*cubesize*cubesize)){
03918 cubesize-=2;
03919 }
03920 }
03921 }
03922
03923
03924
03925
03926
03927
03928 void cemhydmat::extslagcsh(int xpres,int ypres,int zpres){
03929 int check,sump,xchr,ychr,zchr,fchr,i1,action,numnear;
03930 long int tries;
03931 int mstest = 0,mstest2 = 0;
03932
03933
03934
03935
03936
03937
03938 fchr=0;
03939 sump=1;
03940 for(i1=1;((i1<=100)&&(fchr==0)&&(sump!=30030));i1++){
03941
03942
03943 xchr=xpres;
03944 ychr=ypres;
03945 zchr=zpres;
03946 action=0;
03947 sump*=moveone(&xchr,&ychr,&zchr,&action,sump);
03948 if(action==0){printf("Error in value of action in extpozz \n");}
03949 check=mic[xchr][ychr][zchr];
03950
03951
03952 if(xchr!=xpres){
03953 mstest=1;
03954 mstest2=2;
03955 }
03956 if(ychr!=ypres){
03957 mstest=2;
03958 mstest2=3;
03959 }
03960 if(zchr!=zpres){
03961 mstest=3;
03962 mstest2=1;
03963 }
03964
03965
03966 if(check==POROSITY){
03967 if((faces[xpres][ypres][zpres]==0)||(mstest==faces[xpres][ypres][zpres])||(mstest2==faces[xpres][ypres][zpres])){
03968 mic[xchr][ychr][zchr]=SLAGCSH;
03969 faces[xchr][ychr][zchr]=faces[xpres][ypres][zpres];
03970 count[SLAGCSH]+=1;
03971 count[POROSITY]-=1;
03972 fchr=1;
03973 }
03974 }
03975 }
03976
03977
03978
03979 tries=0;
03980 while(fchr==0){
03981 tries+=1;
03982
03983 xchr=(int)((float)SYSIZE*ran1(seed));
03984 ychr=(int)((float)SYSIZE*ran1(seed));
03985 zchr=(int)((float)SYSIZE*ran1(seed));
03986 if(xchr>=SYSIZE){xchr=0;}
03987 if(ychr>=SYSIZE){ychr=0;}
03988 if(zchr>=SYSIZE){zchr=0;}
03989 check=mic[xchr][ychr][zchr];
03990
03991 if(check==POROSITY){
03992 numnear=edgecnt(xchr,ychr,zchr,SLAG,CSH,SLAGCSH);
03993
03994
03995 if((tries>5000)||(numnear<26)){
03996 mic[xchr][ychr][zchr]=SLAGCSH;
03997 count[SLAGCSH]+=1;
03998 count[POROSITY]-=1;
03999 fchr=1;
04000 }
04001 }
04002 }
04003 }
04004
04005
04006
04007
04008 void cemhydmat::dissolve(int cycle){
04009 int nc3aext,ncshext,nchext,ngypext,nanhext,plok;
04010 int nsum5,nsum4,nsum3,nsum2,nhemext,nsum6,nc4aext;
04011 int phid,phnew,plnew,cread;
04012 int i,xloop,yloop,zloop,xc,yc;
04013 int zc,cycnew;
04014 long int ctest;
04015 long int tries;
04016 int placed,cshrand,maxsulfate,msface;
04017 long int ncshgo,nsurf,suminit;
04018 long int xext,nhgd,npchext,nslagc3a=0;
04019 float pdis,plfh3,fchext,fc3aext,fanhext,mass_now,mass_fa_now,tot_mass,heatfill;
04020 float dfact,dfact1,molesdh2o,h2oinit,heat4,fhemext,fc4aext;
04021 float pconvert,pc3scsh,pc2scsh,calcx,calcy,calcz,tdisfact;
04022 float frafm,frettr,frhyg,frtot,mc3ar,mc4ar,p3init;
04023 struct ants *antadd;
04024
04025
04026 nmade=0;
04027 npchext=ncshgo=cshrand=0;
04028
04029 heat_old=heat_new;
04030
04031
04032 nsurf=0;
04033 for(i=0;i<=EMPTYP;i++){
04034 discount[i]=0;
04035 count[i]=0;
04036 }
04037
04038
04039 soluble[C3AH6]=0;
04040 heatsum=0.0;
04041 molesh2o=0.0;
04042 passone(0,EMPTYP,cycle,1);
04043 #ifdef PRINTF
04044 printf("Returned from passone \n");
04045 #endif
04046 fflush(stdout);
04047
04048 sulf_solid=count[GYPSUM]+count[GYPSUMS]+count[HEMIHYD]+count[ANHYDRITE];
04049
04050
04051 if(cycle==1){
04052
04053 cemmass=(specgrav[C3S]*(float)count[C3S]+specgrav[C2S]*
04054 (float)count[C2S]+specgrav[C3A]*(float)count[C3A]+
04055 specgrav[C4AF]*(float)count[C4AF]);
04056
04057
04058
04059 cemmasswgyp=(specgrav[C3S]*(float)count[C3S]+specgrav[C2S]*
04060 (float)count[C2S]+specgrav[C3A]*(float)count[C3A]+
04061 specgrav[C4AF]*(float)count[C4AF]+specgrav[GYPSUM]*
04062 (float)count[GYPSUM]+specgrav[ANHYDRITE]*(float)
04063 count[ANHYDRITE]+specgrav[HEMIHYD]*(float)count[HEMIHYD]);
04064 flyashmass=(specgrav[ASG]*(float)count[ASG]+specgrav[CAS2]*
04065 (float)count[CAS2]+specgrav[POZZ]*(float)count[POZZ]);
04066 CH_mass=specgrav[CH]*(float)count[CH];
04067
04068 tot_mass=cemmass+(float)count[POROSITY]+specgrav[INERT]*
04069 (float)count[INERT]+specgrav[CACL2]*(float)count[CACL2]+
04070 specgrav[ASG]*(float)count[ASG]+
04071 specgrav[SLAG]*(float)count[SLAG]+
04072 specgrav[HEMIHYD]*(float)count[HEMIHYD]+
04073 specgrav[ANHYDRITE]*(float)count[ANHYDRITE]+
04074 specgrav[CAS2]*(float)count[CAS2]+
04075 specgrav[CSH]*(float)count[CSH]+
04076 specgrav[GYPSUM]*(float)count[GYPSUM]+
04077 specgrav[ANHYDRITE]*(float)count[ANHYDRITE]+
04078 specgrav[HEMIHYD]*(float)count[HEMIHYD]+
04079 specgrav[GYPSUMS]*(float)count[GYPSUMS]+
04080 specgrav[POZZ]*(float)count[POZZ]+CH_mass;
04081
04082 if(cemmass!=0.0){
04083 w_to_c=(float)count[POROSITY]/(cemmass+
04084 specgrav[GYPSUM]*(float)count[GYPSUM]+
04085 specgrav[ANHYDRITE]*(float)count[ANHYDRITE]+
04086 specgrav[HEMIHYD]*(float)count[HEMIHYD]);
04087 }
04088 else{
04089 w_to_c=0.0;
04090 }
04091
04092
04093
04094 totfract=count[C3S]+count[C2S];
04095 totfract+=(count[C3A]+count[C4AF]);
04096 totfract+=(count[GYPSUM]+count[ANHYDRITE]+count[HEMIHYD]);
04097 fractwithfill=totfract+count[CACO3]+count[SLAG]+count[INERT];
04098 fractwithfill+=count[POZZ]+count[CAS2]+count[ASG]+count[CACL2];
04099 totfract/=(float)SYSIZE;
04100 totfract/=(float)SYSIZE;
04101 totfract/=(float)SYSIZE;
04102 fractwithfill/=(float)SYSIZE;
04103 fractwithfill/=(float)SYSIZE;
04104 fractwithfill/=(float)SYSIZE;
04105
04106 mass_water=(1.-mass_agg)*(float)count[POROSITY]/tot_mass;
04107 mass_CH=(1.-mass_agg)*CH_mass/tot_mass;
04108
04109 if(cemmass!=0.0){
04110 s_to_c=(float)(count[INERT]*specgrav[INERT]+
04111 count[CACL2]*specgrav[CACL2]+count[ASG]*specgrav[ASG]+
04112 count[CAS2]*specgrav[CAS2]+
04113 count[SLAG]*specgrav[SLAG]+
04114 count[POZZ]*specgrav[POZZ])/cemmass;
04115 }
04116 else{
04117 s_to_c=0.0;
04118 }
04119
04120 if(cemmass!=0.0){
04121 heatfill=(float)(count[INERT]+count[SLAG]+count[POZZ]+count[CACL2]+count[ASG]+count[CAS2])/cemmass;
04122 }
04123 else{
04124 heatfill=0.0;
04125 }
04126 if(w_to_c>0.01){
04127 heat_cf=1000./SYSIZE_POW3*(0.3125+w_to_c+heatfill);
04128 }
04129 else{
04130
04131 heat_cf=1000./SYSIZE_POW3*((1./specgrav[POZZ])+(float)(count[POROSITY]+count[CH]+count[INERT])/(specgrav[POZZ]*(float)count[POZZ]));
04132 }
04133 mass_fill_pozz=(1.-mass_agg)*(float)(count[POZZ]*specgrav[POZZ])/tot_mass;
04134 mass_fill=(1.-mass_agg)*(float)(count[INERT]*specgrav[INERT]+
04135 count[ASG]*specgrav[ASG]+count[SLAG]*specgrav[SLAG]+
04136 count[CAS2]*specgrav[CAS2]+count[POZZ]*specgrav[POZZ]+
04137 count[CACL2]*specgrav[CACL2])/tot_mass;
04138 #ifdef PRINTF
04139 printf("Calculated w/c is %.4f\n",w_to_c);
04140 printf("Calculated s/c is %.4f \n",s_to_c);
04141 printf("Calculated heat conversion factor is %f \n",heat_cf);
04142 printf("Calculated mass fractions of water and filler are %.4f and %.4f \n",
04143 mass_water,mass_fill);
04144 #endif
04145 }
04146
04147 molesdh2o=0.0;
04148 alpha=0.0;
04149
04150
04151 heat4=0.0;
04152 mass_now=0.0;
04153 suminit=c3sinit+c2sinit+c3ainit+c4afinit;
04154
04155
04156
04157 ctest=count[DIFFGYP];
04158 #ifdef PRINTF
04159 printf("ctest is %ld\n",ctest);
04160 #endif
04161 fflush(stdout);
04162 if((float)ctest>(2.5*(float)(count[DIFFC3A]+count[DIFFC4A]))){
04163 ctest=(long int)(2.5*(float)(count[DIFFC3A]+count[DIFFC4A]));
04164 }
04165 for(i=0;i<=EMPTYP;i++){
04166 if((i!=0)&&(i<=ABSGYP)&&(i!=INERTAGG)&&(i!=CSH)){
04167 heatsum+=(float)count[i]*heatf[i]/molarv[i];
04168
04169 molesh2o+=(float)count[i]*waterc[i]/molarv[i];
04170 }
04171
04172 if(i==DIFFC3A){
04173 heatsum+=((float)count[DIFFC3A]-(float)ctest/2.5)*heatf[C3A]/molarv[C3A];
04174 }
04175
04176 if(i==DIFFC4A){
04177 heatsum+=((float)count[DIFFC4A]-(float)ctest/2.5)*heatf[C4AF]/molarv[C4AF];
04178 }
04179
04180
04181 if(i==DIFFGYP){
04182 heatsum+=(float)(count[DIFFGYP]-ctest)*heatf[GYPSUM]/molarv[GYPSUM];
04183
04184 heatsum+=(float)ctest*3.30*heatf[ETTR]/molarv[ETTR];
04185 molesdh2o+=(float)ctest*3.30*waterc[ETTR]/molarv[ETTR];
04186 }
04187 else if(i==DIFFCH){
04188 heatsum+=(float)count[DIFFCH]*heatf[CH]/molarv[CH];
04189 molesdh2o+=(float)count[DIFFCH]*waterc[CH]/molarv[CH];
04190 }
04191 else if(i==DIFFFH3){
04192 heatsum+=(float)count[DIFFFH3]*heatf[FH3]/molarv[FH3];
04193 molesdh2o+=(float)count[DIFFFH3]*waterc[FH3]/molarv[FH3];
04194 }
04195 else if(i==DIFFCSH){
04196
04197 heatsum+=(float)count[DIFFCSH]*heatf[CSH]/molarvcsh[cycle];
04198 molesdh2o+=(float)count[DIFFCSH]*watercsh[cycle]/molarvcsh[cycle];
04199 }
04200 else if(i==DIFFETTR){
04201 heatsum+=(float)count[DIFFETTR]*heatf[ETTR]/molarv[ETTR];
04202 molesdh2o+=(float)count[DIFFETTR]*waterc[ETTR]/molarv[ETTR];
04203 }
04204 else if(i==DIFFCACL2){
04205 heatsum+=(float)count[DIFFCACL2]*heatf[CACL2]/molarv[CACL2];
04206 molesdh2o+=(float)count[DIFFCACL2]*waterc[CACL2]/molarv[CACL2];
04207 }
04208 else if(i==DIFFAS){
04209 heatsum+=(float)count[DIFFAS]*heatf[ASG]/molarv[ASG];
04210 molesdh2o+=(float)count[DIFFAS]*waterc[ASG]/molarv[ASG];
04211 }
04212 else if(i==DIFFCAS2){
04213 heatsum+=(float)count[DIFFCAS2]*heatf[CAS2]/molarv[CAS2];
04214 molesdh2o+=(float)count[DIFFCAS2]*waterc[CAS2]/molarv[CAS2];
04215 }
04216
04217 else if(i==DIFFANH){
04218 heatsum+=(float)count[DIFFANH]*heatf[GYPSUMS]/molarv[GYPSUMS];
04219
04220 molesdh2o+=(float)count[DIFFANH]*2.0/molarv[GYPSUMS];
04221 }
04222
04223 else if(i==DIFFHEM){
04224 heatsum+=(float)count[DIFFHEM]*heatf[GYPSUMS]/molarv[GYPSUMS];
04225
04226 molesdh2o+=(float)count[DIFFHEM]*1.5/molarv[GYPSUMS];
04227 }
04228 else if(i==C3S){
04229 alpha+=(float)(c3sinit-count[C3S]);
04230 mass_now+=specgrav[C3S]*(float)count[C3S];
04231 heat4+=.517*(float)(c3sinit-count[C3S])*specgrav[C3S];
04232 }
04233 else if(i==C2S){
04234 alpha+=(float)(c2sinit-count[C2S]);
04235 mass_now+=specgrav[C2S]*(float)count[C2S];
04236 heat4+=.262*(float)(c2sinit-count[C2S])*specgrav[C2S];
04237 }
04238 else if(i==C3A){
04239 alpha+=(float)(c3ainit-count[C3A]);
04240 mass_now+=specgrav[C3A]*(float)count[C3A];
04241 mc3ar=(c3ainit-(float)count[C3A])/molarv[C3A];
04242 mc4ar=(c4afinit-(float)count[C4AF])/molarv[C4AF];
04243 if((mc3ar+mc4ar)>0.0){
04244 frhyg=(mc3ar/(mc3ar+mc4ar))*(float)count[C3AH6]/molarv[C3AH6];
04245 }
04246 else{
04247 frhyg=0.0;
04248 }
04249 frettr=(float)count[ETTR]/molarv[ETTR];
04250 frafm=3*(float)count[AFM]/molarv[AFM];
04251 frtot=frafm+frettr+frhyg;
04252 if(frtot>0.0){
04253 frettr/=frtot;
04254 frafm/=frtot;
04255 frhyg/=frtot;
04256 heat4+=frafm*1.144*(float)(c3ainit-count[C3A])*specgrav[C3A];
04257 heat4+=frhyg*0.908*(float)(c3ainit-count[C3A])*specgrav[C3A];
04258 heat4+=frettr*1.672*(float)(c3ainit-count[C3A])*specgrav[C3A];
04259 }
04260 }
04261 else if(i==C4AF){
04262 alpha+=(float)(c4afinit-count[C4AF]);
04263 mass_now+=specgrav[C4AF]*(float)count[C4AF];
04264 mc3ar=(c3ainit-(float)count[C3A])/molarv[C3A];
04265 mc4ar=(c4afinit-(float)count[C4AF])/molarv[C4AF];
04266 if((mc3ar+mc4ar)>0.0){
04267 frhyg=(mc4ar/(mc3ar+mc4ar))*(float)count[C3AH6]/molarv[C3AH6];
04268 }
04269 else{
04270 frhyg=0.0;
04271 }
04272 frettr=(float)count[ETTRC4AF]/molarv[ETTRC4AF];
04273 frtot=frettr+frhyg;
04274 if(frtot>0.0){
04275 frettr/=frtot;
04276 frhyg/=frtot;
04277 heat4+=frhyg*.418*(float)(c4afinit-count[C4AF])*specgrav[C4AF];
04278 heat4+=frettr*.725*(float)(c4afinit-count[C4AF])*specgrav[C4AF];
04279 }
04280 }
04281
04282
04283
04284
04285
04286 else if(i==ANHYDRITE){
04287
04288
04289 heat4+=.187*(float)(anhinit-count[ANHYDRITE])*specgrav[ANHYDRITE];
04290
04291 molesh2o+=(float)(anhinit-count[ANHYDRITE])*2.0/molarv[ANHYDRITE];
04292 }
04293
04294 else if(i==HEMIHYD){
04295
04296
04297 heat4+=.132*(float)(heminit-count[HEMIHYD])*specgrav[HEMIHYD];
04298
04299 molesh2o+=(float)(heminit-count[HEMIHYD])*1.5/molarv[HEMIHYD];
04300 }
04301 }
04302 mass_fa_now = specgrav[ASG]*(float)count[ASG];
04303 mass_fa_now += specgrav[CAS2]*(float)count[CAS2];
04304 mass_fa_now += specgrav[POZZ]*(float)count[POZZ];
04305 if(suminit!=0){
04306 alpha=alpha/(float)suminit;
04307 }
04308 else{
04309 alpha=0.0;
04310 }
04311
04312 if(cemmass!=0.0){
04313 alpha_cur=1.0-(mass_now/cemmass);
04314 }
04315 else{
04316 alpha_cur=0.0;
04317 }
04318 if(flyashmass!=0.0){
04319 alpha_fa_cur=1.0-(mass_fa_now/flyashmass);
04320 }
04321 else{
04322 alpha_fa_cur=0.0;
04323 }
04324 h2oinit=(float)porinit/molarv[POROSITY];
04325
04326
04327
04328
04329 heat4+=0.78*((float)npr/1.35)*specgrav[POZZ];
04330
04331
04332
04333 heat4+=0.8*((float)nslagr)*specgrav[SLAG];
04334
04335
04336
04337
04338 heat4+=0.80*((float)nasr/1.3267)*specgrav[ASG];
04339
04340
04341
04342
04343
04344 water_left=(long int)((h2oinit-molesh2o)*molarv[POROSITY]+0.5);
04345 countkeep=count[POROSITY];
04346 heatsum+=(h2oinit-molesh2o-molesdh2o)*heatf[POROSITY];
04347 if(cyccnt==0){
04348
04349 #ifdef OUTFILES
04350 fprintf(heatfile,"Cycle time(h) alpha_vol alpha_mass heat4(kJ/kg_solid) Gsratio2 G-s_ratio\n");
04351 #endif
04352 }
04353 heat_new=heat4;
04354
04355
04356 if(cyccnt==0){
04357
04358
04359 }
04360
04361 chs_new=((float)(count[EMPTYP]+count[POROSITY]-water_left)*heat_cf/1000.);
04362
04363 if(((water_left+water_off)<0)&&(sealed==1)){
04364 #ifdef PRINTF
04365 printf("All water consumed at cycle %d \n",cyccnt);
04366 fflush(stdout);
04367 #endif
04368
04369 }
04370
04371
04372
04373
04374
04375 if((sealed==1)&&((count[POROSITY]-water_left)>0)){
04376 poretodo=(count[POROSITY]-pore_off)-(water_left-water_off);
04377 poretodo-=slagemptyp;
04378 if(poretodo>0){
04379 makeinert(poretodo);
04380 poregone+=poretodo;
04381 }
04382 }
04383
04384
04385 #ifdef OUTFILES
04386 if(cyccnt==0){
04387 fprintf(phasfile,"Cycle DoH Time Porosity C3S C2S C3A C4AF GYPSUM HEMIHYD ANHYDRITE POZZ INERT SLAG ASG CAS2 CH CSH C3AH6 ETTR ETTRC4AF AFM FH3 POZZCSH SLAGCSH CACL2 FREIDEL STRAT GYPSUMS CACO3 AFMC AGG ABSGYP EMPTYP HDCSH water_left \n");
04388 fprintf(perc_phases,"# Cycle SOL_per SOL_tot| Porosity C3S C2S C3A C4AF GYPSUM HEMIHYD ANHYDRITE POZZ INERT SLAG ASG CAS2 CH CSH C3AH6 ETTR ETTRC4AF AFM FH3 POZZCSH SLAGCSH CACL2 FREIDEL STRAT GYPSUMS CACO3 AFMC AGG ABSGYP EMPTYP HDCSH\n");
04389 }
04390 fprintf(phasfile,"%d %.4f %.4f ",cyccnt, alpha_cur, time_cur);
04391 fprintf(disprobfile, "%d %.4f %.4f ", cyccnt, alpha_cur, time_cur);
04392
04393
04394 CSHbox(CSH_vicinity);
04395
04396 for(i=0;i<=HDCSH;i++){
04397 if((i<DIFFCSH)||(i>=EMPTYP)){
04398 if(i==CSH){
04399 fprintf(phasfile,"%ld ",count[CSH]-count[HDCSH]);
04400 }
04401 else{
04402 fprintf(phasfile,"%ld ",count[i]);
04403 }
04404 fprintf(disprobfile, "%f ", disprob[i]);
04405 }
04406
04407 }
04408
04409 fprintf(disprobfile, "\n");
04410 fprintf(phasfile,"%ld\n",water_left);
04411 fflush(phasfile);
04412 fflush(disprobfile);
04413 #endif
04414
04415 #ifdef PRINTF
04416 printf("\n");
04417 #endif
04418
04419 if(cycle==0){
04420 return;
04421 }
04422
04423 #ifdef PRINTF
04424 printf("Cycle %d \n",cyccnt);
04425 #endif
04426
04427 cyccnt+=1;
04428 fflush(stdout);
04429
04430 chold=chnew;
04431 chnew=count[CH];
04432
04433
04434
04435
04436
04437 if(((ncsbar+anhinit+heminit)!=0.0)||(temp_cur>=70.0)){
04438
04439 if((soluble[ETTR]==0)&&((temp_cur>=70.0)||(count[AFM]!=0)||
04440 ((((float)count[GYPSUM]+1.42*(float)count[ANHYDRITE]+1.4*
04441 (float)count[HEMIHYD]+(float)count[GYPSUMS])/((float)ncsbar+
04442 1.42*(float)anhinit+1.4*(float)heminit+((float)netbar/3.30)))<0.25))){
04443 soluble[ETTR]=1;
04444 #ifdef PRINTF
04445 printf("Ettringite is soluble beginning at cycle %d \n",cycle);
04446 #endif
04447
04448 passone(ETTR,ETTR,2,0);
04449 }
04450 }
04451
04452
04453
04454 if(count[DIFFETTR]>DETTRMAX){
04455 disprob[ETTR]=0.0;
04456 }
04457 else{
04458 disprob[ETTR]=disbase[ETTR];
04459 }
04460
04461
04462 if(count[DIFFCACL2]>DCACL2MAX){
04463 disprob[CACL2]=0.0;
04464 }
04465 else{
04466 disprob[CACL2]=disbase[CACL2];
04467 }
04468
04469
04470 if((count[DIFFCACO3]>DCACO3MAX)&&(soluble[ETTR]==0)){
04471 disprob[CACO3]=0.0;
04472 }
04473 else if(count[DIFFCACO3]>(4*DCACO3MAX)){
04474 disprob[CACO3]=0.0;
04475 }
04476 else{
04477 disprob[CACO3]=disbase[CACO3];
04478 }
04479
04480
04481
04482
04483 if((float)count[DIFFCH]>=CHCRIT){
04484 disprob[CH]=disbase[CH]*CHCRIT/(float)count[DIFFCH];
04485 }
04486 else{
04487 disprob[CH]=disbase[CH];
04488 }
04489
04490
04491
04492
04493
04494 #ifdef PRINTF
04495 printf("CH dissolution probability goes from %f ",disprob[CH]);
04496 #endif
04497 disprob[CH]*=((A0_CHSOL-A1_CHSOL*temp_cur)/(A0_CHSOL-A1_CHSOL*25.0));
04498 if((ppozz>0.0)&&(nfill>0)){
04499 disprob[CH]*=ppozz/PPOZZ;
04500 }
04501 #ifdef PRINTF
04502 printf("to %f \n",disprob[CH]);
04503 #endif
04504
04505
04506
04507
04508 disprob[ASG]=disbase[ASG];
04509 disprob[CAS2]=disbase[CAS2];
04510
04511
04512
04513 if(((count[GYPSUM]+count[GYPSUMS])>(int)(((float)ncsbar+
04514 1.42*(float)anhinit+1.4*(float)heminit)*0.05))
04515 ||(count[ETTR]>500*SYSIZE_POW3/1000000.)){
04516 soluble[C3AH6]=1;
04517 passone(C3AH6,C3AH6,2,0);
04518
04519
04520
04521 maxsulfate=count[DIFFGYP];
04522 if((maxsulfate<count[DIFFETTR])&&(soluble[ETTR]==1)){
04523 maxsulfate=count[DIFFETTR];
04524 }
04525
04526
04527 if(maxsulfate<(int)((float)gypready*disprob[GYPSUM]*(float)count[POROSITY]/SYSIZE_POW3)){
04528 maxsulfate=(int)((float)gypready*disprob[GYPSUM]*(float)count[POROSITY]/SYSIZE_POW3);
04529 }
04530 if(maxsulfate>0){
04531 disprob[C3AH6]=disbase[C3AH6]*(float)(maxsulfate/C3AH6CRIT);
04532 if(disprob[C3AH6]>0.5){
04533 disprob[C3AH6]=0.5;
04534 }
04535 }
04536 else{
04537 disprob[C3AH6]=disbase[C3AH6];
04538 }
04539 }
04540 else{
04541 soluble[C3AH6]=0;
04542 }
04543
04544
04545 if((soluble[C3S]==0)&&((cycle>1)||(count[ETTR]>0)||(count[AFM]>0)||(count[ETTRC4AF]>0))){
04546 soluble[C2S]=1;
04547 soluble[C3S]=1;
04548
04549 passone(C3S,C2S,2,0);
04550 }
04551
04552
04553
04554 tdisfact=A0_CHSOL-temp_cur*A1_CHSOL;
04555
04556
04557
04558
04559
04560
04561
04562
04563
04564 pfract=(float)count[POROSITY]/(float)(SYSIZE*SYSIZE*SYSIZE);
04565 if((ncsbar+anhinit+heminit)==0.0){
04566 cs_acc=1.0;
04567 ca_acc=1.0;
04568 dismin_c3a=5.0*DISMIN_C3A_0;
04569 dismin_c4af=5.0*DISMIN_C4AF_0;
04570 }
04571 else{
04572 sulf_conc=sulf_cur*tfractw05*pfractw05/totfract/pfract;
04573 sulf_conc*=(1000000./SYSIZE_POW3);
04574 if(sulf_conc<10.0){
04575 cs_acc=1.0;
04576 ca_acc=1.0;
04577 dismin_c3a=DISMIN_C3A_0;
04578 dismin_c4af=DISMIN_C4AF_0;
04579 }
04580 else if(sulf_conc<20.0){
04581 cs_acc=1.0+((sulf_conc)-10.0)/10.0;
04582 ca_acc=1.0;
04583 dismin_c3a=DISMIN_C3A_0;
04584 dismin_c4af=DISMIN_C4AF_0;
04585 }
04586 else{
04587 cs_acc=1.0+(double)log10(sulf_conc-10.0);
04588 ca_acc=1.0;
04589 dismin_c3a=(6.0-(double)log10(sulf_conc))*DISMIN_C3A_0;
04590 dismin_c4af=(6.0-(double)log10(sulf_conc))*DISMIN_C4AF_0;
04591 if(dismin_c3a<DISMIN_C3A_0){dismin_c3a=DISMIN_C3A_0;}
04592 if(dismin_c4af<DISMIN_C4AF_0){dismin_c4af=DISMIN_C4AF_0;}
04593 }
04594 }
04595
04596
04597
04598
04599
04600
04601
04602
04603 dfact=tdisfact*((float)count[CSH]/((float)CSHSCALE*surffract*totfract/tfractw04))*((float)count[CSH]/((float)CSHSCALE*surffract*totfract/tfractw04))*cs_acc;
04604
04605 disprob[C3S]=DISMIN+dfact*disbase[C3S];
04606 disprob[C2S]=DISMIN2+dfact*disbase[C2S];
04607 if(disprob[C3S]>(1.*disbase[C3S])){disprob[C3S]=(1.*disbase[C3S]);}
04608 if(disprob[C2S]>(1.*disbase[C2S])){disprob[C2S]=(1.*disbase[C2S]);}
04609
04610
04611
04612
04613 disprob[SLAG]=slagreact*(DISMINSLAG+dfact*disbase[SLAG])/10.0;
04614 if(disprob[SLAG]>(slagreact*disbase[SLAG])){disprob[SLAG]=(slagreact*disbase[SLAG]);}
04615 if(disprob[C3S]==disbase[C3S]){disprob[SLAG]=slagreact*disbase[SLAG];}
04616 disprob[ASG]=DISMINASG+dfact*disbase[ASG]/5.0;
04617 if(disprob[ASG]>(1.*disbase[ASG])){disprob[ASG]=(1.*disbase[ASG]);}
04618 if(disprob[C3S]==disbase[C3S]){disprob[ASG]=disbase[ASG];}
04619 disprob[CAS2]=DISMINCAS2+dfact*disbase[CAS2]/5.0;
04620 if(disprob[CAS2]>(1.*disbase[CAS2])){disprob[CAS2]=(1.*disbase[CAS2]);}
04621 if(disprob[C3S]==disbase[C3S]){disprob[CAS2]=disbase[CAS2];}
04622
04623
04624 if(count[DIFFCAS2]>DCAS2MAX){
04625 disprob[CAS2]=0.0;
04626 }
04627 #ifdef PRINTF
04628 printf("Silicate probabilities: %f %f\n",disprob[C3S],disprob[C2S]);
04629 #endif
04630 fflush(stdout);
04631
04632
04633
04634
04635
04636 if((ncsbar+heminit+anhinit)>1000*SYSIZE_POW3/1000000.){
04637
04638
04639
04640 dfact1=tdisfact*((float)count[CSH]/((float)CSHSCALE*surffract*totfract/tfractw04))*((float)count[CSH]/((float)CSHSCALE*surffract*totfract/tfractw04))*ca_acc;
04641 disprob[C3A]=dismin_c3a+dfact1*disbase[C3A];
04642 disprob[C4AF]=dismin_c4af+dfact1*disbase[C4AF];
04643 if(disprob[C3A]>(1.*disbase[C3A])){disprob[C3A]=(1.*disbase[C3A]);}
04644 if(disprob[C4AF]>(1.*disbase[C4AF])){disprob[C4AF]=(1.*disbase[C4AF]);}
04645
04646
04647
04648 disprob[GYPSUM]=(disbase[GYPSUM]/15.)+dfact1*disbase[GYPSUM];
04649 if(disprob[GYPSUM]>(disbase[GYPSUM])){disprob[GYPSUM]=(disbase[GYPSUM]);}
04650 disprob[GYPSUMS]=(disbase[GYPSUMS]/15.)+dfact1*disbase[GYPSUMS];
04651 if(disprob[GYPSUMS]>(disbase[GYPSUMS])){disprob[GYPSUMS]=(disbase[GYPSUMS]);}
04652
04653
04654 if(count[DIFFGYP]>DGYPMAX){
04655 disprob[GYPSUM]=disprob[GYPSUMS]=0.0;
04656 }
04657 disprob[HEMIHYD]=(disbase[HEMIHYD]/15.)+dfact1*disbase[HEMIHYD];
04658 if(disprob[HEMIHYD]>(disbase[HEMIHYD])){disprob[HEMIHYD]=(disbase[HEMIHYD]);}
04659 disprob[ANHYDRITE]=(disbase[ANHYDRITE]/15.)+dfact1*disbase[ANHYDRITE];
04660 if(disprob[ANHYDRITE]>(disbase[ANHYDRITE])){disprob[ANHYDRITE]=(disbase[ANHYDRITE]);}
04661
04662 }
04663 else{
04664
04665
04666 disprob[C3A]=4.*disbase[C3A];
04667 disprob[C4AF]=4.*disbase[C4AF];
04668 disprob[GYPSUM]=disbase[GYPSUM];
04669 disprob[HEMIHYD]=disbase[HEMIHYD];
04670 disprob[ANHYDRITE]=disbase[ANHYDRITE];
04671 }
04672
04673 if((count[EMPTYP]>0)&&((count[POROSITY]+count[EMPTYP])<220000.*(double)(SYSIZE_POW3/1000000.))){
04674 if(countpore==0){countpore=count[EMPTYP];}
04675 saturation=(float)(count[POROSITY])/(float)(count[POROSITY]+(count[EMPTYP]-countpore));
04676
04677
04678
04679
04680
04681
04682
04683 disprob[C3S]*=(saturation*saturation);
04684 disprob[C3S]*=(saturation*saturation);
04685 disprob[C3S]*=(saturation*saturation);
04686 disprob[C3S]*=(saturation*saturation);
04687 disprob[C3S]*=(saturation*saturation);
04688 disprob[C3S]*=(saturation*saturation);
04689 disprob[C3S]*=(saturation*saturation);
04690 disprob[C3S]*=(saturation*saturation);
04691 disprob[C3S]*=(saturation*saturation);
04692 disprob[C3S]*=(saturation);
04693 disprob[SLAG]*=(saturation*saturation);
04694 disprob[SLAG]*=(saturation*saturation);
04695 disprob[SLAG]*=(saturation*saturation);
04696 disprob[SLAG]*=(saturation*saturation);
04697 disprob[SLAG]*=(saturation*saturation);
04698 disprob[SLAG]*=(saturation*saturation);
04699 disprob[SLAG]*=(saturation*saturation);
04700 disprob[SLAG]*=(saturation*saturation);
04701 disprob[SLAG]*=(saturation*saturation);
04702 disprob[SLAG]*=(saturation);
04703 disprob[CH]*=(saturation*saturation);
04704 disprob[CH]*=(saturation*saturation);
04705 disprob[CH]*=(saturation*saturation);
04706 disprob[CH]*=(saturation*saturation);
04707 disprob[CH]*=(saturation*saturation);
04708 disprob[CH]*=(saturation*saturation);
04709 disprob[CH]*=(saturation*saturation);
04710 disprob[CH]*=(saturation*saturation);
04711 disprob[CH]*=(saturation*saturation);
04712 disprob[CH]*=(saturation);
04713 disprob[ASG]*=(saturation*saturation);
04714 disprob[ASG]*=(saturation*saturation);
04715 disprob[ASG]*=(saturation*saturation);
04716 disprob[ASG]*=(saturation*saturation);
04717 disprob[ASG]*=(saturation*saturation);
04718 disprob[ASG]*=(saturation*saturation);
04719 disprob[ASG]*=(saturation*saturation);
04720 disprob[ASG]*=(saturation*saturation);
04721 disprob[ASG]*=(saturation*saturation);
04722 disprob[ASG]*=(saturation);
04723 disprob[CAS2]*=(saturation*saturation);
04724 disprob[CAS2]*=(saturation*saturation);
04725 disprob[CAS2]*=(saturation*saturation);
04726 disprob[CAS2]*=(saturation*saturation);
04727 disprob[CAS2]*=(saturation*saturation);
04728 disprob[CAS2]*=(saturation*saturation);
04729 disprob[CAS2]*=(saturation*saturation);
04730 disprob[CAS2]*=(saturation*saturation);
04731 disprob[CAS2]*=(saturation*saturation);
04732 disprob[CAS2]*=(saturation);
04733 ppozz*=(saturation*saturation);
04734 ppozz*=(saturation*saturation);
04735 ppozz*=(saturation*saturation);
04736 ppozz*=(saturation*saturation);
04737 ppozz*=(saturation*saturation);
04738 ppozz*=(saturation*saturation);
04739 ppozz*=(saturation*saturation);
04740 ppozz*=(saturation*saturation);
04741 ppozz*=(saturation*saturation);
04742 ppozz*=(saturation);
04743 disprob[C2S]*=(saturation*saturation);
04744 disprob[C2S]*=(saturation*saturation);
04745 disprob[C2S]*=(saturation*saturation);
04746 disprob[C2S]*=(saturation*saturation);
04747 disprob[C2S]*=(saturation*saturation);
04748 disprob[C2S]*=(saturation*saturation);
04749 disprob[C2S]*=(saturation*saturation);
04750 disprob[C2S]*=(saturation*saturation);
04751 disprob[C2S]*=(saturation*saturation);
04752 disprob[C2S]*=(saturation*saturation);
04753 disprob[C2S]*=(saturation*saturation);
04754
04755 disprob[C2S]*=(saturation*saturation);
04756 disprob[C2S]*=(saturation*saturation);
04757 disprob[C2S]*=(saturation*saturation);
04758 disprob[C2S]*=(saturation);
04759 disprob[C3A]*=(saturation*saturation);
04760 disprob[C3A]*=(saturation*saturation);
04761 disprob[C3A]*=(saturation*saturation);
04762 disprob[C4AF]*=(saturation*saturation);
04763 disprob[C4AF]*=(saturation*saturation);
04764 disprob[C4AF]*=(saturation*saturation);
04765
04766 }
04767 #ifdef PRINTF
04768 printf("Silicate and aluminate probabilities: %f %f %f %f\n",disprob[C3S],disprob[C2S],disprob[C3A],disprob[C4AF]);
04769 printf("cs_acc is %f and ca_acc is %f sulf_cur is %ld\n",cs_acc,ca_acc,sulf_cur);
04770 #endif
04771 fflush(stdout);
04772
04773
04774 pHfactor=0.0;
04775 if((pHactive==1)&&(count[CSH]>((CSHSCALE*surffract*surffract*totfract*totfract/tfractw04/tfractw04)/8.0))){
04776 pHfactor=1.5;
04777 if(pH_cur>12.5){pHfactor=1.0;}
04778
04779
04780
04781
04782 if(pH_cur>12.75){pHfactor=0.667;}
04783 if(pH_cur>13.00){pHfactor=0.333;}
04784 if(pH_cur>13.25){pHfactor=(0.0);}
04785 if(pH_cur>13.75){pHfactor=(-0.25);}
04786 pHfactor+=concsulfate;
04787 }
04788 nhgd=0;
04789
04790 pc3scsh=molarvcsh[cyccnt]/molarv[C3S]-1.0;
04791 pc2scsh=molarvcsh[cyccnt]/molarv[C2S]-1.0;
04792
04793 slagemptyp=0;
04794 for(xloop=0;xloop<SYSIZE;xloop++){
04795 for(yloop=0;yloop<SYSIZE;yloop++){
04796 for(zloop=0;zloop<SYSIZE;zloop++){
04797 if(mic[xloop][yloop][zloop]>OFFSET){
04798 phid=mic[xloop][yloop][zloop]-OFFSET;
04799
04800 plnew=(int)((float)NEIGHBORS*ran1(seed));
04801 if((plnew<0)||(plnew>=NEIGHBORS)){ plnew=NEIGHBORS-1;}
04802 xc=xloop+xoff[plnew];
04803 yc=yloop+yoff[plnew];
04804 zc=zloop+zoff[plnew];
04805 if(xc<0){xc=(SYSIZEM1);}
04806 if(yc<0){yc=(SYSIZEM1);}
04807 if(xc>=SYSIZE){xc=0;}
04808 if(yc>=SYSIZE){yc=0;}
04809 if(zc<0){zc=(SYSIZEM1);}
04810 if(zc>=SYSIZE){zc=0;}
04811
04812
04813 pdis=ran1(seed);
04814
04815
04816
04817 if(((pdis<=(disprob[phid]/(1.+pHfactor*pHeffect[phid])))||((pdis<=(onepixelbias*disprob[phid]/(1.+pHfactor*pHeffect[phid])))&&(micpart[xloop][yloop][zloop]==0)))&&(mic[xc][yc][zc]==POROSITY)){
04818 discount[phid]+=1;
04819 cread=creates[phid];
04820 count[phid]-=1;
04821 mic[xloop][yloop][zloop]=POROSITY;
04822 if(phid==C3AH6){nhgd+=1;}
04823
04824 if(phid==C4AF){
04825 plfh3=ran1(seed);
04826 if((plfh3<0.0)||(plfh3>1.0)){
04827 plfh3=1.0;
04828 }
04829
04830
04831 if(plfh3<=0.5453){
04832 cread=DIFFFH3;
04833 }
04834 }
04835 if(cread==POROSITY){
04836 count[POROSITY]+=1;
04837 }
04838 if(cread!=POROSITY){
04839 nmade+=1;
04840 ngoing+=1;
04841 phnew=cread;
04842 count[phnew]+=1;
04843 mic[xc][yc][zc]=phnew;
04844 antadd=(struct ants *)malloc(sizeof(struct ants));
04845 antadd->x=xc;
04846 antadd->y=yc;
04847 antadd->z=zc;
04848 antadd->id=phnew;
04849 antadd->cycbirth=cyccnt;
04850
04851 antadd->prevant=tailant;
04852 tailant->nextant=antadd;
04853 antadd->nextant=NULL;
04854 tailant=antadd;
04855 }
04856
04857 if((phid==C3S)||(phid==C2S)){
04858 plfh3=ran1(seed);
04859 if(((phid==C2S)&&(plfh3<=pc2scsh))||(plfh3<=pc3scsh)){
04860 cshboxsize=(int)(3.+5.*(40.-temp_cur)/20.);
04861 if(cshboxsize<1){cshboxsize=1;}
04862 if(cshboxsize>=SYSIZE){cshboxsize=SYSIZE;}
04863 placed=loccsh(xc,yc,zc,cshboxsize);
04864 if(placed!=0){
04865 count[DIFFCSH]+=1;
04866 count[POROSITY]-=1;
04867 }
04868 else{
04869 cshrand+=1;
04870 }
04871 }
04872 }
04873
04874 if((phid==C2S)&&(pc2scsh>1.0)){
04875 plfh3=ran1(seed);
04876 if(plfh3<=(pc2scsh-1.0)){
04877 cshboxsize=(int)(3.+5.*(40.-temp_cur)/20.);
04878 if(cshboxsize<1){cshboxsize=1;}
04879 if(cshboxsize>=SYSIZE){cshboxsize=SYSIZE;}
04880 placed=loccsh(xc,yc,zc,cshboxsize);
04881 if(placed!=0){
04882 count[DIFFCSH]+=1;
04883 count[POROSITY]-=1;
04884 }
04885 else{
04886 cshrand+=1;
04887 }
04888 }
04889 }
04890 }
04891 else{
04892 mic[xloop][yloop][zloop]-=OFFSET;
04893 }
04894
04895 }
04896
04897
04898
04899
04900 if((count[POZZ]>=13000)&&(chnew<(0.15*SYSIZE*SYSIZE*SYSIZE))&&(csh2flag==1)){
04901 if(mic[xloop][yloop][zloop]==CSH){
04902 if((countbox(3,xloop,yloop,zloop))>=1){
04903 pconvert=ran1(seed);
04904 if(pconvert<PCSH2CSH){
04905 count[CSH]-=1;
04906 plfh3=ran1(seed);
04907
04908
04909
04910
04911 calcz=0.0;
04912 cycnew=cshage[xloop][yloop][zloop];
04913 calcy=molarv[POZZCSH]/molarvcsh[cycnew];
04914 if(calcy>1.0){
04915 calcz=calcy-1.0;
04916 calcy=1.0;
04917 printf("Problem of not creating enough pozzolanic CSH during CSH conversion \n");
04918 printf("Current temperature is %f C\n",temp_cur);
04919 }
04920
04921 if(plfh3<=calcy){
04922 mic[xloop][yloop][zloop]=POZZCSH;
04923 count[POZZCSH]+=1;
04924 }
04925 else{
04926 mic[xloop][yloop][zloop]=DIFFCH;
04927 nmade+=1;
04928 ncshgo+=1;
04929 ngoing+=1;
04930 count[DIFFCH]+=1;
04931 antadd=(struct ants *)malloc(sizeof(struct ants));
04932 antadd->x=xloop;
04933 antadd->y=yloop;
04934 antadd->z=zloop;
04935 antadd->id=DIFFCH;
04936 antadd->cycbirth=cyccnt;
04937
04938 antadd->prevant=tailant;
04939 tailant->nextant=antadd;
04940 antadd->nextant=NULL;
04941 tailant=antadd;
04942 }
04943
04944
04945
04946
04947
04948
04949
04950
04951
04952
04953
04954 plfh3=ran1(seed);
04955 calcx=(19.86/molarvcsh[cycnew])-(1.-calcy);
04956
04957 if(plfh3<calcx){
04958 npchext+=1;
04959 }
04960 }
04961 }
04962 }
04963 }
04964
04965 if(mic[xloop][yloop][zloop]==SLAG){
04966 if((countbox(3,xloop,yloop,zloop))>=1){
04967 pconvert=ran1(seed);
04968 if(pconvert<(disprob[SLAG]/(1.+pHfactor*pHeffect[SLAG]))){
04969 nslagr+=1;
04970 count[SLAG]-=1;
04971 discount[SLAG]+=1;
04972
04973 plfh3=ran1(seed);
04974 if(plfh3<p5slag){
04975 nslagc3a+=1;
04976 }
04977
04978 plfh3=ran1(seed);
04979 if(plfh3<p1slag){
04980 mic[xloop][yloop][zloop]=SLAGCSH;
04981
04982 msface=(int)(3.*ran1(seed)+1.);
04983 if(msface>3){msface=1;}
04984 faces[xloop][yloop][zloop]=msface;
04985 count[SLAGCSH]+=1;
04986 }
04987 else{
04988 if(sealed==1){
04989
04990 slagemptyp+=1;
04991 mic[xloop][yloop][zloop]=EMPTYP;
04992 count[EMPTYP]+=1;
04993 }
04994 else{
04995 mic[xloop][yloop][zloop]=POROSITY;
04996 count[POROSITY]+=1;
04997 }
04998 }
04999
05000 p3init=p3slag;
05001 while(p3init>1.0){
05002 extslagcsh(xloop,yloop,zloop);
05003 p3init-=1.0;
05004 }
05005 plfh3=ran1(seed);
05006 if(plfh3<p3init){
05007 extslagcsh(xloop,yloop,zloop);
05008 }
05009 }
05010 }
05011 }
05012 }
05013 }
05014 }
05015
05016 if(ncshgo!=0){printf("CSH dissolved is %ld \n",ncshgo);}
05017
05018 if(npchext>0){printf("npchext is %ld at cycle %d \n",npchext,cycle);}
05019
05020
05021
05022 ncshext=cshrand;
05023 if(cshrand!=0){
05024 printf("cshrand is %d \n",cshrand);
05025 }
05026
05027
05028
05029
05030
05031
05032
05033
05034
05035 fchext=1.3*74*specgrav[C3S]/(specgrav[CH]*228)*(float)discount[C3S]+0.191*(float)discount[C2S]+
05036 0.2584*(float)discount[C4AF];
05037
05038 nchext=(int)fchext;
05039 if(fchext>(float)nchext){
05040 pdis=ran1(seed);
05041 if((fchext-(float)nchext)>pdis){
05042 nchext+=1;
05043 }
05044 }
05045 nchext+=npchext;
05046
05047 slagcum+=discount[SLAG];
05048 chgone=(int)(p4slag*(float)slagcum);
05049 nchext-=chgone;
05050 slagcum-=(int)((float)chgone/p4slag);
05051 nchext-=DIFFCHdeficit;
05052 DIFFCHdeficit=0;
05053 if(nchext<0){
05054 DIFFCHdeficit-=nchext;
05055 nchext=0;
05056 }
05057 fc3aext=discount[C3A]+0.5917*(float)discount[C3AH6];
05058 nc3aext=(int)(fc3aext+nslagc3a);
05059 if(fc3aext>(float)nc3aext){
05060 pdis=ran1(seed);
05061 if((fc3aext-(float)nc3aext)>pdis){
05062 nc3aext+=1;
05063 }
05064 }
05065 fc4aext=0.696*(float)discount[C4AF];
05066 nc4aext=(int)fc4aext;
05067 if(fc4aext>(float)nc4aext){
05068 pdis=ran1(seed);
05069 if((fc4aext-(float)nc4aext)>pdis){
05070 nc4aext+=1;
05071 }
05072 }
05073
05074 ngypext=discount[GYPSUM]+discount[GYPSUMS];
05075
05076
05077
05078
05079
05080 fanhext=(float)discount[ANHYDRITE];
05081 nanhext=(int)fanhext;
05082 if(fanhext>(float)nanhext){
05083 pdis=ran1(seed);
05084 if((fanhext-(float)nanhext)>pdis){
05085 nanhext+=1;
05086 }
05087 }
05088
05089
05090
05091
05092 fhemext=(float)discount[HEMIHYD];
05093
05094
05095 nhemext=(int)fhemext;
05096 if(fhemext>(float)nhemext){
05097 pdis=ran1(seed);
05098 if((fhemext-(float)nhemext)>pdis){
05099 nhemext+=1;
05100 }
05101 }
05102 count[DIFFGYP]+=ngypext;
05103 count[DIFFANH]+=nanhext;
05104 count[DIFFHEM]+=nhemext;
05105 count[DIFFCH]+=nchext;
05106 count[DIFFCSH]+=ncshext;
05107 count[DIFFC3A]+=nc3aext;
05108 count[DIFFC4A]+=nc4aext;
05109
05110 nsum2=nchext+ncshext;
05111 nsum3=nsum2+nc3aext;
05112 nsum4=nsum3+nc4aext;
05113 nsum5=nsum4+ngypext;
05114 nsum6=nsum5+nhemext;
05115 fflush(stdout);
05116
05117
05118 for(xext=1;xext<=(nsum6+nanhext);xext++){
05119 plok=0;
05120 tries=0;
05121 do{
05122 xc=(int)((float)SYSIZE*ran1(seed));
05123 yc=(int)((float)SYSIZE*ran1(seed));
05124 zc=(int)((float)SYSIZE*ran1(seed));
05125 if(xc>=SYSIZE){xc=0;}
05126 if(yc>=SYSIZE){yc=0;}
05127 if(zc>=SYSIZE){zc=0;}
05128
05129 tries++;
05130
05131 if(mic[xc][yc][zc]==POROSITY){
05132 plok=1;
05133 phid=DIFFCH;
05134 count[POROSITY]-=1;
05135 if(xext>nsum6){phid=DIFFANH;}
05136 else if(xext>nsum5){phid=DIFFHEM;}
05137 else if(xext>nsum4){phid=DIFFGYP;}
05138 else if(xext>nsum3){phid=DIFFC4A;}
05139 else if(xext>nsum2){phid=DIFFC3A;}
05140 else if(xext>nchext){phid=DIFFCSH;}
05141 mic[xc][yc][zc]=phid;
05142 nmade+=1;
05143 ngoing+=1;
05144 antadd=(struct ants *)malloc(sizeof(struct ants));
05145
05146 antadd->x=xc;
05147 antadd->y=yc;
05148 antadd->z=zc;
05149 antadd->id=phid;
05150 antadd->cycbirth=cyccnt;
05151
05152 antadd->prevant=tailant;
05153 tailant->nextant=antadd;
05154 antadd->nextant=NULL;
05155 tailant=antadd;
05156 }
05157
05158 if(tries>10*SYSIZE_POW3){
05159 #ifdef PRINTF
05160 printf("Could not place extra diffusing species (too few POROSITY voxels), continuing (line %d),\n",__LINE__);
05161 #endif
05162 continue;
05163 }
05164 } while (plok==0);
05165
05166 }
05167
05168 #ifdef PRINTF
05169 printf("Dissolved- %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",count[DIFFCSH],
05170 count[DIFFCH],count[DIFFGYP],count[DIFFC3A],count[DIFFFH3],
05171 count[DIFFETTR],count[DIFFAS],count[DIFFANH],count[DIFFHEM],
05172 count[DIFFCAS2],count[DIFFCACL2],count[DIFFCACO3]);
05173 #endif
05174
05175 sulf_cur=count[DIFFGYP]+count[DIFFANH]+count[DIFFHEM];
05176
05177
05178
05179
05180
05181
05182 if(sulf_cur>DGYPMAX){
05183 disprob[GYPSUM]=disprob[GYPSUMS]=0.0;
05184 }
05185 else{
05186 disprob[GYPSUM]=disbase[GYPSUM];
05187 disprob[ANHYDRITE]=disbase[ANHYDRITE];
05188 disprob[HEMIHYD]=disbase[HEMIHYD];
05189 disprob[GYPSUMS]=disbase[GYPSUMS];
05190 }
05191
05192 #ifdef PRINTF
05193 printf("C3AH6 dissolved- %ld with prob. of %f \n",nhgd,disprob[C3AH6]);
05194 #endif
05195
05196 fflush(stdout);
05197 }
05198
05199
05200
05201
05202
05203
05204 void cemhydmat::addrand(int randid,long int nneed){
05205 int ix,iy,iz;
05206 long int ic;
05207 int success,cpores;
05208
05209
05210 for(ic=1;ic<=nneed;ic++){
05211 success=0;
05212 while(success==0){
05213 ix=(int)((float)SYSIZE*ran1(seed));
05214 iy=(int)((float)SYSIZE*ran1(seed));
05215 iz=(int)((float)SYSIZE*ran1(seed));
05216 if(ix==SYSIZE){ix=0;}
05217 if(iy==SYSIZE){iy=0;}
05218 if(iz==SYSIZE){iz=0;}
05219 if(mic[ix][iy][iz]==POROSITY){
05220 if((randid!=CACO3)&&(randid!=INERT)){
05221 mic[ix][iy][iz]=randid;
05222 micorig[ix][iy][iz]=randid;
05223 success=1;
05224 }
05225 else{
05226 cpores=countboxc(3,ix,iy,iz);
05227 if(cpores>=26){
05228 mic[ix][iy][iz]=randid;
05229 micorig[ix][iy][iz]=randid;
05230 success=1;
05231 }
05232 }
05233 }
05234 }
05235 }
05236 }
05237
05238
05239 void cemhydmat::measuresurf(void)
05240 {
05241 int sx,sy,sz,jx,jy,jz,faceid;
05242
05243 for(sx=0;sx<SYSIZE;sx++){
05244 for(sy=0;sy<SYSIZE;sy++){
05245 for(sz=0;sz<SYSIZE;sz++){
05246 if(mic[sx][sy][sz]==POROSITY){
05247 for(faceid=0;faceid<6;faceid++){
05248 if(faceid==1){
05249 jx=sx-1;
05250 if(jx<0){jx=SYSIZE-1;}
05251 jy=sy;
05252 jz=sz;
05253 }
05254 else if(faceid==0){
05255 jx=sx+1;
05256 if(jx>(SYSIZE-1)){jx=0;}
05257 jy=sy;
05258 jz=sz;
05259 }
05260 else if(faceid==2){
05261 jy=sy+1;
05262 if(jy>(SYSIZE-1)){jy=0;}
05263 jx=sx;
05264 jz=sz;
05265 }
05266 else if(faceid==3){
05267 jy=sy-1;
05268 if(jy<0){jy=SYSIZE-1;}
05269 jx=sx;
05270 jz=sz;
05271 }
05272 else if(faceid==4){
05273 jz=sz+1;
05274 if(jz>(SYSIZE-1)){jz=0;}
05275 jx=sx;
05276 jy=sy;
05277 }
05278 else if(faceid==5){
05279 jz=sz-1;
05280 if(jz<0){jz=SYSIZE-1;}
05281 jx=sx;
05282 jy=sy;
05283 }
05284
05285 if((mic[jx][jy][jz]==C3S)||(mic[jx][jy][jz]==C2S)||(mic[jx][jy][jz]==C3A)||(mic[jx][jy][jz]==C4AF)||(mic[jx][jy][jz]==INERT)||(mic[jx][jy][jz]==CACO3)){
05286 scnttotal+=1;
05287 if((mic[jx][jy][jz]==C3S)||(mic[jx][jy][jz]==C2S)||(mic[jx][jy][jz]==C3A)||(mic[jx][jy][jz]==C4AF)){
05288 scntcement+=1;
05289 }
05290 }
05291 }
05292 }
05293
05294 }
05295 }
05296 }
05297
05298 #ifdef PRINTF
05299 printf("Cement surface count is %ld \n",scntcement);
05300 printf("Total surface count is %ld \n",scnttotal);
05301 #endif
05302
05303 surffract=(float)scntcement/(float)scnttotal;
05304
05305 #ifdef PRINTF
05306 printf("Surface fraction is %f \n",surffract);
05307 #endif
05308
05309 fflush(stdout);
05310 }
05311
05312
05313
05314 void cemhydmat::resaturate(void)
05315 {
05316 int sx,sy,sz;
05317 long int nresat=0;
05318
05319 for(sx=0;sx<SYSIZE;sx++){
05320 for(sy=0;sy<SYSIZE;sy++){
05321 for(sz=0;sz<SYSIZE;sz++){
05322 if(mic[sx][sy][sz]==EMPTYP){
05323 mic[sx][sy][sz]=POROSITY;
05324 nresat++;
05325 }
05326 }
05327 }
05328 }
05329 if(nresat>0){
05330 porefl1=porefl2=porefl3=1;
05331 }
05332
05333 printf("Number resaturated is %ld \n",nresat);
05334 fflush(stdout);
05335 }
05336
05337
05338
05339 void cemhydmat::outputUnpercImageFile(void){
05340 FILE *imgout;
05341 char extension[10];
05342
05343 char *prefix;
05344 prefix = (char *)malloc(80);
05345
05346
05347
05348 system("mkdir unperc 2> /dev/null");
05349
05350 sprintf(extension, "%04d", icyc);
05351 strcpy(prefix,"unperc/out5.");
05352 strcat(prefix, extension);
05353 strcat(prefix, ".img");
05354 #ifdef PRINTF
05355 printf("name of output file is %s", prefix);
05356 #endif
05357
05358 if((imgout=fopen(prefix, "w"))==NULL){
05359 printf("\nfile %s can not be opened\n", prefix);
05360 free(prefix);
05361 return;
05362 }
05363
05364 for(int dz=0;dz<SYSIZE;dz++){
05365 for(int dy=0;dy<SYSIZE;dy++){
05366 for(int dx=0;dx<SYSIZE;dx++){
05367 fprintf(imgout, "%d\n", mic_CSH[dx][dy][dz]);
05368 }
05369 }
05370 }
05371 fclose(imgout);
05372 free(prefix);
05373 }
05374
05375
05376 void cemhydmat::readhydrparam()
05377 {
05378 int fidc3s,fidc2s,fidc3a,fidc4af,fidgyp,fidagg,ffac3a;
05379 int fidhem,fidanh,fidcaco3;
05380 int read_micr;
05381 long int valin;
05382 int ix,iy,iz,phtodo;
05383 long int nadd;
05384 char filei[80];
05385 FILE *infile;
05386
05387
05388
05389
05390 nseed=iseed;
05391 seed=(&nseed);
05392
05393 #ifdef PRINTF
05394 printf("Seed %d\n", *seed);
05395 #endif
05396
05397
05398 F->get_value(13, (long &)read_micr);
05399
05400
05401 if(read_micr){
05402
05403 #ifdef PRINTF
05404 printf("Enter name of file to read initial microstructure from \n");
05405 #endif
05406
05407 F->get_value(1,filei);
05408
05409
05410 #ifdef PRINTF
05411 printf("%s\n",filei);
05412 fflush(stdout);
05413 #endif
05414 }
05415
05416
05417
05418
05419 #ifdef PRINTF
05420 printf("Enter IDs in file for C3S, C2S, C3A, C4AF, Gypsum, Hemihydrate, Anhydrite, Aggregate, CaCO3\n");
05421 #endif
05422
05423 fidc3s=C3S;
05424 fidc2s=C2S;
05425 fidc3a=C3A;
05426 fidc4af=C4AF;
05427 fidgyp=GYPSUM;
05428 fidhem=HEMIHYD;
05429 fidanh=ANHYDRITE;
05430 fidagg=INERTAGG;
05431 fidcaco3=CACO3;
05432
05433
05434 #ifdef PRINTF
05435 printf("%d %d %d %d %d %d %d %d %d\n",fidc3s,fidc2s,fidc3a,fidc4af,fidgyp,fidhem,fidanh,fidagg,fidcaco3);
05436 printf("Enter ID in file for C3A in fly ash (default=35)\n");
05437 #endif
05438
05439 ffac3a=35;
05440 #ifdef PRINTF
05441 printf("%d\n",ffac3a);
05442 #endif
05443 fflush(stdout);
05444
05445 if(read_micr){
05446
05447 if((infile=fopen(filei,"r"))==NULL){
05448 printf("CEMHYD3D microstructure file %s not found\n", filei);
05449 exit(0);
05450 }
05451
05452 for(iz=0;iz<SYSIZE;iz++){
05453 for(iy=0;iy<SYSIZE;iy++){
05454 for(ix=0;ix<SYSIZE;ix++){
05455 cshage[ix][iy][iz]=0;
05456 faces[ix][iy][iz]=0;
05457
05458 if(fscanf(infile,"%ld",&valin)==EOF){
05459 printf("End of file %s reached, terminating\n", filei);
05460 exit(1);
05461 }
05462
05463 if(valin<0){
05464 printf("Error in the reading at x=%d y=%d z=%d, value %ld\n", ix,iy,iz,valin);
05465 exit(1);
05466 }
05467 mic[ix][iy][iz]=valin;
05468 if(valin==fidc3s){
05469 mic[ix][iy][iz]=C3S;
05470 }
05471 else if(valin==fidc2s){
05472 mic[ix][iy][iz]=C2S;
05473 }
05474 else if((valin==fidc3a)||(valin==ffac3a)){
05475 mic[ix][iy][iz]=C3A;
05476 }
05477 else if(valin==fidc4af){
05478 mic[ix][iy][iz]=C4AF;
05479 }
05480 else if(valin==fidgyp){
05481 mic[ix][iy][iz]=GYPSUM;
05482 }
05483 else if(valin==fidanh){
05484 mic[ix][iy][iz]=ANHYDRITE;
05485 }
05486 else if(valin==fidhem){
05487 mic[ix][iy][iz]=HEMIHYD;
05488 }
05489 else if(valin==fidcaco3){
05490 mic[ix][iy][iz]=CACO3;
05491 }
05492 else if(valin==fidagg){
05493 mic[ix][iy][iz]=INERTAGG;
05494 }
05495 micorig[ix][iy][iz]=mic[ix][iy][iz];
05496 }
05497 }
05498 }
05499 fclose(infile);
05500 }
05501 else{
05502
05503 #ifdef PRINTF
05504 printf("Generated microstructure from memory will be used\n");
05505 #endif
05506 }
05507
05508 fflush(stdout);
05509
05510
05511 if(read_micr){
05512
05513 #ifdef PRINTF
05514 printf("Enter name of file to read particle IDs from \n");
05515 #endif
05516
05517 F->get_value(2,filei);
05518
05519
05520 #ifdef PRINTF
05521 printf("%s\n",filei);
05522 #endif
05523
05524 if((infile=fopen(filei,"r"))==NULL){
05525 printf("CEMHYD3D microstructure ID file %s not found\n", filei);
05526 exit(0);
05527 }
05528 for(iz=0;iz<SYSIZE;iz++){
05529 for(iy=0;iy<SYSIZE;iy++){
05530 for(ix=0;ix<SYSIZE;ix++){
05531
05532 if(fscanf(infile,"%ld",&valin)==EOF){
05533 printf("End of file %s reached, terminating\n", filei);
05534 exit(1);
05535 }
05536 micpart[ix][iy][iz]=valin;
05537 }
05538 }
05539 }
05540
05541 fclose(infile);
05542 }
05543 else{
05544 #ifdef PRINTF
05545 printf("Generated microstructure ID from memory will be used\n");
05546 #endif
05547 }
05548
05549
05550 fflush(stdout);
05551
05552
05553
05554
05555 #ifdef PRINTF
05556 printf("Enter number of one pixel particles to add (0 to quit) \n");
05557 #endif
05558
05559 nadd=0;
05560
05561 #ifdef PRINTF
05562 printf("%ld\n",nadd);
05563 #endif
05564
05565 while(nadd>0){
05566 #ifdef PRINTF
05567 printf("Enter phase to add \n");
05568 printf(" C3S 1 \n");
05569 printf(" C2S 2 \n");
05570 printf(" C3A 3 \n");
05571 printf(" C4AF 4 \n");
05572 printf(" GYPSUM 5 \n");
05573 printf(" HEMIHYD 6 \n");
05574 printf(" ANHYDRITE 7 \n");
05575 printf(" POZZ 8 \n");
05576 printf(" INERT 9 \n");
05577 printf(" SLAG 10 \n");
05578 printf(" ASG 11 \n");
05579 printf(" CAS2 12 \n");
05580 printf(" CH 13 \n");
05581 printf(" CSH 14 \n");
05582 printf(" C3AH6 15 \n");
05583 printf(" Ettringite 16 \n");
05584 printf(" Stable Ettringite from C4AF 17 \n");
05585 printf(" AFM 18 \n");
05586 printf(" FH3 19 \n");
05587 printf(" POZZCSH 20 \n");
05588 printf(" SLAGCSH 21 \n");
05589 printf(" CACL2 22 \n");
05590 printf(" Friedels salt 23 \n");
05591 printf(" Stratlingite 24 \n");
05592 printf(" Calcium carbonate 26 \n");
05593 #endif
05594
05595 phtodo=0;
05596 #ifdef PRINTF
05597 printf("%d \n",phtodo);
05598 #endif
05599 if((phtodo<0)||(phtodo>CACO3)){
05600 printf("Error in phase input for one pixel particles \n");
05601 exit(1);
05602 }
05603 addrand(phtodo,nadd);
05604
05605 #ifdef PRINTF
05606 printf("Enter number of one pixel particles to add (0 to quit) \n");
05607 #endif
05608
05609
05610 nadd=0;
05611 #ifdef PRINTF
05612 printf("%ld\n",nadd);
05613 #endif
05614 }
05615 fflush(stdout);
05616
05617
05618 F->get_value(3,(long &)sealed);
05619
05620
05621
05622
05623 F->get_value(23,(long &)ntimes);
05624
05625
05626
05627
05628 F->get_value(24,pnucch);
05629 F->get_value(25,pscalech);
05630
05631
05632
05633
05634
05635 F->get_value(26,pnucgyp);
05636 F->get_value(27,pscalegyp);
05637
05638
05639
05640
05641
05642 F->get_value(28,pnuchg);
05643 F->get_value(29,pscalehg);
05644
05645
05646
05647
05648
05649 F->get_value(30,pnucfh3);
05650 F->get_value(31,pscalefh3);
05651
05652
05653
05654
05655
05656 F->get_value(17,(long &)burnfreq);
05657 F->get_value(33, adiabatic_curing);
05658 #ifdef PRINTF
05659 printf("Enter cycle frequency for checking percolation of solids (set) \n");
05660 printf("%d\n",burnfreq);
05661 printf("Adiabatic curing conditions %ld\n",adiabatic_curing);
05662 #endif
05663
05664 F->get_value(18,(long &)setfreq);
05665
05666 #ifdef PRINTF
05667 printf("Enter cycle frequency for checking hydration of particles \n");
05668 printf("%d\n",setfreq);
05669 #endif
05670
05671 phydfreq=50000;
05672
05673
05674
05675 outfreq=50000;
05676
05677
05678 F->get_value(4,ind_time);
05679
05680
05681 time_cur+=ind_time;
05682
05683
05684 U_coeff=0;
05685 #ifdef PRINTF
05686 printf("Enter apparent activation energy for hydration in kJ/mole \n");
05687 #endif
05688 F->get_value(5,E_act);
05689
05690 #ifdef PRINTF
05691 printf("%f \n",E_act);
05692 printf("Enter apparent activation energy for pozzolanic reactions in kJ/mole \n");
05693 #endif
05694 F->get_value(6,E_act_pozz);
05695
05696 #ifdef PRINTF
05697 printf("%f \n",E_act_pozz);
05698 printf("Enter apparent activation energy for slag reactions in kJ/mole \n");
05699 #endif
05700 F->get_value(7,E_act_slag);
05701
05702 #ifdef PRINTF
05703 printf("%f \n",E_act_slag);
05704 printf("Enter kinetic factor to convert cycles to time for 25 C \n");
05705 #endif
05706 F->get_value(8,beta);
05707
05708 #ifdef PRINTF
05709 printf("%f \n",beta);
05710 printf("Enter mass fraction of aggregate in concrete \n");
05711 #endif
05712 F->get_value(9,mass_agg);
05713
05714 #ifdef PRINTF
05715 printf("%f \n",mass_agg);
05716 printf("Enter kg of cement (+admixtures) in 1 m3\n");
05717 #endif
05718 F->get_value(10,cem_m3);
05719
05720 #ifdef PRINTF
05721 printf("%f \n",cem_m3);
05722 printf("Enter heat capacity of aggregate in concrete J/g/C\n");
05723 #endif
05724 F->get_value(11,Cp_agg);
05725
05726 #ifdef PRINTF
05727 printf("%f \n",Cp_agg);
05728 printf("Enter heat capacity of cement J/g/C\n");
05729 #endif
05730 F->get_value(12,Cp_cement);
05731
05732 #ifdef PRINTF
05733 printf("%f \n",Cp_cement);
05734 printf("CSH to pozzolanic CSH 0) prohibited or 1) allowed \n");
05735 #endif
05736
05737 csh2flag=0;
05738 #ifdef PRINTF
05739 printf("%d \n",csh2flag);
05740 printf("CH precipitation on aggregate surfaces 0) prohibited or 1) allowed \n");
05741 #endif
05742
05743 chflag=0;
05744 #ifdef PRINTF
05745 printf("%d \n",chflag);
05746 printf("Enter number of cycles before executing total resaturation \n");
05747 #endif
05748
05749 resatcyc=0;
05750 #ifdef PRINTF
05751 printf("%d\n",resatcyc);
05752 printf("Enter choice for C-S-H geometry 0) random or 1) plates \n");
05753 #endif
05754
05755 cshgeom=0;
05756 #ifdef PRINTF
05757 printf("%d \n",cshgeom);
05758 printf("Does pH influence hydration kinetics 0) no or 1) yes \n");
05759 #endif
05760
05761 pHactive=0;
05762 #ifdef PRINTF
05763 printf("%d\n",pHactive);
05764 #endif
05765 F->get_value( 34,Vol_cement_clinker_gypsum );
05766 F->get_value( 35,Vol_cement_SCM );
05767 F->get_value( 36,Vol_water );
05768 F->get_value( 37,Vol_FA );
05769 F->get_value( 38,Vol_CA );
05770 F->get_value( 39,Vol_inert_filler );
05771 F->get_value( 40,Vol_entrained_entrapped_air );
05772 F->get_value( 41,Grain_average_FA );
05773 F->get_value( 42,Grain_average_CA );
05774 F->get_value( 43,ITZ_thickness );
05775 F->get_value( 44,ITZ_Young_red );
05776 F->get_value( 45,Young_SCM );
05777 F->get_value( 46,Poisson_SCM );
05778 F->get_value( 47,Young_FA );
05779 F->get_value( 48,Poisson_FA );
05780 F->get_value( 49,Young_CA );
05781 F->get_value( 50,Poisson_CA );
05782 F->get_value( 51,Young_inert );
05783 F->get_value( 52,Poisson_inert );
05784 F->get_value( 53,Calculate_elastic_homogenization );
05785 }
05786
05787
05788
05789 void cemhydmat::disrealnew_init(void)
05790 {
05791 #ifdef OUTFILES
05792 char fileo[80];
05793 #endif
05794
05795 nseed=iseed;
05796 seed=&nseed;
05797
05798 ncshplategrow=0;
05799 ncshplateinit=0;
05800 slagemptyp=0;
05801 countpore=0;
05802 time_step=0.0;
05803 w_to_c=0.0;
05804 totfract=1.0;
05805 tfractw04=0.438596;
05806 fractwithfill=1.0;
05807 tfractw05=0.384615;
05808 surffract=0.0;
05809 pfractw05=0.615385;
05810 scntcement=0;
05811 scnttotal=0;
05812 saturation=1.0;
05813 cs_acc=1.0;
05814 ca_acc=1.0;
05815 dismin_c3a=DISMIN_C3A_0;
05816 dismin_c4af=DISMIN_C4AF_0;
05817 gsratio2=0.0;
05818 onepixelbias=1.0;
05819 DIFFCHdeficit=0;
05820 slaginit=0;
05821 slagcum=0;
05822 chgone=0;
05823 nch_slag=0;
05824 sulf_cur=0;
05825 pHfactor=0.0;
05826 conccaplus=0.0;
05827 moles_syn_precip=0.0;
05828 concsulfate=0.0;
05829
05830 primevalues[0]=2;
05831 primevalues[1]=3;
05832 primevalues[2]=5;
05833 primevalues[3]=7;
05834 primevalues[4]=11;
05835 primevalues[5]=13;
05836
05837 ngoing=0;
05838 porefl1=porefl2=porefl3=1;
05839 pore_off=water_off=0;
05840 cycflag=0;
05841 heat_old=heat_new=0.0;
05842 chold=chnew=0;
05843 cubesize=CUBEMAX;
05844 ppozz=PPOZZ;
05845 poregone=poretodo=0;
05846
05847
05848 npr=nasr=nslagr=0;
05849 nfill=0;
05850 ncsbar=0;
05851 netbar=0;
05852 porinit=0;
05853 cyccnt=0;
05854 setflag=0;
05855 c3sinit=c2sinit=c3ainit=c4afinit=anhinit=heminit=slaginit=0;
05856
05857
05858 headant=(struct ants *)malloc(sizeof(struct ants));
05859 headant->prevant=NULL;
05860 headant->nextant=NULL;
05861 headant->x=0;
05862 headant->y=0;
05863 headant->z=0;
05864 headant->id=100;
05865 headant->cycbirth=0;
05866 tailant=headant;
05867
05868 LastHydrTime=0.;
05869 LastCycHeat=0.;
05870 LastTotHeat=0.;
05871 LastCycCnt=0;
05872 PrevHydrTime=0.;
05873 PrevCycHeat=0.;
05874
05875
05876 init();
05877 #ifdef PRINTF
05878 printf("After init routine \n");
05879 #endif
05880 fflush(stdout);
05881
05882
05883
05884 #ifdef OUTFILES
05885 fileperc=fopen("percpore.out","w");
05886
05887 fprintf(fileperc, "#cycle alpha_burn #through #tot_phase\n");
05888 disprobfile=fopen("disprob.out","w");
05889 percfile=fopen("percset.out","w");
05890 fprintf(percfile, "#cycle time alpha_burn #through #C3S+C2S+C3A+C4AF+CAS2+SLAG+ASG+POZZ+ETTR+ETTRC4AF+CSH conn_frac\n");
05891 strcpy(heatname,"heat.out");
05892 heatfile=fopen(heatname,"w");
05893 strcpy(chshrname,"chemshr.out");
05894
05895 strcpy(adianame,"adiabatic.out");
05896 strcpy(pHname,"pHfile.out");
05897 pHfile=fopen(pHname,"w");
05898 fprintf(pHfile,"Cycle time(h) alpha_mass pH sigma [Na+] [K+] [Ca++] [SO4--] activityCa activityOH activitySO4 activityK molesSyngenite\n");
05899 strcpy(fileo,"out5.img");
05900 strcpy(phasname,"phases.out");
05901 phasfile=fopen(phasname,"w");
05902 strcpy(ppsname,"percpore.out");
05903 strcpy(phrname,"parthydr.out");
05904 perc_phases=fopen("perc_phases.out","w");
05905 adiafile=fopen(adianame,"w");
05906 fprintf(adiafile,"Cyc Time(h) Temperature Alpha Krate Cp_now Mass_cem kpozz/khyd kslag/khyd\n");
05907 elasfile=fopen("elas.out","w");
05908 fprintf(elasfile,"Cyc\tTime[h] Alpha E_paste nu_paste E_paste_fil nu_paste_fil E_mortar nu_mortar E_concrete nu_concrete\n");
05909 CSHfile=fopen("CSH.out", "w");
05910 fprintf(CSHfile, "cyc alpha [h] HD CSH-total\n");
05911 #endif
05912
05913
05914 molarvcsh[0]=molarv[CSH];
05915 watercsh[0]=waterc[CSH];
05916
05917 krate=exp(-(1000.*E_act/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
05918
05919 kpozz=exp(-(1000.*E_act_pozz/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
05920 kslag=exp(-(1000.*E_act_slag/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
05921 ppozz=PPOZZ*kpozz/krate;
05922
05923 disprob[ASG]=disbase[ASG]*kpozz/krate;
05924 disprob[CAS2]=disbase[CAS2]*kpozz/krate;
05925
05926 disprob[SLAG]=slagreact*disbase[SLAG]*kslag/krate;
05927
05928
05929
05930 measuresurf();
05931 }
05932
05933
05934
05935
05936
05937
05938
05939 void cemhydmat::disrealnew(double GiveTemp, double TargTime, int flag){
05940 int counter=0;
05941
05942 if(adiabatic_curing != 1){
05943 temp_cur=GiveTemp;
05944 temp_0=GiveTemp;
05945 }
05946
05947 InitTime=time_cur;
05948
05949 if(icyc==1){
05950 temp_cur=GiveTemp;
05951 temp_0=GiveTemp;
05952 disrealnew_init();
05953 }
05954
05955
05956
05957
05958
05959
05960 while(flag==0 ? (time_cur<TargTime) : counter<flag){
05961
05962 alpha_last = alpha_cur;
05963
05964
05965
05966 PrevHydrTime=time_cur*3600.;
05967 PrevCycHeat=(double)(heat_new)*heat_cf;
05968
05969 if((sealed==1)&&(icyc==(resatcyc+1))&&(resatcyc!=0)){
05970 resaturate();
05971 sealed=0;
05972 }
05973 if(temp_cur<=80.0){
05974 molarvcsh[icyc]=molarv[CSH]-8.0*((temp_cur-20.)/(80.-20.));
05975 watercsh[icyc]=waterc[CSH]-1.3*((temp_cur-20.)/(80.-20.));
05976 }
05977 else{
05978 molarvcsh[icyc]=molarv[CSH]-8.0;
05979 watercsh[icyc]=waterc[CSH]-1.3;
05980 }
05981
05982 dissolve(icyc);
05983 #ifdef OUTFILES
05984
05985
05986 fflush(stdout);
05987 if(icyc==1){
05988
05989 }
05990 #endif
05991
05992 hydrate(cycflag,ntimes,pnucch,pscalech,pnuchg,pscalehg,pnucfh3,pscalefh3,pnucgyp,pscalegyp);
05993 temp_0=temp_cur;
05994
05995
05996
05997 mass_cement=1.-mass_agg-mass_fill-mass_water-mass_CH;
05998 mass_cem_now=mass_cement;
05999
06000
06001
06002 if(sealed==1){
06003 Cp_now=mass_agg*Cp_agg;
06004 Cp_now+=Cp_pozz*mass_fill;
06005 Cp_now+=Cp_cement*mass_cement;
06006 Cp_now+=Cp_CH*mass_CH;
06007 Cp_now+=(Cp_h2o*mass_water-alpha_cur*WN*mass_cement*(Cp_h2o-Cp_bh2o));
06008 mass_cem_now=mass_cement;
06009 }
06010
06011
06012
06013 else{
06014 mass_cur=1.+WCHSH*mass_cement*alpha_cur;
06015 Cp_now=mass_agg*Cp_agg/mass_cur;
06016 Cp_now+=Cp_pozz*mass_fill/mass_cur;
06017 Cp_now+=Cp_cement*mass_cement/mass_cur;
06018 Cp_now+=Cp_CH*mass_CH/mass_cur;
06019 Cp_now+=(Cp_h2o*mass_water-alpha_cur*WN*mass_cement*(Cp_h2o-Cp_bh2o));
06020 Cp_now+=(WCHSH*Cp_h2o*alpha_cur*mass_cement);
06021 mass_cem_now=mass_cement/mass_cur;
06022 }
06023
06024
06025
06026 krate=exp(-(1000.*E_act/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
06027
06028 kpozz=exp(-(1000.*E_act_pozz/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
06029 kslag=exp(-(1000.*E_act_slag/8.314)*((1./(temp_cur+273.15))-(1./298.15)));
06030
06031
06032 ppozz=PPOZZ*kpozz/krate;
06033 disprob[ASG]=disbase[ASG]*kpozz/krate;
06034 disprob[CAS2]=disbase[CAS2]*kpozz/krate;
06035 disprob[SLAG]=slagreact*disbase[SLAG]*kslag/krate;
06036
06037
06038 if(adiabatic_curing == 1){
06039 if(mass_cem_now>0.01){
06040 temp_cur=temp_0+mass_cem_now*heat_cf*(heat_new-heat_old)/Cp_now;
06041 }
06042 else{
06043 temp_cur=temp_0+mass_fill_pozz*heat_cf*(heat_new-heat_old)/Cp_now;
06044 }
06045 }
06046
06047
06048
06049
06050
06051
06052
06053
06054 if(cyccnt>1){
06055 time_cur+=(2.*(double)(cyccnt-1)-1.0)*beta/krate;
06056 time_step=(2.*(double)(cyccnt-1)-1.0)*beta/krate;
06057 }
06058 gsratio2=0.0;
06059 gsratio2+=(float)(count[CH]+count[CSH]+count[C3AH6]+count[ETTR]);
06060 gsratio2+=(float)(count[POZZCSH]+count[SLAGCSH]+count[FH3]+count[AFM]+count[ETTRC4AF]);
06061 gsratio2+=(float)(count[FREIDEL]+count[STRAT]+count[ABSGYP]+count[AFMC]);
06062 gsratio2=(gsratio2)/(gsratio2+(float)(count[POROSITY]+count[EMPTYP]));
06063
06064
06065 #ifdef OUTFILES
06066 fprintf(adiafile,"%d \t %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",cyccnt,time_cur,temp_cur,alpha_cur,krate,Cp_now,mass_cem_now,kpozz/krate,kslag/krate);
06067 fprintf(heatfile,"%d %f %f %f %f %f %f \n",
06068 cyccnt-1,time_cur,alpha,alpha_cur,heat_new*heat_cf,gsratio2,((0.68*alpha_cur)/(0.32*alpha_cur+w_to_c)));
06069 fflush(adiafile);
06070 fflush(heatfile);
06071 #endif
06072
06073
06074
06075
06076
06077
06078
06079
06080
06081
06082 if(((icyc%burnfreq)==0)&&((porefl1+porefl2+porefl3)!=0)){
06083 porefl1=burn3d(0,1,0,0);
06084 porefl2=burn3d(0,0,1,0);
06085 porefl3=burn3d(0,0,0,1);
06086
06087
06088 if(((porefl1+porefl2+porefl3)==0)&&(sealed==0)){
06089 water_off=water_left;
06090 pore_off=countkeep;
06091 sealed=1;
06092 #ifdef PRINTF
06093 printf("Switching to self-desiccating at cycle %d \n",cyccnt);
06094 #endif
06095 fflush(stdout);
06096 }
06097 }
06098
06099
06100
06101
06102
06103
06104
06105
06106 if(((icyc%setfreq)==0)&&(setflag==0)){
06107 sf1=burnset(1,0,0);
06108 sf2=burnset(0,1,0);
06109 sf3=burnset(0,0,1);
06110 setflag=sf1*sf2*sf3;
06111 }
06112
06113
06114
06115 if((icyc%phydfreq)==0){
06116
06117 }
06118
06119 #ifdef OUTFILES
06120
06121 if(alpha_cur >= TargDoHelas){
06122
06123 if(TargDoHelas<0.1){
06124 TargDoHelas+=0.02;
06125 }
06126 else if(TargDoHelas<0.2){
06127 TargDoHelas+=0.05;
06128 }
06129 else{
06130 TargDoHelas+=0.05;
06131 }
06132
06133 double E_paste_SCM_filler_air, nu_paste_SCM_filler_air, E_mortar, nu_mortar;
06134
06135 CreateHDCSH();
06136 PercolateForOutput();
06137 AnalyticHomogenizationPaste(last_values[2], last_values[3],0);
06138 AnalyticHomogenizationConcrete(last_values[2], last_values[3], &E_paste_SCM_filler_air, &nu_paste_SCM_filler_air, &E_mortar, &nu_mortar, last_values[4], last_values[5]);
06139 fprintf(elasfile,"%d \t%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",cyccnt,time_cur,alpha_cur,last_values[2], last_values[3], E_paste_SCM_filler_air, nu_paste_SCM_filler_air, E_mortar, nu_mortar, last_values[4], last_values[5]);
06140 fflush(elasfile);
06141 }
06142 fprintf(CSHfile, "%d %.4f %.4f %ld %ld\n", icyc, alpha_cur, time_cur, count[HDCSH], count[CSH]);
06143 fflush(CSHfile);
06144 #endif
06145
06146 icyc++;
06147 counter++;
06148 }
06149 }
06150
06151
06152
06153
06154
06155
06156
06157
06158
06159
06160
06161
06162
06163
06164
06165
06166
06167
06168
06169
06170
06171
06172
06173 double cemhydmat::GetHeat(double GiveTemp, double TargTime){
06174
06175
06176 double PartHeat;
06177 TargTime_glob = TargTime;
06178 if(TargTime<LastCallTime){
06179 printf("Cannot go backwards in hydration, time_now = %f s < last_time = %f s\n", TargTime, LastCallTime);
06180 exit(0);
06181 }
06182
06183 if(GiveTemp > 200.){
06184 printf("Temperature exceeds 200 C (file %s, line %d),\n",__FILE__,__LINE__);
06185
06186 }
06187
06188
06189
06190
06191 disrealnew(GiveTemp, TargTime/3600.,0);
06192
06193 #ifdef PRINTF
06194 printf("\nheat_new %f\n", heat_new);
06195 printf("\nTime_cur%f\n", time_cur);
06196 printf("\nPrevHydrTime%f\n", PrevHydrTime/3600.);
06197 #endif
06198
06199 PartHeat=0.;
06200
06201 if(TargTime!=LastCallTime && TargTime!=0.){
06202 if(LastCycCnt-icyc){
06203
06204 PartHeat=(heat_new*heat_cf-PrevCycHeat)*(TargTime-PrevHydrTime)/(3600.*time_cur-PrevHydrTime);
06205
06206 PartHeat+=PrevCycHeat-LastCycHeat;
06207
06208 PartHeat+=LastCycHeat-LastTotHeat;
06209 }
06210 else{
06211 PartHeat=(LastCycHeat-LastTotHeat)*(TargTime-LastCallTime)/(LastHydrTime-LastCallTime);
06212 }
06213
06214 LastTotHeat+=PartHeat;
06215
06216 if(TargTime != LastCallTime){
06217
06218
06219 PartHeat*=cem_m3;
06220
06221 PartHeat/=(TargTime-LastCallTime);
06222 PartHeat*=1000;
06223 }
06224 }
06225
06226 LastCallTime=TargTime;
06227 LastHydrTime=time_cur*3600.;
06228 LastCycHeat=(double)(heat_new)*heat_cf;
06229 LastCycCnt=icyc;
06230
06231 return PartHeat;
06232 }
06233
06234
06235
06236 double cemhydmat::MoveCycles(double GiveTemp, int cycles){
06237 double PartHeat;
06238
06239 disrealnew(GiveTemp, -1., cycles);
06240
06241
06242
06243 PartHeat=heat_new*heat_cf-PrevCycHeat;
06244
06245 PartHeat+=PrevCycHeat-LastCycHeat;
06246
06247 PartHeat+=LastCycHeat-LastTotHeat;
06248
06249 LastTotHeat+=PartHeat;
06250
06251
06252
06253 PartHeat*=cem_m3;
06254
06255 PartHeat/=(3600.*time_cur-LastCallTime);
06256 PartHeat*=1000;
06257
06258 LastCallTime = 3600.*time_cur;
06259 LastHydrTime = 3600.*time_cur;
06260 LastCycHeat = (double)(heat_new)*heat_cf;
06261 LastCycCnt = icyc;
06262
06263 TargTime_glob = time_cur * 3600.;
06264 return time_cur;
06265 }
06266
06267
06268
06269 int cemhydmat::MoveToDoH(double GiveTemp, double DesiredDoH, int maxcyc){
06270
06271 int cycle=1;
06272
06273 while (alpha_cur < DesiredDoH){
06274 if(cycle>maxcyc){
06275 #ifdef PRINTF
06276 printf("Target DoH %f (now is %f) was not reached after %d cycles (%s, line %d)\n", DesiredDoH, alpha_cur, maxcyc, __FILE__,__LINE__);
06277 #endif
06278 return 1;
06279 }
06280 MoveCycles(GiveTemp, 1);
06281 cycle++;
06282 }
06283
06284 return 0;
06285 }
06286
06287
06288
06289
06290 int cemhydmat::MoveToTime(double GiveTemp, double TargTime){
06291 GetHeat(GiveTemp, 3600.*TargTime);
06292 return 0;
06293 }
06294
06295
06296
06297 double cemhydmat::GetTotCemHeat(void)
06298 {
06299 return LastTotHeat;
06300 }
06301
06302
06303 double cemhydmat::GetTotHeat(void)
06304 {
06305 return 1000*LastTotHeat*cem_m3;
06306 }
06307
06308
06309 double cemhydmat::GetCp(void)
06310 {
06311 return Cp_now;
06312 }
06313
06314
06315 double cemhydmat::GetDoHLastCyc(void)
06316 {
06317 return alpha_cur;
06318 }
06319
06320
06321 double cemhydmat::GetDoHActual(void)
06322 {
06323
06324 if (icyc <= 1){
06325 return 0;
06326 }
06327
06328 return alpha_last + (alpha_cur - alpha_last) * (TargTime_glob-PrevHydrTime)/(3600.*time_cur-PrevHydrTime);
06329 }
06330
06331
06332
06333 int cemhydmat::GetCycNum(void)
06334 {
06335 return icyc;
06336 }
06337
06338
06339 double cemhydmat::GetCycTime(void)
06340 {
06341 return time_cur;
06342 }
06343
06344
06345
06346
06347
06348
06349
06350
06351 int cemhydmat::burn3d(int npix, int d1, int d2, int d3)
06352
06353
06354 {
06355 long int ntop,nthrough,ncur,nnew,ntot,nphc;
06356 int i,inew,j,k;
06357 int xl,xh,j1,k1,px,py,pz,qx,qy,qz,xcn,ycn,zcn;
06358 int x1,y1,z1,igood;
06359 int *nmatx,*nmaty,*nmatz,*nnewx,*nnewy,*nnewz;
06360 int jnew,icur;
06361 int bflag;
06362 float mass_burn=0.0,alpha_burn=0.0;
06363
06364 nmatx = new int[SIZE2D];
06365 nmaty = new int[SIZE2D];
06366 nmatz = new int[SIZE2D];
06367 nnewx = new int[SIZE2D];
06368 nnewy = new int[SIZE2D];
06369 nnewz = new int[SIZE2D];
06370
06371
06372
06373
06374 ntop=0;
06375 bflag=0;
06376 nthrough=0;
06377 nphc=0;
06378
06379
06380
06381
06382
06383 i=0;
06384
06385 for(k=0;k<SYSIZE;k++){
06386 for(j=0;j<SYSIZE;j++){
06387
06388 igood=0;
06389 ncur=0;
06390 ntot=0;
06391
06392 px=cx(i,j,k,d1,d2,d3);
06393 py=cy(i,j,k,d1,d2,d3);
06394 pz=cz(i,j,k,d1,d2,d3);
06395 if(mic [px] [py] [pz]==npix){
06396
06397 mic [px] [py] [pz]=BURNT;
06398 ntot+=1;
06399 ncur+=1;
06400
06401
06402 nmatx[ncur]=i;
06403 nmaty[ncur]=j;
06404 nmatz[ncur]=k;
06405
06406 do{
06407 nnew=0;
06408 for(inew=1;inew<=ncur;inew++){
06409 xcn=nmatx[inew];
06410 ycn=nmaty[inew];
06411 zcn=nmatz[inew];
06412
06413
06414 for(jnew=1;jnew<=6;jnew++){
06415 x1=xcn;
06416 y1=ycn;
06417 z1=zcn;
06418 if(jnew==1) x1-=1;
06419 if(jnew==2) x1+=1;
06420 if(jnew==3) y1-=1;
06421 if(jnew==4) y1+=1;
06422 if(jnew==5) z1-=1;
06423 if(jnew==6) z1+=1;
06424
06425 if(y1>=SYSIZE) y1-=SYSIZE;
06426 else if(y1<0) y1+=SYSIZE;
06427
06428 if(z1>=SYSIZE) z1-=SYSIZE;
06429 else if(z1<0) z1+=SYSIZE;
06430
06431
06432 if((x1>=0)&&(x1<SYSIZE)){
06433
06434 px=cx(x1,y1,z1,d1,d2,d3);
06435 py=cy(x1,y1,z1,d1,d2,d3);
06436 pz=cz(x1,y1,z1,d1,d2,d3);
06437 if(mic [px] [py] [pz]==npix){
06438 ntot+=1;
06439 mic [px] [py] [pz]=BURNT;
06440 nnew+=1;
06441 if(nnew>=SIZE2D){
06442 printf("error in size of nnew \n");
06443 }
06444 nnewx[nnew]=x1;
06445 nnewy[nnew]=y1;
06446 nnewz[nnew]=z1;
06447 }
06448 }
06449 }
06450 }
06451 if(nnew>0){
06452 ncur=nnew;
06453
06454 for(icur=1;icur<=ncur;icur++){
06455 nmatx[icur]=nnewx[icur];
06456 nmaty[icur]=nnewy[icur];
06457 nmatz[icur]=nnewz[icur];
06458 }
06459 }
06460 }while (nnew>0);
06461
06462 ntop+=ntot;
06463 xl=0;
06464 xh=SYSIZE-1;
06465
06466 for(j1=0;j1<SYSIZE;j1++){
06467 for(k1=0;k1<SYSIZE;k1++){
06468 px=cx(xl,j1,k1,d1,d2,d3);
06469 py=cy(xl,j1,k1,d1,d2,d3);
06470 pz=cz(xl,j1,k1,d1,d2,d3);
06471 qx=cx(xh,j1,k1,d1,d2,d3);
06472 qy=cy(xh,j1,k1,d1,d2,d3);
06473 qz=cz(xh,j1,k1,d1,d2,d3);
06474 if((mic [px] [py] [pz]==BURNT)&&(mic [qx] [qy] [qz]==BURNT)){
06475 igood=2;
06476 }
06477 if(mic [px] [py] [pz]==BURNT){
06478 mic [px] [py] [pz]=BURNT+1;
06479 }
06480 if(mic [qx] [qy] [qz]==BURNT){
06481 mic [qx] [qy] [qz]=BURNT+1;
06482 }
06483 }
06484 }
06485
06486 if(igood==2){
06487 nthrough+=ntot;
06488 }
06489 }
06490 }
06491 }
06492
06493 for(i=0;i<SYSIZE;i++){
06494 for(j=0;j<SYSIZE;j++){
06495 for(k=0;k<SYSIZE;k++){
06496 if(mic [i] [j] [k]>=BURNT){
06497 nphc+=1;
06498 mic [i] [j] [k]=npix;
06499 }
06500 else if(mic[i][j][k]==npix){
06501 nphc+=1;
06502 }
06503 }
06504 }
06505 }
06506
06507 #ifdef PRINTF
06508 printf("Phase ID= %d \n",npix);
06509 printf("Number accessible from first surface = %ld \n",ntop);
06510 printf("Number contained in through pathways= %ld \n",nthrough);
06511 #endif
06512
06513
06514 mass_burn+=specgrav[C3S]*count[C3S];
06515 mass_burn+=specgrav[C2S]*count[C2S];
06516 mass_burn+=specgrav[C3A]*count[C3A];
06517 mass_burn+=specgrav[C4AF]*count[C4AF];
06518 alpha_burn=1.-(mass_burn/cemmass);
06519
06520 #ifdef OUTFILES
06521 fprintf(fileperc,"%d %f %ld %ld \n",cyccnt,alpha_burn,nthrough,nphc);
06522 fflush(fileperc);
06523 #endif
06524
06525 if(nthrough>0){
06526 bflag=1;
06527 }
06528
06529 delete [] nmatx;
06530 delete [] nmaty;
06531 delete [] nmatz;
06532 delete [] nnewx;
06533 delete [] nnewy;
06534 delete [] nnewz;
06535 return(bflag);
06536 }
06537
06538
06539
06540
06541
06542
06543
06544 int cemhydmat::burnset(int d1, int d2, int d3)
06545 {
06546 long int ntop,nthrough,icur,inew,ncur,nnew,ntot,count_solid;
06547 int i,j,k,setyet;
06548
06549 int *nmatx, *nmaty, *nmatz;
06550 int xl,xh,j1,k1,px,py,pz,qx,qy,qz;
06551 int xcn,ycn,zcn,x1,y1,z1,igood;
06552
06553 int *nnewx, *nnewy, *nnewz;
06554 int jnew;
06555 float mass_burn=0.0,alpha_burn=0.0,con_frac;
06556
06557 char ***newmat;
06558
06559 alloc_char_3D(newmat, SYSIZE);
06560 nmatx = new int[SIZESET];
06561 nmaty = new int[SIZESET];
06562 nmatz = new int[SIZESET];
06563 nnewx = new int[SIZESET];
06564 nnewy = new int[SIZESET];
06565 nnewz = new int[SIZESET];
06566
06567
06568
06569 ntop=0;
06570 nthrough=0;
06571 setyet=0;
06572 for(k=0;k<SYSIZE;k++){
06573 for(j=0;j<SYSIZE;j++){
06574 for(i=0;i<SYSIZE;i++){
06575 newmat[i][j][k]=mic[i][j][k];
06576 }
06577 }
06578 }
06579
06580
06581
06582
06583 i=0;
06584
06585 for(k=0;k<SYSIZE;k++){
06586 for(j=0;j<SYSIZE;j++){
06587
06588 igood=0;
06589 ncur=0;
06590 ntot=0;
06591
06592 px=cx(i,j,k,d1,d2,d3);
06593 py=cy(i,j,k,d1,d2,d3);
06594 pz=cz(i,j,k,d1,d2,d3);
06595
06596
06597 if((mic [px] [py] [pz]==C3S) ||
06598 (mic [px] [py] [pz]==C2S) ||
06599 (mic [px] [py] [pz]==SLAG) ||
06600 (mic [px] [py] [pz]==ASG) ||
06601 (mic [px] [py] [pz]==CAS2) ||
06602 (mic [px] [py] [pz]==POZZ) ||
06603 (mic [px] [py] [pz]==CSH) ||
06604 (mic [px] [py] [pz]==C3AH6) ||
06605 (mic [px] [py] [pz]==ETTR) ||
06606 (mic [px] [py] [pz]==ETTRC4AF) ||
06607 (mic [px] [py] [pz]==C3A) ||
06608 (mic [px] [py] [pz]==C4AF)){
06609
06610 mic [px] [py] [pz]=BURNT;
06611 ntot+=1;
06612 ncur+=1;
06613
06614
06615 nmatx[ncur]=i;
06616 nmaty[ncur]=j;
06617 nmatz[ncur]=k;
06618
06619 do{
06620 nnew=0;
06621 for(inew=1;inew<=ncur;inew++){
06622 xcn=nmatx[inew];
06623 ycn=nmaty[inew];
06624 zcn=nmatz[inew];
06625
06626 qx=cx(xcn,ycn,zcn,d1,d2,d3);
06627 qy=cy(xcn,ycn,zcn,d1,d2,d3);
06628 qz=cz(xcn,ycn,zcn,d1,d2,d3);
06629
06630
06631 for(jnew=1;jnew<=6;jnew++){
06632 x1=xcn;
06633 y1=ycn;
06634 z1=zcn;
06635 if(jnew==1){x1-=1;}
06636 if(jnew==2){x1+=1;}
06637 if(jnew==3){y1-=1;}
06638 if(jnew==4){y1+=1;}
06639 if(jnew==5){z1-=1;}
06640 if(jnew==6){z1+=1;}
06641
06642 if(y1>=SYSIZE){y1-=SYSIZE;}
06643 else if(y1<0){y1+=SYSIZE;}
06644
06645 if(z1>=SYSIZE){z1-=SYSIZE;}
06646 else if(z1<0){z1+=SYSIZE;}
06647
06648
06649 if((x1>=0)&&(x1<SYSIZE)){
06650 px=cx(x1,y1,z1,d1,d2,d3);
06651 py=cy(x1,y1,z1,d1,d2,d3);
06652 pz=cz(x1,y1,z1,d1,d2,d3);
06653
06654
06655 if((mic[px][py][pz]==CSH)||(mic[px][py][pz]==ETTRC4AF)||(mic[px][py][pz]==C3AH6)||(mic[px][py][pz]==ETTR)){
06656 ntot+=1;
06657 mic [px] [py] [pz]=BURNT;
06658 nnew+=1;
06659 if(nnew>=SIZESET){
06660 printf("error in size of nnew %ld\n", nnew);
06661 }
06662 nnewx[nnew]=x1;
06663 nnewy[nnew]=y1;
06664 nnewz[nnew]=z1;
06665 }
06666
06667 else if(((newmat[qx][qy][qz]==CSH)||(newmat[qx][qy][qz]==ETTRC4AF)||(newmat[qx][qy][qz]==C3AH6)||(newmat[qx][qy][qz]==ETTR))
06668 &&((mic [px] [py] [pz]==C3S) ||
06669 (mic [px] [py] [pz]==C2S) ||
06670 (mic [px] [py] [pz]==CAS2) ||
06671 (mic [px] [py] [pz]==SLAG) ||
06672 (mic [px] [py] [pz]==POZZ) ||
06673 (mic [px] [py] [pz]==ASG) ||
06674 (mic [px] [py] [pz]==C3A) ||
06675 (mic [px] [py] [pz]==C4AF))){
06676 ntot+=1;
06677 mic [px] [py] [pz]=BURNT;
06678 nnew+=1;
06679 if(nnew>=SIZESET){
06680 printf("error in size of nnew %ld\n", nnew);
06681 }
06682 nnewx[nnew]=x1;
06683 nnewy[nnew]=y1;
06684 nnewz[nnew]=z1;
06685 }
06686
06687
06688
06689 else if((micpart[qx][qy][qz]==micpart[px][py][pz])
06690 &&(micpart[qx][qy][qz]!=0)
06691 &&((mic [px] [py] [pz]==C3S) ||
06692 (mic [px] [py] [pz]==C2S) ||
06693 (mic [px] [py] [pz]==POZZ) ||
06694 (mic [px] [py] [pz]==SLAG) ||
06695 (mic [px] [py] [pz]==ASG) ||
06696 (mic [px] [py] [pz]==CAS2) ||
06697 (mic [px] [py] [pz]==C3A) ||
06698 (mic [px] [py] [pz]==C4AF))&&((newmat[qx][qy][qz]==C3S)||
06699 (newmat [qx] [qy] [qz]==C2S) ||
06700 (newmat [qx] [qy] [qz]==SLAG) ||
06701 (newmat [qx] [qy] [qz]==ASG) ||
06702 (newmat [qx] [qy] [qz]==POZZ) ||
06703 (newmat [qx] [qy] [qz]==CAS2) ||
06704 (newmat [qx] [qy] [qz]==C3A) ||
06705 (newmat[qx][qy][qz]==C4AF))){
06706 ntot+=1;
06707 mic [px] [py] [pz]=BURNT;
06708 nnew+=1;
06709 if(nnew>=SIZESET){
06710 printf("error in size of nnew %ld\n", nnew);
06711 }
06712 nnewx[nnew]=x1;
06713 nnewy[nnew]=y1;
06714 nnewz[nnew]=z1;
06715 }
06716 }
06717 }
06718 }
06719 if(nnew>0){
06720 ncur=nnew;
06721
06722 for(icur=1;icur<=ncur;icur++){
06723 nmatx[icur]=nnewx[icur];
06724 nmaty[icur]=nnewy[icur];
06725 nmatz[icur]=nnewz[icur];
06726 }
06727 }
06728 }while (nnew>0);
06729
06730 ntop+=ntot;
06731 xl=0;
06732 xh=SYSIZE-1;
06733
06734 for(j1=0;j1<SYSIZE;j1++){
06735 for(k1=0;k1<SYSIZE;k1++){
06736 px=cx(xl,j1,k1,d1,d2,d3);
06737 py=cy(xl,j1,k1,d1,d2,d3);
06738 pz=cz(xl,j1,k1,d1,d2,d3);
06739 qx=cx(xh,j1,k1,d1,d2,d3);
06740 qy=cy(xh,j1,k1,d1,d2,d3);
06741 qz=cz(xh,j1,k1,d1,d2,d3);
06742 if((mic [px] [py] [pz]==BURNT)&&(mic [qx] [qy] [qz]==BURNT)){
06743 igood=2;
06744 }
06745 if(mic [px] [py] [pz]==BURNT){
06746 mic [px] [py] [pz]=BURNT+1;
06747 }
06748 if(mic [qx] [qy] [qz]==BURNT){
06749 mic [qx] [qy] [qz]=BURNT+1;
06750 }
06751 }
06752 }
06753
06754 if(igood==2){
06755 nthrough+=ntot;
06756 }
06757 }
06758 }
06759 }
06760
06761 #ifdef PRINTF
06762 printf("Phase ID= Solid Phases \n");
06763 printf("Number accessible from first surface = %ld \n",ntop);
06764 printf("Number contained in through pathways= %ld \n",nthrough);
06765 #endif
06766
06767 mass_burn+=specgrav[C3S]*count[C3S];
06768 mass_burn+=specgrav[C2S]*count[C2S];
06769 mass_burn+=specgrav[C3A]*count[C3A];
06770 mass_burn+=specgrav[C4AF]*count[C4AF];
06771 alpha_burn=1.-(mass_burn/cemmass);
06772
06773 con_frac=0.0;
06774 count_solid=count[C3S]+count[C2S]+count[C3A]+count[C4AF]+count[ETTR]+count[CSH]+count[C3AH6]+count[ETTRC4AF]+count[POZZ]+count[ASG]+count[SLAG]+count[CAS2];
06775
06776 if(count_solid>0){
06777 con_frac=(float)nthrough/(float)count_solid;
06778 }
06779
06780 #ifdef OUTFILES
06781 fprintf(percfile,"%d %f %f %ld %ld %f\n",cyccnt,time_cur+(2.*(float)(cyccnt)-1.0)*beta/krate,alpha_burn,nthrough,count[C3S]+count[C2S]+count[C3A]+count[C4AF]+count[CAS2]+count[SLAG]+count[ASG]+count[POZZ]+count[ETTR]+count[C3AH6]+count[ETTRC4AF]+count[CSH],con_frac);
06782 fflush(percfile);
06783 #endif
06784
06785 if(con_frac>0.985){setyet=1;}
06786
06787
06788
06789
06790 for(i=0;i<SYSIZE;i++){
06791 for(j=0;j<SYSIZE;j++){
06792 for(k=0;k<SYSIZE;k++){
06793 if(mic [i] [j] [k]>=BURNT){
06794 mic [i] [j] [k]= newmat [i] [j] [k];
06795 }
06796 }
06797 }
06798 }
06799
06800 dealloc_char_3D(newmat, SYSIZE);
06801 delete [] nmatx;
06802 delete [] nmaty;
06803 delete [] nmatz;
06804 delete [] nnewx;
06805 delete [] nnewy;
06806 delete [] nnewz;
06807
06808
06809 return(setyet);
06810 }
06811
06812
06813
06814
06815 void cemhydmat::parthyd(void){
06816 int norig[100000],nleft[100000];
06817 int ix,iy,iz;
06818 char valmic,valmicorig;
06819 int valpart,partmax;
06820 float alpart;
06821 FILE *phydfile;
06822
06823
06824 for(ix=0;ix<100000;ix++){
06825 nleft[ix]=norig[ix]=0;
06826 }
06827 phydfile=fopen(phrname,"a");
06828 fprintf(phydfile,"%d %f\n",cyccnt,alpha_cur);
06829
06830 partmax=0;
06831
06832 for(ix=0;ix<SYSIZE;ix++){
06833 for(iy=0;iy<SYSIZE;iy++){
06834 for(iz=0;iz<SYSIZE;iz++){
06835
06836 if(micpart[ix][iy][iz]!=0){
06837 valpart=micpart[ix][iy][iz];
06838 if(valpart>partmax){partmax=valpart;}
06839 valmic=mic[ix][iy][iz];
06840 if((valmic==C3S)||(valmic==C2S)||(valmic==C3A)||(valmic==C4AF)){
06841 nleft[valpart]+=1;
06842 }
06843 valmicorig=micorig[ix][iy][iz];
06844 if((valmicorig==C3S)||(valmicorig==C2S)||(valmicorig==C3A)||(valmicorig==C4AF)){
06845 norig[valpart]+=1;
06846 }
06847 }
06848 }
06849 }
06850 }
06851
06852
06853 for(ix=100;ix<=partmax;ix++){
06854 alpart=0.0;
06855 if(norig[ix]!=0){
06856 alpart=1.-(float)nleft[ix]/(float)norig[ix];
06857 }
06858 fprintf(phydfile,"%d %d %d %.3f\n",ix,norig[ix],nleft[ix],alpart);
06859 }
06860 fclose(phydfile);
06861 }
06862
06863
06864
06865
06866 int cemhydmat::moveone(int *xloc, int *yloc,int *zloc,int *act, int sumold)
06867 {
06868 int plok,sumnew,xl1,yl1,zl1,act1;
06869
06870 sumnew=1;
06871
06872 xl1=(*xloc);
06873 yl1=(*yloc);
06874 zl1=(*zloc);
06875 act1=(*act);
06876
06877
06878
06879 plok=(int)(6.*ran1(seed));
06880 if((plok>5)||(plok<0)){plok=5;}
06881
06882 switch (plok){
06883 case 0:
06884 xl1-=1;
06885 act1=1;
06886 if(xl1<0){xl1=(SYSIZEM1);}
06887 if(sumold%2!=0){sumnew=2;}
06888 break;
06889 case 1:
06890 xl1+=1;
06891 act1=2;
06892 if(xl1>=SYSIZE){xl1=0;}
06893 if(sumold%3!=0){sumnew=3;}
06894 break;
06895 case 2:
06896 yl1-=1;
06897 act1=3;
06898 if(yl1<0){yl1=(SYSIZEM1);}
06899 if(sumold%5!=0){sumnew=5;}
06900 break;
06901 case 3:
06902 yl1+=1;
06903 act1=4;
06904 if(yl1>=SYSIZE){yl1=0;}
06905 if(sumold%7!=0){sumnew=7;}
06906 break;
06907 case 4:
06908 zl1-=1;
06909 act1=5;
06910 if(zl1<0){zl1=(SYSIZEM1);}
06911 if(sumold%11!=0){sumnew=11;}
06912 break;
06913 case 5:
06914 zl1+=1;
06915 act1=6;
06916 if(zl1>=SYSIZE){zl1=0;}
06917 if(sumold%13!=0){sumnew=13;}
06918 break;
06919 default:
06920 break;
06921 }
06922
06923
06924 *xloc=xl1;
06925 *yloc=yl1;
06926 *zloc=zl1;
06927 *act=act1;
06928
06929
06930 return(sumnew);
06931 }
06932
06933
06934
06935
06936
06937
06938
06939 int cemhydmat::edgecnt(int xck, int yck, int zck, int ph1, int ph2, int ph3)
06940 {
06941 int ixe,iye,ize,edgeback,x2,y2,z2,check;
06942
06943
06944 edgeback=0;
06945
06946
06947
06948 for(ixe=(-1);ixe<=1;ixe++){
06949 x2=xck+ixe;
06950 for(iye=(-1);iye<=1;iye++){
06951 y2=yck+iye;
06952 for(ize=(-1);ize<=1;ize++){
06953
06954 if((ixe!=0)||(iye!=0)||(ize!=0)){
06955 z2=zck+ize;
06956
06957 if(x2<0){x2=(SYSIZEM1);}
06958 else if(x2>=SYSIZE){x2=0;}
06959 if(y2<0){y2=(SYSIZEM1);}
06960 else if(y2>=SYSIZE){y2=0;}
06961 if(z2<0){z2=(SYSIZEM1);}
06962 else if(z2>=SYSIZE){z2=0;}
06963 check=mic[x2][y2][z2];
06964 if((check!=ph1)&&(check!=ph2)&&(check!=ph3)){
06965 edgeback+=1;
06966 }
06967 }
06968 }
06969 }
06970 }
06971
06972 return(edgeback);
06973 }
06974
06975
06976
06977
06978 void cemhydmat::extcsh(void)
06979 {
06980 int numnear,xchr,ychr,zchr,fchr,check,msface;
06981 long int tries;
06982
06983 fchr=0;
06984 tries=0;
06985
06986
06987 while(fchr==0){
06988 tries+=1;
06989
06990 xchr=(int)((float)SYSIZE*ran1(seed));
06991 ychr=(int)((float)SYSIZE*ran1(seed));
06992 zchr=(int)((float)SYSIZE*ran1(seed));
06993 if(xchr>=SYSIZE){xchr=0;}
06994 if(ychr>=SYSIZE){ychr=0;}
06995 if(zchr>=SYSIZE){zchr=0;}
06996 check=mic[xchr][ychr][zchr];
06997
06998
06999 if(check==POROSITY){
07000 numnear=edgecnt(xchr,ychr,zchr,CSH,C3S,C2S);
07001
07002
07003 if((numnear<26)||(tries>5000)){
07004 mic[xchr][ychr][zchr]=CSH;
07005 count[CSH]+=1;
07006 count[POROSITY]-=1;
07007 cshage[xchr][ychr][zchr]=cyccnt;
07008 if(cshgeom==1){
07009 msface=(int)(3.*ran1(seed)+1.);
07010 if(msface>3){msface=1;}
07011 faces[xchr][ychr][zchr]=msface;
07012 ncshplateinit+=1;
07013 }
07014 fchr=1;
07015 }
07016 }
07017 }
07018 }
07019
07020
07021
07022
07023
07024
07025
07026 int cemhydmat::movecsh(int xcur, int ycur, int zcur, int finalstep, int cycorig)
07027 {
07028 int xnew,ynew,znew,action,sumback,sumin,check;
07029 int msface,mstest = 0,mstest2 = 0;
07030 float prcsh,prcsh1,prcsh2,prtest;
07031
07032 action=0;
07033
07034 xnew=xcur;
07035 ynew=ycur;
07036 znew=zcur;
07037 sumin=1;
07038 sumback=moveone(&xnew,&ynew,&znew,&action,sumin);
07039 if(cshgeom==1){
07040
07041 if(xnew!=xcur){
07042 mstest=1;
07043 mstest2=2;
07044 }
07045 if(ynew!=ycur){
07046 mstest=2;
07047 mstest2=3;
07048 }
07049 if(znew!=zcur){
07050 mstest=3;
07051 mstest2=1;
07052 }
07053 }
07054
07055 if(action==0){printf("Error in value of action \n");}
07056 check=mic[xnew][ynew][znew];
07057
07058
07059
07060
07061 prcsh=ran1(seed);
07062 if((check==CSH)&&((cshgeom==0)||(faces[xnew][ynew][znew]==0)||(faces[xnew][ynew][znew]==mstest)||(faces[xnew][ynew][znew]==mstest2))){
07063
07064 count[DIFFCSH]-=1;
07065
07066 prtest=molarvcsh[cyccnt]/molarvcsh[cycorig];
07067 prcsh1=ran1(seed);
07068 if(prcsh1<=prtest){
07069 mic[xcur][ycur][zcur]=CSH;
07070 if(cshgeom==1){
07071 faces[xcur][ycur][zcur]=faces[xnew][ynew][znew];
07072 ncshplategrow+=1;
07073 }
07074 cshage[xcur][ycur][zcur]=cyccnt;
07075 count[CSH]+=1;
07076 }
07077 else{
07078 mic[xcur][ycur][zcur]=POROSITY;
07079 count[POROSITY]+=1;
07080 }
07081
07082 if(prtest>1.0){
07083 prcsh2=ran1(seed);
07084 if(prcsh2<(prtest-1.0)){
07085 extcsh();
07086 }
07087 }
07088 action=0;
07089 }
07090
07091 else if((check==SLAGCSH)||(check==POZZCSH)||(finalstep==1)||
07092 (((check==C3S)||(check==C2S))&&(prcsh<0.001))||
07093 (((check==C3A)||(check==C4AF))&&(prcsh<0.2))||
07094 ((check==CH)&&(prcsh<0.01))||
07095 (check==CACO3)||(check==INERT)){
07096
07097 count[DIFFCSH]-=1;
07098
07099 prtest=molarvcsh[cyccnt]/molarvcsh[cycorig];
07100 prcsh1=ran1(seed);
07101 if(prcsh1<=prtest){
07102 mic[xcur][ycur][zcur]=CSH;
07103 cshage[xcur][ycur][zcur]=cyccnt;
07104 if(cshgeom==1){
07105 msface=(int)(2.*ran1(seed)+1.);
07106 if(msface>2){msface=1;}
07107 if(msface==1){
07108 faces[xcur][ycur][zcur]=mstest;
07109 }
07110 else{
07111 faces[xcur][ycur][zcur]=mstest2;
07112 }
07113 ncshplateinit+=1;
07114 }
07115 count[CSH]+=1;
07116 }
07117 else{
07118 mic[xcur][ycur][zcur]=POROSITY;
07119 count[POROSITY]+=1;
07120 }
07121
07122 if(prtest>1.0){
07123 prcsh2=ran1(seed);
07124 if(prcsh2<(prtest-1.0)){
07125 extcsh();
07126 }
07127 }
07128 action=0;
07129 }
07130
07131 if(action!=0){
07132
07133 if(check==POROSITY){
07134 mic[xcur][ycur][zcur]=POROSITY;
07135 mic[xnew][ynew][znew]=DIFFCSH;
07136 }
07137 else{
07138
07139
07140 action=7;
07141 }
07142 }
07143 return(action);
07144 }
07145
07146
07147
07148
07149
07150 void cemhydmat::extfh3(int xpres, int ypres, int zpres)
07151 {
07152 int multf,numnear,sump,xchr,ychr,zchr,check,fchr,i1,newact;
07153 long int tries;
07154
07155
07156
07157
07158
07159 fchr=0;
07160 sump=1;
07161 for(i1=1;((i1<=500)&&(fchr==0)&&(sump!=30030));i1++){
07162
07163
07164 xchr=xpres;
07165 ychr=ypres;
07166 zchr=zpres;
07167 newact=0;
07168 multf=moveone(&xchr,&ychr,&zchr,&newact,sump);
07169 if(newact==0){printf("Error in value of newact in extfh3 \n");}
07170 check=mic[xchr][ychr][zchr];
07171
07172
07173
07174 if(check==POROSITY){
07175 mic[xchr][ychr][zchr]=FH3;
07176 count[FH3]+=1;
07177 count[POROSITY]-=1;
07178 fchr=1;
07179 }
07180 else{
07181 sump*=multf;
07182 }
07183 }
07184
07185
07186
07187 tries=0;
07188 while(fchr==0){
07189 tries+=1;
07190
07191 xchr=(int)((float)SYSIZE*ran1(seed));
07192 ychr=(int)((float)SYSIZE*ran1(seed));
07193 zchr=(int)((float)SYSIZE*ran1(seed));
07194 if(xchr>=SYSIZE){xchr=0;}
07195 if(ychr>=SYSIZE){ychr=0;}
07196 if(zchr>=SYSIZE){zchr=0;}
07197 check=mic[xchr][ychr][zchr];
07198
07199 if(check==POROSITY){
07200 numnear=edgecnt(xchr,ychr,zchr,FH3,FH3,DIFFFH3);
07201
07202
07203 if((numnear<26)||(tries>5000)){
07204 mic[xchr][ychr][zchr]=FH3;
07205 count[FH3]+=1;
07206 count[POROSITY]-=1;
07207 fchr=1;
07208 }
07209 }
07210 }
07211 }
07212
07213
07214
07215
07216
07217
07218
07219
07220
07221 int cemhydmat::extettr(int xpres, int ypres, int zpres, int etype)
07222 {
07223 int check,newact,multf,numnear,sump,xchr,ychr,zchr,fchr,i1;
07224 int numalum,numsil;
07225 float pneigh,ptest;
07226 long int tries;
07227
07228
07229
07230
07231 fchr=0;
07232 sump=1;
07233
07234
07235 for(i1=1;((i1<=1000)&&(fchr==0));i1++){
07236
07237
07238 xchr=xpres;
07239 ychr=ypres;
07240 zchr=zpres;
07241 newact=0;
07242 multf=moveone(&xchr,&ychr,&zchr,&newact,sump);
07243 if(newact==0){printf("Error in value of action \n");}
07244
07245 check=mic[xchr][ychr][zchr];
07246
07247
07248
07249
07250 if(check==POROSITY){
07251
07252 numsil=edgecnt(xchr,ychr,zchr,C3S,C2S,C3S);
07253 numsil=26-numsil;
07254 if(etype==0){
07255 numnear=edgecnt(xchr,ychr,zchr,ETTR,ETTR,ETTR);
07256 numalum=edgecnt(xchr,ychr,zchr,C3A,C3A,C3A);
07257 numalum=26-numalum;
07258 }
07259 else{
07260 numnear=edgecnt(xchr,ychr,zchr,ETTRC4AF,ETTRC4AF,ETTRC4AF);
07261 numalum=edgecnt(xchr,ychr,zchr,C4AF,C4AF,C4AF);
07262 numalum=26-numalum;
07263 }
07264 pneigh=(float)(numnear+1)/26.0;
07265 pneigh*=pneigh;
07266 if(numalum<=1){pneigh=0.0;}
07267 if(numalum>=2){pneigh+=0.5;}
07268 if(numalum>=3){pneigh+=0.25;}
07269 if(numalum>=5){pneigh+=0.25;}
07270 ptest=ran1(seed);
07271 if(numsil<1){
07272 if(pneigh>=ptest){
07273 if(etype==0){
07274 mic[xchr][ychr][zchr]=ETTR;
07275 count[ETTR]+=1;
07276 }
07277 else{
07278 mic[xchr][ychr][zchr]=ETTRC4AF;
07279 count[ETTRC4AF]+=1;
07280 }
07281 fchr=1;
07282 count[POROSITY]-=1;
07283 }
07284 }
07285 }
07286 }
07287
07288
07289
07290
07291 tries=0;
07292 while(fchr==0){
07293 tries+=1;
07294 newact=7;
07295
07296 xchr=(int)((float)SYSIZE*ran1(seed));
07297 ychr=(int)((float)SYSIZE*ran1(seed));
07298 zchr=(int)((float)SYSIZE*ran1(seed));
07299 if(xchr>=SYSIZE){xchr=0;}
07300 if(ychr>=SYSIZE){ychr=0;}
07301 if(zchr>=SYSIZE){zchr=0;}
07302
07303 check=mic[xchr][ychr][zchr];
07304
07305 if(check==POROSITY){
07306 numsil=edgecnt(xchr,ychr,zchr,C3S,C2S,C3S);
07307 numsil=26-numsil;
07308 if(etype==0){
07309 numnear=edgecnt(xchr,ychr,zchr,ETTR,C3A,C4AF);
07310 }
07311 else{
07312 numnear=edgecnt(xchr,ychr,zchr,ETTRC4AF,C3A,C4AF);
07313 }
07314
07315
07316 if((tries>5000)||((numnear<26)&&(numsil<1))){
07317 if(etype==0){
07318 mic[xchr][ychr][zchr]=ETTR;
07319 count[ETTR]+=1;
07320 }
07321 else{
07322 mic[xchr][ychr][zchr]=ETTRC4AF;
07323 count[ETTRC4AF]+=1;
07324 }
07325 count[POROSITY]-=1;
07326 fchr=1;
07327 }
07328 }
07329 }
07330 return(newact);
07331 }
07332
07333
07334
07335
07336
07337 void cemhydmat::extch(void)
07338 {
07339 int numnear,xchr,ychr,zchr,fchr,check;
07340 long int tries;
07341
07342 fchr=0;
07343 tries=0;
07344
07345
07346 while(fchr==0){
07347 tries+=1;
07348
07349 xchr=(int)((float)SYSIZE*ran1(seed));
07350 ychr=(int)((float)SYSIZE*ran1(seed));
07351 zchr=(int)((float)SYSIZE*ran1(seed));
07352 if(xchr>=SYSIZE){xchr=0;}
07353 if(ychr>=SYSIZE){ychr=0;}
07354 if(zchr>=SYSIZE){zchr=0;}
07355 check=mic[xchr][ychr][zchr];
07356
07357
07358 if(check==POROSITY){
07359 numnear=edgecnt(xchr,ychr,zchr,CH,DIFFCH,CH);
07360
07361
07362 if((numnear<26)||(tries>5000)){
07363 mic[xchr][ychr][zchr]=CH;
07364 count[CH]+=1;
07365 count[POROSITY]-=1;
07366 fchr=1;
07367 }
07368 }
07369 }
07370 }
07371
07372
07373
07374
07375 void cemhydmat::extgyps(int xpres, int ypres, int zpres)
07376 {
07377 int multf,numnear,sump,xchr,ychr,zchr,check,fchr,i1,newact;
07378 long int tries;
07379
07380
07381
07382
07383
07384 fchr=0;
07385 sump=1;
07386 for(i1=1;((i1<=500)&&(fchr==0)&&(sump!=30030));i1++){
07387
07388
07389 xchr=xpres;
07390 ychr=ypres;
07391 zchr=zpres;
07392 newact=0;
07393 multf=moveone(&xchr,&ychr,&zchr,&newact,sump);
07394 if(newact==0){printf("Error in value of newact in extfh3 \n");}
07395 check=mic[xchr][ychr][zchr];
07396
07397
07398
07399 if(check==POROSITY){
07400 mic[xchr][ychr][zchr]=GYPSUMS;
07401 count[GYPSUMS]+=1;
07402 count[POROSITY]-=1;
07403 fchr=1;
07404 }
07405 else{
07406 sump*=multf;
07407 }
07408 }
07409
07410
07411
07412 tries=0;
07413 while(fchr==0){
07414 tries+=1;
07415
07416 xchr=(int)((float)SYSIZE*ran1(seed));
07417 ychr=(int)((float)SYSIZE*ran1(seed));
07418 zchr=(int)((float)SYSIZE*ran1(seed));
07419 if(xchr>=SYSIZE){xchr=0;}
07420 if(ychr>=SYSIZE){ychr=0;}
07421 if(zchr>=SYSIZE){zchr=0;}
07422 check=mic[xchr][ychr][zchr];
07423
07424 if(check==POROSITY){
07425 numnear=edgecnt(xchr,ychr,zchr,HEMIHYD,GYPSUMS,ANHYDRITE);
07426
07427
07428 if((numnear<26)||(tries>5000)){
07429 mic[xchr][ychr][zchr]=GYPSUMS;
07430 count[GYPSUMS]+=1;
07431 count[POROSITY]-=1;
07432 fchr=1;
07433 }
07434 }
07435 }
07436 }
07437
07438
07439
07440
07441
07442
07443
07444 int cemhydmat::moveanh(int xcur, int ycur, int zcur, int finalstep, float nucprgyp)
07445 {
07446 int xnew,ynew,znew,action,sumback,sumin,check = -1;
07447 int nexp,iexp,xexp,yexp,zexp,newact,ettrtype;
07448 float pgen,pexp,pext,p2diff;
07449
07450 action=0;
07451
07452 pgen=ran1(seed);
07453 p2diff=ran1(seed);
07454 if((nucprgyp>=pgen)||(finalstep==1)){
07455 action=0;
07456 mic[xcur][ycur][zcur]=GYPSUMS;
07457 count[DIFFANH]-=1;
07458 count[GYPSUMS]+=1;
07459 pexp=ran1(seed);
07460 if(pexp<0.4){
07461 extgyps(xcur,ycur,zcur);
07462 }
07463 }
07464 else{
07465
07466 xnew=xcur;
07467 ynew=ycur;
07468 znew=zcur;
07469 sumin=1;
07470 sumback=moveone(&xnew,&ynew,&znew,&action,sumin);
07471
07472 if(action==0){printf("Error in value of action \n");}
07473 check=mic[xnew][ynew][znew];
07474
07475
07476
07477 if((check==GYPSUM)||(check==GYPSUMS)||(check==DIFFGYP)){
07478 mic[xcur][ycur][zcur]=GYPSUMS;
07479
07480
07481 count[DIFFANH]-=1;
07482 count[GYPSUMS]+=1;
07483 action=0;
07484
07485 pexp=ran1(seed);
07486 if(pexp<0.4){
07487 extgyps(xnew,ynew,znew);
07488 }
07489 }
07490
07491
07492 else if(((check==C3A)&&(p2diff<SOLIDC3AGYP))||((check==DIFFC3A)&&(p2diff<C3AGYP))||((check==DIFFC4A)&&(p2diff<C3AGYP))){
07493
07494 ettrtype=0;
07495 mic[xcur][ycur][zcur]=ETTR;
07496 if(check==DIFFC4A){
07497 ettrtype=1;
07498 mic[xcur][ycur][zcur]=ETTRC4AF;
07499 }
07500 action=0;
07501 count[DIFFANH]-=1;
07502 count[check]-=1;
07503
07504
07505
07506
07507 pexp=ran1(seed);
07508 nexp=3;
07509 if(pexp<=0.569){
07510 if(ettrtype==0){
07511 mic[xnew][ynew][znew]=ETTR;
07512 count[ETTR]+=1;
07513 }
07514 else{
07515 mic[xnew][ynew][znew]=ETTRC4AF;
07516 count[ETTRC4AF]+=1;
07517 }
07518 nexp=2;
07519 }
07520 else{
07521
07522
07523 if(check==C3A){
07524 mic[xnew][ynew][znew]=C3A;
07525 count[C3A]+=1;
07526 }
07527 else{
07528 if(ettrtype==0){
07529 count[DIFFC3A]+=1;
07530 mic[xnew][ynew][znew]=DIFFC3A;
07531 }
07532 else{
07533 count[DIFFC4A]+=1;
07534 mic[xnew][ynew][znew]=DIFFC4A;
07535 }
07536 }
07537 nexp=3;
07538 }
07539
07540
07541
07542
07543 xexp=xcur;
07544 yexp=ycur;
07545 zexp=zcur;
07546 for(iexp=1;iexp<=nexp;iexp++){
07547 newact=extettr(xexp,yexp,zexp,ettrtype);
07548
07549 switch (newact){
07550 case 1:
07551 xexp-=1;
07552 if(xexp<0){xexp=(SYSIZEM1);}
07553 break;
07554 case 2:
07555 xexp+=1;
07556 if(xexp>=SYSIZE){xexp=0;}
07557 break;
07558 case 3:
07559 yexp-=1;
07560 if(yexp<0){yexp=(SYSIZEM1);}
07561 break;
07562 case 4:
07563 yexp+=1;
07564 if(yexp>=SYSIZE){yexp=0;}
07565 break;
07566 case 5:
07567 zexp-=1;
07568 if(zexp<0){zexp=(SYSIZEM1);}
07569 break;
07570 case 6:
07571 zexp+=1;
07572 if(zexp>=SYSIZE){zexp=0;}
07573 break;
07574 default:
07575 break;
07576 }
07577 }
07578
07579
07580 pexp=ran1(seed);
07581 if(pexp<=0.6935){
07582 newact=extettr(xexp,yexp,zexp,ettrtype);
07583 }
07584 }
07585
07586
07587
07588 if((check==C4AF)&&(p2diff<SOLIDC4AFGYP)){
07589 mic[xcur][ycur][zcur]=ETTRC4AF;
07590 count[ETTRC4AF]+=1;
07591 count[DIFFANH]-=1;
07592
07593
07594
07595
07596 pexp=ran1(seed);
07597 nexp=3;
07598 if(pexp<=0.8174){
07599 mic[xnew][ynew][znew]=ETTRC4AF;
07600 count[ETTRC4AF]+=1;
07601 count[C4AF]-=1;
07602 nexp=2;
07603 pext=ran1(seed);
07604
07605 if(pext<0.2584){
07606 extch();
07607 }
07608 pext=ran1(seed);
07609
07610 if(pext<0.5453){
07611 extfh3(xnew,ynew,znew);
07612 }
07613
07614 }
07615 else{
07616
07617
07618 mic[xnew][ynew][znew]=C4AF;
07619 nexp=3;
07620 }
07621
07622
07623
07624
07625 xexp=xcur;
07626 yexp=ycur;
07627 zexp=zcur;
07628 for(iexp=1;iexp<=nexp;iexp++){
07629 newact=extettr(xexp,yexp,zexp,1);
07630
07631 switch (newact){
07632 case 1:
07633 xexp-=1;
07634 if(xexp<0){xexp=(SYSIZEM1);}
07635 break;
07636 case 2:
07637 xexp+=1;
07638 if(xexp>=SYSIZE){xexp=0;}
07639 break;
07640 case 3:
07641 yexp-=1;
07642 if(yexp<0){yexp=(SYSIZEM1);}
07643 break;
07644 case 4:
07645 yexp+=1;
07646 if(yexp>=SYSIZE){yexp=0;}
07647 break;
07648 case 5:
07649 zexp-=1;
07650 if(zexp<0){zexp=(SYSIZEM1);}
07651 break;
07652 case 6:
07653 zexp+=1;
07654 if(zexp>=SYSIZE){zexp=0;}
07655 break;
07656 default:
07657 break;
07658 }
07659 }
07660
07661
07662 pexp=ran1(seed);
07663 if(pexp<=0.6935){
07664 newact=extettr(xexp,yexp,zexp,1);
07665 }
07666 action=0;
07667 }
07668 }
07669
07670 if(action!=0){
07671
07672 if(check==POROSITY){
07673 mic[xcur][ycur][zcur]=POROSITY;
07674 mic[xnew][ynew][znew]=DIFFANH;
07675 }
07676 else{
07677
07678
07679 action=7;
07680 }
07681 }
07682 return(action);
07683 }
07684
07685
07686
07687
07688
07689
07690
07691 int cemhydmat::movehem(int xcur, int ycur, int zcur, int finalstep, float nucprgyp)
07692 {
07693 int xnew,ynew,znew,action,sumback,sumin,check = -1;
07694 int nexp,iexp,xexp,yexp,zexp,newact,ettrtype;
07695 float pgen,pexp,pext,p2diff;
07696
07697 action=0;
07698
07699 pgen=ran1(seed);
07700 p2diff=ran1(seed);
07701 if((nucprgyp>=pgen)||(finalstep==1)){
07702 action=0;
07703 mic[xcur][ycur][zcur]=GYPSUMS;
07704 count[DIFFHEM]-=1;
07705 count[GYPSUMS]+=1;
07706
07707 pexp=ran1(seed);
07708 if(pexp<0.4){
07709 extgyps(xcur,ycur,zcur);
07710 }
07711 }
07712 else{
07713
07714 xnew=xcur;
07715 ynew=ycur;
07716 znew=zcur;
07717 sumin=1;
07718 sumback=moveone(&xnew,&ynew,&znew,&action,sumin);
07719
07720 if(action==0){printf("Error in value of action \n");}
07721 check=mic[xnew][ynew][znew];
07722
07723
07724
07725 if((check==GYPSUM)||(check==GYPSUMS)||(check==DIFFGYP)){
07726 mic[xcur][ycur][zcur]=GYPSUMS;
07727
07728
07729 count[DIFFHEM]-=1;
07730 count[GYPSUMS]+=1;
07731 action=0;
07732
07733 pexp=ran1(seed);
07734 if(pexp<0.4){
07735 extgyps(xnew,ynew,znew);
07736 }
07737 }
07738
07739
07740 else if(((check==C3A)&&(p2diff<SOLIDC3AGYP))||((check==DIFFC3A)&&(p2diff<C3AGYP))||((check==DIFFC4A)&&(p2diff<C3AGYP))){
07741
07742 ettrtype=0;
07743 mic[xcur][ycur][zcur]=ETTR;
07744 if(check==DIFFC4A){
07745 ettrtype=1;
07746 mic[xcur][ycur][zcur]=ETTRC4AF;
07747 }
07748 action=0;
07749 count[DIFFHEM]-=1;
07750 count[check]-=1;
07751
07752
07753
07754
07755 pexp=ran1(seed);
07756 nexp=3;
07757 if(pexp<=0.5583){
07758 if(ettrtype==0){
07759 mic[xnew][ynew][znew]=ETTR;
07760 count[ETTR]+=1;
07761 }
07762 else{
07763 mic[xnew][ynew][znew]=ETTRC4AF;
07764 count[ETTRC4AF]+=1;
07765 }
07766 nexp=2;
07767 }
07768 else{
07769
07770
07771 if(check==C3A){
07772 mic[xnew][ynew][znew]=C3A;
07773 count[C3A]+=1;
07774 }
07775 else{
07776 if(ettrtype==0){
07777 count[DIFFC3A]+=1;
07778 mic[xnew][ynew][znew]=DIFFC3A;
07779 }
07780 else{
07781 count[DIFFC4A]+=1;
07782 mic[xnew][ynew][znew]=DIFFC4A;
07783 }
07784 }
07785 nexp=3;
07786 }
07787
07788
07789
07790
07791 xexp=xcur;
07792 yexp=ycur;
07793 zexp=zcur;
07794 for(iexp=1;iexp<=nexp;iexp++){
07795 newact=extettr(xexp,yexp,zexp,ettrtype);
07796
07797 switch (newact){
07798 case 1:
07799 xexp-=1;
07800 if(xexp<0){xexp=(SYSIZEM1);}
07801 break;
07802 case 2:
07803 xexp+=1;
07804 if(xexp>=SYSIZE){xexp=0;}
07805 break;
07806 case 3:
07807 yexp-=1;
07808 if(yexp<0){yexp=(SYSIZEM1);}
07809 break;
07810 case 4:
07811 yexp+=1;
07812 if(yexp>=SYSIZE){yexp=0;}
07813 break;
07814 case 5:
07815 zexp-=1;
07816 if(zexp<0){zexp=(SYSIZEM1);}
07817 break;
07818 case 6:
07819 zexp+=1;
07820 if(zexp>=SYSIZE){zexp=0;}
07821 break;
07822 default:
07823 break;
07824 }
07825 }
07826
07827
07828 pexp=ran1(seed);
07829 if(pexp<=0.6053){
07830 newact=extettr(xexp,yexp,zexp,ettrtype);
07831 }
07832 }
07833
07834
07835
07836 if((check==C4AF)&&(p2diff<SOLIDC4AFGYP)){
07837 mic[xcur][ycur][zcur]=ETTRC4AF;
07838 count[ETTRC4AF]+=1;
07839 count[DIFFHEM]-=1;
07840
07841
07842
07843
07844 pexp=ran1(seed);
07845 nexp=3;
07846 if(pexp<=0.802){
07847 mic[xnew][ynew][znew]=ETTRC4AF;
07848 count[ETTRC4AF]+=1;
07849 count[C4AF]-=1;
07850 nexp=2;
07851 pext=ran1(seed);
07852
07853 if(pext<0.2584){
07854 extch();
07855 }
07856 pext=ran1(seed);
07857
07858 if(pext<0.5453){
07859 extfh3(xnew,ynew,znew);
07860 }
07861
07862 }
07863 else{
07864
07865
07866 mic[xnew][ynew][znew]=C4AF;
07867 nexp=3;
07868 }
07869
07870
07871
07872
07873 xexp=xcur;
07874 yexp=ycur;
07875 zexp=zcur;
07876 for(iexp=1;iexp<=nexp;iexp++){
07877 newact=extettr(xexp,yexp,zexp,1);
07878
07879 switch (newact){
07880 case 1:
07881 xexp-=1;
07882 if(xexp<0){xexp=(SYSIZEM1);}
07883 break;
07884 case 2:
07885 xexp+=1;
07886 if(xexp>=SYSIZE){xexp=0;}
07887 break;
07888 case 3:
07889 yexp-=1;
07890 if(yexp<0){yexp=(SYSIZEM1);}
07891 break;
07892 case 4:
07893 yexp+=1;
07894 if(yexp>=SYSIZE){yexp=0;}
07895 break;
07896 case 5:
07897 zexp-=1;
07898 if(zexp<0){zexp=(SYSIZEM1);}
07899 break;
07900 case 6:
07901 zexp+=1;
07902 if(zexp>=SYSIZE){zexp=0;}
07903 break;
07904 default:
07905 break;
07906 }
07907 }
07908
07909
07910 pexp=ran1(seed);
07911 if(pexp<=0.6053){
07912 newact=extettr(xexp,yexp,zexp,1);
07913 }
07914 action=0;
07915 }
07916 }
07917
07918 if(action!=0){
07919
07920 if(check==POROSITY){
07921 mic[xcur][ycur][zcur]=POROSITY;
07922 mic[xnew][ynew][znew]=DIFFHEM;
07923 }
07924 else{
07925
07926
07927 action=7;
07928 }
07929 }
07930 return(action);
07931 }
07932
07933
07934
07935
07936
07937 int cemhydmat::extfreidel(int xpres, int ypres, int zpres)
07938 {
07939 int multf,numnear,sump,xchr,ychr,zchr,check,fchr,i1,newact;
07940 long int tries;
07941
07942
07943
07944
07945
07946 fchr=0;
07947 sump=1;
07948 for(i1=1;((i1<=500)&&(fchr==0)&&(sump!=30030));i1++){
07949
07950
07951 xchr=xpres;
07952 ychr=ypres;
07953 zchr=zpres;
07954 newact=0;
07955 multf=moveone(&xchr,&ychr,&zchr,&newact,sump);
07956 if(newact==0){printf("Error in value of newact in extfreidel \n");}
07957 check=mic[xchr][ychr][zchr];
07958
07959
07960
07961 if(check==POROSITY){
07962 mic[xchr][ychr][zchr]=FREIDEL;
07963 count[FREIDEL]+=1;
07964 count[POROSITY]-=1;
07965 fchr=1;
07966 }
07967 else{
07968 sump*=multf;
07969 }
07970 }
07971
07972
07973
07974 tries=0;
07975 while(fchr==0){
07976 tries+=1;
07977 newact=7;
07978
07979 xchr=(int)((float)SYSIZE*ran1(seed));
07980 ychr=(int)((float)SYSIZE*ran1(seed));
07981 zchr=(int)((float)SYSIZE*ran1(seed));
07982 if(xchr>=SYSIZE){xchr=0;}
07983 if(ychr>=SYSIZE){ychr=0;}
07984 if(zchr>=SYSIZE){zchr=0;}
07985 check=mic[xchr][ychr][zchr];
07986
07987 if(check==POROSITY){
07988 numnear=edgecnt(xchr,ychr,zchr,FREIDEL,FREIDEL,DIFFCACL2);
07989
07990
07991 if((numnear<26)||(tries>5000)){
07992 mic[xchr][ychr][zchr]=FREIDEL;
07993 count[FREIDEL]+=1;
07994 count[POROSITY]-=1;
07995 fchr=1;
07996 }
07997 }
07998 }
07999 return(newact);
08000 }
08001
08002
08003
08004
08005
08006
08007 int cemhydmat::extstrat(int xpres, int ypres, int zpres)
08008 {
08009 int multf,numnear,sump,xchr,ychr,zchr,check,fchr,i1,newact;
08010 long int tries;
08011
08012
08013
08014
08015
08016 fchr=0;
08017 sump=1;
08018 for(i1=1;((i1<=500)&&(fchr==0)&&(sump!=30030));i1++){
08019
08020
08021 xchr=xpres;
08022 ychr=ypres;
08023 zchr=zpres;
08024 newact=0;
08025 multf=moveone(&xchr,&ychr,&zchr,&newact,sump);
08026 if(newact==0){printf("Error in value of newact in extstrat \n");}
08027 check=mic[xchr][ychr][zchr];
08028
08029
08030
08031 if(check==POROSITY){
08032 mic[xchr][ychr][zchr]=STRAT;
08033 count[STRAT]+=1;
08034 count[POROSITY]-=1;
08035 fchr=1;
08036 }
08037 else{
08038 sump*=multf;
08039 }
08040 }
08041
08042
08043
08044 tries=0;
08045 while(fchr==0){
08046 tries+=1;
08047 newact=7;
08048
08049 xchr=(int)((float)SYSIZE*ran1(seed));
08050 ychr=(int)((float)SYSIZE*ran1(seed));
08051 zchr=(int)((float)SYSIZE*ran1(seed));
08052 if(xchr>=SYSIZE){xchr=0;}
08053 if(ychr>=SYSIZE){ychr=0;}
08054 if(zchr>=SYSIZE){zchr=0;}
08055 check=mic[xchr][ychr][zchr];
08056
08057 if(check==POROSITY){
08058 numnear=edgecnt(xchr,ychr,zchr,STRAT,DIFFCAS2,DIFFAS);
08059
08060
08061 if((numnear<26)||(tries>5000)){
08062 mic[xchr][ychr][zchr]=STRAT;
08063 count[STRAT]+=1;
08064 count[POROSITY]-=1;
08065 fchr=1;
08066 }
08067 }
08068 }
08069 return(newact);
08070 }
08071
08072
08073
08074
08075
08076
08077 int cemhydmat::movegyp(int xcur, int ycur, int zcur, int finalstep)
08078 {
08079 int check,xnew,ynew,znew,action,nexp,iexp;
08080 int xexp,yexp,zexp,newact,sumold,sumgarb,ettrtype;
08081 float pexp,pext,p2diff;
08082
08083 sumold=1;
08084
08085
08086
08087 if(mic[xcur][ycur][zcur]!=DIFFGYP){
08088 action=0;
08089 return(action);
08090 }
08091
08092
08093 xnew=xcur;
08094 ynew=ycur;
08095 znew=zcur;
08096 action=0;
08097 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
08098 if(action==0){printf("Error in value of action in movegyp \n");}
08099 check=mic[xnew][ynew][znew];
08100 p2diff=ran1(seed);
08101
08102 if((check==CSH)&&((float)count[ABSGYP]<(gypabsprob*(float)count[CSH]))){
08103 pexp=ran1(seed);
08104 if(pexp<AGRATE){
08105
08106 count[ABSGYP]+=1;
08107 count[DIFFGYP]-=1;
08108 mic[xcur][ycur][zcur]=ABSGYP;
08109 action=0;
08110 }
08111 }
08112
08113
08114
08115
08116
08117 else if(((check==C3A)&&(p2diff<SOLIDC3AGYP))||((check==DIFFC3A)&&(p2diff<C3AGYP))||((check==DIFFC4A)&&(p2diff<C3AGYP))){
08118
08119 ettrtype=0;
08120 mic[xcur][ycur][zcur]=ETTR;
08121 if(check==DIFFC4A){
08122 ettrtype=1;
08123 mic[xcur][ycur][zcur]=ETTRC4AF;
08124 }
08125 action=0;
08126 count[DIFFGYP]-=1;
08127 count[check]-=1;
08128
08129
08130
08131
08132 pexp=ran1(seed);
08133 nexp=2;
08134 if(pexp<=0.40){
08135 if(ettrtype==0){
08136 mic[xnew][ynew][znew]=ETTR;
08137 count[ETTR]+=1;
08138 }
08139 else{
08140 mic[xnew][ynew][znew]=ETTRC4AF;
08141 count[ETTRC4AF]+=1;
08142 }
08143 nexp=1;
08144 }
08145 else{
08146
08147
08148 if(check==C3A){
08149 mic[xnew][ynew][znew]=C3A;
08150 count[C3A]+=1;
08151 }
08152 else{
08153 if(ettrtype==0){
08154 count[DIFFC3A]+=1;
08155 mic[xnew][ynew][znew]=DIFFC3A;
08156 }
08157 else{
08158 count[DIFFC4A]+=1;
08159 mic[xnew][ynew][znew]=DIFFC4A;
08160 }
08161 }
08162 nexp=2;
08163 }
08164
08165
08166
08167
08168 xexp=xcur;
08169 yexp=ycur;
08170 zexp=zcur;
08171 for(iexp=1;iexp<=nexp;iexp++){
08172 newact=extettr(xexp,yexp,zexp,ettrtype);
08173
08174 switch (newact){
08175 case 1:
08176 xexp-=1;
08177 if(xexp<0){xexp=(SYSIZEM1);}
08178 break;
08179 case 2:
08180 xexp+=1;
08181 if(xexp>=SYSIZE){xexp=0;}
08182 break;
08183 case 3:
08184 yexp-=1;
08185 if(yexp<0){yexp=(SYSIZEM1);}
08186 break;
08187 case 4:
08188 yexp+=1;
08189 if(yexp>=SYSIZE){yexp=0;}
08190 break;
08191 case 5:
08192 zexp-=1;
08193 if(zexp<0){zexp=(SYSIZEM1);}
08194 break;
08195 case 6:
08196 zexp+=1;
08197 if(zexp>=SYSIZE){zexp=0;}
08198 break;
08199 default:
08200 break;
08201 }
08202 }
08203
08204
08205 pexp=ran1(seed);
08206 if(pexp<=0.30){
08207 newact=extettr(xexp,yexp,zexp,ettrtype);
08208 }
08209 }
08210
08211
08212
08213 if((check==C4AF)&&(p2diff<SOLIDC4AFGYP)){
08214 mic[xcur][ycur][zcur]=ETTRC4AF;
08215 count[ETTRC4AF]+=1;
08216 count[DIFFGYP]-=1;
08217
08218
08219
08220
08221 pexp=ran1(seed);
08222 nexp=2;
08223 if(pexp<=0.575){
08224 mic[xnew][ynew][znew]=ETTRC4AF;
08225 count[ETTRC4AF]+=1;
08226 count[C4AF]-=1;
08227 nexp=1;
08228 pext=ran1(seed);
08229
08230 if(pext<0.2584){
08231 extch();
08232 }
08233 pext=ran1(seed);
08234
08235 if(pext<0.5453){
08236 extfh3(xnew,ynew,znew);
08237 }
08238
08239 }
08240 else{
08241
08242
08243 mic[xnew][ynew][znew]=C4AF;
08244 nexp=2;
08245 }
08246
08247
08248
08249
08250 xexp=xcur;
08251 yexp=ycur;
08252 zexp=zcur;
08253 for(iexp=1;iexp<=nexp;iexp++){
08254 newact=extettr(xexp,yexp,zexp,1);
08255
08256 switch (newact){
08257 case 1:
08258 xexp-=1;
08259 if(xexp<0){xexp=(SYSIZEM1);}
08260 break;
08261 case 2:
08262 xexp+=1;
08263 if(xexp>=SYSIZE){xexp=0;}
08264 break;
08265 case 3:
08266 yexp-=1;
08267 if(yexp<0){yexp=(SYSIZEM1);}
08268 break;
08269 case 4:
08270 yexp+=1;
08271 if(yexp>=SYSIZE){yexp=0;}
08272 break;
08273 case 5:
08274 zexp-=1;
08275 if(zexp<0){zexp=(SYSIZEM1);}
08276 break;
08277 case 6:
08278 zexp+=1;
08279 if(zexp>=SYSIZE){zexp=0;}
08280 break;
08281 default:
08282 break;
08283 }
08284 }
08285
08286
08287 pexp=ran1(seed);
08288 if(pexp<=0.30){
08289 newact=extettr(xexp,yexp,zexp,1);
08290 }
08291 action=0;
08292 }
08293
08294
08295
08296 if((action!=0)&&(finalstep==1)){
08297 action=0;
08298 count[DIFFGYP]-=1;
08299 count[GYPSUM]+=1;
08300 mic[xcur][ycur][zcur]=GYPSUM;
08301 }
08302
08303 if(action!=0){
08304
08305 if(check==POROSITY){
08306 mic[xcur][ycur][zcur]=POROSITY;
08307 mic[xnew][ynew][znew]=DIFFGYP;
08308 }
08309 else{
08310
08311
08312 action=7;
08313 }
08314 }
08315 return(action);
08316 }
08317
08318
08319
08320
08321
08322
08323 int cemhydmat::movecacl2(int xcur, int ycur, int zcur, int finalstep)
08324 {
08325 int check,xnew,ynew,znew,action,nexp,iexp;
08326 int xexp,yexp,zexp,newact,sumold,sumgarb,keep;
08327 float pexp,pext;
08328
08329 sumold=1;
08330 keep=0;
08331
08332
08333
08334 if(mic[xcur][ycur][zcur]!=DIFFCACL2){
08335 action=0;
08336 return(action);
08337 }
08338
08339
08340 xnew=xcur;
08341 ynew=ycur;
08342 znew=zcur;
08343 action=0;
08344 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
08345 if(action==0){printf("Error in value of action in movecacl2 \n");}
08346 check=mic[xnew][ynew][znew];
08347
08348
08349
08350 if((check==C3A)||(check==DIFFC3A)||(check==DIFFC4A)){
08351
08352 action=0;
08353 mic[xnew][ynew][znew]=FREIDEL;
08354 count[FREIDEL]+=1;
08355 count[check]-=1;
08356
08357
08358
08359
08360 pexp=ran1(seed);
08361 nexp=2;
08362 if(pexp<=0.5793){
08363 mic[xcur][ycur][zcur]=FREIDEL;
08364 count[FREIDEL]+=1;
08365 count[DIFFCACL2]-=1;
08366 nexp=1;
08367 }
08368 else{
08369 keep=1;
08370 nexp=2;
08371 }
08372
08373
08374
08375 xexp=xcur;
08376 yexp=ycur;
08377 zexp=zcur;
08378 for(iexp=1;iexp<=nexp;iexp++){
08379 newact=extfreidel(xexp,yexp,zexp);
08380
08381 switch (newact){
08382 case 1:
08383 xexp-=1;
08384 if(xexp<0){xexp=(SYSIZEM1);}
08385 break;
08386 case 2:
08387 xexp+=1;
08388 if(xexp>=SYSIZE){xexp=0;}
08389 break;
08390 case 3:
08391 yexp-=1;
08392 if(yexp<0){yexp=(SYSIZEM1);}
08393 break;
08394 case 4:
08395 yexp+=1;
08396 if(yexp>=SYSIZE){yexp=0;}
08397 break;
08398 case 5:
08399 zexp-=1;
08400 if(zexp<0){zexp=(SYSIZEM1);}
08401 break;
08402 case 6:
08403 zexp+=1;
08404 if(zexp>=SYSIZE){zexp=0;}
08405 break;
08406 default:
08407 break;
08408 }
08409 }
08410
08411
08412 pexp=ran1(seed);
08413 if(pexp<=0.3295){
08414 newact=extfreidel(xexp,yexp,zexp);
08415 }
08416 }
08417
08418
08419
08420 else if(check==C4AF){
08421 mic[xnew][ynew][znew]=FREIDEL;
08422 count[FREIDEL]+=1;
08423 count[C4AF]-=1;
08424
08425
08426
08427
08428
08429
08430 pexp=ran1(seed);
08431 nexp=1;
08432 if(pexp<=0.4033){
08433 mic[xcur][ycur][zcur]=FREIDEL;
08434 count[FREIDEL]+=1;
08435 count[DIFFCACL2]-=1;
08436 nexp=0;
08437 pext=ran1(seed);
08438
08439 if(pext<0.6412){
08440 extch();
08441 }
08442 pext=ran1(seed);
08443
08444 if(pext<0.3522){
08445 extfh3(xnew,ynew,znew);
08446 }
08447 extfh3(xnew,ynew,znew);
08448
08449 }
08450 else{
08451 nexp=1;
08452 keep=1;
08453 }
08454
08455
08456
08457 xexp=xcur;
08458 yexp=ycur;
08459 zexp=zcur;
08460 for(iexp=1;iexp<=nexp;iexp++){
08461 newact=extfreidel(xexp,yexp,zexp);
08462
08463 switch (newact){
08464 case 1:
08465 xexp-=1;
08466 if(xexp<0){xexp=(SYSIZEM1);}
08467 break;
08468 case 2:
08469 xexp+=1;
08470 if(xexp>=SYSIZE){xexp=0;}
08471 break;
08472 case 3:
08473 yexp-=1;
08474 if(yexp<0){yexp=(SYSIZEM1);}
08475 break;
08476 case 4:
08477 yexp+=1;
08478 if(yexp>=SYSIZE){yexp=0;}
08479 break;
08480 case 5:
08481 zexp-=1;
08482 if(zexp<0){zexp=(SYSIZEM1);}
08483 break;
08484 case 6:
08485 zexp+=1;
08486 if(zexp>=SYSIZE){zexp=0;}
08487 break;
08488 default:
08489 break;
08490 }
08491 }
08492
08493
08494 pexp=ran1(seed);
08495 if(pexp<=0.3176){
08496 newact=extfreidel(xexp,yexp,zexp);
08497 }
08498 action=0;
08499 }
08500
08501
08502
08503 if((action!=0)&&(finalstep==1)){
08504 action=0;
08505 count[DIFFCACL2]-=1;
08506 count[CACL2]+=1;
08507 mic[xcur][ycur][zcur]=CACL2;
08508 }
08509
08510 if(action!=0){
08511
08512 if(check==POROSITY){
08513 mic[xcur][ycur][zcur]=POROSITY;
08514 mic[xnew][ynew][znew]=DIFFCACL2;
08515 }
08516 else{
08517
08518
08519 action=7;
08520 }
08521 }
08522 if(keep==1){action=7;}
08523 return(action);
08524 }
08525
08526
08527
08528
08529
08530
08531 int cemhydmat::movecas2(int xcur, int ycur, int zcur, int finalstep)
08532 {
08533 int check,xnew,ynew,znew,action,nexp,iexp;
08534 int xexp,yexp,zexp,newact,sumold,sumgarb,keep;
08535 float pexp,pext;
08536
08537 sumold=1;
08538 keep=0;
08539
08540
08541
08542 if(mic[xcur][ycur][zcur]!=DIFFCAS2){
08543 action=0;
08544 return(action);
08545 }
08546
08547
08548 xnew=xcur;
08549 ynew=ycur;
08550 znew=zcur;
08551 action=0;
08552 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
08553 if(action==0){printf("Error in value of action in movecas2 \n");}
08554 check=mic[xnew][ynew][znew];
08555
08556
08557
08558 if((check==C3A)||(check==DIFFC3A)||(check==DIFFC4A)){
08559
08560 action=0;
08561 mic[xcur][ycur][zcur]=STRAT;
08562 count[STRAT]+=1;
08563 count[DIFFCAS2]-=1;
08564
08565
08566
08567
08568 pexp=ran1(seed);
08569 nexp=3;
08570 if(pexp<=0.886){
08571 mic[xnew][ynew][znew]=STRAT;
08572 count[STRAT]+=1;
08573 count[check]-=1;
08574 nexp=2;
08575 }
08576
08577
08578
08579 xexp=xcur;
08580 yexp=ycur;
08581 zexp=zcur;
08582 for(iexp=1;iexp<=nexp;iexp++){
08583 newact=extstrat(xexp,yexp,zexp);
08584
08585 switch (newact){
08586 case 1:
08587 xexp-=1;
08588 if(xexp<0){xexp=(SYSIZEM1);}
08589 break;
08590 case 2:
08591 xexp+=1;
08592 if(xexp>=SYSIZE){xexp=0;}
08593 break;
08594 case 3:
08595 yexp-=1;
08596 if(yexp<0){yexp=(SYSIZEM1);}
08597 break;
08598 case 4:
08599 yexp+=1;
08600 if(yexp>=SYSIZE){yexp=0;}
08601 break;
08602 case 5:
08603 zexp-=1;
08604 if(zexp<0){zexp=(SYSIZEM1);}
08605 break;
08606 case 6:
08607 zexp+=1;
08608 if(zexp>=SYSIZE){zexp=0;}
08609 break;
08610 default:
08611 break;
08612 }
08613 }
08614
08615
08616 pexp=ran1(seed);
08617 if(pexp<=0.286){
08618 newact=extstrat(xexp,yexp,zexp);
08619 }
08620 }
08621
08622
08623
08624 else if(check==C4AF){
08625 mic[xnew][ynew][znew]=STRAT;
08626 count[STRAT]+=1;
08627 count[C4AF]-=1;
08628
08629
08630
08631
08632
08633
08634 pexp=ran1(seed);
08635 nexp=2;
08636 if(pexp<=0.786){
08637 mic[xcur][ycur][zcur]=STRAT;
08638 count[STRAT]+=1;
08639 count[DIFFCAS2]-=1;
08640 nexp=1;
08641 pext=ran1(seed);
08642
08643
08644 if(pext<0.329){
08645 extch();
08646 }
08647 pext=ran1(seed);
08648
08649
08650 if(pext<0.6938){
08651 extfh3(xnew,ynew,znew);
08652 }
08653
08654 }
08655 else{
08656 nexp=2;
08657 keep=1;
08658 }
08659
08660
08661
08662 xexp=xcur;
08663 yexp=ycur;
08664 zexp=zcur;
08665 for(iexp=1;iexp<=nexp;iexp++){
08666 newact=extstrat(xexp,yexp,zexp);
08667
08668 switch (newact){
08669 case 1:
08670 xexp-=1;
08671 if(xexp<0){xexp=(SYSIZEM1);}
08672 break;
08673 case 2:
08674 xexp+=1;
08675 if(xexp>=SYSIZE){xexp=0;}
08676 break;
08677 case 3:
08678 yexp-=1;
08679 if(yexp<0){yexp=(SYSIZEM1);}
08680 break;
08681 case 4:
08682 yexp+=1;
08683 if(yexp>=SYSIZE){yexp=0;}
08684 break;
08685 case 5:
08686 zexp-=1;
08687 if(zexp<0){zexp=(SYSIZEM1);}
08688 break;
08689 case 6:
08690 zexp+=1;
08691 if(zexp>=SYSIZE){zexp=0;}
08692 break;
08693 default:
08694 break;
08695 }
08696 }
08697
08698
08699 pexp=ran1(seed);
08700 if(pexp<=0.37){
08701 newact=extstrat(xexp,yexp,zexp);
08702 }
08703 action=0;
08704 }
08705
08706
08707
08708 if((action!=0)&&(finalstep==1)){
08709 action=0;
08710 count[DIFFCAS2]-=1;
08711 count[CAS2]+=1;
08712 mic[xcur][ycur][zcur]=CAS2;
08713 }
08714
08715 if(action!=0){
08716
08717 if(check==POROSITY){
08718 mic[xcur][ycur][zcur]=POROSITY;
08719 mic[xnew][ynew][znew]=DIFFCAS2;
08720 }
08721 else{
08722
08723
08724 action=7;
08725 }
08726 }
08727 if(keep==1){action=7;}
08728 return(action);
08729 }
08730
08731
08732
08733
08734
08735
08736 int cemhydmat::moveas(int xcur, int ycur, int zcur, int finalstep)
08737 {
08738 int check,xnew,ynew,znew,action,nexp,iexp;
08739 int xexp,yexp,zexp,newact,sumold,sumgarb,keep;
08740 float pexp;
08741
08742 sumold=1;
08743 keep=0;
08744
08745
08746
08747 if(mic[xcur][ycur][zcur]!=DIFFAS){
08748 action=0;
08749 return(action);
08750 }
08751
08752
08753 xnew=xcur;
08754 ynew=ycur;
08755 znew=zcur;
08756 action=0;
08757 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
08758 if(action==0){printf("Error in value of action in moveas \n");}
08759 check=mic[xnew][ynew][znew];
08760
08761
08762
08763 if((check==CH)||(check==DIFFCH)){
08764
08765 action=0;
08766 mic[xnew][ynew][znew]=STRAT;
08767 count[STRAT]+=1;
08768 count[check]-=1;
08769
08770
08771
08772
08773 pexp=ran1(seed);
08774 nexp=2;
08775 if(pexp<=0.7538){
08776 mic[xcur][ycur][zcur]=STRAT;
08777 count[STRAT]+=1;
08778 count[DIFFAS]-=1;
08779 nexp=1;
08780 }
08781 else{
08782 keep=1;
08783 nexp=2;
08784 }
08785
08786
08787
08788 xexp=xcur;
08789 yexp=ycur;
08790 zexp=zcur;
08791 for(iexp=1;iexp<=nexp;iexp++){
08792 newact=extstrat(xexp,yexp,zexp);
08793
08794 switch (newact){
08795 case 1:
08796 xexp-=1;
08797 if(xexp<0){xexp=(SYSIZEM1);}
08798 break;
08799 case 2:
08800 xexp+=1;
08801 if(xexp>=SYSIZE){xexp=0;}
08802 break;
08803 case 3:
08804 yexp-=1;
08805 if(yexp<0){yexp=(SYSIZEM1);}
08806 break;
08807 case 4:
08808 yexp+=1;
08809 if(yexp>=SYSIZE){yexp=0;}
08810 break;
08811 case 5:
08812 zexp-=1;
08813 if(zexp<0){zexp=(SYSIZEM1);}
08814 break;
08815 case 6:
08816 zexp+=1;
08817 if(zexp>=SYSIZE){zexp=0;}
08818 break;
08819 default:
08820 break;
08821 }
08822 }
08823
08824
08825 pexp=ran1(seed);
08826 if(pexp<=0.326){
08827 newact=extstrat(xexp,yexp,zexp);
08828 }
08829 }
08830
08831
08832
08833 if((action!=0)&&(finalstep==1)){
08834 action=0;
08835 count[DIFFAS]-=1;
08836 count[ASG]+=1;
08837 mic[xcur][ycur][zcur]=ASG;
08838 }
08839
08840 if(action!=0){
08841
08842 if(check==POROSITY){
08843 mic[xcur][ycur][zcur]=POROSITY;
08844 mic[xnew][ynew][znew]=DIFFAS;
08845 }
08846 else{
08847
08848
08849 action=7;
08850 }
08851 }
08852 if(keep==1){action=7;}
08853 return(action);
08854 }
08855
08856
08857
08858
08859
08860
08861 int cemhydmat::movecaco3(int xcur,int ycur,int zcur,int finalstep)
08862 {
08863 int check,xnew,ynew,znew,action;
08864 int xexp,yexp,zexp,newact,sumold,sumgarb,keep;
08865 float pexp;
08866
08867 sumold=1;
08868 keep=0;
08869
08870
08871
08872 if(mic[xcur][ycur][zcur]!=DIFFCACO3){
08873 action=0;
08874 return(action);
08875 }
08876
08877
08878 xnew=xcur;
08879 ynew=ycur;
08880 znew=zcur;
08881 action=0;
08882 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
08883 if(action==0){printf("Error in value of action in moveas \n");}
08884 check=mic[xnew][ynew][znew];
08885
08886
08887
08888
08889 if(check==AFM){
08890
08891 action=0;
08892 pexp=ran1(seed);
08893 if(pexp<=0.479192){
08894 mic[xnew][ynew][znew]=AFMC;
08895 count[AFMC]+=1;
08896 }
08897 else{
08898 mic[xnew][ynew][znew]=ETTR;
08899 count[ETTR]+=1;
08900 }
08901 count[check]-=1;
08902
08903
08904
08905
08906 pexp=ran1(seed);
08907 if(pexp<=0.078658){
08908 mic[xcur][ycur][zcur]=AFMC;
08909 count[AFMC]+=1;
08910 count[DIFFCACO3]-=1;
08911 }
08912 else{
08913 keep=1;
08914 }
08915
08916
08917
08918 xexp=xnew;
08919 yexp=ynew;
08920 zexp=znew;
08921
08922
08923 pexp=ran1(seed);
08924 if(pexp<=0.26194){
08925 newact=extettr(xexp,yexp,zexp,0);
08926 }
08927 }
08928
08929
08930
08931 if((action!=0)&&(finalstep==1)){
08932 action=0;
08933 count[DIFFCACO3]-=1;
08934 count[CACO3]+=1;
08935 mic[xcur][ycur][zcur]=CACO3;
08936 }
08937
08938 if(action!=0){
08939
08940 if(check==POROSITY){
08941 mic[xcur][ycur][zcur]=POROSITY;
08942 mic[xnew][ynew][znew]=DIFFCACO3;
08943 }
08944 else{
08945
08946
08947 action=7;
08948 }
08949 }
08950 if(keep==1){action=7;}
08951 return(action);
08952 }
08953
08954
08955
08956
08957
08958 void cemhydmat::extafm(int xpres, int ypres, int zpres)
08959 {
08960 int check,sump,xchr,ychr,zchr,fchr,i1,newact,numnear;
08961 long int tries;
08962
08963
08964
08965
08966
08967 fchr=0;
08968 sump=1;
08969 for(i1=1;((i1<=100)&&(fchr==0)&&(sump!=30030));i1++){
08970
08971
08972 xchr=xpres;
08973 ychr=ypres;
08974 zchr=zpres;
08975 newact=0;
08976 sump*=moveone(&xchr,&ychr,&zchr,&newact,sump);
08977 if(newact==0){printf("Error in value of newact in extafm \n");}
08978 check=mic[xchr][ychr][zchr];
08979
08980
08981 if(check==POROSITY){
08982 mic[xchr][ychr][zchr]=AFM;
08983 count[AFM]+=1;
08984 count[POROSITY]-=1;
08985 fchr=1;
08986 }
08987 }
08988
08989
08990
08991 tries=0;
08992 while(fchr==0){
08993 tries+=1;
08994
08995 xchr=(int)((float)SYSIZE*ran1(seed));
08996 ychr=(int)((float)SYSIZE*ran1(seed));
08997 zchr=(int)((float)SYSIZE*ran1(seed));
08998 if(xchr>=SYSIZE){xchr=0;}
08999 if(ychr>=SYSIZE){ychr=0;}
09000 if(zchr>=SYSIZE){zchr=0;}
09001 check=mic[xchr][ychr][zchr];
09002
09003
09004 if(check==POROSITY){
09005 numnear=edgecnt(xchr,ychr,zchr,AFM,C3A,C4AF);
09006
09007
09008 if((tries>5000)||(numnear<26)){
09009 mic[xchr][ychr][zchr]=AFM;
09010 count[AFM]+=1;
09011 count[POROSITY]-=1;
09012 fchr=1;
09013 }
09014 }
09015 }
09016 }
09017
09018
09019
09020
09021
09022 int cemhydmat::moveettr(int xcur, int ycur, int zcur, int finalstep)
09023 {
09024 int check,xnew,ynew,znew,action;
09025 int sumold,sumgarb;
09026 float pexp,pafm,pgrow;
09027
09028
09029
09030 if(mic[xcur][ycur][zcur]!=DIFFETTR){
09031 action=0;
09032 return(action);
09033 }
09034
09035
09036 xnew=xcur;
09037 ynew=ycur;
09038 znew=zcur;
09039 action=0;
09040 sumold=1;
09041 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
09042 if(action==0){printf("Error in value of action in moveettr \n");}
09043 check=mic[xnew][ynew][znew];
09044
09045
09046
09047 if(check==C4AF){
09048
09049 mic[xcur][ycur][zcur]=AFM;
09050 count[AFM]+=1;
09051 count[DIFFETTR]-=1;
09052
09053
09054
09055
09056
09057 pexp=ran1(seed);
09058
09059 if(pexp<=0.278){
09060 mic[xnew][ynew][znew]=AFM;
09061 count[AFM]+=1;
09062 count[C4AF]-=1;
09063 pafm=ran1(seed);
09064
09065 if(pafm<=0.3241){
09066 extch();
09067 }
09068 pafm=ran1(seed);
09069
09070 if(pafm<=0.4313){
09071 extfh3(xnew,ynew,znew);
09072 }
09073 }
09074 else if (pexp<=0.348){
09075 mic[xnew][ynew][znew]=FH3;
09076 count[FH3]+=1;
09077 count[C4AF]-=1;
09078 }
09079 action=0;
09080 }
09081
09082
09083
09084 else if((check==C3A)||(check==DIFFC3A)){
09085
09086 action=0;
09087 mic[xcur][ycur][zcur]=AFM;
09088 count[DIFFETTR]-=1;
09089 count[AFM]+=1;
09090 count[check]-=1;
09091
09092
09093
09094
09095 pexp=ran1(seed);
09096 if(pexp<=0.2424){
09097 mic[xnew][ynew][znew]=AFM;
09098 count[AFM]+=1;
09099 pafm=(-0.1);
09100 }
09101 else{
09102
09103
09104 if(check==C3A){
09105 mic[xnew][ynew][znew]=C3A;
09106 count[C3A]+=1;
09107 }
09108 else{
09109 count[DIFFC3A]+=1;
09110 mic[xnew][ynew][znew]=DIFFC3A;
09111 }
09112
09113 pafm=0.04699;
09114 }
09115
09116
09117 pexp=ran1(seed);
09118 if(pexp<=pafm){
09119 extafm(xcur,ycur,zcur);
09120 }
09121 }
09122
09123
09124 else if(check==ETTR){
09125 pgrow=ran1(seed);
09126 if(pgrow<=ETTRGROW){
09127 mic[xcur] [ycur] [zcur]=ETTR;
09128 count[ETTR]+=1;
09129 action=0;
09130 count[DIFFETTR]-=1;
09131 }
09132 }
09133
09134
09135
09136 if((action!=0)&&(finalstep==1)){
09137 action=0;
09138 count[DIFFETTR]-=1;
09139 count[ETTR]+=1;
09140 mic[xcur][ycur][zcur]=ETTR;
09141 }
09142
09143 if(action!=0){
09144
09145 if(check==POROSITY){
09146 mic[xcur][ycur][zcur]=POROSITY;
09147 mic[xnew][ynew][znew]=DIFFETTR;
09148 }
09149 else{
09150
09151
09152 action=7;
09153 }
09154 }
09155 return(action);
09156 }
09157
09158
09159
09160
09161
09162 void cemhydmat::extpozz(int xpres, int ypres, int zpres)
09163 {
09164 int check,sump,xchr,ychr,zchr,fchr,i1,action,numnear;
09165 long int tries;
09166
09167
09168
09169
09170
09171 fchr=0;
09172 sump=1;
09173 for(i1=1;((i1<=100)&&(fchr==0)&&(sump!=30030));i1++){
09174
09175
09176 xchr=xpres;
09177 ychr=ypres;
09178 zchr=zpres;
09179 action=0;
09180 sump*=moveone(&xchr,&ychr,&zchr,&action,sump);
09181 if(action==0){printf("Error in value of action in extpozz \n");}
09182 check=mic[xchr][ychr][zchr];
09183
09184
09185 if(check==POROSITY){
09186 mic[xchr][ychr][zchr]=POZZCSH;
09187 count[POZZCSH]+=1;
09188 count[POROSITY]-=1;
09189 fchr=1;
09190 }
09191 }
09192
09193
09194
09195 tries=0;
09196 while(fchr==0){
09197 tries+=1;
09198
09199 xchr=(int)((float)SYSIZE*ran1(seed));
09200 ychr=(int)((float)SYSIZE*ran1(seed));
09201 zchr=(int)((float)SYSIZE*ran1(seed));
09202 if(xchr>=SYSIZE){xchr=0;}
09203 if(ychr>=SYSIZE){ychr=0;}
09204 if(zchr>=SYSIZE){zchr=0;}
09205 check=mic[xchr][ychr][zchr];
09206
09207 if(check==POROSITY){
09208 numnear=edgecnt(xchr,ychr,zchr,POZZ,CSH,POZZCSH);
09209
09210
09211 if((tries>5000)||(numnear<26)){
09212 mic[xchr][ychr][zchr]=POZZCSH;
09213 count[POZZCSH]+=1;
09214 count[POROSITY]-=1;
09215 fchr=1;
09216 }
09217 }
09218 }
09219 }
09220
09221
09222
09223
09224
09225 int cemhydmat::movefh3(int xcur, int ycur, int zcur, int finalstep, float nucprob)
09226 {
09227 int check,xnew,ynew,znew,action,sumold,sumgarb;
09228 float pgen;
09229
09230
09231 pgen=ran1(seed);
09232
09233 if((nucprob>=pgen)||(finalstep==1)){
09234 action=0;
09235 mic[xcur][ycur][zcur]=FH3;
09236 count[FH3]+=1;
09237 count[DIFFFH3]-=1;
09238 }
09239 else{
09240
09241
09242 xnew=xcur;
09243 ynew=ycur;
09244 znew=zcur;
09245 action=0;
09246 sumold=1;
09247 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
09248 if(action==0){printf("Error in value of action in movefh3 \n");}
09249 check=mic[xnew][ynew][znew];
09250
09251
09252 if(check==FH3){
09253 mic[xcur][ycur][zcur]=FH3;
09254 count[FH3]+=1;
09255 count[DIFFFH3]-=1;
09256 action=0;
09257 }
09258
09259 if(action!=0){
09260
09261 if(check==POROSITY){
09262 mic[xcur][ycur][zcur]=POROSITY;
09263 mic[xnew][ynew][znew]=DIFFFH3;
09264 }
09265 else{
09266
09267
09268 action=7;
09269 }
09270 }
09271 }
09272 return(action);
09273 }
09274
09275
09276
09277
09278
09279 int cemhydmat::movech(int xcur, int ycur, int zcur, int finalstep, float nucprob)
09280 {
09281 int check,xnew,ynew,znew,action,sumgarb,sumold;
09282 float pexp,pgen,pfix;
09283
09284
09285 pgen=ran1(seed);
09286 if((nucprob>=pgen)||(finalstep==1)){
09287 action=0;
09288 mic[xcur][ycur][zcur]=CH;
09289 count[DIFFCH]-=1;
09290 count[CH]+=1;
09291 }
09292 else{
09293
09294
09295 xnew=xcur;
09296 ynew=ycur;
09297 znew=zcur;
09298 action=0;
09299 sumold=1;
09300 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
09301 if(action==0){printf("Error in value of action in movech \n");}
09302 check=mic[xnew][ynew][znew];
09303
09304
09305 if((check==CH)&&(pgen<=CHGROW)){
09306 mic[xcur][ycur][zcur]=CH;
09307 count[DIFFCH]-=1;
09308 count[CH]+=1;
09309 action=0;
09310 }
09311
09312
09313 else if(((check==INERTAGG)||(check==CACO3)||(check==INERT))&&(pgen<=CHGROWAGG)&&(chflag==1)){
09314 mic[xcur][ycur][zcur]=CH;
09315 count[DIFFCH]-=1;
09316 count[CH]+=1;
09317 action=0;
09318 }
09319
09320
09321
09322 else if((pgen<=ppozz)&&(check==POZZ)&&(npr<=(int)((float)nfill*1.35))){
09323 action=0;
09324 mic[xcur][ycur][zcur]=POZZCSH;
09325 count[POZZCSH]+=1;
09326
09327
09328 npr+=1;
09329 count[DIFFCH]-=1;
09330
09331 pfix=ran1(seed);
09332 if(pfix<=(1./1.35)){
09333 mic[xnew][ynew][znew]=POZZCSH;
09334 count[POZZ]-=1;
09335 count[POZZCSH]+=1;
09336 }
09337
09338 pexp=ran1(seed);
09339
09340
09341
09342 extpozz(xcur,ycur,zcur);
09343 if(pexp<=0.05466){
09344 extpozz(xcur,ycur,zcur);
09345 }
09346 }
09347 else if(check==DIFFAS){
09348 action=0;
09349 mic[xcur][ycur][zcur]=STRAT;
09350 count[STRAT]+=1;
09351
09352
09353 nasr+=1;
09354 count[DIFFCH]-=1;
09355
09356 pfix=ran1(seed);
09357 if(pfix<=0.7538){
09358 mic[xnew][ynew][znew]=STRAT;
09359 count[STRAT]+=1;
09360 count[DIFFAS]-=1;
09361 }
09362
09363
09364 extstrat(xcur,ycur,zcur);
09365 pexp=ran1(seed);
09366 if(pexp<=0.5035){
09367 extstrat(xcur,ycur,zcur);
09368 }
09369 }
09370
09371 if(action!=0){
09372
09373 if(check==POROSITY){
09374 mic[xcur][ycur][zcur]=POROSITY;
09375 mic[xnew][ynew][znew]=DIFFCH;
09376 }
09377 else{
09378
09379
09380 action=7;
09381 }
09382 }
09383 }
09384 return(action);
09385 }
09386
09387
09388
09389
09390
09391 void cemhydmat::extc3ah6(int xpres, int ypres, int zpres)
09392 {
09393 int check,sump,xchr,ychr,zchr,fchr,i1,action,numnear;
09394 long int tries;
09395
09396
09397
09398
09399
09400 fchr=0;
09401 sump=1;
09402 for(i1=1;((i1<=100)&&(fchr==0)&&(sump!=30030));i1++){
09403
09404
09405 xchr=xpres;
09406 ychr=ypres;
09407 zchr=zpres;
09408 action=0;
09409 sump*=moveone(&xchr,&ychr,&zchr,&action,sump);
09410 if(action==0){printf("Error in action value in extc3ah6 \n");}
09411 check=mic[xchr][ychr][zchr];
09412
09413
09414 if(check==POROSITY){
09415 mic[xchr][ychr][zchr]=C3AH6;
09416 count[C3AH6]+=1;
09417 count[POROSITY]-=1;
09418 fchr=1;
09419 }
09420 }
09421
09422
09423 tries=0;
09424 while(fchr==0){
09425 tries+=1;
09426 xchr=(int)((float)SYSIZE*ran1(seed));
09427 ychr=(int)((float)SYSIZE*ran1(seed));
09428 zchr=(int)((float)SYSIZE*ran1(seed));
09429 if(xchr>=SYSIZE){xchr=0;}
09430 if(ychr>=SYSIZE){ychr=0;}
09431 if(zchr>=SYSIZE){zchr=0;}
09432 check=mic[xchr][ychr][zchr];
09433
09434 if(check==POROSITY){
09435 numnear=edgecnt(xchr,ychr,zchr,C3AH6,C3A,C3AH6);
09436
09437
09438 if((tries>5000)||(numnear<26)){
09439 mic[xchr][ychr][zchr]=C3AH6;
09440 count[C3AH6]+=1;
09441 count[POROSITY]-=1;
09442 fchr=1;
09443 }
09444 }
09445 }
09446 }
09447
09448
09449
09450
09451
09452 int cemhydmat::movec3a(int xcur, int ycur, int zcur, int finalstep, float nucprob)
09453 {
09454 int check,xnew,ynew,znew,action,sumgarb,sumold;
09455 int xexp,yexp,zexp,nexp,iexp,newact;
09456 float pgen,pexp,pafm,pgrow,p2diff;
09457
09458
09459 if(mic[xcur][ycur][zcur]!=DIFFC3A){
09460 action=0;
09461 return(action);
09462 }
09463
09464
09465 pgen=ran1(seed);
09466 p2diff=ran1(seed);
09467
09468 if((nucprob>=pgen)||(finalstep==1)){
09469 action=0;
09470 mic[xcur][ycur][zcur]=C3AH6;
09471 count[C3AH6]+=1;
09472
09473 count[DIFFC3A]-=1;
09474
09475
09476 pexp=ran1(seed);
09477 if(pexp<=0.69){
09478 extc3ah6(xcur,ycur,zcur);
09479 }
09480 }
09481 else{
09482
09483 xnew=xcur;
09484 ynew=ycur;
09485 znew=zcur;
09486 action=0;
09487 sumold=1;
09488 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
09489 if(action==0){printf("Error in value of action in movec3a \n");}
09490 check=mic[xnew][ynew][znew];
09491
09492
09493 if(check==C3AH6){
09494 pgrow=ran1(seed);
09495
09496
09497 if(pgrow<=C3AH6GROW){
09498 mic[xcur][ycur][zcur]=C3AH6;
09499 count[C3AH6]+=1;
09500 count[DIFFC3A]-=1;
09501 action=0;
09502
09503
09504 pexp=ran1(seed);
09505 if(pexp<=0.69){
09506 extc3ah6(xcur,ycur,zcur);
09507 }
09508 }
09509 }
09510
09511
09512
09513 else if((check==DIFFGYP)&&(p2diff<C3AGYP)){
09514
09515 mic[xnew][ynew][znew]=ETTR;
09516 count[ETTR]+=1;
09517
09518 count[DIFFGYP]-=1;
09519 action=0;
09520
09521
09522 pexp=ran1(seed);
09523 nexp=2;
09524 if(pexp<=0.40){
09525 mic[xcur][ycur][zcur]=ETTR;
09526 count[ETTR]+=1;
09527 count[DIFFC3A]-=1;
09528 nexp=1;
09529 }
09530 else{
09531
09532 action=7;
09533 nexp=2;
09534 }
09535
09536
09537
09538
09539 xexp=xnew;
09540 yexp=ynew;
09541 zexp=znew;
09542 for(iexp=1;iexp<=nexp;iexp++){
09543 newact=extettr(xexp,yexp,zexp,0);
09544
09545 switch (newact){
09546 case 1:
09547 xexp-=1;
09548 if(xexp<0){xexp=(SYSIZEM1);}
09549 break;
09550 case 2:
09551 xexp+=1;
09552 if(xexp>=SYSIZE){xexp=0;}
09553 break;
09554 case 3:
09555 yexp-=1;
09556 if(yexp<0){yexp=(SYSIZEM1);}
09557 break;
09558 case 4:
09559 yexp+=1;
09560 if(yexp>=SYSIZE){yexp=0;}
09561 break;
09562 case 5:
09563 zexp-=1;
09564 if(zexp<0){zexp=(SYSIZEM1);}
09565 break;
09566 case 6:
09567 zexp+=1;
09568 if(zexp>=SYSIZE){zexp=0;}
09569 break;
09570 default:
09571 break;
09572 }
09573 }
09574
09575
09576 pexp=ran1(seed);
09577 if(pexp<=0.30){
09578 newact=extettr(xexp,yexp,zexp,0);
09579 }
09580 }
09581
09582
09583 else if((check==DIFFHEM)&&(p2diff<C3AGYP)){
09584
09585 mic[xnew][ynew][znew]=ETTR;
09586 count[ETTR]+=1;
09587
09588 count[DIFFHEM]-=1;
09589 action=0;
09590
09591
09592 pexp=ran1(seed);
09593 nexp=3;
09594 if(pexp<=0.5583){
09595 mic[xcur][ycur][zcur]=ETTR;
09596 count[ETTR]+=1;
09597 count[DIFFC3A]-=1;
09598 nexp=2;
09599 }
09600 else{
09601
09602 action=7;
09603 nexp=3;
09604 }
09605
09606
09607
09608
09609 xexp=xnew;
09610 yexp=ynew;
09611 zexp=znew;
09612 for(iexp=1;iexp<=nexp;iexp++){
09613 newact=extettr(xexp,yexp,zexp,0);
09614
09615 switch (newact){
09616 case 1:
09617 xexp-=1;
09618 if(xexp<0){xexp=(SYSIZEM1);}
09619 break;
09620 case 2:
09621 xexp+=1;
09622 if(xexp>=SYSIZE){xexp=0;}
09623 break;
09624 case 3:
09625 yexp-=1;
09626 if(yexp<0){yexp=(SYSIZEM1);}
09627 break;
09628 case 4:
09629 yexp+=1;
09630 if(yexp>=SYSIZE){yexp=0;}
09631 break;
09632 case 5:
09633 zexp-=1;
09634 if(zexp<0){zexp=(SYSIZEM1);}
09635 break;
09636 case 6:
09637 zexp+=1;
09638 if(zexp>=SYSIZE){zexp=0;}
09639 break;
09640 default:
09641 break;
09642 }
09643 }
09644
09645
09646 pexp=ran1(seed);
09647 if(pexp<=0.6053){
09648 newact=extettr(xexp,yexp,zexp,0);
09649 }
09650 }
09651
09652
09653 else if((check==DIFFANH)&&(p2diff<C3AGYP)){
09654
09655 mic[xnew][ynew][znew]=ETTR;
09656 count[ETTR]+=1;
09657
09658 count[DIFFANH]-=1;
09659 action=0;
09660
09661
09662 pexp=ran1(seed);
09663 nexp=3;
09664 if(pexp<=0.569){
09665 mic[xcur][ycur][zcur]=ETTR;
09666 count[ETTR]+=1;
09667 count[DIFFC3A]-=1;
09668 nexp=2;
09669 }
09670 else{
09671
09672 action=7;
09673 nexp=3;
09674 }
09675
09676
09677
09678
09679 xexp=xnew;
09680 yexp=ynew;
09681 zexp=znew;
09682 for(iexp=1;iexp<=nexp;iexp++){
09683 newact=extettr(xexp,yexp,zexp,0);
09684
09685 switch (newact){
09686 case 1:
09687 xexp-=1;
09688 if(xexp<0){xexp=(SYSIZEM1);}
09689 break;
09690 case 2:
09691 xexp+=1;
09692 if(xexp>=SYSIZE){xexp=0;}
09693 break;
09694 case 3:
09695 yexp-=1;
09696 if(yexp<0){yexp=(SYSIZEM1);}
09697 break;
09698 case 4:
09699 yexp+=1;
09700 if(yexp>=SYSIZE){yexp=0;}
09701 break;
09702 case 5:
09703 zexp-=1;
09704 if(zexp<0){zexp=(SYSIZEM1);}
09705 break;
09706 case 6:
09707 zexp+=1;
09708 if(zexp>=SYSIZE){zexp=0;}
09709 break;
09710 default:
09711 break;
09712 }
09713 }
09714
09715
09716 pexp=ran1(seed);
09717 if(pexp<=0.6935){
09718 newact=extettr(xexp,yexp,zexp,0);
09719 }
09720 }
09721
09722
09723 else if(check==DIFFCACL2){
09724
09725 mic[xcur][ycur][zcur]=FREIDEL;
09726 count[FREIDEL]+=1;
09727
09728 count[DIFFC3A]-=1;
09729 action=0;
09730
09731
09732 pexp=ran1(seed);
09733 nexp=2;
09734 if(pexp<=0.5793){
09735 mic[xnew][ynew][znew]=FREIDEL;
09736 count[FREIDEL]+=1;
09737 count[DIFFCACL2]-=1;
09738 nexp=1;
09739 }
09740 else{
09741 nexp=2;
09742 }
09743
09744
09745
09746
09747 xexp=xnew;
09748 yexp=ynew;
09749 zexp=znew;
09750 for(iexp=1;iexp<=nexp;iexp++){
09751 newact=extfreidel(xexp,yexp,zexp);
09752
09753 switch (newact){
09754 case 1:
09755 xexp-=1;
09756 if(xexp<0){xexp=(SYSIZEM1);}
09757 break;
09758 case 2:
09759 xexp+=1;
09760 if(xexp>=SYSIZE){xexp=0;}
09761 break;
09762 case 3:
09763 yexp-=1;
09764 if(yexp<0){yexp=(SYSIZEM1);}
09765 break;
09766 case 4:
09767 yexp+=1;
09768 if(yexp>=SYSIZE){yexp=0;}
09769 break;
09770 case 5:
09771 zexp-=1;
09772 if(zexp<0){zexp=(SYSIZEM1);}
09773 break;
09774 case 6:
09775 zexp+=1;
09776 if(zexp>=SYSIZE){zexp=0;}
09777 break;
09778 default:
09779 break;
09780 }
09781 }
09782
09783
09784 pexp=ran1(seed);
09785 if(pexp<=0.3295){
09786 newact=extfreidel(xexp,yexp,zexp);
09787 }
09788 }
09789
09790
09791 else if(check==DIFFCAS2){
09792
09793 mic[xnew][ynew][znew]=STRAT;
09794 count[STRAT]+=1;
09795
09796 count[DIFFCAS2]-=1;
09797 action=0;
09798
09799
09800 pexp=ran1(seed);
09801 nexp=3;
09802 if(pexp<=0.886){
09803 mic[xcur][ycur][zcur]=STRAT;
09804 count[STRAT]+=1;
09805 count[DIFFC3A]-=1;
09806 nexp=2;
09807 }
09808 else{
09809 action=7;
09810 nexp=3;
09811 }
09812
09813
09814
09815
09816 xexp=xnew;
09817 yexp=ynew;
09818 zexp=znew;
09819 for(iexp=1;iexp<=nexp;iexp++){
09820 newact=extstrat(xexp,yexp,zexp);
09821
09822 switch (newact){
09823 case 1:
09824 xexp-=1;
09825 if(xexp<0){xexp=(SYSIZEM1);}
09826 break;
09827 case 2:
09828 xexp+=1;
09829 if(xexp>=SYSIZE){xexp=0;}
09830 break;
09831 case 3:
09832 yexp-=1;
09833 if(yexp<0){yexp=(SYSIZEM1);}
09834 break;
09835 case 4:
09836 yexp+=1;
09837 if(yexp>=SYSIZE){yexp=0;}
09838 break;
09839 case 5:
09840 zexp-=1;
09841 if(zexp<0){zexp=(SYSIZEM1);}
09842 break;
09843 case 6:
09844 zexp+=1;
09845 if(zexp>=SYSIZE){zexp=0;}
09846 break;
09847 default:
09848 break;
09849 }
09850 }
09851
09852
09853 pexp=ran1(seed);
09854 if(pexp<=0.286){
09855 newact=extstrat(xexp,yexp,zexp);
09856 }
09857 }
09858
09859
09860
09861
09862 pgrow=ran1(seed);
09863 if((check==DIFFETTR)||((check==ETTR)&&(soluble[ETTR]==1)&&(pgrow<=C3AETTR))){
09864
09865 mic[xnew][ynew][znew]=AFM;
09866 count[AFM]+=1;
09867
09868 count[check]-=1;
09869 action=0;
09870
09871
09872 pexp=ran1(seed);
09873 if(pexp<=0.2424){
09874 mic[xcur][ycur][zcur]=AFM;
09875 count[AFM]+=1;
09876 count[DIFFC3A]-=1;
09877 pafm=(-0.1);
09878 }
09879 else{
09880 action=7;
09881 pafm=0.04699;
09882 }
09883
09884
09885 pexp=ran1(seed);
09886 if(pexp<=pafm){
09887 extafm(xnew,ynew,znew);
09888 }
09889 }
09890 if((action!=0)&&(action!=7)){
09891
09892
09893 if(check==POROSITY){
09894 mic[xcur][ycur][zcur]=POROSITY;
09895 mic[xnew][ynew][znew]=DIFFC3A;
09896 }
09897 else{
09898
09899
09900 action=7;
09901 }
09902 }
09903 }
09904 return(action);
09905 }
09906
09907
09908
09909
09910
09911 int cemhydmat::movec4a(int xcur, int ycur, int zcur, int finalstep, float nucprob)
09912 {
09913 int check,xnew,ynew,znew,action,sumgarb,sumold;
09914 int xexp,yexp,zexp,nexp,iexp,newact;
09915 float pgen,pexp,pafm,pgrow,p2diff;
09916
09917
09918 if(mic[xcur][ycur][zcur]!=DIFFC4A){
09919 action=0;
09920 return(action);
09921 }
09922
09923
09924 pgen=ran1(seed);
09925 p2diff=ran1(seed);
09926
09927 if((nucprob>=pgen)||(finalstep==1)){
09928 action=0;
09929 mic[xcur][ycur][zcur]=C3AH6;
09930 count[C3AH6]+=1;
09931
09932 count[DIFFC4A]-=1;
09933
09934
09935 pexp=ran1(seed);
09936 if(pexp<=0.69){
09937 extc3ah6(xcur,ycur,zcur);
09938 }
09939 }
09940 else{
09941
09942 xnew=xcur;
09943 ynew=ycur;
09944 znew=zcur;
09945 action=0;
09946 sumold=1;
09947 sumgarb=moveone(&xnew,&ynew,&znew,&action,sumold);
09948 if(action==0){printf("Error in value of action in movec4a \n");}
09949 check=mic[xnew][ynew][znew];
09950
09951
09952 if(check==C3AH6){
09953 pgrow=ran1(seed);
09954
09955
09956 if(pgrow<=C3AH6GROW){
09957 mic[xcur][ycur][zcur]=C3AH6;
09958 count[C3AH6]+=1;
09959 count[DIFFC4A]-=1;
09960 action=0;
09961
09962
09963 pexp=ran1(seed);
09964 if(pexp<=0.69){
09965 extc3ah6(xcur,ycur,zcur);
09966 }
09967 }
09968 }
09969
09970
09971
09972 else if((check==DIFFGYP)&&(p2diff<C3AGYP)){
09973
09974 mic[xnew][ynew][znew]=ETTRC4AF;
09975 count[ETTRC4AF]+=1;
09976
09977 count[DIFFGYP]-=1;
09978 action=0;
09979
09980
09981 pexp=ran1(seed);
09982 nexp=2;
09983 if(pexp<=0.40){
09984 mic[xcur][ycur][zcur]=ETTRC4AF;
09985 count[ETTRC4AF]+=1;
09986 count[DIFFC4A]-=1;
09987 nexp=1;
09988 }
09989 else{
09990
09991 action=7;
09992 nexp=2;
09993 }
09994
09995
09996
09997
09998 xexp=xnew;
09999 yexp=ynew;
10000 zexp=znew;
10001 for(iexp=1;iexp<=nexp;iexp++){
10002 newact=extettr(xexp,yexp,zexp,1);
10003
10004 switch (newact){
10005 case 1:
10006 xexp-=1;
10007 if(xexp<0){xexp=(SYSIZEM1);}
10008 break;
10009 case 2:
10010 xexp+=1;
10011 if(xexp>=SYSIZE){xexp=0;}
10012 break;
10013 case 3:
10014 yexp-=1;
10015 if(yexp<0){yexp=(SYSIZEM1);}
10016 break;
10017 case 4:
10018 yexp+=1;
10019 if(yexp>=SYSIZE){yexp=0;}
10020 break;
10021 case 5:
10022 zexp-=1;
10023 if(zexp<0){zexp=(SYSIZEM1);}
10024 break;
10025 case 6:
10026 zexp+=1;
10027 if(zexp>=SYSIZE){zexp=0;}
10028 break;
10029 default:
10030 break;
10031 }
10032 }
10033
10034
10035 pexp=ran1(seed);
10036 if(pexp<=0.30){
10037 newact=extettr(xexp,yexp,zexp,1);
10038 }
10039 }
10040
10041
10042 else if((check==DIFFHEM)&&(p2diff<C3AGYP)){
10043
10044 mic[xnew][ynew][znew]=ETTRC4AF;
10045 count[ETTRC4AF]+=1;
10046
10047 count[DIFFHEM]-=1;
10048 action=0;
10049
10050
10051 pexp=ran1(seed);
10052 nexp=3;
10053 if(pexp<=0.5583){
10054 mic[xcur][ycur][zcur]=ETTRC4AF;
10055 count[ETTRC4AF]+=1;
10056 count[DIFFC4A]-=1;
10057 nexp=2;
10058 }
10059 else{
10060
10061 action=7;
10062 nexp=3;
10063 }
10064
10065
10066
10067
10068 xexp=xnew;
10069 yexp=ynew;
10070 zexp=znew;
10071 for(iexp=1;iexp<=nexp;iexp++){
10072 newact=extettr(xexp,yexp,zexp,1);
10073
10074 switch (newact){
10075 case 1:
10076 xexp-=1;
10077 if(xexp<0){xexp=(SYSIZEM1);}
10078 break;
10079 case 2:
10080 xexp+=1;
10081 if(xexp>=SYSIZE){xexp=0;}
10082 break;
10083 case 3:
10084 yexp-=1;
10085 if(yexp<0){yexp=(SYSIZEM1);}
10086 break;
10087 case 4:
10088 yexp+=1;
10089 if(yexp>=SYSIZE){yexp=0;}
10090 break;
10091 case 5:
10092 zexp-=1;
10093 if(zexp<0){zexp=(SYSIZEM1);}
10094 break;
10095 case 6:
10096 zexp+=1;
10097 if(zexp>=SYSIZE){zexp=0;}
10098 break;
10099 default:
10100 break;
10101 }
10102 }
10103
10104
10105 pexp=ran1(seed);
10106 if(pexp<=0.6053){
10107 newact=extettr(xexp,yexp,zexp,1);
10108 }
10109 }
10110
10111
10112 else if((check==DIFFANH)&&(p2diff<C3AGYP)){
10113
10114 mic[xnew][ynew][znew]=ETTRC4AF;
10115 count[ETTRC4AF]+=1;
10116
10117 count[DIFFANH]-=1;
10118 action=0;
10119
10120
10121 pexp=ran1(seed);
10122 nexp=3;
10123 if(pexp<=0.569){
10124 mic[xcur][ycur][zcur]=ETTRC4AF;
10125 count[ETTRC4AF]+=1;
10126 count[DIFFC4A]-=1;
10127 nexp=2;
10128 }
10129 else{
10130
10131 action=7;
10132 nexp=3;
10133 }
10134
10135
10136
10137
10138 xexp=xnew;
10139 yexp=ynew;
10140 zexp=znew;
10141 for(iexp=1;iexp<=nexp;iexp++){
10142 newact=extettr(xexp,yexp,zexp,1);
10143
10144 switch (newact){
10145 case 1:
10146 xexp-=1;
10147 if(xexp<0){xexp=(SYSIZEM1);}
10148 break;
10149 case 2:
10150 xexp+=1;
10151 if(xexp>=SYSIZE){xexp=0;}
10152 break;
10153 case 3:
10154 yexp-=1;
10155 if(yexp<0){yexp=(SYSIZEM1);}
10156 break;
10157 case 4:
10158 yexp+=1;
10159 if(yexp>=SYSIZE){yexp=0;}
10160 break;
10161 case 5:
10162 zexp-=1;
10163 if(zexp<0){zexp=(SYSIZEM1);}
10164 break;
10165 case 6:
10166 zexp+=1;
10167 if(zexp>=SYSIZE){zexp=0;}
10168 break;
10169 default:
10170 break;
10171 }
10172 }
10173
10174
10175 pexp=ran1(seed);
10176 if(pexp<=0.6935){
10177 newact=extettr(xexp,yexp,zexp,1);
10178 }
10179 }
10180
10181
10182 else if(check==DIFFCACL2){
10183
10184 mic[xcur][ycur][zcur]=FREIDEL;
10185 count[FREIDEL]+=1;
10186
10187 count[DIFFC4A]-=1;
10188 action=0;
10189
10190
10191 pexp=ran1(seed);
10192 nexp=2;
10193 if(pexp<=0.5793){
10194 mic[xnew][ynew][znew]=FREIDEL;
10195 count[FREIDEL]+=1;
10196 count[DIFFCACL2]-=1;
10197 nexp=1;
10198 }
10199 else{
10200 nexp=2;
10201 }
10202
10203
10204
10205
10206 xexp=xnew;
10207 yexp=ynew;
10208 zexp=znew;
10209 for(iexp=1;iexp<=nexp;iexp++){
10210 newact=extfreidel(xexp,yexp,zexp);
10211
10212 switch (newact){
10213 case 1:
10214 xexp-=1;
10215 if(xexp<0){xexp=(SYSIZEM1);}
10216 break;
10217 case 2:
10218 xexp+=1;
10219 if(xexp>=SYSIZE){xexp=0;}
10220 break;
10221 case 3:
10222 yexp-=1;
10223 if(yexp<0){yexp=(SYSIZEM1);}
10224 break;
10225 case 4:
10226 yexp+=1;
10227 if(yexp>=SYSIZE){yexp=0;}
10228 break;
10229 case 5:
10230 zexp-=1;
10231 if(zexp<0){zexp=(SYSIZEM1);}
10232 break;
10233 case 6:
10234 zexp+=1;
10235 if(zexp>=SYSIZE){zexp=0;}
10236 break;
10237 default:
10238 break;
10239 }
10240 }
10241
10242
10243 pexp=ran1(seed);
10244 if(pexp<=0.3295){
10245 newact=extfreidel(xexp,yexp,zexp);
10246 }
10247 }
10248
10249
10250 else if(check==DIFFCAS2){
10251
10252 mic[xnew][ynew][znew]=STRAT;
10253 count[STRAT]+=1;
10254
10255 count[DIFFCAS2]-=1;
10256 action=0;
10257
10258
10259 pexp=ran1(seed);
10260 nexp=3;
10261 if(pexp<=0.886){
10262 mic[xcur][ycur][zcur]=STRAT;
10263 count[STRAT]+=1;
10264 count[DIFFC4A]-=1;
10265 nexp=2;
10266 }
10267 else{
10268 action=7;
10269 nexp=3;
10270 }
10271
10272
10273
10274
10275 xexp=xnew;
10276 yexp=ynew;
10277 zexp=znew;
10278 for(iexp=1;iexp<=nexp;iexp++){
10279 newact=extstrat(xexp,yexp,zexp);
10280
10281 switch (newact){
10282 case 1:
10283 xexp-=1;
10284 if(xexp<0){xexp=(SYSIZEM1);}
10285 break;
10286 case 2:
10287 xexp+=1;
10288 if(xexp>=SYSIZE){xexp=0;}
10289 break;
10290 case 3:
10291 yexp-=1;
10292 if(yexp<0){yexp=(SYSIZEM1);}
10293 break;
10294 case 4:
10295 yexp+=1;
10296 if(yexp>=SYSIZE){yexp=0;}
10297 break;
10298 case 5:
10299 zexp-=1;
10300 if(zexp<0){zexp=(SYSIZEM1);}
10301 break;
10302 case 6:
10303 zexp+=1;
10304 if(zexp>=SYSIZE){zexp=0;}
10305 break;
10306 default:
10307 break;
10308 }
10309 }
10310
10311
10312 pexp=ran1(seed);
10313 if(pexp<=0.286){
10314 newact=extstrat(xexp,yexp,zexp);
10315 }
10316 }
10317
10318
10319
10320
10321 pgrow=ran1(seed);
10322 if((check==DIFFETTR)||((check==ETTR)&&(soluble[ETTR]==1)&&(pgrow<=C3AETTR))){
10323
10324 mic[xnew][ynew][znew]=AFM;
10325 count[AFM]+=1;
10326
10327 count[check]-=1;
10328 action=0;
10329
10330
10331 pexp=ran1(seed);
10332 if(pexp<=0.2424){
10333 mic[xcur][ycur][zcur]=AFM;
10334 count[AFM]+=1;
10335 count[DIFFC4A]-=1;
10336 pafm=(-0.1);
10337 }
10338 else{
10339 action=7;
10340 pafm=0.04699;
10341 }
10342
10343
10344 pexp=ran1(seed);
10345 if(pexp<=pafm){
10346 extafm(xnew,ynew,znew);
10347 }
10348 }
10349 if((action!=0)&&(action!=7)){
10350
10351
10352 if(check==POROSITY){
10353 mic[xcur][ycur][zcur]=POROSITY;
10354 mic[xnew][ynew][znew]=DIFFC4A;
10355 }
10356 else{
10357
10358
10359 action=7;
10360 }
10361 }
10362 }
10363 return(action);
10364 }
10365
10366
10367
10368
10369
10370 void cemhydmat::hydrate(int fincyc, int stepmax, float chpar1, float chpar2, float hgpar1, float hgpar2, float fhpar1, float fhpar2, float gypar1, float gypar2)
10371 {
10372 int xpl,ypl,zpl,phpl,agepl,xpnew,ypnew,zpnew;
10373 float chprob,c3ah6prob,fh3prob,gypprob;
10374 long int nleft,ntodo,ndale;
10375 int istep,termflag,reactf = -1;
10376 float beterm;
10377 struct ants *curant,*antgone;
10378
10379 ntodo=nmade;
10380 nleft=nmade;
10381 termflag=0;
10382
10383
10384 for(istep=1;((istep<=stepmax)&&(nleft>0));istep++){
10385 if((fincyc==1)&&(istep==stepmax)){termflag=1;}
10386
10387 nleft=0;
10388 ndale=0;
10389
10390
10391 beterm=exp(-(double)(count[DIFFCH])*1000000./SYSIZE_POW3/chpar2);
10392 chprob=chpar1*(1.-beterm);
10393 beterm=exp(-(double)(count[DIFFC3A])*1000000./SYSIZE_POW3/hgpar2);
10394 c3ah6prob=hgpar1*(1.-beterm);
10395 beterm=exp(-(double)(count[DIFFFH3])*1000000./SYSIZE_POW3/fhpar2);
10396 fh3prob=fhpar1*(1.-beterm);
10397 beterm=exp(-(double)(count[DIFFANH]+count[DIFFHEM])*1000000./SYSIZE_POW3/gypar2);
10398 gypprob=gypar1*(1.-beterm);
10399
10400
10401 curant=headant->nextant;
10402 while(curant!=NULL){
10403 ndale+=1;
10404 xpl=curant->x;
10405 ypl=curant->y;
10406 zpl=curant->z;
10407 phpl=curant->id;
10408 agepl=curant->cycbirth;
10409
10410
10411 if(phpl==DIFFCSH){
10412
10413
10414 reactf=movecsh(xpl,ypl,zpl,termflag,agepl);
10415 }
10416 else if(phpl==DIFFANH){
10417
10418
10419 reactf=moveanh(xpl,ypl,zpl,termflag,gypprob);
10420 }
10421 else if(phpl==DIFFHEM){
10422
10423
10424 reactf=movehem(xpl,ypl,zpl,termflag,gypprob);
10425 }
10426 else if(phpl==DIFFCH){
10427
10428
10429 reactf=movech(xpl,ypl,zpl,termflag,chprob);
10430 }
10431 else if(phpl==DIFFFH3){
10432
10433
10434 reactf=movefh3(xpl,ypl,zpl,termflag,fh3prob);
10435 }
10436 else if(phpl==DIFFGYP){
10437
10438
10439 reactf=movegyp(xpl,ypl,zpl,termflag);
10440 }
10441 else if(phpl==DIFFC3A){
10442
10443
10444 reactf=movec3a(xpl,ypl,zpl,termflag,c3ah6prob);
10445 }
10446 else if(phpl==DIFFC4A){
10447
10448
10449 reactf=movec4a(xpl,ypl,zpl,termflag,c3ah6prob);
10450 }
10451 else if(phpl==DIFFETTR){
10452
10453
10454 reactf=moveettr(xpl,ypl,zpl,termflag);
10455 }
10456 else if(phpl==DIFFCACL2){
10457
10458
10459 reactf=movecacl2(xpl,ypl,zpl,termflag);
10460 }
10461 else if(phpl==DIFFCAS2){
10462
10463
10464 reactf=movecas2(xpl,ypl,zpl,termflag);
10465 }
10466 else if(phpl==DIFFAS){
10467
10468
10469 reactf=moveas(xpl,ypl,zpl,termflag);
10470 }
10471 else if(phpl==DIFFCACO3){
10472
10473
10474 reactf=movecaco3(xpl,ypl,zpl,termflag);
10475 }
10476 else{
10477 printf("Error in ID of phase \n");
10478 }
10479
10480
10481 if(reactf!=0){
10482 nleft+=1;
10483 xpnew=xpl;
10484 ypnew=ypl;
10485 zpnew=zpl;
10486
10487
10488 switch (reactf) {
10489 case 1:
10490 xpnew-=1;
10491 if(xpnew<0){xpnew=(SYSIZEM1);}
10492 break;
10493 case 2:
10494 xpnew+=1;
10495 if(xpnew>=SYSIZE){xpnew=0;}
10496 break;
10497 case 3:
10498 ypnew-=1;
10499 if(ypnew<0){ypnew=(SYSIZEM1);}
10500 break;
10501 case 4:
10502 ypnew+=1;
10503 if(ypnew>=SYSIZE){ypnew=0;}
10504 break;
10505 case 5:
10506 zpnew-=1;
10507 if(zpnew<0){zpnew=(SYSIZEM1);}
10508 break;
10509 case 6:
10510 zpnew+=1;
10511 if(zpnew>=SYSIZE){zpnew=0;}
10512 break;
10513 default:
10514 break;
10515 }
10516
10517
10518 curant->x=xpnew;
10519 curant->y=ypnew;
10520 curant->z=zpnew;
10521 curant->id=phpl;
10522 curant=curant->nextant;
10523 }
10524
10525 else{
10526 if(ndale==1){
10527 headant->nextant=curant->nextant;
10528 }
10529 else{
10530 (curant->prevant)->nextant=curant->nextant;
10531 }
10532 if(curant->nextant!=NULL){
10533 (curant->nextant)->prevant=curant->prevant;
10534 }
10535 else{
10536 tailant=curant->prevant;
10537 }
10538 antgone=curant;
10539 curant=curant->nextant;
10540
10541 free(antgone);
10542 ngoing-=1;
10543 }
10544 }
10545 ntodo=nleft;
10546 }
10547 }
10548
10549
10550 void cemhydmat::laguer(fcomplex_cem a[],int m,fcomplex_cem *x,float eps,int polish){
10551 int j,iter;
10552 float err,dxold,cdx,abx;
10553 fcomplex_cem sq,h,gp,gm,g2,g,b,d,dx,f,x1;
10554
10555 dxold=Cabs(*x);
10556 for (iter=1;iter<=MAXIT;iter++) {
10557 b=a[m];
10558 err=Cabs(b);
10559 d=f=Complex(0.0,0.0);
10560 abx=Cabs(*x);
10561 for (j=m-1;j>=0;j--) {
10562 f=Cadd(Cmul(*x,f),d);
10563 d=Cadd(Cmul(*x,d),b);
10564 b=Cadd(Cmul(*x,b),a[j]);
10565 err=Cabs(b)+abx*err;
10566 }
10567 err *= EPSS;
10568 if (Cabs(b) <= err) return;
10569 g=Cdiv(d,b);
10570 g2=Cmul(g,g);
10571 h=Csub(g2,RCmul(2.0,Cdiv(f,b)));
10572 sq=Csqrt(RCmul((float) (m-1),Csub(RCmul((float) m,h),g2)));
10573 gp=Cadd(g,sq);
10574 gm=Csub(g,sq);
10575 if (Cabs(gp) < Cabs(gm))gp=gm;
10576 dx=Cdiv(Complex((float) m,0.0),gp);
10577 x1=Csub(*x,dx);
10578 if (x->r == x1.r && x->i == x1.i) return;
10579 *x=x1;
10580 cdx=Cabs(dx);
10581 if (iter > 6 && cdx >= dxold) return;
10582 dxold=cdx;
10583 if (!polish)
10584 if (cdx <= eps*Cabs(*x)) return;
10585 }
10586 nrerror("Too many iterations in routine cemhydmat - LAGUER\n");
10587 }
10588
10589
10590
10591 void cemhydmat::zroots(fcomplex_cem a[],int m,fcomplex_cem roots[],int polish){
10592 int jj,j,i;
10593 fcomplex_cem x,b,c;
10594 fcomplex_cem *ad;
10595
10596 ad = new fcomplex_cem[MAXM];
10597
10598 for (j=0;j<=m;j++) ad[j]=a[j];
10599 for (j=m;j>=1;j--) {
10600 x=Complex(0.0,0.0);
10601 laguer(ad,j,&x,EPSP,0);
10602 if (fabs(x.i) <= (2.0*EPSP*fabs(x.r))) x.i=0.0;
10603 roots[j]=x;
10604 b=ad[j];
10605 for (jj=j-1;jj>=0;jj--) {
10606 c=ad[jj];
10607 ad[jj]=b;
10608 b=Cadd(Cmul(x,b),c);
10609 }
10610 }
10611 if (polish)
10612 for (j=1;j<=m;j++)
10613 laguer(a,m,&roots[j],EPSP,1);
10614 for (j=2;j<=m;j++) {
10615 x=roots[j];
10616 for (i=j-1;i>=1;i--) {
10617 if (roots[i].r <= x.r) break;
10618 roots[i+1]=roots[i];
10619 }
10620 roots[i+1]=x;
10621 }
10622
10623 delete [] ad;
10624 }
10625
10626
10627
10628 void cemhydmat::pHpred(void){
10629 int j,syngen_change=0,syn_old=0, counter=0;
10630 double concnaplus,conckplus;
10631 double concohminus = 0.,A,B,C,conctest,concsulfate1;
10632 double volpore,grams_cement;
10633 double releasedna,releasedk,activitySO4,activityK,test_precip;
10634 double activityCa,activityOH,Istrength,Anow,Bnow,Inew;
10635 double conductivity=0.0;
10636 fcomplex_cem coef[5],roots[5];
10637 float sumbest,sumtest,pozzreact,KspCH;
10638
10639
10640
10641
10642 KspCH=KspCH25C*(1.534385-0.02057*temp_cur);
10643
10644 if(conccaplus>1.0){conccaplus=0.0;}
10645
10646 volpore=(double)count[POROSITY]+0.38*(double)count[CSH]+0.20*(double)count[POZZCSH]+0.20*count[SLAGCSH];
10647
10648 volpore*=VOLFACTOR;
10649 volpore*=VOLFACTOR;
10650 volpore*=VOLFACTOR;
10651
10652 grams_cement=cemmasswgyp*MASSFACTOR*MASSFACTOR*MASSFACTOR;
10653
10654 volpore/=grams_cement;
10655
10656 pozzreact=((float)npr/1.35)*MASSFACTOR*MASSFACTOR*MASSFACTOR*specgrav[POZZ];
10657
10658
10659 if(time_cur>1.0){
10660 releasedk=(2.*(rspotassium+(totpotassium-rspotassium)*alpha_cur));
10661 releasedk/=MMK2O;
10662 releasedna=(2.*(rssodium+(totsodium-rssodium)*alpha_cur));
10663 releasedna/=MMNa2O;
10664 }
10665 else{
10666
10667
10668
10669 releasedk=(2.*((0.9+0.1*time_cur)*(rspotassium)+(totpotassium-rspotassium)*alpha_cur));
10670 releasedk/=MMK2O;
10671 releasedna=(2.*((0.9+0.1*time_cur)*(rssodium)+(totsodium-rssodium)*alpha_cur));
10672 releasedna/=MMNa2O;
10673 }
10674
10675
10676
10677
10678 conckplus=((releasedk-moles_syn_precip*KperSyn)/(volpore+BK*alpha_cur+BprimeK*pozzreact));
10679 concnaplus=(releasedna)/(volpore+BNa*alpha_cur+BprimeNa*pozzreact);
10680
10681 do{
10682
10683 activityCa=activityOH=activitySO4=activityK=1.0;
10684 Inew=0.0;
10685 if(((concnaplus+conckplus)>0.0)&&(soluble[ETTR]==0)){
10686
10687 Istrength=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10688 if(Istrength<1.0){Istrength=1.0;}
10689 while((fabs(Istrength-Inew)/Istrength)>0.10){
10690 Istrength=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10691 if(Istrength<1.0){Istrength=1.0;}
10692 Anow=activeA0*295.*sqrt(295.)/((temp_cur+273.15)*sqrt(temp_cur+273.15));
10693 Bnow=activeB0*sqrt(295.)/(sqrt(temp_cur+273.15));
10694
10695 activityCa=(-Anow*zCa*zCa*sqrt(Istrength))/(1.+aCa*Bnow*sqrt(Istrength));
10696 activityCa+=(0.2-0.0000417*Istrength)*Anow*zCa*zCa*Istrength/sqrt(1000.);
10697 activityCa=exp(activityCa);
10698 activityOH=(-Anow*zOH*zOH*sqrt(Istrength))/(1.+aOH*Bnow*sqrt(Istrength));
10699 activityOH+=(0.2-0.0000417*Istrength)*Anow*zOH*zOH*Istrength/sqrt(1000.);
10700 activityOH=exp(activityOH);
10701 activityK=(-Anow*zK*zK*sqrt(Istrength))/(1.+aK*Bnow*sqrt(Istrength));
10702 activityK+=(0.2-0.0000417*Istrength)*Anow*zK*zK*Istrength/sqrt(1000.);
10703 activityK=exp(activityK);
10704 activitySO4=(-Anow*zSO4*zSO4*sqrt(Istrength))/(1.+aSO4*Bnow*sqrt(Istrength));
10705 activitySO4+=(0.2-0.0000417*Istrength)*Anow*zSO4*zSO4*Istrength/sqrt(1000.);
10706 activitySO4=exp(activitySO4);
10707
10708
10709
10710
10711 A=(-KspCH/(activityCa*activityOH*activityOH));
10712 B=conckplus+concnaplus;
10713 C=(-2.*KspGypsum/(activityCa*activitySO4));
10714 concohminus=conckplus+concnaplus;
10715 coef[0]=Complex(C,0.0);
10716 coef[1]=Complex((A+2.*B*C)/C,0.0);
10717 coef[2]=Complex(B*B/C+4.,0.0);
10718 coef[3]=Complex(4.*B/C,0.0);
10719 coef[4]=Complex(4./C,0.0);
10720
10721
10722
10723
10724
10725 roots[1]=Complex(0.0,0.0);
10726 roots[2]=Complex(0.0,0.0);
10727 roots[3]=Complex(0.0,0.0);
10728 roots[4]=Complex(0.0,0.0);
10729 zroots(coef,4,roots,1);
10730 sumbest=100;
10731
10732 for(j=1;j<=4;j++){
10733
10734 fflush(stdout);
10735 if(((roots[j].i)==0.0)&&((roots[j].r)>0.0)){
10736
10737 conctest=sqrt(KspCH/(roots[j].r*activityCa*activityOH*activityOH));
10738 concsulfate1=KspGypsum/(roots[j].r*activityCa*activitySO4);
10739 sumtest=concnaplus+conckplus+2.*roots[j].r-conctest-2.*concsulfate1;
10740 if(fabs(sumtest)<sumbest){
10741 sumbest=fabs(sumtest);
10742 concohminus=conctest;
10743 conccaplus=roots[j].r;
10744 concsulfate=concsulfate1;
10745 }
10746 }
10747 }
10748
10749 Inew=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10750 }
10751 }
10752 else{
10753
10754 Istrength=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10755 if(Istrength<1.0){Istrength=1.0;}
10756 while((fabs(Istrength-Inew)/Istrength)>0.10 && counter<4){
10757
10758 Istrength=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10759 Anow=activeA0*295.*sqrt(295.)/((temp_cur+273.15)*sqrt(temp_cur+273.15));
10760 Bnow=activeB0*sqrt(295.)/(sqrt(temp_cur+273.15));
10761
10762 activityCa=(-Anow*zCa*zCa*sqrt(Istrength))/(1.+aCa*Bnow*sqrt(Istrength));
10763 activityCa+=(0.2-0.0000417*Istrength)*Anow*zCa*zCa*Istrength/sqrt(1000.);
10764 activityCa=exp(activityCa);
10765 activityOH=(-Anow*zOH*zOH*sqrt(Istrength))/(1.+aOH*Bnow*sqrt(Istrength));
10766 activityOH+=(0.2-0.0000417*Istrength)*Anow*zOH*zOH*Istrength/sqrt(1000.);
10767 activityOH=exp(activityOH);
10768 activityK=(-Anow*zK*zK*sqrt(Istrength))/(1.+aK*Bnow*sqrt(Istrength));
10769 activityK+=(0.2-0.0000417*Istrength)*Anow*zK*zK*Istrength/sqrt(1000.);
10770 activityK=exp(activityK);
10771
10772 concohminus=conckplus+concnaplus;
10773 if((conccaplus)>(0.1*(concohminus))){
10774 concohminus+=(2.*conccaplus);
10775 }
10776 conccaplus=(KspCH/(activityCa*activityOH*activityOH*concohminus*concohminus));
10777 concsulfate=0.0;
10778
10779 Inew=1000.*(zK*zK*conckplus+zNa*zNa*concnaplus+zCa*zCa*conccaplus);
10780 counter++;
10781 }
10782 }
10783
10784 syngen_change=0;
10785 if(syn_old!=2){
10786 test_precip=conckplus*conckplus*activityK*activityK;
10787 test_precip*=conccaplus*activityCa;
10788 test_precip*=concsulfate*concsulfate*activitySO4*activitySO4;
10789 if(test_precip>KspSyngenite){
10790 #ifdef PRINTF
10791 printf("Syngenite precipitating at cycle %d\n",icyc);
10792 #endif
10793 syngen_change=syn_old=1;
10794
10795 if(conckplus>0.002){
10796 conckplus-=0.001;
10797 moles_syn_precip+=0.001*volpore/KperSyn;
10798 }
10799 else if(conckplus>0.0002){
10800 conckplus-=0.0001;
10801 moles_syn_precip+=0.0001*volpore/KperSyn;
10802 }
10803 else{
10804 moles_syn_precip+=conckplus*volpore/KperSyn;
10805 conckplus=0.0;
10806 }
10807 }
10808
10809
10810
10811
10812
10813 if((syn_old==0)&&(moles_syn_precip>0.0)){
10814 syngen_change=syn_old=2;
10815
10816 if((moles_syn_precip/volpore)>0.001){
10817 conckplus+=0.001*KperSyn;
10818 moles_syn_precip-=(0.001*volpore);
10819 }
10820 else{
10821 conckplus+=(moles_syn_precip*KperSyn/volpore);
10822 moles_syn_precip=0.0;
10823 }
10824 }
10825 }
10826 } while(syngen_change!=0);
10827
10828 if(concohminus<(0.0000001)){
10829 concohminus=0.0000001;
10830 conccaplus=(KspCH/(activityCa*activityOH*activityOH*concohminus*concohminus));
10831 }
10832 pH_cur=14.0+log10(concohminus*activityOH);
10833
10834
10835 Istrength/=1000.;
10836 conductivity+=zCa*conccaplus*(lambdaCa_0/(1.+GCa*sqrt(Istrength)));
10837 conductivity+=zOH*concohminus*(lambdaOH_0/(1.+GOH*sqrt(Istrength)));
10838 conductivity+=zNa*concnaplus*(lambdaNa_0/(1.+GNa*sqrt(Istrength)));
10839 conductivity+=zK*conckplus*(lambdaK_0/(1.+GK*sqrt(Istrength)));
10840 conductivity+=zSO4*concsulfate*(lambdaSO4_0/(1.+GSO4*sqrt(Istrength)));
10841 conductivity*=cm2perL2m;
10842
10843
10844 #ifdef OUTFILES
10845 fprintf(pHfile,"%d %.4f %f %.4f %f %f %f %f %f %.4f %.4f %.4f %.4f %f\n",cyccnt-1,time_cur,alpha_cur,pH_cur,conductivity,concnaplus,conckplus,conccaplus,concsulfate,activityCa,activityOH,activitySO4,activityK,moles_syn_precip);
10846 fflush(pHfile);
10847 #endif
10848
10849 }
10850
10851
10852 int cemhydmat::IsSolidPhase(int phase){
10853 if ((phase>=C3S && phase<=ABSGYP) || (phase==HDCSH)){
10854 return 1;
10855 }
10856 else{
10857 return 0;
10858 }
10859 }
10860
10861 void cemhydmat::burn_phases(int d1, int d2, int d3) {
10862 long int icur,inew,ncur,nnew;
10863 int i,j,k, cnt,kh;
10864 int *nmatx, *nmaty, *nmatz;
10865 int xl,xh,j1,k1,px,py,pz,qx,qy,qz;
10866 int xcn,ycn,zcn,x1,y1,z1,igood;
10867 int *nnewx, *nnewy, *nnewz;
10868 int jnew;
10869 int phase_temp[51];
10870 char ***newmat;
10871
10872
10873 alloc_char_3D(newmat, SYSIZE);
10874 nmatx = new int[SIZESET];
10875 nmaty = new int[SIZESET];
10876 nmatz = new int[SIZESET];
10877 nnewx = new int[SIZESET];
10878 nnewy = new int[SIZESET];
10879 nnewz = new int[SIZESET];
10880
10881 last=NULL;
10882
10883
10884
10885
10886
10887
10888
10889
10890 for(k=0;k<SYSIZE;k++){
10891 for(j=0;j<SYSIZE;j++){
10892 for(i=0;i<SYSIZE;i++){
10893 newmat[i][j][k]=mic_CSH[i][j][k];
10894
10895 if(mic_CSH[i][j][k]==EMPTYP)
10896 ArrPerc[i][j][k]=EMPTYP;
10897 else
10898 ArrPerc[i][j][k]=0;
10899 }
10900 }
10901 }
10902
10903 for(k=0;k<51;k++){
10904 phase[k]=0;
10905 }
10906
10907
10908
10909
10910 i=0;
10911 cnt=0;
10912
10913 for(k=0;k<SYSIZE;k++){
10914 for(j=0;j<SYSIZE;j++){
10915
10916 igood=0;
10917 ncur=0;
10918 for(kh=0;kh<51;kh++){
10919 phase_temp[kh]=0;
10920 }
10921
10922
10923
10924 while(last!=NULL){
10925 current=last;
10926 last=last->prev;
10927
10928 delete current;
10929 }
10930
10931
10932 px=cx(i,j,k,d1,d2,d3);
10933 py=cy(i,j,k,d1,d2,d3);
10934 pz=cz(i,j,k,d1,d2,d3);
10935
10936 if(IsSolidPhase(newmat [px] [py] [pz])==1){
10937
10938 phase_temp[(int)newmat[px][py][pz]]++;
10939
10940
10941 WriteUnsortedList(px, py, pz);
10942 newmat [px] [py] [pz]=BURNT;
10943 ncur+=1;
10944
10945
10946
10947
10948
10949 nmatx[ncur]=i;
10950 nmaty[ncur]=j;
10951 nmatz[ncur]=k;
10952
10953 do{
10954 nnew=0;
10955 for(inew=1;inew<=ncur;inew++){
10956 xcn=nmatx[inew];
10957 ycn=nmaty[inew];
10958 zcn=nmatz[inew];
10959
10960 qx=cx(xcn,ycn,zcn,d1,d2,d3);
10961 qy=cy(xcn,ycn,zcn,d1,d2,d3);
10962 qz=cz(xcn,ycn,zcn,d1,d2,d3);
10963
10964
10965 for(jnew=1;jnew<=6;jnew++){
10966 x1=xcn;
10967 y1=ycn;
10968 z1=zcn;
10969 if(jnew==1){x1-=1;}
10970 if(jnew==2){x1+=1;}
10971 if(jnew==3){y1-=1;}
10972 if(jnew==4){y1+=1;}
10973 if(jnew==5){z1-=1;}
10974 if(jnew==6){z1+=1;}
10975
10976 if(y1>=SYSIZE){y1-=SYSIZE;}
10977 else if(y1<0){y1+=SYSIZE;}
10978
10979 if(z1>=SYSIZE){z1-=SYSIZE;}
10980 else if(z1<0){z1+=SYSIZE;}
10981
10982
10983 if((x1>=0)&&(x1<SYSIZE)){
10984 px=cx(x1,y1,z1,d1,d2,d3);
10985 py=cy(x1,y1,z1,d1,d2,d3);
10986 pz=cz(x1,y1,z1,d1,d2,d3);
10987
10988
10989
10990 if((IsSolidPhase(newmat [px][py][pz])==1) &&
10991 (newmat [px][py][pz]!=C3S) &&
10992 (newmat [px][py][pz]!=C2S) &&
10993 (newmat [px][py][pz]!=C3A) &&
10994 (newmat [px][py][pz]!=C4AF)){
10995
10996
10997
10998
10999 phase_temp[(int)newmat[px][py][pz]]++;
11000 WriteUnsortedList(px, py, pz);
11001 newmat [px] [py] [pz]=BURNT;
11002 nnew+=1;
11003 if(nnew>=SIZESET){
11004 printf("error in size of nnew %ld\n", nnew);
11005 }
11006 nnewx[nnew]=x1;
11007 nnewy[nnew]=y1;
11008 nnewz[nnew]=z1;
11009 }
11010
11011
11012 else if(((IsSolidPhase(mic_CSH [qx][qy][qz])==1) &&
11013 (mic_CSH [qx][qy][qz]!=C3S) &&
11014 (mic_CSH [qx][qy][qz]!=C2S) &&
11015 (mic_CSH [qx][qy][qz]!=C3A) &&
11016 (mic_CSH [qx][qy][qz]!=C4AF)) &&
11017 ((newmat [px] [py] [pz]==C3S) ||
11018 (newmat [px] [py] [pz]==C2S) ||
11019 (newmat [px] [py] [pz]==C3A) ||
11020 (newmat [px] [py] [pz]==C4AF))){
11021
11022 phase_temp[(int)newmat[px][py][pz]]++;
11023 WriteUnsortedList(px, py, pz);
11024 newmat [px] [py] [pz]=BURNT;
11025 nnew+=1;
11026 if(nnew>=SIZESET){
11027 printf("error in size of nnew %ld\n", nnew);
11028 }
11029 nnewx[nnew]=x1;
11030 nnewy[nnew]=y1;
11031 nnewz[nnew]=z1;
11032 }
11033
11034
11035
11036 else if((micpart[qx][qy][qz]==micpart[px][py][pz])
11037 &&((newmat [px] [py] [pz]==C3S) ||
11038 (newmat [px] [py] [pz]==C2S) ||
11039 (newmat [px] [py] [pz]==C3A) ||
11040 (newmat [px] [py] [pz]==C4AF))&&
11041 ((mic_CSH [qx][qy][qz]==C3S)||
11042 (mic_CSH [qx] [qy] [qz]==C2S) ||
11043 (mic_CSH [qx] [qy] [qz]==C3A) ||
11044 (mic_CSH [qx][qy][qz]==C4AF))){
11045
11046
11047 phase_temp[(int)newmat[px][py][pz]]++;
11048 WriteUnsortedList(px, py, pz);
11049 newmat [px] [py] [pz]=BURNT;
11050 nnew+=1;
11051 if(nnew>=SIZESET){
11052 printf("error in size of nnew %ld\n", nnew);
11053 }
11054 nnewx[nnew]=x1;
11055 nnewy[nnew]=y1;
11056 nnewz[nnew]=z1;
11057 }
11058 }
11059 }
11060 }
11061 if(nnew>0){
11062 ncur=nnew;
11063
11064 for(icur=1;icur<=ncur;icur++){
11065 nmatx[icur]=nnewx[icur];
11066 nmaty[icur]=nnewy[icur];
11067 nmatz[icur]=nnewz[icur];
11068 }
11069 }
11070 }while (nnew>0);
11071
11072
11073 xl=0;
11074 xh=SYSIZE-1;
11075
11076 for(j1=0;j1<SYSIZE;j1++){
11077 for(k1=0;k1<SYSIZE;k1++){
11078 px=cx(xl,j1,k1,d1,d2,d3);
11079 py=cy(xl,j1,k1,d1,d2,d3);
11080 pz=cz(xl,j1,k1,d1,d2,d3);
11081 qx=cx(xh,j1,k1,d1,d2,d3);
11082 qy=cy(xh,j1,k1,d1,d2,d3);
11083 qz=cz(xh,j1,k1,d1,d2,d3);
11084 if((newmat [px] [py] [pz]==BURNT)&&(newmat [qx] [qy] [qz]==BURNT)){
11085 igood=2;
11086 }
11087 if(newmat [px] [py] [pz]==BURNT){
11088 newmat [px] [py] [pz]=BURNT+1;
11089 }
11090 if(newmat [qx] [qy] [qz]==BURNT){
11091 newmat [qx] [qy] [qz]=BURNT+1;
11092 }
11093 }
11094 }
11095 if(igood==2){
11096
11097
11098 while(last!=NULL){
11099 ArrPerc[last->x][last->y][last->z] = mic_CSH[last->x][last->y][last->z];
11100
11101 current=last;
11102 last=last->prev;
11103
11104 delete current;
11105 }
11106
11107
11108 for(kh=0;kh<51;kh++){
11109 phase[kh]+=phase_temp[kh];
11110 }
11111
11112 }
11113
11114 }
11115 }
11116 }
11117
11118
11119
11120
11121 #ifdef OUTFILES
11122 outputImageFilePerc();
11123 #endif
11124
11125 for(kh=0;kh<51;kh++){
11126 cnt+=phase[kh];
11127 }
11128
11129 #ifdef OUTFILES
11130 fprintf(perc_phases,"%d %d ",cyccnt,cnt);
11131 cnt=0;
11132 #endif
11133
11134 phase[EMPTYP] = count[EMPTYP];
11135
11136
11137 for(kh=1;kh<=HDCSH;kh++){
11138 if(kh>=DIFFCSH && kh<=EMPTYP){
11139 continue;
11140 }
11141 cnt+=count[kh];
11142 }
11143
11144 #ifdef OUTFILES
11145 fprintf(perc_phases,"%d | ",cnt);
11146 for(kh=0;kh<=HDCSH;kh++){
11147 if(kh>ABSGYP && kh<EMPTYP){
11148 continue;
11149 }
11150
11151 phase[EMPTYP] = count[EMPTYP];
11152 fprintf(perc_phases, "%ld %ld ",
11153 phase[kh], kh==CSH?(count[CSH]-count[HDCSH]):count[kh]);
11154 }
11155 #endif
11156
11157
11158 #ifdef OUTFILES
11159 fprintf(perc_phases,"\n");
11160 fflush(percfile);
11161 #endif
11162
11163 dealloc_char_3D(newmat, SYSIZE);
11164 delete [] nmatx;
11165 delete [] nmaty;
11166 delete [] nmatz;
11167 delete [] nnewx;
11168 delete [] nnewy;
11169 delete [] nnewz;
11170
11171 }
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182 int cemhydmat::IsConnected(int cx, int cy, int cz, int dx, int dy, int dz){
11183
11184 int CentPhase,NeighPhase;
11185
11186 CentPhase=ArrPerc[AdjCoord(cx)][AdjCoord(cy)][AdjCoord(cz)];
11187 if (IsSolidPhase(CentPhase)){
11188 NeighPhase=ArrPerc[AdjCoord(cx+dx)][AdjCoord(cy+dy)][AdjCoord(cz+dz)];
11189
11190
11191 if (IsSolidPhase(NeighPhase)){
11192
11193
11194
11195 if((NeighPhase!=C3S) &&
11196 NeighPhase!=C2S &&
11197 NeighPhase!=C3A &&
11198 NeighPhase!=C4AF){
11199 return 2;
11200 }
11201
11202
11203
11204 else if((CentPhase!=C3S &&
11205 CentPhase!=C2S &&
11206 CentPhase!=C3A &&
11207 CentPhase!=C4AF) &&
11208 (NeighPhase==C3S ||
11209 NeighPhase==C2S ||
11210 NeighPhase==C3A ||
11211 NeighPhase==C4AF)){
11212 return 2;
11213 }
11214
11215
11216
11217
11218
11219 else if((micpart[AdjCoord(cx)][AdjCoord(cy)][AdjCoord(cz)]==
11220 micpart[AdjCoord(cx+dx)][AdjCoord(cy+dy)][AdjCoord(cz+dz)]) &&
11221 (CentPhase==C3S ||
11222 CentPhase==C2S ||
11223 CentPhase==C3A ||
11224 CentPhase==C4AF) &&
11225 (NeighPhase==C3S ||
11226 NeighPhase==C2S ||
11227 NeighPhase==C3A ||
11228 NeighPhase==C4AF)){
11229 return 2;
11230 }
11231
11232 else{
11233 return 1;
11234 }
11235
11236 }
11237 return 0;
11238
11239 }
11240 return 0;
11241 }
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278 void cemhydmat::GenerateConnNumbers(void){
11279 int cx, cy, cz;
11280 int CentPhase;
11281
11282
11283 for(cz=0;cz<SYSIZE;cz++){
11284 for(cy=0;cy<SYSIZE;cy++){
11285 for(cx=0;cx<SYSIZE;cx++){
11286
11287 ConnNumbers[cx][cy][cz]=0;
11288
11289
11290 CentPhase=ArrPerc[cx][cy][cz];
11291 if (IsSolidPhase(CentPhase)){
11292
11293
11294
11295
11296
11297
11298
11299 if(IsConnected(cx, cy, cz, 1, 0, 0)==1){
11300 ConnNumbers[cx][cy][cz]+=1;
11301 }
11302
11303
11304 if(IsConnected(cx, cy, cz, 0, 1, 0)==1){
11305 ConnNumbers[cx][cy][cz]+=2;
11306 }
11307
11308
11309 if(IsConnected(cx, cy, cz, 0, 0, 1)==1){
11310 ConnNumbers[cx][cy][cz]+=4;
11311 }
11312
11313
11314
11315
11316
11317 if(IsSolidPhase(ArrPerc[AdjCoord(cx+1)][AdjCoord(cy+1)][AdjCoord(cz)])){
11318 if((IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11319 IsConnected(cx+1, cy, cz, 0, 1, 0)!=2) &&
11320 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11321 IsConnected(cx, cy+1, cz, 1, 0, 0)!=2)){
11322 ConnNumbers[cx][cy][cz]+=8;
11323 }
11324 }
11325
11326
11327
11328
11329
11330 if(IsSolidPhase(ArrPerc[AdjCoord(cx+1)][AdjCoord(cy)][AdjCoord(cz+1)])){
11331 if((IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11332 IsConnected(cx+1, cy, cz, 0, 0, 1)!=2) &&
11333 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11334 IsConnected(cx, cy, cz+1, 1, 0, 0)!=2)){
11335 ConnNumbers[cx][cy][cz]+=16;
11336 }
11337 }
11338
11339
11340
11341
11342
11343 if(IsSolidPhase(ArrPerc[AdjCoord(cx)][AdjCoord(cy+1)][AdjCoord(cz+1)])){
11344 if((IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11345 IsConnected(cx, cy+1, cz, 0, 0, 1)!=2) &&
11346 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11347 IsConnected(cx, cy, cz+1, 0, 1, 0)!=2)){
11348 ConnNumbers[cx][cy][cz]+=32;
11349 }
11350 }
11351
11352
11353
11354
11355
11356
11357 if(IsSolidPhase(ArrPerc[AdjCoord(cx+1)][AdjCoord(cy)][AdjCoord(cz-1)])){
11358 if((IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11359 IsConnected(cx+1, cy, cz, 0, 0, -1)!=2) &&
11360 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11361 IsConnected(cx, cy, cz-1, 1, 0, 0)!=2)){
11362 ConnNumbers[cx][cy][cz]+=64;
11363 }
11364 }
11365
11366
11367
11368
11369
11370
11371 if(IsSolidPhase(ArrPerc[AdjCoord(cx)][AdjCoord(cy+1)][AdjCoord(cz-1)])){
11372 if((IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11373 IsConnected(cx, cy+1, cz, 0, 0, -1)!=2) &&
11374 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11375 IsConnected(cx, cy, cz-1, 0, 1, 0)!=2)){
11376 ConnNumbers[cx][cy][cz]+=128;
11377 }
11378 }
11379
11380
11381
11382
11383
11384
11385
11386 if(IsSolidPhase(ArrPerc[AdjCoord(cx-1)][AdjCoord(cy+1)][AdjCoord(cz)])){
11387 if((IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11388 IsConnected(cx, cy+1, cz, -1, 0, 0)!=2) &&
11389 (IsConnected(cx, cy, cz, -1, 0, 0)!=2 ||
11390 IsConnected(cx-1, cy, cz, 0, 1, 0)!=2)){
11391 ConnNumbers[cx][cy][cz]+=256;
11392 }
11393 }
11394
11395
11396
11397
11398
11399
11400 if(IsSolidPhase(ArrPerc[AdjCoord(cx+1)][AdjCoord(cy+1)][AdjCoord(cz+1)])){
11401
11402
11403 if((IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11404 IsConnected(cx+1, cy, cz, 0, 0, 1)!=2 ||
11405 IsConnected(cx+1, cy, cz+1, 0, 1, 0)!=2) &&
11406 (IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11407 IsConnected(cx+1, cy, cz, 0, 1, 0)!=2 ||
11408 IsConnected(cx+1, cy+1, cz, 0, 0, 1)!=2) &&
11409
11410 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11411 IsConnected(cx, cy+1, cz, 1, 0, 0)!=2 ||
11412 IsConnected(cx+1, cy+1, cz, 0, 0, 1)!=2) &&
11413 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11414 IsConnected(cx, cy+1, cz, 0, 0, 1)!=2 ||
11415 IsConnected(cx, cy+1, cz+1, 1, 0, 0)!=2) &&
11416
11417 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11418 IsConnected(cx, cy, cz+1, 1, 0, 0)!=2 ||
11419 IsConnected(cx+1, cy, cz+1, 0, 1, 0)!=2) &&
11420 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11421 IsConnected(cx, cy, cz+1, 0, 1, 0)!=2 ||
11422 IsConnected(cx, cy+1, cz+1, 1, 0, 0)!=2)){
11423 ConnNumbers[cx][cy][cz]+=512;
11424 }
11425 }
11426
11427
11428
11429
11430
11431
11432
11433 if(IsSolidPhase(ArrPerc[AdjCoord(cx+1)][AdjCoord(cy+1)][AdjCoord(cz-1)])){
11434
11435 if((IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11436 IsConnected(cx+1, cy, cz, 0, 0, -1)!=2 ||
11437 IsConnected(cx+1, cy, cz-1, 0, 1, 0)!=2) &&
11438 (IsConnected(cx, cy, cz, 1, 0, 0)!=2 ||
11439 IsConnected(cx+1, cy, cz, 0, 1, 0)!=2 ||
11440 IsConnected(cx+1, cy+1, cz, 0, 0, -1)!=2) &&
11441
11442 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11443 IsConnected(cx, cy+1, cz, 1, 0, 0)!=2 ||
11444 IsConnected(cx+1, cy+1, cz, 0, 0, -1)!=2) &&
11445 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11446 IsConnected(cx, cy+1, cz, 0, 0, -1)!=2 ||
11447 IsConnected(cx, cy+1, cz-1, 1, 0, 0)!=2) &&
11448
11449 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11450 IsConnected(cx, cy, cz-1, 1, 0, 0)!=2 ||
11451 IsConnected(cx+1, cy, cz-1, 0, 1, 0)!=2) &&
11452 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11453 IsConnected(cx, cy, cz-1, 0, 1, 0)!=2 ||
11454 IsConnected(cx, cy+1, cz-1, 1, 0, 0)!=2)){
11455 ConnNumbers[cx][cy][cz]+=1024;
11456 }
11457 }
11458
11459
11460
11461
11462
11463
11464
11465 if(IsSolidPhase(ArrPerc[AdjCoord(cx-1)][AdjCoord(cy+1)][AdjCoord(cz-1)])){
11466
11467 if((IsConnected(cx, cy, cz, -1, 0, 0)!=2 ||
11468 IsConnected(cx-1, cy, cz, 0, 0, -1)!=2 ||
11469 IsConnected(cx-1, cy, cz-1, 0, 1, 0)!=2) &&
11470 (IsConnected(cx, cy, cz, -1, 0, 0)!=2 ||
11471 IsConnected(cx-1, cy, cz, 0, 1, 0)!=2 ||
11472 IsConnected(cx-1, cy+1, cz, 0, 0, -1)!=2) &&
11473
11474 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11475 IsConnected(cx, cy+1, cz, -1, 0, 0)!=2 ||
11476 IsConnected(cx-1, cy+1, cz, 0, 0, -1)!=2) &&
11477 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11478 IsConnected(cx, cy+1, cz, 0, 0, -1)!=2 ||
11479 IsConnected(cx, cy+1, cz-1, -1, 0, 0)!=2) &&
11480
11481 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11482 IsConnected(cx, cy, cz-1, -1, 0, 0)!=2 ||
11483 IsConnected(cx-1, cy, cz-1, 0, 1, 0)!=2) &&
11484 (IsConnected(cx, cy, cz, 0, 0, -1)!=2 ||
11485 IsConnected(cx, cy, cz-1, 0, 1, 0)!=2 ||
11486 IsConnected(cx, cy+1, cz-1, -1, 0, 0)!=2)){
11487 ConnNumbers[cx][cy][cz]+=2048;
11488 }
11489 }
11490
11491
11492
11493
11494
11495
11496 if(IsSolidPhase(ArrPerc[AdjCoord(cx-1)][AdjCoord(cy+1)][AdjCoord(cz+1)])){
11497
11498 if((IsConnected(cx, cy, cz, -1, 0, 0)!=2 ||
11499 IsConnected(cx-1, cy, cz, 0, 0, 1)!=2 ||
11500 IsConnected(cx-1, cy, cz+1, 0, 1, 0)!=2) &&
11501 (IsConnected(cx, cy, cz, -1, 0, 0)!=2 ||
11502 IsConnected(cx-1, cy, cz, 0, 1, 0)!=2 ||
11503 IsConnected(cx-1, cy+1, cz, 0, 0, 1)!=2) &&
11504
11505 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11506 IsConnected(cx, cy+1, cz, -1, 0, 0)!=2 ||
11507 IsConnected(cx-1, cy+1, cz, 0, 0, 1)!=2) &&
11508 (IsConnected(cx, cy, cz, 0, 1, 0)!=2 ||
11509 IsConnected(cx, cy+1, cz, 0, 0, 1)!=2 ||
11510 IsConnected(cx, cy+1, cz+1, -1, 0, 0)!=2) &&
11511
11512 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11513 IsConnected(cx, cy, cz+1, -1, 0, 0)!=2 ||
11514 IsConnected(cx-1, cy, cz+1, 0, 1, 0)!=2) &&
11515 (IsConnected(cx, cy, cz, 0, 0, 1)!=2 ||
11516 IsConnected(cx, cy, cz+1, 0, 1, 0)!=2 ||
11517 IsConnected(cx, cy+1, cz+1, -1, 0, 0)!=2)){
11518 ConnNumbers[cx][cy][cz]+=4096;
11519 }
11520 }
11521
11522
11523 }
11524 }
11525 }
11526 }
11527 }
11528
11529 void cemhydmat::outputImageFilePerc(void){
11530 FILE *perc_img;
11531 char extension[10];
11532
11533 char *prefix;
11534 prefix = (char *)malloc(80);
11535
11536
11537
11538 system("mkdir perc 2> /dev/null");
11539
11540 sprintf(extension, "%04d", icyc);
11541 strcpy(prefix,"perc/out5.");
11542 strcat(prefix, extension);
11543 strcat(prefix, ".p.img");
11544 #ifdef PRINTF
11545 printf("name of output file is %s\n", prefix);
11546 #endif
11547
11548 if((perc_img=fopen(prefix, "w"))==NULL){
11549 printf("\nfile %s can not be opened\n", prefix);
11550 free(prefix);
11551 return;
11552 }
11553
11554 for(int dz=0;dz<SYSIZE;dz++){
11555 for(int dy=0;dy<SYSIZE;dy++){
11556 for(int dx=0;dx<SYSIZE;dx++){
11557 fprintf(perc_img, "%d %d\n", ArrPerc[dx][dy][dz],
11558 ConnNumbers[dx][dy][dz]);
11559 }
11560 }
11561 }
11562
11563 fclose(perc_img);
11564 free(prefix);
11565 }
11566
11567
11568
11569 void cemhydmat::WriteUnsortedList(int px, int py, int pz){
11570 current = new percolatedpath;
11571 if(last!=NULL){
11572 last->next=current;
11573 }
11574 else {
11575 current->prev=NULL;
11576 }
11577
11578 current->x=px;
11579 current->y=py;
11580 current->z=pz;
11581 current->prev=last;
11582 last=current;
11583 }
11584
11585
11586
11587 inline int cemhydmat::AdjCoord(int coord){
11588 if(coord<0){coord+=SYSIZE;}
11589 if(coord>=SYSIZE){coord-=SYSIZE;}
11590 return coord;
11591 }
11592
11593
11594 int cemhydmat::NumSol(int cx, int cy, int cz){
11595 int cnt=0;
11596 int *p_arr;
11597
11598
11599 for (int dx = -BoxSize; dx <= BoxSize; dx++){
11600 for (int dy = -BoxSize; dy <= BoxSize; dy++){
11601 for (int dz = -BoxSize; dz <= BoxSize; dz++){
11602
11603 if(mic_CSH[AdjCoord(cx+dx)][AdjCoord(cy+dy)][AdjCoord(cz+dz)]!=POROSITY && mic_CSH[AdjCoord(cx+dx)][AdjCoord(cy+dy)][AdjCoord(cz+dz)]!=EMPTYP){
11604
11605 cnt++;
11606 }
11607 }
11608 }
11609 }
11610
11611
11612 CSH_vicinity[cnt]++;
11613
11614
11615
11616 if(cnt>=SolidLimit){
11617 cnt=0;
11618
11619 for (int dx = -BoxSize; dx <= BoxSize; dx++){
11620 for (int dy = -BoxSize; dy <= BoxSize; dy++){
11621 for (int dz = -BoxSize; dz <= BoxSize; dz++){
11622
11623 p_arr = &mic_CSH[AdjCoord(cx+dx)][AdjCoord(cy+dy)][AdjCoord(cz+dz)];
11624
11625 if(*p_arr==CSH){
11626 *p_arr=HDCSH;
11627 cnt++;
11628
11629
11630 }
11631 }
11632 }
11633 }
11634 }
11635 else{
11636 cnt=0;
11637
11638
11639 }
11640 return cnt;
11641 }
11642
11643
11644
11645
11646 void cemhydmat::CSHbox(unsigned int *CSH_vicinity){
11647 int TotPhase=0;
11648 int cx,cy,cz;
11649
11650 for(int i=0; i<=((2*BoxSize+1)*(2*BoxSize+1)*(2*BoxSize+1));i++){
11651 CSH_vicinity[i]=0;
11652 }
11653
11654
11655 for (cx = 0; cx < SYSIZE; cx++){
11656 for (cy = 0; cy < SYSIZE; cy++){
11657 for (cz = 0; cz < SYSIZE; cz++){
11658 mic_CSH[cx][cy][cz]=mic[cx][cy][cz];
11659 }
11660 }
11661 }
11662
11663
11664
11665 for (cx = 0; cx < SYSIZE; cx++){
11666 for (cy = 0; cy < SYSIZE; cy++){
11667 for (cz = 0; cz < SYSIZE; cz++){
11668
11669 if(mic_CSH[cx][cy][cz]==CSH || mic_CSH[cx][cy][cz]==HDCSH){
11670 TotPhase+=NumSol(cx,cy,cz);
11671 }
11672 }
11673 }
11674 }
11675
11676 count[HDCSH]=TotPhase;
11677 }
11678
11679
11680
11681 void cemhydmat::nrerror(const char *error_text){
11682 printf("\nNumerical Recipes run-time error...\n");
11683 printf("%s\n",error_text);
11684 printf("...now exiting to system...\n");
11685 exit(1);
11686 }
11687
11688
11689 float* cemhydmat::vector(int nl,int nh){
11690 float *v;
11691
11692 v=(float *)malloc((unsigned) (nh-nl+1)*sizeof(float));
11693 if (!v){
11694 nrerror("allocation failure in vector()");
11695 }
11696 return v-nl;
11697 }
11698
11699 int* cemhydmat::ivector(int nl,int nh){
11700 int *v;
11701
11702 v=(int *)malloc((unsigned) (nh-nl+1)*sizeof(int));
11703 if (!v) nrerror("allocation failure in ivector()");
11704 return v-nl;
11705 }
11706
11707 double* cemhydmat::dvector(int nl,int nh){
11708 double *v;
11709
11710 v=(double *)malloc((unsigned) (nh-nl+1)*sizeof(double));
11711 if (!v) nrerror("allocation failure in dvector()");
11712 return v-nl;
11713 }
11714
11715
11716
11717
11718 float** cemhydmat::matrix_cem(int nrl,int nrh,int ncl,int nch){
11719
11720 int i;
11721 float **m;
11722
11723 m=(float **) malloc((unsigned) (nrh-nrl+1)*sizeof(float*));
11724 if (!m) nrerror("allocation failure 1 in matrix_cem()");
11725 m -= nrl;
11726
11727 for(i=nrl;i<=nrh;i++) {
11728 m[i]=(float *) malloc((unsigned) (nch-ncl+1)*sizeof(float));
11729 if (!m[i]) nrerror("allocation failure 2 in matrix_cem()");
11730 m[i] -= ncl;
11731 }
11732 return m;
11733 }
11734
11735 double** cemhydmat::dmatrix(int nrl,int nrh,int ncl,int nch){
11736 int i;
11737 double **m;
11738
11739 m=(double **) malloc((unsigned) (nrh-nrl+1)*sizeof(double*));
11740 if (!m) nrerror("allocation failure 1 in dmatrix()");
11741 m -= nrl;
11742
11743 for(i=nrl;i<=nrh;i++) {
11744 m[i]=(double *) malloc((unsigned) (nch-ncl+1)*sizeof(double));
11745 if (!m[i]) nrerror("allocation failure 2 in dmatrix()");
11746 m[i] -= ncl;
11747 }
11748 return m;
11749 }
11750
11751 int** cemhydmat::imatrix(int nrl,int nrh,int ncl,int nch){
11752 int i,**m;
11753
11754 m=(int **)malloc((unsigned) (nrh-nrl+1)*sizeof(int*));
11755 if (!m) nrerror("allocation failure 1 in imatrix()");
11756 m -= nrl;
11757
11758 for(i=nrl;i<=nrh;i++) {
11759 m[i]=(int *)malloc((unsigned) (nch-ncl+1)*sizeof(int));
11760 if (!m[i]) nrerror("allocation failure 2 in imatrix()");
11761 m[i] -= ncl;
11762 }
11763 return m;
11764 }
11765
11766
11767
11768 float** cemhydmat::submatrix(float **a,int oldrl,int oldrh,int oldcl,int,int newrl,int newcl){
11769 int i,j;
11770 float **m;
11771
11772 m=(float **) malloc((unsigned) (oldrh-oldrl+1)*sizeof(float*));
11773 if (!m) nrerror("allocation failure in submatrix()");
11774 m -= newrl;
11775
11776 for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+oldcl-newcl;
11777
11778 return m;
11779 }
11780
11781
11782
11783 void free_vector(float *v, int nl){
11784 free((char*) (v+nl));
11785 }
11786
11787 void free_ivector(int *v,int nl){
11788 free((char*) (v+nl));
11789 }
11790
11791 void free_dvector(double *v,int nl){
11792 free((char*) (v+nl));
11793 }
11794
11795
11796
11797 void free_matrix(float **m,int nrl,int nrh, int ncl){
11798 int i;
11799
11800 for(i=nrh;i>=nrl;i--) free((char*) (m[i]+ncl));
11801 free((char*) (m+nrl));
11802 }
11803
11804 void free_dmatrix(double **m,int nrl,int nrh, int ncl){
11805 int i;
11806
11807 for(i=nrh;i>=nrl;i--) free((char*) (m[i]+ncl));
11808 free((char*) (m+nrl));
11809 }
11810
11811 void free_imatrix(int **m,int nrl,int nrh,int ncl){
11812 int i;
11813
11814 for(i=nrh;i>=nrl;i--) free((char*) (m[i]+ncl));
11815 free((char*) (m+nrl));
11816 }
11817
11818 void free_submatrix(float *b,int nrl){
11819 free((char*) (b+nrl));
11820 }
11821
11822 float** cemhydmat::convert_matrix(float *a,int nrl,int nrh,int ncl,int nch){
11823 int i,j,nrow,ncol;
11824 float **m;
11825
11826 nrow=nrh-nrl+1;
11827 ncol=nch-ncl+1;
11828 m = (float **) malloc((unsigned) (nrow)*sizeof(float*));
11829 if (!m) nrerror("allocation failure in convert_matrix()");
11830 m -= nrl;
11831 for(i=0,j=nrl;i<=nrow-1;i++,j++) m[j]=a+ncol*i-ncl;
11832 return m;
11833 }
11834
11835 void free_convert_matrix(float **b,int nrl){
11836 free((char*) (b+nrl));
11837 }
11838
11839 fcomplex_cem cemhydmat::Cadd(fcomplex_cem a,fcomplex_cem b){
11840 fcomplex_cem c;
11841 c.r=a.r+b.r;
11842 c.i=a.i+b.i;
11843 return c;
11844 }
11845
11846 fcomplex_cem cemhydmat::Csub(fcomplex_cem a,fcomplex_cem b){
11847 fcomplex_cem c;
11848 c.r=a.r-b.r;
11849 c.i=a.i-b.i;
11850 return c;
11851 }
11852
11853 fcomplex_cem cemhydmat::Cmul(fcomplex_cem a,fcomplex_cem b){
11854 fcomplex_cem c;
11855 c.r=a.r*b.r-a.i*b.i;
11856 c.i=a.i*b.r+a.r*b.i;
11857 return c;
11858 }
11859
11860 fcomplex_cem cemhydmat::Complex(float re,float im){
11861 fcomplex_cem c;
11862 c.r=re;
11863 c.i=im;
11864 return c;
11865 }
11866
11867 fcomplex_cem cemhydmat::Conjg(fcomplex_cem z){
11868 fcomplex_cem c;
11869 c.r=z.r;
11870 c.i = -z.i;
11871 return c;
11872 }
11873
11874 fcomplex_cem cemhydmat::Cdiv(fcomplex_cem a,fcomplex_cem b){
11875 fcomplex_cem c;
11876 float r,den;
11877 if (fabs(b.r) >= fabs(b.i)) {
11878 r=b.i/b.r;
11879 den=b.r+r*b.i;
11880 c.r=(a.r+r*a.i)/den;
11881 c.i=(a.i-r*a.r)/den;
11882 } else {
11883 r=b.r/b.i;
11884 den=b.i+r*b.r;
11885 c.r=(a.r*r+a.i)/den;
11886 c.i=(a.i*r-a.r)/den;
11887 }
11888 return c;
11889 }
11890
11891 float cemhydmat::Cabs(fcomplex_cem z){
11892 float x,y,ans,temp;
11893 x=fabs(z.r);
11894 y=fabs(z.i);
11895 if (x == 0.0)
11896 ans=y;
11897 else if (y == 0.0)
11898 ans=x;
11899 else if (x > y) {
11900 temp=y/x;
11901 ans=x*sqrt(1.0+temp*temp);
11902 } else {
11903 temp=x/y;
11904 ans=y*sqrt(1.0+temp*temp);
11905 }
11906 return ans;
11907 }
11908
11909 fcomplex_cem cemhydmat::Csqrt(fcomplex_cem z){
11910 fcomplex_cem c;
11911 float x,y,w,r;
11912 if ((z.r == 0.0) && (z.i == 0.0)) {
11913 c.r=0.0;
11914 c.i=0.0;
11915 return c;
11916 } else {
11917 x=fabs(z.r);
11918 y=fabs(z.i);
11919 if (x >= y) {
11920 r=y/x;
11921 w=sqrt(x)*sqrt(0.5*(1.0+sqrt(1.0+r*r)));
11922 } else {
11923 r=x/y;
11924 w=sqrt(y)*sqrt(0.5*(r+sqrt(1.0+r*r)));
11925 }
11926 if (z.r >= 0.0) {
11927 c.r=w;
11928 c.i=z.i/(2.0*w);
11929 } else {
11930 c.i=(z.i >= 0) ? w : -w;
11931 c.r=z.i/(2.0*c.i);
11932 }
11933 return c;
11934 }
11935 }
11936
11937 fcomplex_cem cemhydmat::RCmul(float x,fcomplex_cem a){
11938 fcomplex_cem c;
11939 c.r=x*a.r;
11940 c.i=x*a.i;
11941 return c;
11942 }
11943
11944
11945
11946 void cemhydmat::CreateHDCSH(void){
11947 CSHbox(CSH_vicinity);
11948 }
11949
11950
11951 void cemhydmat::PercolateForOutput(void){
11952 burn_phases(1,0,0);
11953 }
11954
11955
11956 double cemhydmat::GetWcr(void){
11957 return w_to_c;
11958 }
11959
11960
11961
11962
11963
11964 void cemhydmat::GetInputParams(char *my_string){
11965 sprintf(my_string, "%d", iseed);
11966 }
11967
11968 long cemhydmat::cx(int x,int y,int z,int a,int b,int c){
11969 return (1-b-c)*x+(1-a-c)*y+(1-a-b)*z;
11970 }
11971
11972
11973 long cemhydmat::cy(int x,int y,int z,int a,int b,int c){
11974 return (1-a-b)*x+(1-b-c)*y+(1-a-c)*z;
11975 }
11976
11977 long cemhydmat::cz(int x,int y,int z,int a,int b,int c){
11978 return (1-a-c)*x+(1-a-b)*y+(1-b-c)*z;
11979 }
11980
11981
11982 void cemhydmat::AnalyticHomogenizationPaste(double &E, double &nu, int perc_unperc_flag){
11983
11984
11985 int index,x,i;
11986 double sum = 0.;
11987 double LevelI[2][3];
11988 double E_CSH_hmg,nu_CSH_hmg;
11989 HomogData CSH_level, Paste_level;
11990
11991
11992
11993 for(x=0;x<34;x++){
11994 PhaseFrac[x] = 0.;
11995 }
11996
11997 for(x=0;x<51;x++){
11998 index = x;
11999 if(x==HDCSH){
12000 index = 31;
12001 }
12002 else if(x==EMPTYP){
12003 index = 30;
12004 }
12005 else if(x>=DIFFCSH){
12006 continue;
12007 }
12008
12009
12010 if(perc_unperc_flag == 0){
12011 PhaseFrac[index+1] += phase[x];
12012 }
12013 else{
12014 if(x==CSH){
12015 PhaseFrac[index+1] += (count[CSH]-count[HDCSH]);
12016 }
12017 else{
12018 PhaseFrac[index+1] += count[x];
12019 }
12020
12021 }
12022 }
12023
12024 for(x=2;x<34;x++){
12025 PhaseFrac[x] /= SYSIZE_POW3;
12026 sum += PhaseFrac[x];
12027 }
12028
12029
12030
12031 PhaseFrac[1] = 1 - sum;
12032
12033 for(x=0;x<34;x++){
12034
12035
12036
12037 }
12038
12039 double PhaseMatrix[][3]= {{PhaseFrac[1], 0.001,0.499924},
12040 {PhaseFrac[2], 135.0,0.3000},
12041 {PhaseFrac[3], 130.0,0.3000},
12042 {PhaseFrac[4], 145.0,0.3000},
12043 {PhaseFrac[5], 125.0,0.3000},
12044 {PhaseFrac[6], 30.0,0.3000},
12045 {PhaseFrac[7], 62.9,0.3000},
12046 {PhaseFrac[8], 73.6,0.2750},
12047 {PhaseFrac[9], 72.8,0.1670},
12048 {PhaseFrac[10],79.6,0.3099},
12049 {PhaseFrac[11],72.8,0.1670},
12050 {PhaseFrac[12],72.8,0.1670},
12051 {PhaseFrac[13],72.8,0.1670},
12052 {PhaseFrac[14],38.0,0.3050},
12053
12054 {PhaseFrac[16],22.4, 0.25},
12055 {PhaseFrac[17],22.4, 0.25},
12056 {PhaseFrac[18],22.4, 0.25},
12057 {PhaseFrac[19],42.3, 0.3238},
12058 {PhaseFrac[20],22.4, 0.2459},
12059 {PhaseFrac[21],22.4, 0.2459},
12060 {PhaseFrac[22],22.4, 0.2459},
12061 {PhaseFrac[23],42.3, 0.3238},
12062 {PhaseFrac[24],22.4, 0.2459},
12063 {PhaseFrac[25],22.4, 0.25},
12064 {PhaseFrac[26],30.0, 0.30},
12065 {PhaseFrac[27],0.001, 0.001},
12066 {PhaseFrac[28],42.3, 0.3238},
12067 {PhaseFrac[29],79.6, 0.3099},
12068 {PhaseFrac[30],30.0, 0.30},
12069 {PhaseFrac[31],0.001, 0.001}};
12070
12071
12072
12073 if(PhaseFrac[15] == 0. && PhaseFrac[32] == 0.){
12074 LevelI[0][0] = 1.;
12075 LevelI[1][0] = 0.;
12076 }
12077 else {
12078 LevelI[0][0] = PhaseFrac[15]/(PhaseFrac[15]+PhaseFrac[32]);
12079 LevelI[1][0] = PhaseFrac[32]/(PhaseFrac[15]+PhaseFrac[32]);
12080 }
12081
12082 LevelI[0][1]=21.7;
12083 LevelI[0][2]=0.24;
12084
12085 LevelI[1][1]=29.4;
12086 LevelI[1][2]=0.24;
12087
12088
12089 CSH_level.MT_mtrx(*LevelI, 2, 0);
12090
12091
12092 for(i=0;i<31;i++){
12093 PhaseMatrix[i][0] = PhaseFrac[i+1];
12094 }
12095
12096
12097
12098 PhaseMatrix[14][0] = PhaseFrac[15]+PhaseFrac[32];
12099 PhaseMatrix[14][1] = CSH_level.E_hmg;
12100 PhaseMatrix[14][2] = CSH_level.nu_hmg;
12101
12102 E_CSH_hmg = CSH_level.E_hmg;
12103 nu_CSH_hmg = CSH_level.nu_hmg;
12104
12105 Paste_level.SCS(*PhaseMatrix, 31);
12106
12107 E = Paste_level.E_hmg;
12108 nu = Paste_level.nu_hmg;
12109 }
12110
12111
12112 void cemhydmat::AnalyticHomogenizationConcrete(double E_paste_inp, double nu_paste_inp, double *E_paste, double *nu_paste, double *E_mortar, double *nu_mortar, double &E_concrete, double &nu_concrete){
12113
12114 HomogData Paste_level, Mortar_level, Concrete_level;
12115
12116
12117 double vol_tot_paste = Vol_cement_clinker_gypsum + Vol_cement_SCM + Vol_water + Vol_inert_filler + Vol_entrained_entrapped_air;
12118 double PhaseMatrix[][3]= {{(Vol_cement_clinker_gypsum + Vol_water)/vol_tot_paste, E_paste_inp, nu_paste_inp},
12119 {Vol_cement_SCM / vol_tot_paste, Young_SCM, Poisson_SCM},
12120 {Vol_inert_filler / vol_tot_paste, Young_inert, Poisson_inert},
12121 {Vol_entrained_entrapped_air / vol_tot_paste, 0.001, 0.001}};
12122 Paste_level.MT_mtrx(*PhaseMatrix, 4, 0);
12123 *E_paste = Paste_level.E_hmg;
12124 *nu_paste = Paste_level.nu_hmg;
12125
12126
12127
12128
12129 double n_FA, n_CA, vol_ITZ_FA, vol_ITZ_CA;
12130 n_FA = Vol_FA / (4./3.*PI*pow(0.01*Grain_average_FA/2.,3.));
12131 vol_ITZ_FA = n_FA * 4./3.*PI*(pow(0.01*Grain_average_FA/2.+0.00001*ITZ_thickness,3)-pow(0.01*Grain_average_FA/2.,3));
12132 n_CA = Vol_CA / (4./3.*PI*pow(0.01*Grain_average_CA/2.,3));
12133 vol_ITZ_CA = n_CA * 4./3.*PI*(pow(0.01*Grain_average_CA/2.+0.00001*ITZ_thickness,3)-pow(0.01*Grain_average_CA/2.,3));
12134 double vol_tot_mortar = vol_tot_paste + Vol_FA;
12135 double Mortar[][3]= {{Vol_FA / vol_tot_mortar, Young_FA, Poisson_FA},
12136 {vol_ITZ_FA/vol_tot_mortar, *E_paste * ITZ_Young_red, *nu_paste},
12137 {(vol_tot_paste - vol_ITZ_FA)/vol_tot_mortar, *E_paste, *nu_paste},
12138 {100., 10., 0.3}};
12139 Mortar_level.HerveZaoui(*Mortar, 4);
12140 *E_mortar=Mortar_level.E_hmg;
12141 *nu_mortar=Mortar_level.nu_hmg;
12142
12143
12144 double vol_tot_concrete = vol_tot_mortar + Vol_CA;
12145 double Concrete[][3]= {{Vol_CA / vol_tot_concrete, Young_CA, Poisson_CA},
12146 {vol_ITZ_CA/vol_tot_concrete, *E_paste * ITZ_Young_red, *nu_paste},
12147 {(vol_tot_mortar - vol_ITZ_CA)/vol_tot_concrete, *E_mortar, *nu_mortar},
12148 {100., 10., 0.3}};
12149 Concrete_level.HerveZaoui(*Concrete, 4);
12150 E_concrete=Concrete_level.E_hmg;
12151 nu_concrete=Concrete_level.nu_hmg;
12152 }
12153
12154
12155 void cemhydmat::GetInitClinkerPhases(double &c3s, double &c2s, double &c3a, double &c4af, double &gypsum, double &hemi, double & anh) {
12156 double sum = c3sinit + c2sinit + c3ainit + c4afinit + ncsbar + heminit + anhinit;
12157
12158 if(icyc>1){
12159 c3s = (double)c3sinit/sum;
12160 c2s = (double)c2sinit/sum;
12161 c3a = (double)c3ainit/sum;
12162 c4af = (double)c4afinit/sum;
12163 gypsum = (double)ncsbar/sum;
12164 hemi = (double)heminit/sum;
12165 anh = (double)anhinit/sum;
12166 }
12167
12168 }
12169
12170 #ifdef PYTHON
12171 #include <boost/python.hpp>
12172 BOOST_PYTHON_MODULE(cemhydmat)
12173 {
12174 boost::python::class_<cemhydmat>("cemhydmat")
12175 .def("readcem", &cemhydmat::readcem)
12176 .def("MoveCycles", &cemhydmat::MoveCycles)
12177 ;
12178 }
12179 #endif