GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
voronoi2dCellColour.m
Go to the documentation of this file.
1 function [p6cp6, area, avg_area, num_edges, var]=voronoi2dCellColour(x,y,radius,edgeCol,dx,colScheme)
2 %vorCellColour Determine the Voronoi diagram of the input data, and colour the
3 %cells with the value of the orientational correlations defined at each
4 %site (col=1), or with the area of the cell (col=0).
5 %x,y: are the locations of the sites
6 %radius: is the area over which to perform the triangulation. This should
7 % avoid too large values to ensure the traingulation does not run off to
8 % infinity
9 %edgeCol: Defines the Voronoi diagram edge colours for edge indexed pair. edgeCol<0 is
10 % red, edgeCol==0 is black, edgeCol>0 is white
11 %dx: this is the increment size of the data
12 %colScheme: defines the colouring scheme, 1 for orientational correlations on the site
13 % with 6-fold symmetry, 0 for cell area
14 % Returns: p6cp6 = local values of correlations
15 % area = cell areas
16 % avg_area = average area of cells
17 % num_edges = cell edges count
18 % var = variance
19 %
20 %Testcase: Generate a 2D grid centred on 0 and calculate voronoi diagram
21 % x=linspace(-1,1,20); y=x;
22 % radius = 0.5; dx = 1; q = ones(length(x)*length(y),1);
23 % voronoi2dCellColour(kron(x',ones(length(y),1)),kron(ones(length(x),1),y'),0.75,zeros(length(x)^2,1),1,0);
24 
25 DT = delaunayTriangulation([x y]);
26 [v,c]=voronoiDiagram(DT);
27 if colScheme==1
28  p6cp6=zeros(length(c),1);
29 end
33 
35 R = DT.Points;
36 
37 %Credit to MathWorks support team for neighboringVertices.m
38 vTriAtt = vertexAttachments(DT);
39 for ii = 1:size(R,1)
40  % 2. Use the connectivity list to get the vertex indices of all these
41  % triangles
42  verticesOfTI = DT.ConnectivityList(vTriAtt{ii},:);
43  % 3. Find all the unique vertices and remove the current vertex
44  neighboursOfInternal{ii} = setdiff(unique(verticesOfTI), ii);
45 end
46 
47 % Calculate the Voronoi diagram
48 for jj = 1:length(c)
49  %Credit to MathWorks team for voronoi examples. https://uk.mathworks.com/help/matlab/ref/voronoi.html
50  if (all(c{jj}~=1) && all(sqrt((x(jj)).^2 + (y(jj)).^2) < radius)); % If at least one of the indices is 1,
51  % then it is an open region and we can't patch that.
52 
53  area(jj)=polyarea(v(c{jj},1),v(c{jj},2));
54  avg_area = avg_area + area(jj);
55  if colScheme==1
56  [p6(jj),nn(jj)] = psi6_DT([x(jj),y(jj)],x(neighboursOfInternal{jj}),y(neighboursOfInternal{jj}));
57  p6cp6(jj) = sum(conj(p6(jj)).*p6(jj));
58  h = patch(v(c{jj},1),v(c{jj},2),p6cp6(jj)); % use g6 as color
59  else
60  h = patch(v(c{jj},1),v(c{jj},2),area(jj)); % use area as color
61  end
62  if edgeCol(jj)< 0
63  h.EdgeColor = 'red';
64  h.LineWidth = '2';
65  h.LineStyle = '-';
66  elseif edgeCol(jj) == 0
67  h.EdgeColor = 'black';
68  h.LineStyle = '-'
69  else
70  h.EdgeColor = 'white';
71  h.LineStyle = '-'
72  end
73  num_edges(jj) = length(c{jj});
74  get(h);
75  end
76 end
77 
78 avg_area=avg_area./nnz(area);
79 var = sum((area(area>1) - avg_area).^2);
80 var = var./nnz(area);
81 
82 hold on; plot(x,y,'r*');plot(x,y,'bo');colorbar
83 set(gca,'FontName','Latin Modern Roman','FontSize',22);
84 set(gca,'TickLabelInterpreter', 'latex');
85 axis square;ylabel('$y$ (m)','Interpreter','latex');xlabel('$x$ (m)','Interpreter','latex');
and colour the % cells with the value of the orientational correlations defined at each % or with the area of the edgeCol is white % dx
end % Calculate the Voronoi diagram for jj
and colour the % cells with the value of the orientational correlations defined at each % or with the area of the y
plot(x, y, 'r *')
for ii
locations
Definition: findNN.m:6
% Calculate delaunay triangulation
% radius
and colour the % cells with the value of the orientational correlations defined at each % or with the area of the edgeCol
colorbar off
Definition: quKineticSpec.m:83
c
Definition: VtxCorr.m:27
ylabel(' $y$(m)', 'Interpreter', 'latex')
colorbar
Definition: quKineticSpec.m:55
end num_edges
__global__ void zeros(double *field, int n)
Creates a field of all zeros ,.
% Credit to MathWorks support team for neighboringVertices m vTriAtt
if colScheme
end if sqrt(sum([x(ii), y(ii)].^ 2))< radius %% ignore edges if(length(DT.vertexAttachments
with(5, 7)(3
def current
Definition: vort.py:172
def voronoi(dataName, dataType, value)
Definition: vis.py:85
% Find all the unique vertices and remove the current vertex neighboursOfInternal
and assumes too high and very sparse Start at
Definition: velField.m:5
% Indexing needs to % be modified if you wish to use the ordered data sets % Calculate the Voronoi diagram of the resulting data
Definition: VtxCorr.m:36
% axis([1e4 1e7 5e-18 1e-10])
xlabel(' $x$(m)', 'Interpreter', 'latex')
and colour the % cells with the value of the orientational correlations defined at each % or with the area of the cell(col=0). % x
hold on
% If at least one of the indices is
def run(start, fin, incr)
Definition: vort.py:215
p6cp6(jj)
axis square
% voronoi2dCellColour(kron(x', ones(length(y), 1)), kron(ones(length(x), 1), y'), 0.75, zeros(length(x)^ 2, 1), 1, 0)
and colour the % cells with the value of the orientational correlations defined at each % site(col=1)
length
Definition: vort.py:75