forked from mlxd/GPUE
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function [g6B,bin] = binData(g6C,binMax,bins) | ||
%Bin the data returned from g6_struct into equi-separated partitions | ||
% g6C: Matrix containing the g6 values output from g6_struct | ||
% binMax: The maximum binning value | ||
% bins: The number of bins to take | ||
%Returns | ||
% g6B: The binned g6 data | ||
% bin: The bin values of g6B | ||
|
||
bin = linspace(0,binMax,bins); | ||
g6B = zeros(length(bin)-1,1); | ||
for kk=1:(length(bin)-1) | ||
idx = find( g6C(1,:) >= bin(kk) & g6C(1,:) < bin(kk+1) ); | ||
if length(idx) >0 | ||
g6B(kk) = sum(g6C(2,idx))./length(idx); %Average the values in a bin | ||
else | ||
g6B(kk) = 0; | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function [neighbours,locations] = findNN(pos,X,Y,radius) | ||
% Returns values and indices of nearest neighbours to location pos in | ||
% positions X,Y within radius. | ||
|
||
r = sqrt(bsxfun(@minus,pos(1),X).^2 + bsxfun(@minus,pos(2),Y).^2); | ||
locations = find(r < radius & r~=0); | ||
neighbours = [X(locations) Y(locations)]; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function [g6C] = g6_struct(X,Y,rad) | ||
%Determine the orientational correlation function between every pairing of | ||
%points, and sorts the results based on distance between points. This gives | ||
%g6(r). | ||
% X,Y: Vectors of x,y values for points. | ||
% rad: Radius in which to examine for neighbouring points. | ||
%Return: | ||
% g6C: Matrix of g6 values and parameters | ||
|
||
%Determine all orientational order values for points | ||
psi6p = zeros(length(X),1); | ||
for ii=1:length(X) | ||
psi6p(ii) = psi6([X(ii),Y(ii)],X,Y,rad); | ||
end | ||
|
||
%Calculate all n choose k pairings of points, and give distance between | ||
%them, values for the respective orientational orders, and g6 values. Sort | ||
%the values based on separated distance | ||
S = uniqPairIdx_precalc([X,Y],psi6p); | ||
[~,order] = sort([S(:).rabs],'ascend'); | ||
SSorted = S(order); | ||
|
||
%Create output structure for next stage of calculation | ||
for ii=1:size(SSorted,2) | ||
g6S(ii).r = SSorted(ii).rabs; | ||
psi6_1 = SSorted(ii).cor0; | ||
psi6_2 = SSorted(ii).cor1; | ||
g6S(ii).val = abs(conj(psi6_1)*conj(psi6_1)); | ||
end | ||
g6C = cell2mat(squeeze(struct2cell(g6S))); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function [psi6_pos,nn] = psi6(pos,X,Y,radius) | ||
[nn,idx] = findNN(pos,X,Y,radius); | ||
psi6_pos = 0; | ||
|
||
if size(nn,1) > 0 | ||
for ii=1:size(nn,1) | ||
psi6_pos = psi6_pos + exp(6*1i*getAngle2(pos, [X(idx(ii)), Y(idx(ii))] )); | ||
end | ||
psi6_pos = psi6_pos./length(nn); | ||
end | ||
nn=length(nn); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function [S] = uniqPairIdx_precalc(R,psi6p) | ||
%Calculate all unique pairings of the orientational correlations, and | ||
%create a struct to return that holds the distance between paired elements, | ||
%and the respective orientational order values. | ||
% R: Vectors of R=[X Y] values for points. | ||
% psi6p: Orientational order values defined over the range of points | ||
%Return: | ||
% S: Struct of orientational corder values cor0,cor1 and distance | ||
% between elements | ||
count = 0; | ||
for ii=1:(size(R,1)-1) | ||
for jj=ii+1:size(R,1) | ||
count = count +1; | ||
S(count).cor0 = psi6p(ii); | ||
S(count).cor1 = psi6p(jj); | ||
S(count).rabs = sqrt( sum( (R(ii,:) - R(jj,:) ).^2 ) ); | ||
end | ||
end | ||
end |