-
Notifications
You must be signed in to change notification settings - Fork 0
/
dem_funcs.cpp
147 lines (126 loc) · 2.97 KB
/
dem_funcs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include <vector>
#include "headers/proteins.h"
using namespace std;
vector<double> PBCswitch(int crowds, int index)
{
vector<double> b(3);
for(int i=0;i<3;i++){b[i]=0;}
if(index>=crowds && index<2*crowds){b[0]=-2;}
else if(index>=2*crowds && index<3*crowds){b[0]=2;}
else if(index>=3*crowds && index<4*crowds){b[1]=-2;}
else if(index>=4*crowds && index<5*crowds){b[1]=2;}
else if(index>=5*crowds && index<6*crowds){b[2]=-2;}
else if(index>=6*crowds){b[2]=2;}
return b;
}
vector<double> PDF(vector<protein> crowds, int Ncr) // For all crowders
{
int bins=1000;
int count=0;
double cut=L/2.0;
double space=cut/100.0;
double mag, mag2;
int spot;
vector<double> pos1(3), pos2(3);
vector<double> distr(100);
for(int i=0;i<Ncr;i++)
{
pos1=crowds[i].getv("coords");
for (int j=i+1;j<Ncr;j++)
{
mag=0; mag2=0;
pos2=crowds[j].getv("coords");
for(int k=0;k<3;k++)
{
mag2+=(pos1[k]-pos2[k])*(pos1[k]-pos2[k]);
}
mag=pow(mag2,0.5);
if(mag<cut)
{
spot = floor(mag/space);
distr[spot]+=1;
count+=1;
}
}
}
for(int i=0;i<bins;i++){distr[i]=distr[i]/(count*phi); distr[i]/(4*pi*((i+1)*space)*((i+1)*space)*space);}
return distr;
}
vector<double> PDF1(vector<protein> crowds, int Ncr) //g(r) for central particle
{
int bins=100;
int count=0;
//double cut=L-3*pow(10,-10); gone for PBC stuff
//double space=cut/bins;
double mag, mag2, mag2p;
int spot;
// PBC box stuff
vector<double> pbcmag2(3);
vector<bool> pbcCheck(3);
double R = pow(6.0/pi,1/3.0)*L;
double space=R/bins;
int x,y,z;
vector<double> posc(3);
vector<double> distr(bins);
//cout<<"size of crowder vector is "<<crowds.size()<<endl;
for(int i=0;i<Ncr;i++)
{
for(int j=0;j<3;j++){pbcmag2[j]=0;pbcCheck[j]=false;}
mag2=0;
cout<<"accessing crowder "<<i<<endl;
posc=crowds[i].getv("coords");
//cout<<"check1.9"<<endl;
for(int k=0;k<3;k++)
{
mag2+=(posc[k])*(posc[k]);
if(posc[k]>L-R)
{
pbcCheck[k]=true;
//cout<<k<<" pbs pos = "<<posc[k]<<endl;
pbcmag2[k]=(posc[k]-2*L)*(posc[k]-2*L)-posc[k]*posc[k];
}
else if(posc[k]<R-L)
{
pbcCheck[k]=true;
//cout<<k<<" pbcpos = "<<posc[k]<<endl;
pbcmag2[k]=(posc[k]+2*L)*(posc[k]+2*L)-posc[k]*posc[k];
}
}
mag=pow(mag2,0.5);
if(mag<R)
{
spot=floor(mag/space);
cout<<"bin number = "<<spot<<endl;
distr[spot]+=1;
count+=1;
for(int el=0;el<3;el++)
{
if(pbcCheck[el])
{
mag2p=mag2+pbcmag2[el];
mag=pow(mag2p,0.5);
if(mag<R){
spot=floor(mag/space);
cout<<"bin number = "<<spot<<endl;
distr[spot]+=1;
count++;
}
}
}
}
}
for(int i=0;i<bins;i++)
{
distr[i]=distr[i]/(count);
distr[i]=8*L*L*L*distr[i]/(4*pi*((i+1)*space)*((i+1)*space)*space);
}
cout<<"space = "<<space<<endl;
cout<<"count = "<<count<<endl;
cout<<"L = "<<L<<endl;
cout<<"R = "<<R<<endl;
return distr;
}
vector<double> EscCheck(protein main, double t)
{
// should make use of proteins internal storage for velocities and whatnot
}