


{"id":363687,"date":"2024-04-23T10:40:36","date_gmt":"2024-04-23T10:40:36","guid":{"rendered":"\/forum\/forums\/topic\/fdtdjisuanguangzijingtinengdaijiegouwenti\/"},"modified":"2024-04-23T10:40:36","modified_gmt":"2024-04-23T10:40:36","slug":"fdtdjisuanguangzijingtinengdaijiegouwenti","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fdtdjisuanguangzijingtinengdaijiegouwenti\/","title":{"rendered":"FDTD\u8ba1\u7b97\u5149\u5b50\u6676\u4f53\u80fd\u5e26\u7ed3\u6784\u95ee\u9898"},"content":{"rendered":"<p>\u8001\u5e08\u60a8\u597d\uff0c\u5728\u6848\u4f8b&ldquo;<span style=\"font-size: 14pt\">Bandstructure of planar photonic crystal with a hexagonal lattice<\/span>&rdquo;\u4e2d\uff0c\u6211\u4f7f\u7528\u4e86\u5982\u4e0b\u811a\u672c\u6765\u8ba1\u7b97\u80fd\u5e26\u7ed3\u6784\uff0c\u4f46\u7cfb\u7edf\u62a5\u9519\u3002<\/p>\n<p>#############################################################################<\/p>\n<p># This script combines the results from the Gamma-M-K-Gamma sweep<\/p>\n<p># and plots the frequency spectrum fs from the bandstructure object<\/p>\n<p># results over k, and the bandstructure.<\/p>\n<p># The bandstructure information is extracted using tolerance and num_band<\/p>\n<p># specified by the user at the beginning of the script.<\/p>\n<p>#<\/p>\n<p># Properties:<\/p>\n<p># a: period used to normalize the frequency (f_norm=f*a\/c)<\/p>\n<p># f_band: Frequencies of bands in units of Hz<\/p>\n<p># f_band_norm: Frequencies of bands in units of Hz * a \/ c<\/p>\n<p>#############################################################################<\/p>\n<p># User Defined properties:<\/p>\n<p>tolerance = 1e-3; #tolerance for finding peaks and accepting bands<\/p>\n<p># setting this too low will result in noisy data where sidelobes of<\/p>\n<p># peaks are interpreted as new bands<\/p>\n<p># setting it too high will mean that some bands are not found<\/p>\n<p>num_band = 10; #number of bands to search for in the bandstructure<\/p>\n<p>#<\/p>\n<p>#############################################################################<\/p>\n<p>&nbsp;<\/p>\n<p>runsweep; # run all sweeps<\/p>\n<p>&nbsp;<\/p>\n<p># get a from model<\/p>\n<p>a = getnamed(&#8220;::model&#8221;,&#8221;a&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p># get fs data from the sweeps<\/p>\n<p>sweepname=&#8221;Gamma-M&#8221;;<\/p>\n<p>spectrum=getsweepresult(sweepname,&#8221;spectrum&#8221;);<\/p>\n<p>f=c\/spectrum.lambda;<\/p>\n<p>fs_all=matrix(length(f),30); # initialize matrix to store fs data in<\/p>\n<p>fs_all(1:length(f),1:10)=spectrum.fs;<\/p>\n<p>&nbsp;<\/p>\n<p>sweepname=&#8221;M-K&#8221;;<\/p>\n<p>spectrum=getsweepresult(sweepname,&#8221;spectrum&#8221;);<\/p>\n<p>fs_all(1:length(f),11:20)=spectrum.fs;<\/p>\n<p>&nbsp;<\/p>\n<p>sweepname=&#8221;K-Gamma&#8221;;<\/p>\n<p>spectrum=getsweepresult(sweepname,&#8221;spectrum&#8221;);<\/p>\n<p>fs_all(1:length(f),21:30)=spectrum.fs;<\/p>\n<p>&nbsp;<\/p>\n<p># simple imaging of fs vs k<\/p>\n<p>image(1:30,f,transpose(fs_all),&#8221;k (Gamma-M-K-Gamma)&#8221;,&#8221;f (Hz)&#8221;,&#8221;bandstructure, logscale&#8221;,&#8221;logplot&#8221;);<\/p>\n<p>image(1:30,f,transpose(fs_all),&#8221;k (Gamma-M-K-Gamma)&#8221;,&#8221;f (Hz)&#8221;,&#8221;bandstructure, linearscale&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>setplot(&#8220;colorbar min&#8221;,0);<\/p>\n<p>setplot(&#8220;colorbar max&#8221;,max(fs_all)*1e-4);<\/p>\n<p>&nbsp;<\/p>\n<p># plot bandstructure<\/p>\n<p>bandstructure=matrix(num_band,30); # initialize matrix in which to store band frequency information<\/p>\n<p>&nbsp;<\/p>\n<p># loop over sweep results<\/p>\n<p>for (i=1:30){<\/p>\n<p>#use findpeaks to find num_band number of peaks<\/p>\n<p>temp = findpeaks(fs_all(1:length(f),i),num_band);<\/p>\n<p>&nbsp;<\/p>\n<p>#collect data for any peaks that are more than &#8216;tolerance&#8217; of the maximum peak (to avoid minor peaks like sidelobes)<\/p>\n<p>minvalue = fs_all(temp(1),i)*tolerance;<\/p>\n<p>f_band=matrix(num_band);<\/p>\n<p>for(bandcount = 1:num_band) {<\/p>\n<p>if( fs_all(temp(bandcount),i) &gt; minvalue) {<\/p>\n<p>f_band(bandcount) = f(temp(bandcount));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>f_band_norm = f_band*a\/c; # normalize the frequency vector<\/p>\n<p>bandstructure(1:num_band,i)=f_band_norm;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>bandstructure=transpose(bandstructure);<\/p>\n<p>plot(1:30,bandstructure,&#8221;k (Gamma-M-K-Gamma)&#8221;,&#8221;f (Hz*a\/c)&#8221;,&#8221;bandstructure&#8221;,&#8221;plot points&#8221;);<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2024\/04\/23-04-2024-1713868699-mceclip0.png\" width=\"1166\" height=\"86\"><\/p>\n<p>\u8bf7\u95ee\u8001\u5e08\u662f\u6211\u8bbe\u7f6e\u6709\u4ec0\u4e48\u95ee\u9898\u5417\uff1f<\/p>\n","protected":false},"template":"","class_list":["post-363687","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["294265","2592","343827"],"_bbp_author_ip":["23.206.193.154"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["1528"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["363687"],"_bbp_forum_id":["27835"],"_bbp_engagement":["2592","294265","343827"],"_bbp_voice_count":["3"],"_bbp_reply_count":["6"],"_bbp_last_reply_id":["382957"],"_bbp_last_active_id":["382957"],"_bbp_last_active_time":["2024-09-18 09:02:06"]},"test":"liqingyunsztu-edu-cn"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/363687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/363687\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=363687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}