From 07d9e0bdb4b755ed3e7ff89433a0d61411b9eed3 Mon Sep 17 00:00:00 2001 From: LyceanEM <60020395+LyceanEM@users.noreply.github.com> Date: Wed, 29 May 2024 16:05:09 +0100 Subject: [PATCH] Adding discrete_transmit_power to math_functions, and it's use in excitation_function in base_classes. This allows the definition of an aperture with a specific total transmit power. --- .gitignore | 1 + lyceanem/base_classes.py | 12 ++++++++++-- lyceanem/utility/math_functions.py | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 93fa01b..cd72454 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,4 @@ cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python /examples/ /lyceanem/_version.py +/lyceanem/tests/rotation_tests.py diff --git a/lyceanem/base_classes.py b/lyceanem/base_classes.py index 1cae8d2..b1f944b 100644 --- a/lyceanem/base_classes.py +++ b/lyceanem/base_classes.py @@ -381,11 +381,11 @@ def export_all_points(self, point_index=None): def excitation_function( self, desired_e_vector, - transmit_amplitude=1, point_index=None, phase_shift="none", wavelength=1.0, steering_vector=np.zeros((1, 3)), + transmit_power=1.0 ): # generate the local excitation function and then convert into the global coordinate frame. if point_index == None: @@ -404,7 +404,15 @@ def excitation_function( ) aperture_weights = aperture_weights * phase_weights.reshape(-1, 1) - return aperture_weights * transmit_amplitude + from .utility.math_functions import discrete_transmit_power + if 'Area' in aperture_points.point_data.keys(): + areas=aperture_points.point_data['Area'] + else: + areas=np.zeros((aperture_points.points.shape[0])) + areas[:]=wavelength**2 + + calibrated_amplitude_density=discrete_transmit_power(aperture_weights,areas,transmit_power) + return calibrated_amplitude_density def export_all_structures(self): diff --git a/lyceanem/utility/math_functions.py b/lyceanem/utility/math_functions.py index 683ef3d..2778cd7 100644 --- a/lyceanem/utility/math_functions.py +++ b/lyceanem/utility/math_functions.py @@ -74,6 +74,29 @@ def calc_normals(T): return T +def discrete_transmit_power(weights,element_area,transmit_power=100.0,impedance=np.pi*120.0): + """ + Calculate the transmitting aperture amplitude density required for a given transmit power in watts. + Parameters + ---------- + weights + element_area + transmit_power + impedance + + Returns + ------- + + """ + #to start with assume area per element is consistent + power_at_point=np.abs(weights.reshape(-1,1))*element_area.reshape(-1,1) # calculate power + #integrate power over aperture and normalise to desired power for whole aperture + power_normalisation=transmit_power/np.sum(power_at_point) + transmit_power_density=(power_at_point*power_normalisation)/element_area.reshape(-1,1) + #calculate amplitude density + transmit_amplitude_density=(transmit_power_density*impedance)**0.5 + transmit_excitation=transmit_amplitude_density.reshape(-1,1)*element_area.reshape(-1,1)*np.exp(1j*np.angle(weights.reshape(-1,1))) + return transmit_excitation @guvectorize( [(float32[:], float32[:], float32[:], float32)],