实验一:用C 语言编程证明金刚石晶胞内原子特性的不同 一:实验要求
金刚石的晶胞是由两个面心立方嵌套而成,其中一个面心立方是另一个面心立方沿其对角线平移1/4而得。用C 语言编程证明金刚石晶胞中两类碳原子(原胞中两个原子)的物理性质是不同的。
二:实验目的
1) 深化对晶胞和原胞概念的理解。
2) 锻炼以C 语言为工具,去解决和证明问题的能力。
三:实验源代码
源代码:
#include
#include
#define pi 3.1415926
struct Atom
{ int x,y,z; };
void Angle(struct Atom v1,struct Atom v2)
{
float seta1,m1,m2,seta;
m1=sqrt(v1.x*v1.x+v1.y*v1.y+v1.z*v1.z);
m2=sqrt(v2.x*v2.x+v2.y*v2.y+v2.z*v2.z);
seta1=(v1.x*v2.x+v1.y*v2.y+v1.z*v2.z)/m1/m2;
seta=acos(seta1)/pi*180;
printf("%4f ",seta);
};
main()
{
int i,j;
struct Atom vector1[6];
struct Atom vector2[6];
struct Atom temp;
struct Atom catom1[14]={0,0,0,4,0,0,0,4,0,2,2,0,4,4,0,2,0,2,0,2,2,4,2,2,2,4,2,0,0,4,4,0,4,0,4,4,2,2,4,4,4,4};
struct Atom catom2[14];
for(i=0;i
{
catom2[i].x=catom1[i].x+1;
catom2[i].y=catom1[i].y+1;
catom2[i].z=catom1[i].z+1;
}
for(i=0,j=0;i
{
temp.x=catom1[i].x-catom2[0].x;
temp.y=catom1[i].y-catom2[0].y;
temp.z=catom1[i].z-catom2[0].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==3) {
vector2[j]=temp;
j++;
}
}
for(i=0,j=0;i
{
temp.x=catom2[i].x-catom1[13].x;
temp.y=catom2[i].y-catom1[13].y;
temp.z=catom2[i].z-catom1[13].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==3) {
vector1[j]=temp;
j++;
}
}
printf("I类原子最近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector1[i],vector1[j]); }
printf("\n");
printf("II类原子最近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector2[i],vector2[j]); }
printf("\n");
for(i=0,j=0;i
{
temp.x=catom1[i].x-catom2[0].x;
temp.y=catom1[i].y-catom2[0].y;
temp.z=catom1[i].z-catom2[0].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==11) {
vector2[j]=temp;
j++;
}
}
for(i=0,j=0;i
{
temp.x=catom2[i].x-catom1[13].x;
temp.y=catom2[i].y-catom1[13].y;
temp.z=catom2[i].z-catom1[13].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==11) {
vector1[j]=temp;
j++;
}
}
printf("I类原子次近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector1[i],vector1[j]); }
printf("\n");
printf("II类原子次近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector2[i],vector2[j]); }
printf("\n");
system("pause");
}
四:实验结果
结果如下图:
由图可知:同层原子的键角都不完全相同,所以金刚石晶胞内原子特性是不同的。
实验一:用C 语言编程证明金刚石晶胞内原子特性的不同 一:实验要求
金刚石的晶胞是由两个面心立方嵌套而成,其中一个面心立方是另一个面心立方沿其对角线平移1/4而得。用C 语言编程证明金刚石晶胞中两类碳原子(原胞中两个原子)的物理性质是不同的。
二:实验目的
1) 深化对晶胞和原胞概念的理解。
2) 锻炼以C 语言为工具,去解决和证明问题的能力。
三:实验源代码
源代码:
#include
#include
#define pi 3.1415926
struct Atom
{ int x,y,z; };
void Angle(struct Atom v1,struct Atom v2)
{
float seta1,m1,m2,seta;
m1=sqrt(v1.x*v1.x+v1.y*v1.y+v1.z*v1.z);
m2=sqrt(v2.x*v2.x+v2.y*v2.y+v2.z*v2.z);
seta1=(v1.x*v2.x+v1.y*v2.y+v1.z*v2.z)/m1/m2;
seta=acos(seta1)/pi*180;
printf("%4f ",seta);
};
main()
{
int i,j;
struct Atom vector1[6];
struct Atom vector2[6];
struct Atom temp;
struct Atom catom1[14]={0,0,0,4,0,0,0,4,0,2,2,0,4,4,0,2,0,2,0,2,2,4,2,2,2,4,2,0,0,4,4,0,4,0,4,4,2,2,4,4,4,4};
struct Atom catom2[14];
for(i=0;i
{
catom2[i].x=catom1[i].x+1;
catom2[i].y=catom1[i].y+1;
catom2[i].z=catom1[i].z+1;
}
for(i=0,j=0;i
{
temp.x=catom1[i].x-catom2[0].x;
temp.y=catom1[i].y-catom2[0].y;
temp.z=catom1[i].z-catom2[0].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==3) {
vector2[j]=temp;
j++;
}
}
for(i=0,j=0;i
{
temp.x=catom2[i].x-catom1[13].x;
temp.y=catom2[i].y-catom1[13].y;
temp.z=catom2[i].z-catom1[13].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==3) {
vector1[j]=temp;
j++;
}
}
printf("I类原子最近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector1[i],vector1[j]); }
printf("\n");
printf("II类原子最近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector2[i],vector2[j]); }
printf("\n");
for(i=0,j=0;i
{
temp.x=catom1[i].x-catom2[0].x;
temp.y=catom1[i].y-catom2[0].y;
temp.z=catom1[i].z-catom2[0].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==11) {
vector2[j]=temp;
j++;
}
}
for(i=0,j=0;i
{
temp.x=catom2[i].x-catom1[13].x;
temp.y=catom2[i].y-catom1[13].y;
temp.z=catom2[i].z-catom1[13].z;
if((temp.x*temp.x+temp.y*temp.y+temp.z*temp.z)==11) {
vector1[j]=temp;
j++;
}
}
printf("I类原子次近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector1[i],vector1[j]); }
printf("\n");
printf("II类原子次近一层原子的键角\n");
for(i=0;i
for(j=i+1;j
{ Angle(vector2[i],vector2[j]); }
printf("\n");
system("pause");
}
四:实验结果
结果如下图:
由图可知:同层原子的键角都不完全相同,所以金刚石晶胞内原子特性是不同的。