1212
1313### Import Libraries
1414import os , tempfile
15- from pylab import *
15+ from matplotlib import pylab as plt
16+ import numpy as np
1617
1718from CSXCAD import ContinuousStructure
1819from openEMS import openEMS
@@ -148,26 +149,29 @@ class phantom:
148149port .CalcPort (Sim_Path , f )
149150s11 = port .uf_ref / port .uf_inc
150151s11_dB = 20.0 * np .log10 (np .abs (s11 ))
151- figure ()
152- plot (f / 1e9 , s11_dB , 'k-' , linewidth = 2 , label = '$S_{11}$' )
153- grid ()
154- legend ()
155- ylabel ('S-Parameter (dB)' )
156- xlabel ('Frequency (GHz)' )
152+ plt .figure ()
153+ plt .plot (f / 1e9 , s11_dB , 'k-' , linewidth = 2 , label = '$S_{11}$' )
154+ plt .grid ()
155+ plt .legend ()
156+ plt .ylabel ('S-Parameter (dB)' )
157+ plt .xlabel ('Frequency (GHz)' )
158+ plt .title ('S-Parameter' )
157159
158160Zin = port .uf_tot / port .if_tot
159161
160162Pin_f0 = np .interp (f0 , f , port .P_acc )
161163
162164# plot feed point impedance
163165Zin = port .uf_tot / port .if_tot
164- figure ()
165- plot (f / 1e9 , np .real (Zin ), 'k-' , linewidth = 2 , label = r'$\Re\{Z_{in}\}$' )
166- plot (f / 1e9 , np .imag (Zin ), 'r--' , linewidth = 2 , label = r'$\Im\{Z_{in}\}$' )
167- grid ()
168- legend ()
169- ylabel ('Zin (Ohm)' )
170- xlabel ('Frequency (GHz)' )
166+ plt .figure ()
167+ plt .plot (f / 1e9 , np .real (Zin ), 'k-' , linewidth = 2 , label = r'$\Re\{Z_{in}\}$' )
168+ plt .plot (f / 1e9 , np .imag (Zin ), 'r--' , linewidth = 2 , label = r'$\Im\{Z_{in}\}$' )
169+ plt .grid ()
170+ plt .legend ()
171+ plt .ylabel ('Zin (Ohm)' )
172+ plt .xlabel ('Frequency (GHz)' )
173+ plt .title ('Input Impedance' )
174+
171175
172176SAR_src = os .path .join (Sim_Path , 'SAR.h5' ) # calculated SAR output
173177SAR_fn = os .path .join (Sim_Path , 'SAR_10g.h5' ) # calculated SAR output
@@ -191,21 +195,22 @@ class phantom:
191195# The nf2ff far-field is calculated to determine the radiated power (that was not absorbed)
192196nf2ff_res = nf2ff .CalcNF2FF (Sim_Path , f0 , theta , phi , center = [0 ,0 ,0 ], read_cached = post_proc_only , verbose = 1 )
193197
194- print (f'max SAR: { max_sar / Pin_f0 } W/kg normalized to 1 W accepted power' )
195- print (f'whole body SAR: { ptotal / Pin_f0 / mass } W/kg normalized to 1 W accepted power' )
196- print (f'accepted power: { Pin_f0 } W (100 %)' )
197- print (f'radiated power: { nf2ff_res .Prad [0 ]} W ({ 100 * (nf2ff_res .Prad [0 ]) / Pin_f0 :.1f} %)' )
198- print (f'absorbed power: { ptotal } W ({ 100 * (ptotal ) / Pin_f0 :.1f} %)' )
198+ print (f'max SAR: { max_sar / Pin_f0 :.4g } W/kg normalized to 1 W accepted power' )
199+ print (f'whole body SAR: { ptotal / Pin_f0 / mass :.4g } W/kg normalized to 1 W accepted power' )
200+ print (f'accepted power: { Pin_f0 :.4g } W (100 %)' )
201+ print (f'radiated power: { nf2ff_res .Prad [0 ]:.4g } W ({ 100 * (nf2ff_res .Prad [0 ]) / Pin_f0 :.1f} %)' )
202+ print (f'absorbed power: { ptotal :.4g } W ({ 100 * (ptotal ) / Pin_f0 :.1f} %)' )
199203print (f'power budget: { 100 * (nf2ff_res .Prad [0 ] + ptotal ) / Pin_f0 :.1f} %' ) # this ideally should be within 95 to 100%
200204
201205# plot SAR on a x/y and x/z-plane
202- fig , axs = subplots (1 ,2 , figsize = (12 , 5 ))
206+ fig , axs = plt . subplots (1 ,2 , figsize = (12 , 5 ))
203207
204208X ,Y = np .meshgrid (mesh [0 ], mesh [1 ], indexing = 'ij' )
205209Nz = len (mesh [2 ])
206210sar_xy = sar [:,:,Nz // 2 ]
207211im = axs [0 ].pcolormesh (X ,Y ,sar_xy / Pin_f0 , vmax = max_sar / Pin_f0 )
208212axs [0 ].axis ('equal' )
213+ axs [0 ].set_title ('xy-plane' )
209214plt .colorbar (im )
210215m_idx = np .unravel_index (np .argmax (sar_xy ), sar_xy .shape )
211216
@@ -214,6 +219,8 @@ class phantom:
214219sar_xz = sar [:,Ny // 2 ,:]
215220im = axs [1 ].pcolormesh (X ,Z ,sar_xz / Pin_f0 , vmax = max_sar / Pin_f0 )
216221axs [1 ].axis ('equal' )
222+ axs [1 ].set_title ('xz-plane' )
217223plt .colorbar (im )
224+ fig .suptitle ('Specific Absorbtion Rate (SAR)' )
218225
219- show ()
226+ plt . show ()
0 commit comments