/************************************************************************************************************* The MIT License Copyright (C) 2006-2019 David Dubbeldam, Sofia Calero, Thijs Vlugt, Donald E. Ellis, and Randall Q. Snurr. D.Dubbeldam@uva.nl http://www.uva.nl/profiel/d/u/d.dubbeldam/d.dubbeldam.html scaldia@upo.es http://www.upo.es/raspa/ t.j.h.vlugt@tudelft.nl http://homepage.tudelft.nl/v9k6y don-ellis@northwestern.edu http://dvworld.northwestern.edu/ snurr@northwestern.edu http://zeolites.cqe.northwestern.edu/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "constants.h" #include "molecule.h" #include "framework.h" #include "framework_energy.h" #include "framework_force.h" #include "simulation.h" #include "ewald.h" #include "potentials.h" #include "utils.h" #include "output.h" #include "cbmc.h" #include "mc_moves.h" #include "grids.h" #include "spacegroup.h" #include "spectra.h" #include "molecule.h" // not used void CalculateFrameworkFullForce(int m) { POINT pos1,pos2; REAL energy,force_factor,rr; int i,j,f1,typeA,typeB; VECTOR dr,f; UAdsorbateAdsorbateVDW[CurrentSystem]=0.0; for(i=0;ix=0.0; Force->y=0.0; Force->z=0.0; CoulombForce->x=0.0; CoulombForce->y=0.0; CoulombForce->z=0.0; if((Framework[CurrentSystem].FrameworkModel==GRID)&&(VDWGrid[typeA])) { *UVDW=InterpolateVDWForceGrid(typeA,pos,Force); if((ChargeMethod!=NONE)&&CoulombGrid) *UCoulomb=InterpolateCoulombForceGrid(typeA,pos,CoulombForce); } else { chargeA=PseudoAtoms[typeA].Charge1; for(f1=0;f1x-=force_factor*dr.x; Force->y-=force_factor*dr.y; Force->z-=force_factor*dr.z; if(Framework[CurrentSystem].FrameworkModel==FLEXIBLE) { Framework[CurrentSystem].Atoms[f1][i].Force.x+=force_factor*dr.x; Framework[CurrentSystem].Atoms[f1][i].Force.y+=force_factor*dr.y; Framework[CurrentSystem].Atoms[f1][i].Force.z+=force_factor*dr.z; } } if(rrx-=temp*dr.x; CoulombForce->y-=temp*dr.y; CoulombForce->z-=temp*dr.z; } } } } } void CalculateFrameworkBondForce(void) { int i,f1; REAL r,rr,r1,DF,U; REAL temp,temp2,exp_term; REAL *parms; VECTOR posA,posB,dr,f; int A,B; UHostBond[CurrentSystem]=0.0; for(f1=0;f1p_2 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2 [A] r1=r-parms[1]; U=0.5*parms[0]*SQR(MIN2(fabs(r1),parms[2])) +parms[0]*parms[2]*MAX2(fabs(r1)-parms[2],(REAL)0.0); DF=-parms[0]*(SIGN(MIN2(fabs(r1),parms[2]),r1))/r; break; case QUARTIC_BOND: // (1/2)*p_0*(r-p_1)^2+(1/3)*p_2*(r-p_1)^3+(1/4)*p_3*(r-p_1)^4 // =========================================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] temp=r-parms[1]; temp2=SQR(r-parms[1]); U=0.5*parms[0]*temp2+(1.0/3.0)*parms[2]*temp*temp2+0.25*parms[3]*SQR(temp2); DF=temp*(parms[0]+parms[2]*temp+parms[3]*temp2)/r; break; case CFF_QUARTIC_BOND: // p_0*(r-p_1)^2+p_2*(r-p_1)^3+p_3*(r-p_1)^4 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] temp=r-parms[1]; temp2=SQR(r-parms[1]); U=parms[0]*temp2+parms[2]*temp*temp2+parms[3]*SQR(temp2); DF=temp*(2.0*parms[0]+3.0*parms[2]*temp+4.0*parms[3]*temp2)/r; break; case MM3_BOND: // p_0*(r-p_1)^2*(1.0-2.55*(r-p_1)+(7.0/12.0)*2.55^2*(r-p_1)^2) // ================================================================= // p_0 [mdyne/A molecule] // p_1 [A] temp=r-parms[1]; temp2=SQR(temp); U=parms[0]*temp2*(1.0-2.55*temp+(7.0/12.0)*SQR(2.55)*temp2); DF=parms[0]*(2.0+2.55*(4.0*2.55*(7.0/12.0)*temp-3.0)*temp)*temp/r; break; case MEASURE_BOND: U=DF=0.0; break; case RIGID_BOND: U=DF=0.0; break; case FIXED_BOND: U=DF=0.0; break; default: fprintf(stderr, "Undefined Bond potential in routine 'CalculateFrameworkBondForce' ('framework_force.c')\n"); exit(0); break; } // add contribution to the Adsorbate stretch energy UHostBond[CurrentSystem]+=U; // forces are oppositely directed to the gradient f.x=-DF*dr.x; f.y=-DF*dr.y; f.z=-DF*dr.z; // add contribution to the forces Framework[CurrentSystem].Atoms[f1][A].Force.x+=f.x; Framework[CurrentSystem].Atoms[f1][A].Force.y+=f.y; Framework[CurrentSystem].Atoms[f1][A].Force.z+=f.z; Framework[CurrentSystem].Atoms[f1][B].Force.x-=f.x; Framework[CurrentSystem].Atoms[f1][B].Force.y-=f.y; Framework[CurrentSystem].Atoms[f1][B].Force.z-=f.z; // add contribution to the stress tensor StrainDerivativeTensor[CurrentSystem].ax-=dr.x*f.x; StrainDerivativeTensor[CurrentSystem].bx-=dr.y*f.x; StrainDerivativeTensor[CurrentSystem].cx-=dr.z*f.x; StrainDerivativeTensor[CurrentSystem].ay-=dr.x*f.y; StrainDerivativeTensor[CurrentSystem].by-=dr.y*f.y; StrainDerivativeTensor[CurrentSystem].cy-=dr.z*f.y; StrainDerivativeTensor[CurrentSystem].az-=dr.x*f.z; StrainDerivativeTensor[CurrentSystem].bz-=dr.y*f.z; StrainDerivativeTensor[CurrentSystem].cz-=dr.z*f.z; } } } } void CalculateFrameworkUreyBradleyForce(void) { int i,f1; REAL r,rr,r1,DF,U; REAL temp,temp2,exp_term; VECTOR dr,f,posA,posC; REAL *parms; int A,C; UHostUreyBradley[CurrentSystem]=0.0; for(f1=0;f1p_2 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2 [A] r1=r-parms[1]; U=0.5*parms[0]*SQR(MIN2(fabs(r1),parms[2])) +parms[0]*parms[2]*MAX2(fabs(r1)-parms[2],(REAL)0.0); DF=-parms[0]*(SIGN(MIN2(fabs(r1),parms[2]),r1))/r; break; case QUARTIC_UREYBRADLEY: // (1/2)*p_0*(r-p_1)^2+(1/3)*p_2*(r-p_1)^3+(1/4)*p_3*(r-p_1)^4 // =========================================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] temp=r-parms[1]; temp2=SQR(r-parms[1]); U=0.5*parms[0]*temp2+(1.0/3.0)*parms[2]*temp*temp2+0.25*parms[3]*SQR(temp2); DF=temp*(parms[0]+parms[2]*temp+parms[3]*temp2)/r; break; case CFF_QUARTIC_UREYBRADLEY: // p_0*(r-p_1)^2+p_2*(r-p_1)^3+p_3*(r-p_1)^4 // =============================================== // p_0/k_B [K/A^2] // p_1 [A] // p_2/k_B [K/A^3] // p_3/k_B [K/A^4] temp=r-parms[1]; temp2=SQR(r-parms[1]); U=parms[0]*temp2+parms[2]*temp*temp2+parms[3]*SQR(temp2); DF=temp*(2.0*parms[0]+3.0*parms[2]*temp+4.0*parms[3]*temp2)/r; break; case MM3_UREYBRADLEY: // p_0*(r-p_1)^2*(1.0-2.55*(r-p_1)+(7.0/12.0)*2.55^2*(r-p_1)^2) // ================================================================= // p_0 [mdyne/A molecule] // p_1 [A] temp=r-parms[1]; temp2=SQR(temp); U=parms[0]*temp2*(1.0-2.55*temp+(7.0/12.0)*SQR(2.55)*temp2); DF=parms[0]*(2.0+2.55*(4.0*2.55*(7.0/12.0)*temp-3.0)*temp)*temp/r; break; case RIGID_UREYBRADLEY: U=DF=0.0; break; case FIXED_UREYBRADLEY: U=DF=0.0; break; default: fprintf(stderr, "Undefined Urey-Bradley potential in routine 'CalculateFrameworkUreyBradleyForce' ('framework_force.c')\n"); exit(0); break; } // add contribution to the Adsorbate Urey-Bradley energy UHostUreyBradley[CurrentSystem]+=U; // forces are oppositely directed to the gradient f.x=-DF*dr.x; f.y=-DF*dr.y; f.z=-DF*dr.z; // add contribution to the forces Framework[CurrentSystem].Atoms[f1][A].Force.x+=f.x; Framework[CurrentSystem].Atoms[f1][A].Force.y+=f.y; Framework[CurrentSystem].Atoms[f1][A].Force.z+=f.z; Framework[CurrentSystem].Atoms[f1][C].Force.x-=f.x; Framework[CurrentSystem].Atoms[f1][C].Force.y-=f.y; Framework[CurrentSystem].Atoms[f1][C].Force.z-=f.z; // add contribution to the stress tensor StrainDerivativeTensor[CurrentSystem].ax-=dr.x*f.x; StrainDerivativeTensor[CurrentSystem].bx-=dr.y*f.x; StrainDerivativeTensor[CurrentSystem].cx-=dr.z*f.x; StrainDerivativeTensor[CurrentSystem].ay-=dr.x*f.y; StrainDerivativeTensor[CurrentSystem].by-=dr.y*f.y; StrainDerivativeTensor[CurrentSystem].cy-=dr.z*f.y; StrainDerivativeTensor[CurrentSystem].az-=dr.x*f.z; StrainDerivativeTensor[CurrentSystem].bz-=dr.y*f.z; StrainDerivativeTensor[CurrentSystem].cz-=dr.z*f.z; } } } } void CalculateFrameworkBendForce(void) { int i,A,B,C,D,f1; REAL *parms,DF,U,temp,temp2; REAL CosTheta,Theta,SinTheta; REAL rab,rbc,rac,DTDX; VECTOR posA,posB,posC,posD; VECTOR Rab,Rbc,Rac,fa,fb,fc,dtA,dtB,dtC;; VECTOR Rad,Rbd,Rcd,t,ip,ap,cp; REAL rt2,rap2,rcp2; REAL terma,termc,delta,delta2,rm,ptrt2,term; VECTOR dpdia,dpdic,m,dedip,fd; Rab.x=Rab.y=Rab.z=0.0; Rad.x=Rad.y=Rad.z=0.0; Rcd.x=Rcd.y=Rcd.z=0.0; Rbd.x=Rbd.y=Rbd.z=0.0; Rbc.x=Rbc.y=Rbc.z=0.0; ap.x=ap.y=ap.z=0.0; cp.x=cp.y=cp.z=0.0; t.x=t.y=t.z=0.0; delta=rcp2=rap2=rt2=0.0; rbc=rab=temp=0.0; UHostBend[CurrentSystem]=0.0; for(f1=0;f11e-8) { A=Framework[CurrentSystem].Torsions[f1][i].A; typeA=Framework[CurrentSystem].Atoms[f1][A].Type; posA=Framework[CurrentSystem].Atoms[f1][A].Position; B=Framework[CurrentSystem].Torsions[f1][i].D; typeB=Framework[CurrentSystem].Atoms[f1][B].Type; posB=Framework[CurrentSystem].Atoms[f1][B].Position; if(!BITVAL(Framework[CurrentSystem].ExclusionMatrix[f1][A][B],7)) { dr.x=posA.x-posB.x; dr.y=posA.y-posB.y; dr.z=posA.z-posB.z; dr=ApplyBoundaryCondition(dr); rr=SQR(dr.x)+SQR(dr.y)+SQR(dr.z); PotentialGradient(typeA,typeB,rr,&energy,&force_factor,1.0); UHostHostVDW[CurrentSystem]+=parms[6]*energy; force_factor=parms[6]*force_factor; StrainDerivativeTensor[CurrentSystem].ax+=force_factor*dr.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=force_factor*dr.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=force_factor*dr.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=force_factor*dr.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=force_factor*dr.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=force_factor*dr.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=force_factor*dr.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=force_factor*dr.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=force_factor*dr.z*dr.z; // forces f.x=force_factor*dr.x; f.y=force_factor*dr.y; f.z=force_factor*dr.z; Framework[CurrentSystem].Atoms[f1][A].Force.x-=f.x; Framework[CurrentSystem].Atoms[f1][A].Force.y-=f.y; Framework[CurrentSystem].Atoms[f1][A].Force.z-=f.z; Framework[CurrentSystem].Atoms[f1][B].Force.x+=f.x; Framework[CurrentSystem].Atoms[f1][B].Force.y+=f.y; Framework[CurrentSystem].Atoms[f1][B].Force.z+=f.z; } } } } } return 0; } int CalculateFrameworkIntraChargeChargeForce(void) { int i,j,typeA,typeB; REAL chargeA,chargeB; REAL r,rr,energy,DF; VECTOR posA,posB,dr,f; int f1,f2,A,B; REAL *parms; REAL alpha; // Framework-Framework energy UHostHostChargeChargeReal[CurrentSystem]=0.0; if(ChargeMethod==NONE) return 0; // contributions from intra-framework for(f1=0;f11e-8) { A=Framework[CurrentSystem].Torsions[f1][i].A; chargeA=Framework[CurrentSystem].Atoms[f1][A].Charge; posA=Framework[CurrentSystem].Atoms[f1][A].Position; B=Framework[CurrentSystem].Torsions[f1][i].D; chargeB=Framework[CurrentSystem].Atoms[f1][B].Charge; posB=Framework[CurrentSystem].Atoms[f1][B].Position; if(!BITVAL(Framework[CurrentSystem].ExclusionMatrix[f1][A][B],7)) { dr.x=posA.x-posB.x; dr.y=posA.y-posB.y; dr.z=posA.z-posB.z; dr=ApplyBoundaryCondition(dr); rr=SQR(dr.x)+SQR(dr.y)+SQR(dr.z); r=sqrt(rr); // note: no cutoff used here switch(ChargeMethod) { case NONE: DF=0.0; break; case SHIFTED_COULOMB: case TRUNCATED_COULOMB: case EWALD: default: UHostHostChargeChargeReal[CurrentSystem]+=parms[7]*COULOMBIC_CONVERSION_FACTOR*chargeA*chargeB/r; DF=parms[7]*COULOMBIC_CONVERSION_FACTOR*chargeA*chargeB/(rr*r); break; } StrainDerivativeTensor[CurrentSystem].ax-=DF*dr.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx-=DF*dr.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx-=DF*dr.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay-=DF*dr.x*dr.y; StrainDerivativeTensor[CurrentSystem].by-=DF*dr.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy-=DF*dr.z*dr.y; StrainDerivativeTensor[CurrentSystem].az-=DF*dr.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz-=DF*dr.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz-=DF*dr.z*dr.z; Framework[CurrentSystem].Atoms[f1][A].Force.x+=DF*dr.x; Framework[CurrentSystem].Atoms[f1][A].Force.y+=DF*dr.y; Framework[CurrentSystem].Atoms[f1][A].Force.z+=DF*dr.z; Framework[CurrentSystem].Atoms[f1][B].Force.x-=DF*dr.x; Framework[CurrentSystem].Atoms[f1][B].Force.y-=DF*dr.y; Framework[CurrentSystem].Atoms[f1][B].Force.z-=DF*dr.z; } } } } } return 0; } int CalculateFrameworkIntraChargeBondDipoleForce(void) { int i,j,f1,f2; int A1,A2; int Type; VECTOR posA,posB,posA1,posA2,dr; REAL rr,ri2,energy,temp,length,chargeB; VECTOR dipoleA,fb1,fa1,fa2,term; REAL DipoleMagnitudeA; REAL_MATRIX3x3 v; v.ax=v.bx=v.cx=0.0; v.ay=v.by=v.cy=0.0; v.az=v.bz=v.cz=0.0; UHostHostChargeBondDipoleReal[CurrentSystem]=0.0; if(ChargeMethod==NONE) return 0; // contributions from intra-framework for(f1=0;f1=0) { Framework[CurrentSystem].Atoms[f1][ConnectedAtomA].Force.x-=(1.0-ReductionA)*f.x; Framework[CurrentSystem].Atoms[f1][ConnectedAtomA].Force.y-=(1.0-ReductionA)*f.y; Framework[CurrentSystem].Atoms[f1][ConnectedAtomA].Force.z-=(1.0-ReductionA)*f.z; } if(ncell==0) { Framework[CurrentSystem].Atoms[f2][j].Force.x+=ReductionB*f.x; Framework[CurrentSystem].Atoms[f2][j].Force.y+=ReductionB*f.y; Framework[CurrentSystem].Atoms[f2][j].Force.z+=ReductionB*f.z; if(ConnectedAtomB>=0) { Framework[CurrentSystem].Atoms[f2][ConnectedAtomB].Force.x+=(1.0-ReductionB)*f.x; Framework[CurrentSystem].Atoms[f2][ConnectedAtomB].Force.y+=(1.0-ReductionB)*f.y; Framework[CurrentSystem].Atoms[f2][ConnectedAtomB].Force.z+=(1.0-ReductionB)*f.z; } StrainDerivativeTensor[CurrentSystem].ax+=f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=f.z*dr.z; } else { // no force on particle outside the main unit cell // only the interaction on 'i' in the unit cell counts StrainDerivativeTensor[CurrentSystem].ax+=0.5*f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=0.5*f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=0.5*f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=0.5*f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=0.5*f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=0.5*f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=0.5*f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=0.5*f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=0.5*f.z*dr.z; } } } } ncell++; } } } } // contributions from interactions 1-4 torsions // TODO: fix to handle anisotropic sites for(f1=0;f11e-8) { A=MIN2(Framework[CurrentSystem].Torsions[f1][i].A,Framework[CurrentSystem].Torsions[f1][i].D); B=MAX2(Framework[CurrentSystem].Torsions[f1][i].A,Framework[CurrentSystem].Torsions[f1][i].D); if(!BITVAL(Framework[CurrentSystem].ExclusionMatrix[f1][A][B],7)) { typeA=Framework[CurrentSystem].Atoms[f1][A].Type; posA=Framework[CurrentSystem].Atoms[f1][A].Position; typeB=Framework[CurrentSystem].Atoms[f1][B].Type; posB=Framework[CurrentSystem].Atoms[f1][B].Position; dr.x=posA.x-posB.x; dr.y=posA.y-posB.y; dr.z=posA.z-posB.z; dr=ApplyBoundaryCondition(dr); rr=SQR(dr.x)+SQR(dr.y)+SQR(dr.z); PotentialGradient(typeA,typeB,rr,&energy,&force_factor,1.0); UHostHostVDW[CurrentSystem]+=parms[6]*energy; force_factor=parms[6]*force_factor; StrainDerivativeTensor[CurrentSystem].ax+=force_factor*dr.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=force_factor*dr.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=force_factor*dr.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=force_factor*dr.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=force_factor*dr.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=force_factor*dr.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=force_factor*dr.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=force_factor*dr.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=force_factor*dr.z*dr.z; // forces f.x=force_factor*dr.x; f.y=force_factor*dr.y; f.z=force_factor*dr.z; Framework[CurrentSystem].Atoms[f1][A].Force.x-=f.x; Framework[CurrentSystem].Atoms[f1][A].Force.y-=f.y; Framework[CurrentSystem].Atoms[f1][A].Force.z-=f.z; Framework[CurrentSystem].Atoms[f1][B].Force.x+=f.x; Framework[CurrentSystem].Atoms[f1][B].Force.y+=f.y; Framework[CurrentSystem].Atoms[f1][B].Force.z+=f.z; } } } } } return 0; } int CalculateFrameworkIntraReplicaChargeChargeForce(void) { int i,j,typeA,typeB,start; REAL chargeA,chargeB; REAL rr,energy,DF; VECTOR posA,posB,dr,f; int f1,f2,ncell,k1,k2,k3,index_j; int A,B; REAL *parms; REAL alpha,r; // Framework-Framework energy UHostHostChargeChargeReal[CurrentSystem]=0.0; if(ChargeMethod==NONE) return 0; for(f1=0;f11e-8) { A=MIN2(Framework[CurrentSystem].Torsions[f1][i].A,Framework[CurrentSystem].Torsions[f1][i].D); B=MAX2(Framework[CurrentSystem].Torsions[f1][i].A,Framework[CurrentSystem].Torsions[f1][i].D); if(!BITVAL(Framework[CurrentSystem].ExclusionMatrix[f1][A][B],7)) { chargeA=Framework[CurrentSystem].Atoms[f1][A].Charge; posA=Framework[CurrentSystem].Atoms[f1][A].Position; chargeB=Framework[CurrentSystem].Atoms[f1][B].Charge; posB=Framework[CurrentSystem].Atoms[f1][B].Position; dr.x=posA.x-posB.x; dr.y=posA.y-posB.y; dr.z=posA.z-posB.z; dr=ApplyBoundaryCondition(dr); rr=SQR(dr.x)+SQR(dr.y)+SQR(dr.z); r=sqrt(rr); // note: no cutoff used here switch(ChargeMethod) { case NONE: DF=0.0; break; case SHIFTED_COULOMB: case TRUNCATED_COULOMB: case EWALD: default: UHostHostChargeChargeReal[CurrentSystem]+=parms[7]*COULOMBIC_CONVERSION_FACTOR*chargeA*chargeB/r; DF=parms[7]*COULOMBIC_CONVERSION_FACTOR*chargeA*chargeB/(rr*r); break; } StrainDerivativeTensor[CurrentSystem].ax-=DF*dr.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx-=DF*dr.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx-=DF*dr.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay-=DF*dr.x*dr.y; StrainDerivativeTensor[CurrentSystem].by-=DF*dr.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy-=DF*dr.z*dr.y; StrainDerivativeTensor[CurrentSystem].az-=DF*dr.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz-=DF*dr.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz-=DF*dr.z*dr.z; Framework[CurrentSystem].Atoms[f1][A].Force.x+=DF*dr.x; Framework[CurrentSystem].Atoms[f1][A].Force.y+=DF*dr.y; Framework[CurrentSystem].Atoms[f1][A].Force.z+=DF*dr.z; Framework[CurrentSystem].Atoms[f1][B].Force.x-=DF*dr.x; Framework[CurrentSystem].Atoms[f1][B].Force.y-=DF*dr.y; Framework[CurrentSystem].Atoms[f1][B].Force.z-=DF*dr.z; } } } } } return 0; } void CalculateFrameworkAdsorbateReplicaVDWForce(void) { int i,j,k,f1; int typeA,typeB,type; REAL rr,scaling; REAL energy,force_factor; VECTOR posA,posB,dr,f; int ConnectedAtomA,ConnectedAtomB; REAL ReductionA,ReductionB; int ncell,k1,k2,k3; UHostAdsorbateVDW[CurrentSystem]=0.0; for(i=0;i=0) { Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.x-=(1.0-ReductionA)*f.x; Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.y-=(1.0-ReductionA)*f.y; Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.z-=(1.0-ReductionA)*f.z; } if(Framework[CurrentSystem].FrameworkModel==FLEXIBLE) { Framework[CurrentSystem].Atoms[f1][k].Force.x+=ReductionB*f.x; Framework[CurrentSystem].Atoms[f1][k].Force.y+=ReductionB*f.y; Framework[CurrentSystem].Atoms[f1][k].Force.z+=ReductionB*f.z; if(ConnectedAtomB>=0) { Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.x+=(1.0-ReductionB)*f.x; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.y+=(1.0-ReductionB)*f.y; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.z+=(1.0-ReductionB)*f.z; } } StrainDerivativeTensor[CurrentSystem].ax+=f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=f.z*dr.z; } } } ncell++; } } } } } void CalculateFrameworkCationReplicaVDWForce(void) { int i,j,k,f1; int typeA,typeB,type; REAL rr,scaling; REAL energy,force_factor; VECTOR posA,posB,dr,f; int ConnectedAtomA,ConnectedAtomB; REAL ReductionA,ReductionB; int ncell,k1,k2,k3; UHostCationVDW[CurrentSystem]=0.0; for(i=0;i=0) { Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.x-=(1.0-ReductionA)*f.x; Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.y-=(1.0-ReductionA)*f.y; Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.z-=(1.0-ReductionA)*f.z; } if(Framework[CurrentSystem].FrameworkModel==FLEXIBLE) { Framework[CurrentSystem].Atoms[f1][k].Force.x+=ReductionB*f.x; Framework[CurrentSystem].Atoms[f1][k].Force.y+=ReductionB*f.y; Framework[CurrentSystem].Atoms[f1][k].Force.z+=ReductionB*f.z; if(ConnectedAtomB>=0) { Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.x+=(1.0-ReductionB)*f.x; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.y+=(1.0-ReductionB)*f.y; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.z+=(1.0-ReductionB)*f.z; } } StrainDerivativeTensor[CurrentSystem].ax+=f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=f.z*dr.z; } } } ncell++; } } } } } int CalculateFrameworkAdsorbateReplicaChargeChargeForce(void) { int i,j,k,f1; int typeA,typeB,type; REAL rr,chargeA,chargeB; REAL energy,DF,scaling; VECTOR posA,posB,dr,f; int ConnectedAtomA,ConnectedAtomB; REAL ReductionA,ReductionB; int ncell,k1,k2,k3; UHostAdsorbateChargeChargeReal[CurrentSystem]=0.0; if(ChargeMethod==NONE) return 0; for(i=0;i=0) { Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.x-=(1.0-ReductionA)*f.x; Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.y-=(1.0-ReductionA)*f.y; Adsorbates[CurrentSystem][i].Atoms[ConnectedAtomA].Force.z-=(1.0-ReductionA)*f.z; } if(Framework[CurrentSystem].FrameworkModel==FLEXIBLE) { Framework[CurrentSystem].Atoms[f1][k].Force.x+=ReductionB*f.x; Framework[CurrentSystem].Atoms[f1][k].Force.y+=ReductionB*f.y; Framework[CurrentSystem].Atoms[f1][k].Force.z+=ReductionB*f.z; if(ConnectedAtomB>=0) { Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.x+=(1.0-ReductionB)*f.x; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.y+=(1.0-ReductionB)*f.y; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.z+=(1.0-ReductionB)*f.z; } } StrainDerivativeTensor[CurrentSystem].ax+=f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=f.z*dr.z; } } } ncell++; } } } } return 0; } int CalculateFrameworkCationReplicaChargeChargeForce(void) { int i,j,k,f1; int typeA,typeB,type; REAL rr,chargeA,chargeB; REAL energy,DF,scaling; VECTOR posA,posB,dr,f; int ConnectedAtomA,ConnectedAtomB; REAL ReductionA,ReductionB; int ncell,k1,k2,k3; UHostCationChargeChargeReal[CurrentSystem]=0.0; if(ChargeMethod==NONE) return 0; for(i=0;i=0) { Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.x-=(1.0-ReductionA)*f.x; Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.y-=(1.0-ReductionA)*f.y; Cations[CurrentSystem][i].Atoms[ConnectedAtomA].Force.z-=(1.0-ReductionA)*f.z; } if(Framework[CurrentSystem].FrameworkModel==FLEXIBLE) { Framework[CurrentSystem].Atoms[f1][k].Force.x+=ReductionB*f.x; Framework[CurrentSystem].Atoms[f1][k].Force.y+=ReductionB*f.y; Framework[CurrentSystem].Atoms[f1][k].Force.z+=ReductionB*f.z; if(ConnectedAtomB>=0) { Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.x+=(1.0-ReductionB)*f.x; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.y+=(1.0-ReductionB)*f.y; Framework[CurrentSystem].Atoms[f1][ConnectedAtomB].Force.z+=(1.0-ReductionB)*f.z; } } StrainDerivativeTensor[CurrentSystem].ax+=f.x*dr.x; StrainDerivativeTensor[CurrentSystem].bx+=f.y*dr.x; StrainDerivativeTensor[CurrentSystem].cx+=f.z*dr.x; StrainDerivativeTensor[CurrentSystem].ay+=f.x*dr.y; StrainDerivativeTensor[CurrentSystem].by+=f.y*dr.y; StrainDerivativeTensor[CurrentSystem].cy+=f.z*dr.y; StrainDerivativeTensor[CurrentSystem].az+=f.x*dr.z; StrainDerivativeTensor[CurrentSystem].bz+=f.y*dr.z; StrainDerivativeTensor[CurrentSystem].cz+=f.z*dr.z; } } } ncell++; } } } } return 0; }