int drawanimation=0; int ipybot=400,ipytop=295; float Clong,Cshear; // long and shear wave velocity (Jul 24) //float Clong=1.2179,Cshear=0.6947; // long and shear wave velocity (Jul 24) float uca=1; // side length of cubic unit cell (m) #define VERN "cc3bmod.cpp" #define LennJonesflag 0 #define zview 1 #define makedatfile 0 // 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) // Jul 30 2002 cc1mod suspected error in spring constants // Jul 25 fix tick labels, .001 tick marks // Jul 24 2002 changed Cshear to 0.619 to 0.6947 // Jul 22 improve scale // Jul 21 // Jul 20 ang4 ang5 random again (previously both 0) // Jul 2 plot infinite R asymptote chart // Jul 1 02 - watch 3 atoms, brightness chart versus R // June 29 Add legendre poly func and "naive" mode, spherical Bessel // Ye toroidal. Numerical spherical bessel function too. // mod2 Jun 28 added legendre poly up to order 4 // md4mod.cpp June 26 // md2mod3.cpp June 24 show "fr" for cursor // 2 June 8 excitetype; watch y motion on 2nd atom // md2mod.cpp June 7 eps=0.0174... improvements // 612m June 1 vibrational modes // 612k.cpp May 31 tip velocity ratio // 3d612j2 May 31 fixed energy error // 3d612j May 30, but need to invert I; May 31 invert I // i angular momentum; energy ratio; back to float // h5 show impulse as function of time // h4 try float for position, etc. // 3d612h.cpp May 25th // 3d612g2 looking for problem; contact, liftoff, hop // - it is important that dt is small enough // - integers for velocity is a problem since there are // large forces adding up, or something else wrong. // - Also, it runs much slower when I use integers for mv... // 3d612g last three neighbours within 255, so use u.s. char // vscale mvx now int // f May 24 max optional up to 11700 atoms // 3d612e Thurs May 16, May 17 r33 white dot // 3d612c.cpp May 15 use dynamic allocation to allow // up to 9460 molecules... sphere of radius 13.1 // 3d612b.cpp May 14 May 15 // 612h.cpp May 12 model of friction as sinusoidal hard floor // 612g May 9 // 612f.cpp May 9 found size dependence, apparently that coef of rest // approaches 1 in limit of large size, since time scale of // collision gets longer and longer when sphere is large. // (but of course these are circles and not spheres) // 612e.cpp (1st neigh only) // - put in dissipative term // 612d.cpp May 8 // - interact with near neighbours only (incl 2nd neigh) // Demonstrated coef of rest. near 1 over wide range of speed. // (circr=24, dt=0.02) // May 7 612c.cpp - but it occurs to me that the actual // equilibrium distance is not the same as the two-body // equilibrium distance due to the longer range terms. // Therefore, the ball is highly excited when it starts. // - dt must be small enough // - It is possible to speed up the calculation by constucting // a near neighbour table, since the object is solid and // keeps the same set of near neighbours unless something // extreme happens. // - What is the speed of sound? What is Young's modulus? // - What is the density? // - Extending this to 3D from 2D seems straightforward. // - initial settling and cooling period before starting // seems to help a lot. // 612b.cpp May 6 // elast2 May 6, 2002 viscoelastic model of dice // but this is based on linear theory (small vibrations) // so I can't see how to make this work... // Using Lennard Jones 6-12 potential. // Equilibrium distance is 1.12246 units. // Floor is assumed to be infinitely hard. #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 9 unsigned int *m0nl,*m1nl,*m2nl; unsigned int *m3nl,*m4nl,*m5nl; unsigned int *m6nl,*m7nl,*m8nl; int *m9nl; unsigned char *m13nl,*m11nl; 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,ksp2,k8pt; float densityrho,cellmass; int n8pt[8]; void main(void) { // main 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 m5nl";getch();closegraph();return;} if (!(m7nl=new unsigned int[MaxNm])) {cout<<"Not enough for m5nl";getch();closegraph();return;} if (!(m8nl=new unsigned int[MaxNm])) {cout<<"Not enough for m5nl";getch();closegraph();return;} if (!(m9nl=new int[MaxNm])) {cout<<"Not enough for m9nl";getch();closegraph();return;} if (!(m11nl=new unsigned char[MaxNm])) {cout<<"Not enough for m11nl";getch();closegraph();return;} if (!(m13nl=new unsigned char[MaxNm])) {cout<<"Not enough for m13nl";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.6*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/(1.333333*3.1415926),0.333333); if (whichshape==1) maxpossrad=pow((MaxNm/(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/(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 = "<uca*uca*0.9*0.9)&&(d2maxnoneigh) {maxnoneigh=mnn1;} if (mnn1>3) {cout<<"mnn1 reached 3 ";exit(0);} } //. } //..1 if ((d2>uca*uca*1.3*1.3)&&(d2maxnoneigh) {maxnoneigh=mnn2;} if (mnn2>(6+12)/2) {cout<<"mnn2 reached 9 ";exit(0);} } //. } //..1 } // 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; 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(3,25);cout<<" f "; for (ifr=0;ifrmaxr2fordamage) maxr2fordamage=r122; //if (r122>maxeverr122) maxeverr122=r122; //if (r122maxr122now) maxr122now=r122; //if (r1220.01*uca*uca) { // not too close float vr,Fvbyr,Fvx,Fvy,Fvz; if (LennJonesflag) { //.. // Lennard-Jones 6-12 potential // U(r) = 4.0*eps*(1/r^12-1/r^6) // F(r) = dU/dr = 4.0*eps*(12/r^13-6/r^7) // F(r)/r = 4.0*eps*(12/r^14-6/r^8... // dF/dr = 4.0*eps*(156/r^14-42/r^8) // 4.0*eps*(30.9543205-16.667711)=57.14644*eps = 1.0 r128=r122*r122*r122*r122; r1214=r128*r122*r122*r122; Fbyr=4.0*eps*((12.0/r1214)-(6.0/r128)); } //.. else { //.. // Quadratic potential; r121=sqrt(r122); if (i1n<6/2) Fbyr=-ksp1*(r121-uca)/r121; if ((i1n>=6/2)&&(i1n<(6+12)/2)) Fbyr=-ksp2*(r121-1.4142136*uca)/r121; } //.. Fx=dx*Fbyr; Fy=dy*Fbyr; Fz=dz*Fbyr; dp1x+=Fx; dp1y+=Fy; dp1z+=Fz; //gotoxy(3,25);cout<<" j "; if (dissipcoef==0) { //gotoxy(3,25);cout<<" j1 "; cellmass=densityrho*uca*uca*uca; mvx[im2]-=dt*Fx/cellmass; mvy[im2]-=dt*Fy/cellmass; mvz[im2]-=dt*Fz/cellmass; } else { //.. //gotoxy(3,25);cout<<" j2 "; cellmass=densityrho*uca*uca*uca; 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(3,25);cout<<" k "; } // not too close } // dim12!=0 } // i1 if (dissipcoef==0) { //.. cellmass=densityrho*uca*uca*uca; 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*uca*uca*uca; max[im1]+=dp1x/cellmass; may[im1]+=dp1y/cellmass; maz[im1]+=dp1z/cellmass; } //. if (maxr2fordamage>3.5) countdamagedatoms=countdamagedatoms+1.0; } // im1 if (dissipcoef!=0) { //. for (im=0;im=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