{"id":130,"date":"2017-08-09T15:29:27","date_gmt":"2017-08-09T20:29:27","guid":{"rendered":"http:\/\/people.brandonu.ca\/ploskers\/?page_id=130"},"modified":"2021-09-18T13:50:21","modified_gmt":"2021-09-18T18:50:21","slug":"matlab-files","status":"publish","type":"page","link":"https:\/\/people.brandonu.ca\/ploskers\/matlab-files\/","title":{"rendered":"Matlab files"},"content":{"rendered":"<hr \/>\n<p><strong>Matlab files:<\/strong> As part of the\u00a0 2017 PIMS Graduate Math Modelling in Industry Workshop (GMMIW), my team of students (Muhammad Zubair, Charlene Chu, Mounada Gbadamassi, Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, and Xiaohong Zhang) created a Matlab program that plots the probability of state transfer over some specified interval of time, specifically looking at unweighted trees with integer spectrum (from &#8220;Small integral trees&#8221; by A. E. Brouwer). This could be edited for other purposes (e.g. weighted trees). These files are available below (unfortunately I am not able to upload them as .m files or even .txt files due to internal security policy).<\/p>\n<p>&nbsp;<\/p>\n<p>% File #1: integer_trees_generator.m<br \/>\n% 2017 Graduate Math Modelling in Industry Workshop<br \/>\n% Project 3: Modelling a quantum spin network<br \/>\n% Mentor: Sarah Plosker &#8211; Brandon University<br \/>\n% Team 3: Muhammad Zubair, Charlene Chu, Mounada Gbadamassi,Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, Xiaohong Zhang<\/p>\n<p>&nbsp;<\/p>\n<p>% clear and initiate variables<br \/>\nclc % clears the comand window<br \/>\nclear all % clears all the work space variables<br \/>\nclose all % closes all the open figure windows<\/p>\n<p>timestep=0.001; % timestep size<br \/>\ndynamics=0; % 0 if XY dynamics and 1 if XYZ dynamics<br \/>\nmax_value_plot=1; % plot max_value of PST for the tree if 1<br \/>\nindividual_edge_plot=0; % plots the PST values for the individual edges<br \/>\nmin_time=1000*pi; % the starting time of the simulation<br \/>\nmax_time=2000*pi; % the end time of the simulation<br \/>\nsparse_to_full=0; % Setting this to 1 will return the adjacency matrix as<br \/>\n%full matrix rather than a sparse matrix. This is<br \/>\n%stored in A_full variable<\/p>\n<p>% load integer trees<br \/>\ninteger_trees_generator; % generates a structure with 66 trees, which can be<br \/>\n% used to simulate<\/p>\n<p>&nbsp;<\/p>\n<p>%convert the level based tree specification into an adjacency matrix<\/p>\n<p>%if you want to simulate one of the integer trees proposed by Brouwer<br \/>\n%uncomment the following and comment the next instance of assignment to<br \/>\n%parent variable<\/p>\n<p>%parent=integer_trees(17).tree; % level based tree specification<\/p>\n<p>% if you want to specify the tree based on the level sequence use the<br \/>\n% following<br \/>\nparent=[0,1,1,3,3,2,2,4,4,5,5,6,6,7,7];<\/p>\n<p>%Code to convert the level sequence to Ajacency matrix<br \/>\nj = find(parent);<br \/>\nn=length(parent);<br \/>\nA = sparse(parent(j), j, 1, n, n);<br \/>\nA = A + A&#8217;;<br \/>\nrow=[];<br \/>\ncol=[];<br \/>\nif sparse_to_full==1<br \/>\nA_full=full(A);<br \/>\nend<br \/>\n% calculate the hamiltonian operator<br \/>\nif dynamics==0<br \/>\nL=A;<br \/>\nelseif dynamics==1<br \/>\nL=diag(sum(A,2))-A;<br \/>\nend<\/p>\n<p>% calculate the Probability of Perfect State Transfer<br \/>\nk=1;<br \/>\nmax_vale_location=struct(&#8216;value&#8217;, [],&#8217;location&#8217;,[]);<br \/>\ntemp=zeros(size(L));<br \/>\nfor i=1:size(L,1)<br \/>\ntemp(i,i+1:end)=ones(1,size(L,2)-i);<br \/>\nend<\/p>\n<p>for t=min_time:timestep:max_time<br \/>\nM(:,:,t)= abs(expm(1i*t*L));<br \/>\nmax_val(k)=max(max(M(:,:,t).*temp));<br \/>\n[row,col]=find(M(:,:,t)==max_val(k));<br \/>\nmax_value_location(k).value=max_val(k);<br \/>\nmax_value_location(k).location=[row, col];<br \/>\nend<\/p>\n<p>% figure plotting<br \/>\nif individual_edge_plot==1<br \/>\nfor i=1:(size(L,1)-1)<br \/>\nfor j=i+1:size(L,2)<br \/>\nfigure, plot([min_time:timestep:max_time],squeeze(M(i,j,:))),ylim([0,1.1]),xlabel(&#8216;Time&#8217;), ylabel(&#8216;Probability of PST&#8217;),title([&#8216;node &#8216;,num2str(i),&#8217;-&#8216;,num2str(j)]),hold on<br \/>\nplot([0,2*pi],[1,1],&#8217;&#8211;r&#8217;,&#8217;LineWidth&#8217;,2)<br \/>\nend<br \/>\nend<br \/>\nend<\/p>\n<p>if max_value_plot==1<br \/>\nfigure, plot([min_time:timestep:max_time],max_val), ylim([0,1.1]), xlabel(&#8216;Time&#8217;),ylabel(&#8216;Probability of PST&#8217;), title(&#8216;Maximum PST value&#8217;)<br \/>\nend<\/p>\n<p>% graph plotting<\/p>\n<p>if tree_plot==1<br \/>\nfigure, treeplot(parent)<br \/>\ntitle(&#8216;Tree&#8217;)<br \/>\naxis off<br \/>\nend<\/p>\n<p>&nbsp;<\/p>\n<p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br \/>\n% File #2: PST_simulation_temp<br \/>\n% 2017 Graduate Math Modelling in Industry Workshop<br \/>\n% Project 3: Modelling a quantum spin network<br \/>\n% Mentor: Sarah Plosker &#8211; Brandon University<br \/>\n% Team 3: Muhammad Zubair, Charlene Chu, Mounada Gbadamassi,Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, Xiaohong Zhang<\/p>\n<p>% clear and initiate variables<br \/>\nclc % clears the comand window<br \/>\nclear all % clears all the work space variables<br \/>\nclose all % closes all the open figure windows<\/p>\n<p>timestep=0.001; % timestep size<br \/>\ndynamics=0; % 0 if XY dynamics and 1 if XYZ dynamics<br \/>\nmax_value_plot=1; % plot max_value of PST for the tree if 1<br \/>\nindividual_edge_plot=0; % plots the PST values for the individual edges<br \/>\nmin_time=1000*pi; % the starting time of the simulation<br \/>\nmax_time=2000*pi; % the end time of the simulation<br \/>\nsparse_to_full=0; % Setting this to 1 will return the adjacency matrix as<br \/>\n%full matrix rather than a sparse matrix. This is<br \/>\n%stored in A_full variable<\/p>\n<p>% load integer trees<br \/>\ninteger_trees_generator; % generates a structure with 66 trees, which can be<br \/>\n% used to simulate<\/p>\n<p>%convert the level based tree specification into an adjacency matrix<\/p>\n<p>%if you want to simulate one of the integer trees proposed by Brouwer<br \/>\n%uncomment the following and comment the next instance of assignment to<br \/>\n%parent variable<\/p>\n<p>%parent=integer_trees(17).tree; % level based tree specification<\/p>\n<p>% if you want to specify the tree based on the level sequence use the<br \/>\n% following<br \/>\nparent=[0,1,1,3,3,2,2,4,4,5,5,6,6,7,7];<\/p>\n<p>%Code to convert the level sequence to Ajacency matrix<br \/>\nj = find(parent);<br \/>\nn=length(parent);<br \/>\nA = sparse(parent(j), j, 1, n, n);<br \/>\nA = A + A&#8217;;<br \/>\nrow=[];<br \/>\ncol=[];<br \/>\nif sparse_to_full==1<br \/>\nA_full=full(A);<br \/>\nend<br \/>\n% calculate the hamiltonian operator<br \/>\nif dynamics==0<br \/>\nL=A;<br \/>\nelseif dynamics==1<br \/>\nL=diag(sum(A,2))-A;<br \/>\nend<\/p>\n<p>% calculate the Probability of Perfect State Transfer<br \/>\nk=1;<br \/>\nmax_vale_location=struct(&#8216;value&#8217;, [],&#8217;location&#8217;,[]);<br \/>\ntemp=zeros(size(L));<br \/>\nfor i=1:size(L,1)<br \/>\ntemp(i,i+1:end)=ones(1,size(L,2)-i);<br \/>\nend<\/p>\n<p>for t=min_time:timestep:max_time<br \/>\nM(:,:,t)= abs(expm(1i*t*L));<br \/>\nmax_val(k)=max(max(M(:,:,t).*temp));<br \/>\n[row,col]=find(M(:,:,t)==max_val(k));<br \/>\nmax_value_location(k).value=max_val(k);<br \/>\nmax_value_location(k).location=[row, col];<br \/>\nend<\/p>\n<p>% figure plotting<br \/>\nif individual_edge_plot==1<br \/>\nfor i=1:(size(L,1)-1)<br \/>\nfor j=i+1:size(L,2)<br \/>\nfigure, plot([min_time:timestep:max_time],squeeze(M(i,j,:))),ylim([0,1.1]),xlabel(&#8216;Time&#8217;), ylabel(&#8216;Probability of PST&#8217;),title([&#8216;node &#8216;,num2str(i),&#8217;-&#8216;,num2str(j)]),hold on<br \/>\nplot([0,2*pi],[1,1],&#8217;&#8211;r&#8217;,&#8217;LineWidth&#8217;,2)<br \/>\nend<br \/>\nend<br \/>\nend<\/p>\n<p>if max_value_plot==1<br \/>\nfigure, plot([min_time:timestep:max_time],max_val), ylim([0,1.1]), xlabel(&#8216;Time&#8217;),ylabel(&#8216;Probability of PST&#8217;), title(&#8216;Maximum PST value&#8217;)<br \/>\nend<\/p>\n<p>% graph plotting<\/p>\n<p>if tree_plot==1<br \/>\nfigure, treeplot(parent)<br \/>\ntitle(&#8216;Tree&#8217;)<br \/>\naxis off<br \/>\nend<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Matlab files: As part of the\u00a0 2017 PIMS Graduate Math Modelling in Industry Workshop (GMMIW), my team of students (Muhammad Zubair, Charlene Chu, Mounada Gbadamassi, Ruwan Chamara Karunanayaka, Naghmeh Shahverdi, and Xiaohong Zhang) created a Matlab program that plots the probability of state transfer over some specified interval of time, specifically looking at unweighted trees [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-130","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/pages\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":3,"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/pages\/130\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/pages\/130\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/people.brandonu.ca\/ploskers\/wp-json\/wp\/v2\/media?parent=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}