


{"id":217664,"date":"2022-07-04T16:09:19","date_gmt":"2022-07-04T16:09:19","guid":{"rendered":"\/forum\/forums\/reply\/217664\/"},"modified":"2022-07-04T16:09:19","modified_gmt":"2022-07-04T16:09:19","slug":"217664","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/217664\/","title":{"rendered":"Reply To: Calculating the phase in FDTD"},"content":{"rendered":"<p>&lt;p&gt;There are 2 steps using script to get the phase:&lt;br&gt;1: get the field components. As you know, the phase is associated with Ex,Ey, Ez (or H components). So you can use&lt;br&gt;E=getresult(&#8220;monitor&#8221;,&#8221;E&#8221;);&lt;br&gt;Ex=E.Ex;&lt;br&gt;Ey=E.Ey;&lt;br&gt;Ez=E.Ez;&lt;br&gt;similarly you can get x,y,z and f.&lt;br&gt;2: get the phase. for example for Ex, you can write&lt;br&gt;xphase=angle(Ex);&lt;br&gt;which will be a function of xyz and f.&lt;\/p&gt;&lt;p&gt;In addition:&lt;br&gt;1: you can use Ex=getdata(&#8220;monitor&#8221;,&#8221;EX&#8221;) if you know you want Ex&lt;br&gt;2: you can use pinch to remove singular dimension: https:\/\/optics.ansys.com\/hc\/en-us\/articles\/360034405674-pinch-Script-command&nbsp;&lt;\/p&gt;&lt;p&gt;Please note that, a plannar frequency-domain monitor gives E\/H\/P as a function of x,y,z and wavelength\/frequency. So in general the phase extracted from a monitor will have 4 dimensions, although one of the xyz will be singleton.&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;You can specify a particular dimension. Say you have a xy plane monitor. The phase will be&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;Phase(1:nx,1:ny,1,1:nf)&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;Using pinch to remove z singleton; phase=pinch(phase).&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;If you want to image phase or a specific wavelength, you can specify the frequency point, say fn (1&lt;=fn&lt;=nf), then&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;Image(x,y, pinch(phase(:,:fn)), &ldquo;x&rdquo;,&rdquo;y&rdquo;,&rdquo;phase&rdquo;);&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-217664","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/217664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/217664\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=217664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}