Allink
v0.1
|
00001 #include "Forces.h" 00002 00003 void Forces::PullBead(){ 00004 Pm[Bead2Move].Pos[2] += IncrDist; 00005 if(VAR_IF_TYPE(SysShape,SYS_ROD)) 00006 Pm[Bead2Move-1].Pos[2] += IncrDist; 00007 } 00008 void Forces::PushBead(){ 00009 Pm[Bead2Move].Pos[2] -= IncrDist; 00010 if(VAR_IF_TYPE(SysShape,SYS_ROD)) 00011 Pm[Bead2Move-1].Pos[2] -= IncrDist; 00012 } 00013 void Forces::SelectBead(int p){ 00014 if(p<0 && p > pNPart()) return; 00015 Bead2Move = p; 00016 if(pType(p) != 2) 00017 Pm[p].Typ = 1; 00018 if(pType(Old2Move) == 1) 00019 Pm[Old2Move].Typ = 0; 00020 Old2Move = p; 00021 } 00022 void Forces::Wave(){ 00023 for(int s=0;s<NEdge;s++){ 00024 for(int ss=0;ss<NEdge;ss++){ 00025 Pm[s*NEdge+ss].Pos[2] = .5+.1*sin(s*Dx*60.*INV_DUE_PI+Time)*sin(ss*Dx*30.*INV_DUE_PI+Time); 00026 } 00027 } 00028 } 00029 void Forces::AddCircle(int n){ 00030 for(int p=0;p<pNPart();p++){ 00031 double CosTh = (Nano[n].Pos[0] - pPos(p,0))/Nano[n].Rad; 00032 double SenTh = sqrt(1 - QUAD(CosTh)); 00033 double Sign = 1.; 00034 for(int d=0;d<3;d++){ 00035 Pm[p].Vel[d] += (Fm[p].Dir[d] + Fm[p].Ext[d])*pDeltat(); 00036 } 00037 if(pType(p) != 2) Pm[p].Typ = 0; 00038 if(p <= NEdge){ 00039 Sign *= -1.; 00040 if(Pm[p].Pos[2] + .5*Pm[p].Vel[2]*pDeltat() >= Sign*(Nano[n].Rad)*SenTh + Nano[n].Pos[2]){ 00041 Pm[p].Pos[2] = Sign*(Nano[n].Rad)*SenTh + Nano[n].Pos[2]; 00042 Pm[p].Vel[2] = 0.; 00043 Sign = 1.; 00044 if(Pm[p].Pos[0] > Nano[n].Pos[0]) 00045 Sign = -1.; 00046 if(p > 1) 00047 Fm[p-1].Dir[0] -= Kf.Cont*SenTh*Sign; 00048 if(p < NEdge - 1) 00049 Fm[p+1].Dir[0] += Kf.Cont*SenTh*Sign; 00050 if(Pm[p].Typ != 2) 00051 Pm[p].Typ = 1; 00052 } 00053 else 00054 Fm[p].Dir[0] = 0.; 00055 } 00056 else if( p> NEdge){ 00057 if(Pm[p].Pos[2] + .5*Pm[p].Vel[2]*pDeltat() <= Sign*(Nano[n].Rad)*SenTh + Nano[n].Pos[2]){ 00058 Pm[p].Pos[2] = Sign*(Nano[n].Rad)*SenTh + Nano[n].Pos[2]; 00059 Pm[p].Vel[2] = 0.; 00060 Sign = 1.; 00061 if(Pm[p].Pos[0] > Nano[n].Pos[0]) 00062 Sign = -1.; 00063 if(p > NEdge) 00064 Fm[p-1].Dir[0] -= Kf.Cont*SenTh*Sign; 00065 if(p < pNPart() - 1) 00066 Fm[p+1].Dir[0] += Kf.Cont*SenTh*Sign; 00067 if(Pm[p].Typ != 2) 00068 Pm[p].Typ = 1; 00069 } 00070 else 00071 Fm[p].Dir[0] = 0.; 00072 } 00073 } 00074 } 00075 void Forces::AddCylinder(int n){ 00076 for(int p=0;p<pNPart();p++){ 00077 if(Pm[p].Typ == 2) continue; 00078 double Dist = sqrt(SQR(Pm[p].Pos[0]-Nano[n].Pos[0])+SQR(Pm[p].Pos[1]-Nano[n].Pos[1])); 00079 if(Dist > Nano[n].Rad) continue; 00080 double Zed = (Nano[n].Rad-Dist)*tan(Nano[n].Hamaker*DUE_PI/360.); 00081 Pm[p].Typ = 1; 00082 Pm[p].Pos[2] = .5*Nano[n].Height + Nano[n].Pos[2] + Zed; 00083 } 00084 } 00088 double Forces::HeightBoundary(double *Pos,int dir){ 00089 return Pos[2]; 00090 int nNano = 0; 00091 int dir2 = (dir+1)%2; 00092 for(int n=0;n<pNNano();n++){ 00093 if(fabs(Pos[dir] - Nano[n].Pos[dir]) < Nano[n].Rad){ 00094 nNano = n; 00095 break; 00096 } 00097 } 00098 double yNano = Pos[dir2] - Nano[nNano].Pos[dir2]; 00099 double Lat1 = Nano[nNano].Pos[dir] - sqrt(SQR(Nano[nNano].Rad)-SQR(yNano) ) - Pos[dir]; 00100 double Lat2 = Nano[nNano].Pos[dir] + sqrt(SQR(Nano[nNano].Rad)-SQR(yNano) ) - Pos[dir]; 00101 double Dist = MIN(fabs(Lat1),fabs(Lat2)); 00102 //double Dist = sqrt(SQR(Pos[0]-Nano[nNano].Pos[0])+SQR(Pos[1]-Nano[nNano].Pos[1])); 00103 //double Zed = (Nano[nNano].Rad-Dist)*tan(Nano[nNano].Hamaker*DUE_PI/360.); 00104 double Zed = Dist*tan(Nano[nNano].Hamaker*DUE_PI/360.); 00105 Pos[2] = .5*Nano[nNano].Height + Nano[nNano].Pos[2] + Zed; 00106 return .5*Nano[nNano].Height + Nano[nNano].Pos[2] + Zed; 00107 } 00108 void Forces::AddPore(int n){ 00109 for(int p=0;p<pNPart();p++){ 00110 if(Pm[p].Typ == 2) continue; 00111 double Dist = sqrt(SQR(Pm[p].Pos[0]-Nano[n].Pos[0])+SQR(Pm[p].Pos[1]-Nano[n].Pos[1])); 00112 if(Dist > Nano[n].Rad) continue; 00113 Pm[p].Typ = 1; 00114 Pm[p].Pos[2] = Nano->Pos[2]; 00115 } 00116 } 00117 void Forces::AddRigid(){ 00118 for(int p=0;p<pNPart();p++){ 00119 if(Pm[p].Typ == 2) continue; 00120 Pm[p].Typ = 0; 00121 } 00122 for(int n=0;n<pNNano();n++){ 00123 if(VAR_IF_TYPE(Nano[n].Shape,SHAPE_SPH)){ 00124 AddCircle(n); 00125 } 00126 else if(VAR_IF_TYPE(Nano[n].Shape,SHAPE_CYL)){ 00127 AddCylinder(n); 00128 } 00129 else if(VAR_IF_TYPE(Nano[n].Shape,SHAPE_PORE)){ 00130 AddPore(n); 00131 } 00132 } 00133 }