


{"id":281823,"date":"2023-05-01T19:57:03","date_gmt":"2023-05-01T19:57:03","guid":{"rendered":"\/forum\/forums\/topic\/issues-with-array-splicing-and-power-calculation-in-mode\/"},"modified":"2023-05-01T20:07:48","modified_gmt":"2023-05-01T20:07:48","slug":"issues-with-array-splicing-and-power-calculation-in-mode","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/issues-with-array-splicing-and-power-calculation-in-mode\/","title":{"rendered":"issues with array splicing and power calculation in MODE"},"content":{"rendered":"<p>I have calculated the poynting vector for my simulation and stored its magnitude in an array called S.<\/p>\n<p>S has dimensions (2081,361) and my simulation domain extends from -26um to 26um in the horizontal and 5um to -4um in the vertical.&nbsp;<\/p>\n<p>I use the following script to get the normalized power in the region bounded from 5um to 0um and -26 to 26um:<\/p>\n<p>x1=26e06;<\/p>\n<p>x2=-26e-06;<\/p>\n<p>z1=5e-6;<\/p>\n<p>z2=0e-6;<\/p>\n<p>selectmode(1);<\/p>\n<p>setanalysis(&#8220;integration shape&#8221;,&#8221;rectangular&#8221;);<\/p>\n<p>setanalysis(&#8220;z1&#8221;,z1);setanalysis(&#8220;z2&#8221;,z2);<\/p>\n<p>setanalysis(&#8220;x1&#8221;,x1);setanalysis(&#8220;x2&#8221;,x2);<\/p>\n<p>area=getanalysis(&#8220;fraction integrated&#8221;);<\/p>\n<p>?area;<\/p>\n<p>BUT, if I were to splice the array &#8216;S&#8217; as x = S(:,1:201) where 1 is the row index corresponding to 5um and 201 is the index corresponding 0um in my simulation domain and then I perform a sum(x)\/sum(S) I get an incorrect answer to what is given in the script above.<\/p>\n<p>However if I splice the array &#8216;S&#8217; as x = S(:,161:361) and then take the sum(x)\/sum(S), I get the correct value given by the script above. I do not understand why this gives the correct result because this captures the array values which are beneath the region I specified in the script, why in a manual calculation using array splicing I need to specify indices which do not belong to the region 5um to 0um vertical, but instead specify 0 to -4um vertical. A pic of S is shown below.<\/p>\n<p>&nbsp;<\/p>\n<p><a class=\"wp-colorbox-image cboxElement\" href=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/05\/01-05-2023-1682970935-S.JPG\"><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/05\/01-05-2023-1682970935-S.JPG\" alt=\"\"><\/a><\/p>\n<p>Also, if I use GUI power integration, it gives correct answer as script:<\/p>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/05\/01-05-2023-1682971507-f.JPG\" alt=\"\"><\/p>\n<p>what am I not understanding about splicing in lumerical, or what am I not understanding about the built in &#8216;fraction integrated&#8217; function?&nbsp;<\/p>\n<p>Thanks<\/p>\n","protected":false},"template":"","class_list":["post-281823","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["271826","2592"],"_bbp_author_ip":["96.7.74.173"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["362"],"_edit_lock":["1682974013:201846"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["281823"],"_bbp_forum_id":["27833"],"_bbp_engagement":["2592","271826"],"_bbp_voice_count":["2"],"_bbp_reply_count":["5"],"_bbp_last_reply_id":["282254"],"_bbp_last_active_id":["282254"],"_bbp_last_active_time":["2023-05-03 21:12:12"]},"test":"nirvan-gajadharsinghuni-jena-de"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/281823","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\/281823\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=281823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}