int drawanimation=0; int ipybot=400,ipytop=295; float Clong,Cshear; // long and shear wave velocity (Jul 24) float uca=1; // side length of unit cell (m) float ucc=0.93; // side length of unit cell (m) #define VERN "hc2mod.cpp" #define zview 1 #define makedatfile 0 // hc2mod.cpp random angles again // f trying to find problem // e The pattern of cm's of 6 clusters definitely looks wrong! // d Aug 18 looking for any problem //extrafactor=extrafactor*1.1; // Aug 18 experiment // hc1cmod.cpp Aug 17 fix maxpossrad, 3cl 6cl force // try nu=0.35 // hc1bmod.cpp works fine, enumerates 3-clus. and 6-clus. only // hc1mod.cpp Aug 17 hexagonal unit cell - works fine, for nu=0.25 only // Aug 7 added Y2O3 // cc3bmod Aug 5 g/cc, GPa input units, display // Aug 4 -- oops! I noticed that I set mvx[] = 0 by mistake // (That is why the breathing mode worked while while others didn't.) // cc3mod.cpp Aug 3 8pt // cc2mod.cpp Jul 31 ksp1, ksp2 only (Poisson=.25 if isotropic) // (tested and works perfectly for breathing, dog, sph2 modes) #include #include #include #include #include #include #include #include #include int MaxNm,ActNm; int getmnl(int im1,int in2); void setmnl(int im1,int in2,int im3); // Molecule positions: #define MaxNn 10 unsigned int *m0nl,*m1nl,*m2nl; unsigned int *m3nl,*m4nl,*m5nl; unsigned int *m6nl,*m7nl,*m8nl; int *m9nl; int *m10nl,*m11nl; int *m12nl,*m13nl,*m14nl; unsigned char *mcol; unsigned char *oldmx,*oldmy,*oldmz; unsigned char *atouched; void makescr(void); // and velocities... float *mx,*my,*mz; float *mvx,*mvy,*mvz; float *max,*may,*maz; float r122,r121,dx,dy,dz,r124,r126,r127,r1212,r1213,r12,r128,r1214; float mindist2=-1,maxdist2=-1,mindistever=1000; float totalenergy,mintotalenergy=2000,maxtotalenergy=-2000; char beepc=7; float dissipcoef; long int vmaxvalever=0; #define nofr 640 float *fsumr1,*fsumi1; float *fsumr2,*fsumi2; float *fsumr3,*fsumi3; unsigned char *oldfgraf; float LegenP(int n,float x); float SphBess1j(int n,float x); float SeriesSphBess1j(int n,float x); float rPix(int n,float x,float y,float z); float rPiy(int n,float x,float y,float z); float rPiz(int n,float x,float y,float z); float CrPix(int n,float x,float y,float z); float CrPiy(int n,float x,float y,float z); float CrPiz(int n,float x,float y,float z); float C2rPix(int n,float x,float y,float z); float C2rPiy(int n,float x,float y,float z); float C2rPiz(int n,float x,float y,float z); float ksguess=1,klguess=1; float THETAx(int n,float x,float y,float z); float THETAy(int n,float x,float y,float z); float THETAz(int n,float x,float y,float z); double factorial(double arg); void mn(char *ch1); char matername[50]; float ksp1,ksp3,ksp4,k3pt,k6pt; float densityrho,cellmass; int n6pt[8]; float cellvol; void main(void) { // main cellvol=uca*uca*sqrt(3.0)*0.5*ucc; // unit cell volume clrscr(); float C11,C12,C44,bulkmodulus,shearmodulus,Youngsmodulus,Poissonratio,lambdaLame,r1; float Y100,Poisson100; int matertype,isotropic=-1,i1; LBnewm: strcpy(matername,"?????"); for (i1=8;i1<=25;i1++) { //. gotoxy(40,i1);cout<<" "; } //. for (i1=10;i1<=25;i1++) { //. gotoxy(10,i1);cout<<" "; } //. gotoxy(1,25);cout<<" "; gotoxy(1,1);cout<<"Material Property Input Options:"; gotoxy(1,2);cout<<"--------------------------------"; gotoxy(1,3);cout<<"1. Specify density, Y, Poisson ratio"; gotoxy(1,4);cout<<"2. "; gotoxy(1,5);cout<<"3. Cubic crystal: (dens., C11, C12, C44)"; gotoxy(1,6);cout<<"4. "; gotoxy(1,5+2); cout<<"5. Si crys 300K"; gotoxy(1,6+2); cout<<"6. Ge crys 300K"; gotoxy(1,7+2); cout<<"7. KCl crys 4 K"; gotoxy(1,8+2); cout<<"8. LiCl crys 300K"; gotoxy(1,9+2); cout<<"9. LiF crys 0 K"; gotoxy(1,10+2);cout<<"10. GaSb crys 300K"; gotoxy(1,11+2);cout<<"11. MgO crys 300K"; gotoxy(1,12+2);cout<<"12. NaCl crys 300K"; gotoxy(1,13+2);cout<<"13. GaP crys 300K"; gotoxy(1,14+2);cout<<"14. GaAs crys 300K"; gotoxy(1,15+2);cout<<"15. CsBr crys 300K"; gotoxy(1,16+2);cout<<"16. Diamond 300K"; gotoxy(1,17+2);cout<<"17. Ag crys 300K"; gotoxy(1,18+2);cout<<"18. InAs crys 293K"; gotoxy(1,19+2);cout<<"19. Fe crys 300K"; gotoxy(1,20+2);cout<<"20. Ni crys 300K"; gotoxy(1,21+2);cout<<"21. Al crys 300K"; gotoxy(1,22+2);cout<<"22. Cu crys 300K"; gotoxy(1,23+2);cout<<"23. Au crys 300K"; gotoxy(21,7); cout<<"24. RbI crys 300K"; gotoxy(21,8); cout<<"25. W crys 0 K"; gotoxy(21,9); cout<<"26. Ta crys 0 K"; gotoxy(21,10); cout<<"27. V crys 0 K"; gotoxy(21,11); cout<<"28. BaF2 crys 300K"; gotoxy(21,12); cout<<"29. InSb crys 300K"; gotoxy(21,13); cout<<"30. RbBr crys 300K"; gotoxy(21,14); cout<<"31. CsI crys 300K"; gotoxy(21,15); cout<<"32. Nb crys 300K"; gotoxy(21,16); cout<<"33. RbCl crys 300K"; gotoxy(21,17); cout<<"34. KF crys 300K"; gotoxy(21,18); cout<<"35. InP crys 300K"; gotoxy(21,19); cout<<"36. GaN ZincBlende"; gotoxy(21,20); cout<<"37. Mo crys "; gotoxy(21,21); cout<<"38. Y2O3 crys 293K"; gotoxy(21,22); cout<<"39. - - - "; gotoxy(21,23); cout<<"40. - - - "; gotoxy(21,24); cout<<"41. - - - "; gotoxy(21,25); cout<<"42. - - - "; gotoxy(41,7); cout<<"43. - - - ";// gotoxy(41,8); cout<<"44. - - - ";// gotoxy(41,9); cout<<"45. - - - ";// gotoxy(41,10);cout<<"46. Copper, Cu";// gotoxy(41,11);cout<<"47. Aluminum, Al"; gotoxy(41,12);cout<<"48. Cast Iron "; gotoxy(41,13);cout<<"49. Lead, Pb"; gotoxy(41,14);cout<<"50. Lucite ";//. gotoxy(41,15);cout<<"51. Silver, Ag";//.. gotoxy(41,16);cout<<"52. Steel ";// gotoxy(41,17);cout<<"53. fcc crys ";// gotoxy(41,18);cout<<"54. Brass "; gotoxy(41,19);cout<<"55. Europium, Eu";// gotoxy(41,20);cout<<"56. Alumina Al2O3"; gotoxy(41,21);cout<<"57. 96%SilicaGlass"; gotoxy(41,22);cout<<"58. Fused Quartz"; gotoxy(41,23);cout<<"59. Silcon Carbide"; gotoxy(41,24);cout<<"60. Glass (Pyrex)"; gotoxy(41,25);cout<<"61. - - - "; gotoxy(61, 7); cout<<"62. - - - "; gotoxy(61, 8); cout<<"63. - - - "; gotoxy(61, 9); cout<<"64. - - - "; gotoxy(61,10); cout<<"65. - - - "; gotoxy(61,11); cout<<"66. - - - "; gotoxy(61,12); cout<<"67. - - - "; gotoxy(61,13); cout<<"68. Beryllium, Be"; gotoxy(61,14); cout<<"69. Cerium, Ce"; gotoxy(61,15); cout<<"70. Dysprosium,Dy"; gotoxy(61,16); cout<<"71. Erbium, Er"; gotoxy(61,17); cout<<"72. Ruthenium, Ru"; gotoxy(61,18); cout<<"73. Holmium, Ho"; gotoxy(61,19); cout<<"74. Plutonium, Pu"; gotoxy(61,20); cout<<"75. Thulium, Tm"; gotoxy(61,21); cout<<"76. Uranium, U"; gotoxy(61,22); cout<<"77. Yttrium, Y"; gotoxy(61,23); cout<<"78. Ytterbium, Yb"; gotoxy(61,24); cout<<"79. Tungsten, W"; gotoxy(61,25); cout<<"80. Osmium, Os"; gotoxy(50,4);cout<<"Material number? "; //matertype=1; gotoxy(50,4);cout<<"Material number? ";cin>>matertype; LBnextmat: for (i1=1;i1<=25;i1++) { //. gotoxy(1,i1);cout<<" "; } //. for (i1=7;i1<=25;i1++) { //.. gotoxy(21,i1);cout<<" "; } //.. for (i1=7;i1<=25;i1++) { //.. gotoxy(41,i1);cout<<" "; } //.. for (i1=7;i1<=25;i1++) { //.. gotoxy(61,i1);cout<<" "; } //.. gotoxy(1,1);cout<<" "; gotoxy(1,2);cout<<" "; gotoxy(1,3);cout<<" "; gotoxy(1,5);cout<<" "; if (matertype<1) return; { //.. crystals float rd=-1.00; int im; im=matertype; // From Table 22.2 on page 447 of "Solid State Physics" by // Ashcroft and Mermin 1976 if (im==5) {C11= 166;C12=64; C44=80; rd=2.33; mn("Si crys 300K");} // // 166.0 64.0 79.6 2.329 - ioffe if (im==6) {C11= 129;C12=48; C44=67; rd=5.32; mn("Ge crys 300K");} // // 126 44.0 67.7 - ioffe // From Table 2 and Table 3 on pages 149 and 150 of C. Kittel // Introduction to Solid State Physics 4th Ed. 1971 if (im==7) {C11= 48.3;C12=5.4; C44=6.6; rd=2.038;mn("KCl crys @ 4K");} // if (im==8) {C11= 49.4;C12=22.8;C44=24.6;rd=2.07; mn("LiCl crys 300K");} // if (im==9) {C11=124.6;C12=42.4;C44=64.9;rd=2.646;mn("LiF crys @ 0K");} if (im==10) {C11= 88.5;C12=40.4;C44=43.3;rd=5.614;mn("GaSb crys 300K");} // // 88.3 40.2 43.2 5.614 300K ioffe if (im==11) {C11=286 ;C12=87 ;C44=148 ;rd=3.60; mn("MgO crys 300K");} // if (im==12) {C11= 48.7;C12=12.4;C44=12.6;rd=2.17; mn("NaCl crys 300K");} // if (im==13) {C11=140.5;C12=62.0;C44=70.3;rd=4.138;mn("GaP crys 300K");} // if (im==14) {C11=119.0;C12=53.4;C44=59.6;rd=5.317;mn("GaAs crys 300K");} // if (im==15) {C11=30.0; C12=7.8 ;C44=7.6 ;rd=4.43; mn("CsBr crys 300K");} // Kittel Table 3 if (im==16){C11=1076; C12=125; C44=576; rd=3.516;mn("Diamond 300K");} // Kittel Table 3 // 1079 124 578 3.515 300K ioffe if (im==17) {C11=124; C12= 93; C44=46; rd=10.6; mn("Ag crys 300K");} //Ashcroft& Mermin Table 22.2 - J. DeLaunay 1956 if (im==18) {C11=83.4; C12=45.4;C44=39.5;rd=5.68; mn("InAs crys 293K");}// www.ioffe.rssi.ru - Burenkov et al. 1975 if (im==19) {C11=234; C12=136; C44=118; rd=7.87; mn("Fe crys 300K");} //Ashcroft& Mermin Table 22.2 - Rayne 1961 if (im==20) {C11=245; C12=140; C44=125; rd=8.97; mn("Ni crys 300K");} //Ashcroft& Mermin Table 22.2 - Alers 1960 if (im==21) {C11=107; C12= 61; C44= 28; rd=2.73; mn("Al crys 300K");} // Ashcroft& Mermin Table 22.2 - Ho 1969 if (im==22) {C11=168; C12=121; C44=75; rd=9.02; mn("Cu crys 300K");} // Ashcroft& Mermin Table 22.2 - J. DeLaunay 1956 if (im==23) {C11=186; C12=157; C44=42; rd=19.5; mn("Au crys 300K");} // Ashcroft/Mermin Table 22.2 - J. DeLaunay 1956 // (im==23) {C11=192.3;C12=163.1;C44=42.0;rd=19.5; mn("Au crys");} // Kittel Table 2 if (im==24) {C11=25.6; C12=3.1; C44=2.9; rd=3.55; mn("RbI cry. 300K");} // Kittel Table 3 if (im==25) {C11=532.6; C12=204.9; C44=163.1; rd=19.317; mn("W crys O K");} if (im==26) {C11=266.3; C12=158.2; C44=87.5; rd=16.696; mn("Ta crys 0 K");} if (im==27) {C11=232.4; C12=119.4; C44=46.0; rd=6.051; mn("V crys 0 K");} if (im==28) {C11=89.1; C12=40.0; C44=25.4; rd=4.886; mn("BaF2 crys 300K");} if (im==29) {C11=66.7; C12=36.5; C44=30.2; rd=5.77; mn("InSb crys 300K");} // www.ioffe.rssi.ru // (im==29) {C11=67.2; C12=36.7; C44=30.2; rd=5.77; mn("InSb crys 300K");} // Kittel if (im==30) {C11=31.7; C12=4.2; C44=3.9; rd=3.35; mn("RbBr crys 300K");} if (im==31) {C11=24.6; C12=6.7; C44=6.2; rd=4.51; mn("CsI crys 300K");} if (im==32) {C11=247; C12=135; C44=28.7; rd=8.58; mn("Nb crys 300K");} if (im==33) {C11=36.1; C12=6.2; C44=4.7; rd=2.76; mn("RbCl crys 300K");} if (im==34) {C11=65.6; C12=14.6; C44=12.5; rd=2.48; mn("KF crys 300K");} if (im==35) {C11=101.1;C12=56.1; C44=45.6; rd=4.81; mn("InP crys 300K");} // www.ioffe.rssi.ru if (im==36) {C11=293; C12=159; C44=155; rd=6.15; mn("GaN ZincBlende");} // @ 300K - www.ioffe.rssi.ru // GaN can also have wurtzite structure, which is hexagonal, not cubic if (im==37) {C11=46.30; C12=16.10; C44=10.90; rd=10.22; mn("Mo crys");} // if (im==38) {C11=223.7; C12=112.4; C44=74.6; rd=5.01; mn("Y2O3 crys 293K");} // ref [22] in matprop.htm - Palko et al 2001 if (im==39) {C11=-1; C12=-1; C44=-1; rd=-1; mn("???");} if (im==40) {C11=-1; C12=-1; C44=-1; rd=-1; mn("???");} if (im==41) {C11=-1; C12=-1; C44=-1; rd=-1; mn("???");} if (im==42) {C11=-1; C12=-1; C44=-1; rd=-1; mn("???");} // AlxGa1-xAs has C12=5)&&(im<=42)) { //. if (rd<0) goto LBnewm; C11=C11*1.0e9; C12=C12*1.0e9; C44=C44*1.0e9; densityrho=rd*1000.0; } //. } //.. crystals #5-42 { // rho Y G #43-80 float Y=-1,pr=-1,rd=-1; int im; im=matertype; if (im==43){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==44){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==45){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==46){rd=8.93; Y=122 ;pr=0.33 ;mn("Copper, Cu");} // if (im==47){rd=2.7; Y=71;pr=0.33;mn("Aluminum, Al");} // if (im==48){rd=7.70; Y=105 ;pr=0.28;mn("Cast iron");} // if (im==49){rd=11.34;Y=16.5 ;pr=0.43 ;mn("Lead, Pb");} // if (im==50){rd=1.20; Y=4 ;pr=0.4 ;mn("Lucite");} // if (im==51){rd=10.5; Y=78 ;pr=0.37 ;mn("Silver, Ag");} // if (im==52){rd=7.8; Y=210 ;pr=0.29 ;mn("Steel");} // if (im==53){rd=0.001;Y=1.215e-9 ;pr=0.2589 ;mn("avg fcc md crystal");} // if (im==54){rd=8.4; Y=104 ;pr=0.37 ;mn("Brass");} // if (im==55){rd=5.26;Y=18.2;pr=0.152;mn("Europium, Eu");} if (im==56){rd=3.9 ; Y=340 ;pr=0.22 ;mn("Alumina Al2O3");} // if (im==57){rd=2.18 ; Y=68 ;pr=0.19 ;mn("96% silica glass");} // if (im==58){rd=2.2 ; Y=70 ;pr=0.17 ;mn("Fused quartz");} // if (im==59){rd=3.1 ; Y=410 ;pr=0.24 ;mn("Silicon carbide");} // , SiC if (im==60){rd=2.30; Y=62 ;pr=0.24 ;mn("Pyrex glass");} // if (im==61){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==62){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==63){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==64){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==65){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==66){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==67){rd=-1 ; Y=-1 ;pr=-1 ;mn("??");} if (im==68){rd=1.844; Y=303; pr=0.1667;mn("Beryllium, Be");} // (nu 0.07-0.18) if (im==69){rd=6.7 ; Y=41.4; pr=0.248; mn("Cerium, Ce");} // if (im==70){rd=8.54 ; Y=61.4; pr=0.237; mn("Dysprosium, Dy");} // if (im==71){rd=9.05 ; Y=69.9; pr=0.237; mn("Erbium, Er");} // if (im==72){rd=12.2; Y=414; pr=0.25; mn("Ruthenium, Ru");} // if (im==73){rd=8.8 ; Y=64.8; pr=0.231; mn("Holmium, Ho");} // if (im==74){rd=19.81; Y=96.5; pr=0.18; mn("Plutonium, Pu");} // (nu 0.15-0.21) if (im==75){rd=9.33 ; Y=74; pr=0.213; mn("Thulium");} // if (im==76){rd=19.07; Y=190; pr=0.22; mn("Uranium, U");} // if (im==77){rd=4.472; Y=63.5; pr=0.243; mn("Yttrium, Y");} // if (im==78){rd=6.98 ; Y=23.7; pr=0.207; mn("Ytterbium, Yb");} // if (im==79){rd=19.3; Y=345; pr=0.17; mn("Tungsten, W");} // if (im==80){rd=22.6; Y=552; pr=0.25; mn("Osmium, Os");} // if ((im>=43)&&(im<=100)) { // get C11,C12,C44 if (rd<0) goto LBnewm; densityrho=rd*1000.0; Y=Y*1e9; C44=Y/(2.0*(1.0+pr)); lambdaLame=Y*pr/((1+pr)*(1-2*pr)); C11=lambdaLame+2*C44; C12=C11-2*C44; // Assume isotropic } // get C11,C12,C44 } // rho Y G if (matertype==1) { // 1 Y and Poisson gotoxy(50-2,11);cout<<"* Density ? (g/cc) "; //densityrho=1e3; gotoxy(50-2,11);cout<<"* Density ? (g/cc) ";cin>>densityrho; densityrho=densityrho*1000.0; if (densityrho<=0) {cout<<"* Non-positive density...*";return;} gotoxy(50-2,11);cout<<" "; gotoxy(50-2,15);cout<<"* Young's modulus ? (GPa) "; //Youngsmodulus=1e11; gotoxy(50-2,15);cout<<"* Young's modulus ? (GPa) ";cin>>Youngsmodulus; Youngsmodulus=Youngsmodulus*1e9; if (Youngsmodulus<0) {cout<<"* negative Y *";return;} gotoxy(50-2,15);cout<<" "; LBnewPR: gotoxy(50-2,16);cout<<"* Poisson ratio ? "; //Poissonratio=0.15; gotoxy(50-2,16);cout<<"* Poisson ratio ? ";cin>>Poissonratio; gotoxy(50-2,16);cout<<" "; C44 = Youngsmodulus/(2.0*(1.0+Poissonratio)); lambdaLame=Youngsmodulus*Poissonratio/((1+Poissonratio)*(1-2*Poissonratio)); C11 = lambdaLame + 2*C44; C12 = C11 - 2*C44; // Assume isotropic } // 1 Y and Poisson if (matertype==3) { // 3 Cubic crystal gotoxy(50,11);cout<<"Density ? (g/cc) ";cin>>densityrho; if (densityrho<=0) {cout<<"* Non-positive density...*";return;} densityrho=densityrho*1000.0; gotoxy(50,12);cout<<"C11 ? (GPa) ";cin>>C11; gotoxy(50,13);cout<<"C12 = lambda (GPa) ? ";cin>>C12; gotoxy(50,14);cout<<"C44 = G = æ ? (GPa) ";cin>>C44; C11=C11*1e9; C12=C12*1e9; C44=C44*1e9; } // 3 Cubic crystal gotoxy(50,9);cout<800) cout<<"Density = "<<0.001*densityrho<<" g/cc "; else cout<<"Density = "<1e6) cout<<"C11 = "<<1.0e-9*C11<<" GPa "; else cout<<"C11 = "<1e6) cout<<"C12 = "<<1.0e-9*C12<<" GPa "; else cout<<"C12 = "<1e6) cout<<"C44 = "<<1.0e-9*C44<<" GPa "; else cout<<"C44 = "<1e6) { //. cout<<"Young mod. = "; printf("%5.1f",1.0e-9*Youngsmodulus); cout<<" GPa "; } //. else cout<<"Young mod. = "<1e6) { //. cout<<"B = "; printf("%5.1f",1.0e-9*bulkmodulus); cout<<" GPa "; } //. else cout<<"B = "<1e6) cout<<"G, æ, C' = "<<1.0e-9*shearmodulus<<" GPa "; else cout<<"G, æ, C' = "<1e6) cout<<"Lambda = "<<1.0e-9*lambdaLame<<" GPa "; else cout<<"Lambda = "<>foutname; fout=fopen(foutname,"wb"); } // dissipcoef=0; gotoxy(55,1);cout<>MaxNm; if (MaxNm<=0) {closegraph();return;} //if (!(mnn=new unsigned char[MaxNm])) {cout<<"Not enough for mnn";getch();closegraph();return;} if (drawanimation==1) { //. if (!(mcol=new unsigned char[MaxNm])) {cout<<"Not enough for mcol";getch();closegraph();return;} if (!(oldmx=new unsigned char[MaxNm])) {cout<<"Not enough for oldmx";getch();closegraph();return;} if (!(oldmy=new unsigned char[MaxNm])) {cout<<"Not enough for oldmy";getch();closegraph();return;} if (!(oldmz=new unsigned char[MaxNm])) {cout<<"Not enough for oldmz";getch();closegraph();return;} } // if (!(atouched=new unsigned char[MaxNm])) {cout<<"Not enough for atouched";getch();closegraph();return;} if (!(m0nl=new unsigned int[MaxNm])) {cout<<"Not enough for m0nl";getch();closegraph();return;} if (!(m1nl=new unsigned int[MaxNm])) {cout<<"Not enough for m1nl";getch();closegraph();return;} if (!(m2nl=new unsigned int[MaxNm])) {cout<<"Not enough for m2nl";getch();closegraph();return;} if (!(m3nl=new unsigned int[MaxNm])) {cout<<"Not enough for m3nl";getch();closegraph();return;} if (!(m4nl=new unsigned int[MaxNm])) {cout<<"Not enough for m4nl";getch();closegraph();return;} if (!(m5nl=new unsigned int[MaxNm])) {cout<<"Not enough for m5nl";getch();closegraph();return;} if (!(m6nl=new unsigned int[MaxNm])) {cout<<"Not enough for m6nl";getch();closegraph();return;} if (!(m7nl=new unsigned int[MaxNm])) {cout<<"Not enough for m7nl";getch();closegraph();return;} if (!(m8nl=new unsigned int[MaxNm])) {cout<<"Not enough for m8nl";getch();closegraph();return;} if (!(m9nl=new int[MaxNm])) {cout<<"Not enough for m9nl";getch();closegraph();return;} if (!(m10nl=new int[MaxNm])) {cout<<"Not enough for m10nl";getch();closegraph();return;} if (!(m11nl=new int[MaxNm])) {cout<<"Not enough for m11nl";getch();closegraph();return;} if (!(m12nl=new int[MaxNm])) {cout<<"Not enough for m12nl";getch();closegraph();return;} if (!(m13nl=new int[MaxNm])) {cout<<"Not enough for m13nl";getch();closegraph();return;} if (!(m14nl=new int[MaxNm])) {cout<<"Not enough for m14nl";getch();closegraph();return;} if (!(mx=new float[MaxNm])) {cout<<"Not enough for mx";getch();closegraph();return;} if (!(my=new float[MaxNm])) {cout<<"Not enough for my";getch();closegraph();return;} if (!(mz=new float[MaxNm])) {cout<<"Not enough for mz";getch();closegraph();return;} if (!(mvx=new float[MaxNm])) {cout<<"Not enough for mvx";getch();closegraph();return;} if (!(mvy=new float[MaxNm])) {cout<<"Not enough for mvy";getch();closegraph();return;} if (!(mvz=new float[MaxNm])) {cout<<"Not enough for mvz";getch();closegraph();return;} if (dissipcoef!=0) { //.. if (!(max=new float[MaxNm])) {cout<<"Not enough for max";getch();closegraph();return;} if (!(may=new float[MaxNm])) {cout<<"Not enough for may";getch();closegraph();return;} if (!(maz=new float[MaxNm])) {cout<<"Not enough for maz";getch();closegraph();return;} } //.. gotoxy(1,1);cout<<"Memory space is sufficient... "; int bx0=370,by0=150; float dt,ttot; dt=0.5*uca/sqrt(C11/densityrho); cout.precision(3); //float Clong,Cshear; // long and shear wave velocity (Jul 24) Clong=sqrt(C11/densityrho); Cshear=sqrt(C44/densityrho); float ang4,ang5; randomize(); float xmax=60; float ymax=xmax*480/640.0; float sfx=(640.0-100)/xmax; int ix,iy,iz,im,im1,im2; float ObjRad,maxpossrad; float aspectr,radratio; int whichshape; gotoxy(1,5);cout<<"0=sphere"; gotoxy(1,6);cout<<"1=hollow sphere"; gotoxy(1,7);cout<<"2=cylinder"; gotoxy(1,8);cout<<"3=flat cube"; gotoxy(55,2);cout<<"What shape? "; //whichshape=0; cin>>whichshape; if (whichshape<0) {closegraph();return;} aspectr=1; radratio=1; if (whichshape==1) {gotoxy(20,6);cout<<"rad ratio? (rin/rout) ";cin>>radratio;} if (whichshape==2) {gotoxy(15,7);cout<<"h/D ? ";cin>>aspectr;} if (whichshape==3) {gotoxy(15,8);cout<<"h/w ? ";cin>>aspectr;} float cmvx,cmvy,cmvz,cmx,cmy,cmz; if (whichshape==0) maxpossrad=pow(MaxNm*cellvol/(1.333333*3.1415926),0.333333); if (whichshape==1) maxpossrad=pow((MaxNm*cellvol/(1.0-pow(radratio,3.0)))/(1.333333*3.1415926),0.3333333); // MaxNm = 3.14159 * maxpossrad^3 * 2.0* aspectr if (whichshape==2) maxpossrad=pow(MaxNm*cellvol/(2.0*3.1415926*aspectr),0.333333); cout.precision(2); gotoxy(40,7);cout<<"Max. poss."; gotoxy(40,8);cout<<"rad is "<>ObjRad; //if (ObjRad<=0) {closegraph();return;} int et,excitetype; et=1;gotoxy(1,1+et);cout<>excitetype; if (excitetype<0) {closegraph();return;} ///float Clong=1.16282,Cshear=0.61980; // long and shear wave velocity et=7;gotoxy(1,1+et);cout<<" "; et=8;gotoxy(1,1+et);cout<<" "; et=9;gotoxy(1,1+et);cout<<" "; et=10;gotoxy(1,1+et);cout<<" "; int iClong=Clong; int iCshear=Cshear; gotoxy(1,9);cout<<"Clong="<=20)&&(excitetype<30)) { // gotoxy(35,7);cout<<"Beta guess? ";cin>>betaguess; ksguess=betaguess/ObjRad; } // if ((excitetype>=30)&&(excitetype<40)) { // gotoxy(35,7);cout<<"Beta guess? ";cin>>betaguess; alphaguess=betaguess*Cshear/Clong; klguess=alphaguess/ObjRad; } // int ticksper=4; long int countruns=0; int manualendflag; float ttotperFTrun; float binw=0.0010,binwHz,binwbeta,betamax,betamin; gotoxy(35,8);cout<<"beta "; gotoxy(30,8 );cout<<"beta min ";cin>>betamin; float omeg2,r33,ftfminHz,ftfrmin,omegamin; gotoxy(45,8 );cout<<"max ";cin>>betamax; float FTpeakwidth=0.05; // width of Fourier peaks (beta) gotoxy(35,9);cout<<"peak width ";cin>>FTpeakwidth; if (FTpeakwidth<=0) {closegraph();return;} float MinObjRad; //MinObjRad=3; gotoxy(30,10);cout<<"Min R? ";cin>>MinObjRad; if (MinObjRad<=0) {closegraph();return;} int extrarows; //extrarows=3; gotoxy(42,10);cout<<"Extra rows at top? (0-8)";cin>>extrarows; ipytop=ipytop-16*extrarows; ftfminHz=ftfrmin/ObjRad; int ifr,ifrcursor=nofr/2; int ipyft; BeginNextRun: manualendflag=0; countruns++; ipyft=ipybot-countruns; setfillstyle(SOLID_FILL,0); bar(0,ipyft-20,639,ipyft-2); setcolor(1); line(0,ipytop,639,ipytop); float beta; int ipx,ipy,ibeta; // 0.001 tick marks and labels if (betamax-betamin<50*0.001) for (ibeta=0;ibeta<1000.0*betamax;ibeta=ibeta+1) {// ibeta 0.01 if ((ibeta%10)!=0) { //. ipx = nofr*(0.001*ibeta-betamin)/(betamax-betamin); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipyft-2,1); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+1,1); if ((betamax-betamin<=0.02)&&(betamax-betamin>=0.01)&&((ibeta%5)==0)) { //.. ix=-1+1+ipx/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { //... cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".00"<=0.005)&&((ibeta%2)==0)) { //.. ix=-1+1+ipx/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".00"<=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { //... cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".00"<=0)&&(ipx<640)) putpixel(ipx,ipyft-2,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+1,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+2,7); if ((betamax-betamin<=0.2)&&(betamax-betamin>=0.1)&&((ibeta%5)==0)) { //.. ix=-1+1+ipx/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { //... cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".0"<=0.05)&&((ibeta%2)==0)) { //.. ix=-1+1+ipx/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".0"<=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { //... cout.precision(2); gotoxy(ix,iy); if (ibeta<10) cout<<".0"<=0)&&(ipx<640)) putpixel(ipx,ipyft-2,1); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+1,1); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+2,1); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+1,1); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+2,1); if ((betamax-betamin<2)&&(betamax-betamin>=1)&&((ibeta%5)==0)) { //.. ix=1+(ipx-4)/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { // ... cout.precision(1); gotoxy(ix,iy); if (ibeta<10) cout<<"."<=0.5)&&((ibeta%2)==0)) { //.. ix=1+(ipx-4)/8; iy=(ipytop+32)/16; if ((ix>=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { // cout.precision(1); gotoxy(ix,iy); if (ibeta<10) cout<<"."<=1)&&(ix<=79-1)&&(iy>=1)&&(iy<=25)) { //... cout.precision(1); gotoxy(ix,iy); if (ibeta<10) cout<<"."<=1)&&(ix<=79)&&(iy>=1)&&(iy<=25)) {gotoxy(ix,iy);cout<=0)&&(ipx<640)) putpixel(ipx,ipyft-2,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipyft-3,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipyft-4,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+1,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+2,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+3,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+4,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx,ipytop+5,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+1,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+2,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+3,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+4,7); if ((ipx>=0)&&(ipx<640)) putpixel(ipx+1,ipytop+5,7); }// ibeta //ObjRad=sqrt(14.0+countruns); ObjRad=MinObjRad*(ipytop-1.0*ipybot)/(ipytop*1.0+countruns-1.0*ipybot); if (ObjRad>0.98*maxpossrad) { // done setrgbpalette(pal.colors[7],30,63,63); // for text char beepc=7; cout<>ObjRad; //if (ObjRad<=0) return; //ObjRad=ObjRad+1.0; //gotoxy(1,17);cout<<"alright at d "; gotoxy(55,5);cout<<"shape="<radratio*ObjRad)) insideflag=1; // holl sphere if ((whichshape==2)&&(r1=MaxNm) { // not enough memory space gotoxy(1,1);cout<<"Error: * MaxNm = "<=iz0+2) break; } // im2 if (count3a!=3) {m10nl[im]=0; count6a=0;} if (count3b!=3) {m11nl[im]=0; count6b=0;} if (count6a!=3) m13nl[im]=0; if (count6b!=3) m14nl[im]=0; } //. im gotoxy(1,3);cout<<"Making neighbour list:"; //gotoxy(2,19);cout<<" a5 "; // Now construct near neighbour list: for (im=0;imuca*uca*0.999*0.999)&&(d2maxnoneigh) {maxnoneigh=mnn1;} if (mnn1>3) {cout<<" mnn1 reached 3 ";exit(0);} } //. } //..1 if ((d2>ucc*ucc*0.999*0.999)&&(d2maxnoneigh) {maxnoneigh=mnn2;} if (mnn2>4) {cout<<"* mnn2 reached 4 ";exit(0);} } //. } //..2 - ksp3 if ((d2>uca*uca*0.999*0.999+ucc*ucc*0.999*0.999)&&(d2maxnoneigh) {maxnoneigh=mnn3;} if (mnn3>10) {cout<<"* mnn3 reached 10 ";exit(0);} } //. } //..3 - ksp4 } // im2 } // im1 ///gotoxy(1,8);cout<<"Max no neigh = "<=MaxNm) { //.. cout<<"*** Error ActNm > MaxNm ***";getch();return; } //.. long int liclocklast,liclock2,liclocklastdrawn; liclocklast=clock(); liclocklastdrawn=clock(); int graphflag=1; //gotoxy(2,19);cout<<" b "; for (ifr=0;ifr=10)&&(excitetype<20)) { // my naive toroidal mode of order n gotoxy(2,24);cout<<"Init.";gotoxy(8,24);cout<<"Excit."; if (excitetype!=11) {gotoxy(2,25);cout<<"n="<=20)&&(excitetype<30)) { // true toroidal mode of order n gotoxy(2,24);cout<<"Init.";gotoxy(8,24);cout<<"Excit."; gotoxy(2,25);cout<<"n="<=30)&&(excitetype<40)) { // true spheroidal mode of order n gotoxy(2,24);cout<<"Init.";gotoxy(8,24);cout<<"Excit."; gotoxy(2,25);cout<<"n="<ttotperFTrun) { // goto BeginNextRun; } // //gotoxy(2,19);cout<<" f "; for (ifr=0;ifr0.01*uca*uca) { // not too close float vr,Fvbyr,Fvx,Fvy,Fvz; r121=sqrt(r122); if (i1n<3) Fbyr=-ksp1*(r121-uca)/r121; if ((i1n>=3)&&(i1n<4)) Fbyr=-ksp3*(r121-ucc)/r121; if ((i1n>=4)&&(i1n<10)) Fbyr=-ksp4*(r121-sqrt(uca*uca+ucc*ucc))/r121; Fx=dx*Fbyr; Fy=dy*Fbyr; Fz=dz*Fbyr; dp1x+=Fx; dp1y+=Fy; dp1z+=Fz; //gotoxy(2,19);cout<<" j "; if (dissipcoef==0) { //gotoxy(2,19);cout<<" j1 "; cellmass=densityrho*cellvol; mvx[im2]-=dt*Fx/cellmass; mvy[im2]-=dt*Fy/cellmass; mvz[im2]-=dt*Fz/cellmass; } else { //.. //gotoxy(2,19);cout<<" j2 "; cellmass=densityrho*cellvol; max[im2]-=Fx/cellmass; may[im2]-=Fy/cellmass; maz[im2]-=Fz/cellmass; vr=dx*(mvx[im1]-mvx[im2])+dy*(mvy[im1]-mvy[im2]); vr=vr; Fvbyr=-dissipcoef*vr/r128; Fvx=Fvbyr*dx; Fvy=Fvbyr*dy; Fvz=Fvbyr*dz; max[im1]+=Fvx/cellmass; may[im1]+=Fvy/cellmass; maz[im1]+=Fvz/cellmass; max[im2]-=Fvx/cellmass; may[im2]-=Fvy/cellmass; maz[im2]-=Fvz/cellmass; } //.. //gotoxy(2,19);cout<<" k "; } // not too close } // dim12!=0 } // i1 if (dissipcoef==0) { //.. cellmass=densityrho*cellvol; mvx[im1]+=dt*dp1x/cellmass; mvy[im1]+=dt*dp1y/cellmass; mvz[im1]+=dt*dp1z/cellmass; } //.. else { //. //{gotoxy(60,10);cout<<"* access max *";return;} cellmass=densityrho*cellvol; max[im1]+=dp1x/cellmass; may[im1]+=dp1y/cellmass; maz[im1]+=dp1z/cellmass; } //. } // im1 /* if ((countruns==1)&&(litcount==1)) { // gotoxy(40,4);cout<<" &&& "<=liclocklastdrawn+ticksper) { //. another clock tick gotoxy(39,1);cout<peakv2now) peakv2now=v2now; } // im cout.precision(2); gotoxy(1,5);cout<<"KE="<100) mx[im]=100; if (my[im]>100) my[im]=100; if (mz[im]>100) mz[im]=100; if (drawanimation==1) if (mcol[im]!=0) { // non-black int ic; ic=14; int i54=sfx*mx[im]+128; int i55=sfx*my[im]; int i56=sfx*mz[im]+128; float r1,r2,dx,dy,dz; ic=14; // always yellow! if (drawanimation) if (ic!=0) { // putpixel(bx0+i54-128,by0-i55,ic); if (zview) putpixel(bx0+171.2+i56-128,by0-i55,ic); } // } // non-black if (drawanimation==1) { // oldmx[im]=mx[im]*sfx+128; oldmy[im]=my[im]*sfx; oldmz[im]=mz[im]*sfx+128; } // } // ix iy float fhz; /* for (fhz=0.001;fhz<0.5;fhz=fhz+0.001) { // fhz omeg2=2.0*3.14159*ftfminHz+fhz*2.0*3.14159; i1=omeg2/binw; putpixel(i1,200,10); putpixel(i1,479,10); } // fhz */ /* for (fhz=0.01;fhz<0.5;fhz=fhz+0.01) { // fhz omeg2=2.0*3.14159*ftfminHz+fhz*2.0*3.14159; i1=omeg2/binw; putpixel(i1,200,13); putpixel(i1,479,13); } // fhz for (fhz=0.1;fhz<0.5;fhz=fhz+0.1) { // fhz omeg2=2.0*3.14159*ftfminHz+fhz*2.0*3.14159; i1=omeg2/binw; putpixel(i1,479,14); putpixel(i1,478,14); putpixel(i1,477,14); } // fhz */ float maxr332=0; int i8,i80; /* setcolor(0); i80=0; for (ifr=1;ifrmaxr332) {maxr332=r33;} } // .. ifr if (maxr332<=0) maxr332=1.0; //setcolor(1);line(ifrcursor,471,ifrcursor,479); //cout.precision(4); //gotoxy(1,10);cout<<(2.0*3.14159/Cshear)*(ifrcursor*binw/(2.0*3.1416)+ftfminHz)*ObjRad<<" "; /* i80=0; for (ifr=1;ifr15) ic=15; if (ic==7) ic=8; if (ic==1) ic=2; putpixel(ifr,ipyft,ic); } // .. LBcheckforkeystroke: if (kbhit()) { // key hit char ch1; ch1=getch(); if (ch1=='q') goto QUIT; if (ch1=='r') makescr(); if (ch1=='a') goto BeginNextRun; if (ch1=='t') {ticksper=ticksper+1;gotoxy(40,5);cout<=MaxNn) {cout<<"* Error: Call to setmnl() has in2="<=MaxNn) {cout<<"* Error: Call to getmnl() has in2="<14) {cout<<"x ="<>scrfilename; scrfout=fopen(scrfilename,"wb"); unsigned char ch1b,ch2b,ch3b,ch4b,ch5,ch6; int scrwid=640; int scrhgt=ipybot-ipytop; int scrx0=0; int scry0=ipytop; setcolor(15); line(scrx0,scry0-1,scrwid+scrwid-1,scry0-1); line(scrx0,scry0+scrhgt,scrwid+scrwid-1,scry0+scrhgt); ch3b=scrwid/256; ch1b=scrwid%256; ch4b=scrhgt/256; ch2b=scrhgt%256; fprintf(scrfout,"%c%c%c%c%c%c%c%c%c%c%c%c%c",'s','c','r',ch3b,ch1b,ch4b,ch2b,'0','0','0','0',13,10); int ipixcol,ix,iy; gotoxy(65,10);cout<<"saving "; for (iy=scry0;iy