00001 #include "lenjonesmat.h"
00002 #include "matrix.h"
00003 #include "vector.h"
00004 #include "stochdriver.h"
00005 #include "global.h"
00006 #include "intpoints.h"
00007
00008 lenjonesmat::lenjonesmat (void)
00009 {
00010 eps = 0.0; sig = 0.0; mindist=0.0; eqdist=0.0;
00011 }
00012
00013 lenjonesmat::~lenjonesmat (void)
00014 {
00015
00016 }
00017
00018 void lenjonesmat::read (XFILE *in)
00019 {
00020 xfscanf (in,"%lf %lf",&eps,&sig);
00021
00022
00023
00024 eqdist = sig*1.122462048;
00025 }
00026
00027
00028
00029
00030
00031
00032
00033
00034 double lenjonesmat::compute_force (double r)
00035 {
00036 double f,c1,c2;
00037
00038 if (r<mindist){
00039 fprintf (stderr,"\n\n distance between atoms (%le) is smaller than minimum defined distance (%le)",r,mindist);
00040 fprintf (stderr,"\n see file %s, line %d",__FILE__,__LINE__);
00041 }
00042
00043 c1=24.0*eps*sig*sig*sig*sig*sig*sig/r/r/r/r/r/r/r;
00044 c2=2.0*sig*sig*sig*sig*sig*sig/r/r/r/r/r/r;
00045
00046 f=c1*(1.0-c2);
00047
00048 return f;
00049 }
00050
00051
00052
00053
00054
00055
00056 double lenjonesmat::equilib_distance ()
00057 {
00058 return eqdist;
00059 }
00060
00061
00062
00063
00064 double lenjonesmat::first_derivative (double r)
00065 {
00066 double f,c1,c2,tmp;
00067
00068 if (r<mindist){
00069 fprintf (stderr,"\n\n distance between atoms (%le) is smaller than minimum defined distance (%le)",r,mindist);
00070 fprintf (stderr,"\n see file %s, line %d",__FILE__,__LINE__);
00071 }
00072
00073 tmp = sig/r;
00074 c1=24.0*eps*tmp*tmp*tmp*tmp*tmp*tmp/r;
00075 c2=2.0*tmp*tmp*tmp*tmp*tmp*tmp;
00076
00077 f=c1*(1.0-c2);
00078
00079 return f;
00080 }
00081
00082
00083
00084 double lenjonesmat::second_derivative (double r)
00085 {
00086 double f,c1,c2,tmp;
00087
00088 if (r<mindist){
00089 fprintf (stderr,"\n\n distance between atoms (%le) is smaller than minimum defined distance (%le)",r,mindist);
00090 fprintf (stderr,"\n see file %s, line %d",__FILE__,__LINE__);
00091 }
00092
00093 tmp = sig/r;
00094 c1=tmp*tmp*tmp*tmp*tmp*tmp/r/r;
00095 c2=tmp*tmp*tmp*tmp*tmp*tmp;
00096
00097 f=4.0*eps*c1*(12.0*13.0*c2-42.0);
00098
00099 return f;
00100 }
00101