Matlab files

% File #1: integer_trees_generator.m
% 2017 Graduate Math Modelling in Industry Workshop
% Project 3: Modelling a quantum spin network
% Mentor: Sarah Plosker – Brandon University
% Team 3: Muhammad Zubair, Charlene Chu, Mounada Gbadamassi,Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, Xiaohong Zhang

 

% clear and initiate variables
clc % clears the comand window
clear all % clears all the work space variables
close all % closes all the open figure windows

timestep=0.001; % timestep size
dynamics=0; % 0 if XY dynamics and 1 if XYZ dynamics
max_value_plot=1; % plot max_value of PST for the tree if 1
individual_edge_plot=0; % plots the PST values for the individual edges
min_time=1000*pi; % the starting time of the simulation
max_time=2000*pi; % the end time of the simulation
sparse_to_full=0; % Setting this to 1 will return the adjacency matrix as
%full matrix rather than a sparse matrix. This is
%stored in A_full variable

% load integer trees
integer_trees_generator; % generates a structure with 66 trees, which can be
% used to simulate

 

%convert the level based tree specification into an adjacency matrix

%if you want to simulate one of the integer trees proposed by Brouwer
%uncomment the following and comment the next instance of assignment to
%parent variable

%parent=integer_trees(17).tree; % level based tree specification

% if you want to specify the tree based on the level sequence use the
% following
parent=[0,1,1,3,3,2,2,4,4,5,5,6,6,7,7];

%Code to convert the level sequence to Ajacency matrix
j = find(parent);
n=length(parent);
A = sparse(parent(j), j, 1, n, n);
A = A + A’;
row=[];
col=[];
if sparse_to_full==1
A_full=full(A);
end
% calculate the hamiltonian operator
if dynamics==0
L=A;
elseif dynamics==1
L=diag(sum(A,2))-A;
end

% calculate the Probability of Perfect State Transfer
k=1;
max_vale_location=struct(‘value’, [],’location’,[]);
temp=zeros(size(L));
for i=1:size(L,1)
temp(i,i+1:end)=ones(1,size(L,2)-i);
end

for t=min_time:timestep:max_time
M(:,:,t)= abs(expm(1i*t*L));
max_val(k)=max(max(M(:,:,t).*temp));
[row,col]=find(M(:,:,t)==max_val(k));
max_value_location(k).value=max_val(k);
max_value_location(k).location=[row, col];
end

% figure plotting
if individual_edge_plot==1
for i=1:(size(L,1)-1)
for j=i+1:size(L,2)
figure, plot([min_time:timestep:max_time],squeeze(M(i,j,:))),ylim([0,1.1]),xlabel(‘Time’), ylabel(‘Probability of PST’),title([‘node ‘,num2str(i),’-‘,num2str(j)]),hold on
plot([0,2*pi],[1,1],’–r’,’LineWidth’,2)
end
end
end

if max_value_plot==1
figure, plot([min_time:timestep:max_time],max_val), ylim([0,1.1]), xlabel(‘Time’),ylabel(‘Probability of PST’), title(‘Maximum PST value’)
end

% graph plotting

if tree_plot==1
figure, treeplot(parent)
title(‘Tree’)
axis off
end

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File #2: PST_simulation_temp
% 2017 Graduate Math Modelling in Industry Workshop
% Project 3: Modelling a quantum spin network
% Mentor: Sarah Plosker – Brandon University
% Team 3: Muhammad Zubair, Charlene Chu, Mounada Gbadamassi,Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, Xiaohong Zhang

% clear and initiate variables
clc % clears the comand window
clear all % clears all the work space variables
close all % closes all the open figure windows

timestep=0.001; % timestep size
dynamics=0; % 0 if XY dynamics and 1 if XYZ dynamics
max_value_plot=1; % plot max_value of PST for the tree if 1
individual_edge_plot=0; % plots the PST values for the individual edges
min_time=1000*pi; % the starting time of the simulation
max_time=2000*pi; % the end time of the simulation
sparse_to_full=0; % Setting this to 1 will return the adjacency matrix as
%full matrix rather than a sparse matrix. This is
%stored in A_full variable

% load integer trees
integer_trees_generator; % generates a structure with 66 trees, which can be
% used to simulate

%convert the level based tree specification into an adjacency matrix

%if you want to simulate one of the integer trees proposed by Brouwer
%uncomment the following and comment the next instance of assignment to
%parent variable

%parent=integer_trees(17).tree; % level based tree specification

% if you want to specify the tree based on the level sequence use the
% following
parent=[0,1,1,3,3,2,2,4,4,5,5,6,6,7,7];

%Code to convert the level sequence to Ajacency matrix
j = find(parent);
n=length(parent);
A = sparse(parent(j), j, 1, n, n);
A = A + A’;
row=[];
col=[];
if sparse_to_full==1
A_full=full(A);
end
% calculate the hamiltonian operator
if dynamics==0
L=A;
elseif dynamics==1
L=diag(sum(A,2))-A;
end

% calculate the Probability of Perfect State Transfer
k=1;
max_vale_location=struct(‘value’, [],’location’,[]);
temp=zeros(size(L));
for i=1:size(L,1)
temp(i,i+1:end)=ones(1,size(L,2)-i);
end

for t=min_time:timestep:max_time
M(:,:,t)= abs(expm(1i*t*L));
max_val(k)=max(max(M(:,:,t).*temp));
[row,col]=find(M(:,:,t)==max_val(k));
max_value_location(k).value=max_val(k);
max_value_location(k).location=[row, col];
end

% figure plotting
if individual_edge_plot==1
for i=1:(size(L,1)-1)
for j=i+1:size(L,2)
figure, plot([min_time:timestep:max_time],squeeze(M(i,j,:))),ylim([0,1.1]),xlabel(‘Time’), ylabel(‘Probability of PST’),title([‘node ‘,num2str(i),’-‘,num2str(j)]),hold on
plot([0,2*pi],[1,1],’–r’,’LineWidth’,2)
end
end
end

if max_value_plot==1
figure, plot([min_time:timestep:max_time],max_val), ylim([0,1.1]), xlabel(‘Time’),ylabel(‘Probability of PST’), title(‘Maximum PST value’)
end

% graph plotting

if tree_plot==1
figure, treeplot(parent)
title(‘Tree’)
axis off
end