harmolab.rwg — chaîne de calcul RWG#
Les six étapes de la chaîne de calcul RWG : topologie du maillage (rwg1), vecteurs ρ (rwg2), matrice d’impédance (rwg3), résolution linéaire et résultats des ports (rwg4), densité de courant de surface (rwg5, rwg6). Théorie : Fonctions de base RWG.
rwg1 — points, triangles, arêtes#
- class harmolab.rwg.rwg1.Points(points_data)[source]#
Bases :
objectClass representing a set of points in a three-dimensional space.
This class stores 3D points and provides information about the dimensions (length, width, height) of the space occupied by these points.
- Attributes:
- points (ndarray): A numpy array containing the coordinates of the points in shape (3, N),
where N is the total number of points in 3D space.
total_of_points (int): The total number of points in the set.
length (float): The length (maximum dimension along the X axis) of the point set.
width (float): The width (maximum dimension along the Y axis) of the point set.
height (float): The height (maximum dimension along the Z axis) of the point set.
Initialize a Points object with coordinate data.
- Parameters:
- points_data (ndarray): A numpy array of shape (3, N) representing the coordinates
of N points in 3D space. The first row contains the X coordinates, the second row the Y coordinates, and the third row the Z coordinates of the points.
- class harmolab.rwg.rwg1.Triangles(triangles_data)[source]#
Bases :
objectClass representing a set of triangles in a 3D mesh.
This class stores triangles, computes their geometric properties (areas, centers), and detects common edges between triangles.
- Attributes:
- triangles (n-d-array): A numpy array of shape (3, N) representing the vertex indices
of each triangle in 3D space.
total_of_triangles (int): The total number of triangles in the set.
triangles_area (n-d-array): An array containing the areas of each triangle.
triangles_center (n-d-array): An array containing the coordinates of each triangle’s center.
triangles_plus (n-d-array): An array containing the indices of triangles that share a common edge.
triangles_minus (n-d-array): An array containing the indices of triangles that share a common edge.
Class representing a set of triangles in a 3D mesh. This class stores triangles, computes their geometric properties (areas, centers), and detects common edges between triangles. Attributes: * triangles (n-d-array): A numpy array of shape (3, N) representing the vertex indices of each triangle in 3D space. * total_of_triangles (int): The total number of triangles in the set. * triangles_area (n-d-array): An array containing the areas of each triangle. * triangles_center (n-d-array): An array containing the coordinates of each triangle’s center. * triangles_plus (n-d-array): An array containing the indices of triangles that share a common edge. * triangles_minus (n-d-array): An array containing the indices of triangles that share a common edge.- calculate_triangles_area_and_center(points_data)[source]#
Compute the areas and centers of all triangles.
This method uses the mesh point coordinates to compute the area and the center of each triangle. The area is calculated using the cross product of the vectors formed by the triangle’s vertices. The center is computed as the average of the coordinates of the three vertices.
Parameter: points_data (Points): An object of the Points class containing the mesh point coordinates.
- set_triangles_area_and_center(triangles_area, triangles_center)[source]#
Manually set the areas and centers of triangles.
- Parameters:
triangles_area (n-d-array): Array of triangle areas.
triangles_center (n-d-array): Array of triangle centers.
- get_edges()[source]#
Detect common edges between triangles and determine the « plus » and « minus » triangle relations.
This method analyzes triangles to find common edges and classify them into pairs of triangles sharing an edge. The indices of the triangles with common edges are stored in the arrays triangles_plus and triangles_minus.
Note: records edges shared between more than two triangles.
Return: Edges: An object of the Edges class representing the common edges between triangles.
- set_triangles_plus_minus(triangles_plus, triangles_minus)[source]#
Manually set the triangles that share common edges.
Parameters: * triangles_plus (n-d-array): Indices of the triangles sharing common edges in the « plus » order. * triangles_minus (n-d-array): Indices of the triangles sharing common edges in the « minus » order.
- class harmolab.rwg.rwg1.Edges(first_points, second_points)[source]#
Bases :
objectClass representing a set of edges in a 3D mesh.
This class stores the edges of the mesh defined by pairs of points and computes the length of each edge.
- Attributes:
first_points (n-d-array): A numpy array containing the indices of the first points of each edge.
second_points (n-d-array): A numpy array containing the indices of the second points of each edge.
edges_length (n-d-array): An array containing the length of each edge.
total_number_of_edges (int): The total number of edges in the set.
Initialize an Edges object with the indices of the points defining the edges.
- Parameters:
first_points (n-d-array): Array containing the indices of the first points of each edge.
second_points (n-d-array): Array containing the indices of the second points of each edge.
- compute_edges_length(point_data)[source]#
Compute the lengths of all edges using vectorized operations for better performance.
This method retrieves the coordinates of all start and end points of the edges simultaneously and calculates the Euclidean norm across the entire set.
- Parameters:
point_data (Points): A Points object containing the coordinates of the mesh points.
- harmolab.rwg.rwg1.load_mesh_file(filename, load_from_matlab=True)[source]#
Load a MAT file containing a mesh and return the mesh points and triangles.
This function loads a MATLAB MAT file and extracts the point and triangle data. If the file comes from MATLAB, it adjusts the triangle indices (which often start at “1” in MATLAB) by converting them to a zero-based format.
- Parameters:
filename (str): The name of the .mat file to load.
- load_from_matlab (bool): If True, the triangle indices will be adjusted to start at 0
(MATLAB indices start at 1, but Python uses 0-based indexing).
- Returns:
points (n-d-array): A numpy array of shape (3, N) containing the mesh point coordinates.
triangles (n-d-array): A numpy array of shape (4, M) containing the indices of the triangle vertices.
- Exceptions raised:
FileNotFoundError: If the file does not exist. RuntimeError: If an error occurs while loading the file. ValueError: If the file does not contain the variables “p” (points) and “t” (triangles).
- harmolab.rwg.rwg1.filter_complexes_jonctions(point_data, triangle_data, edge_data)[source]#
Remove edges from T-junctions: when three triangles share the same edge. This corresponds to inconsistencies in a mesh (non-manifold geometry or topological artifacts).
- Parameters:
point_data : point data (used here to recompute edge lengths after removal) triangle_data : contains triangles and their triangle_plus / triangle_minus relations edge_data : contains edges (first_points, second_points)
- Behavior:
Removes identical edges (regardless of orientation) when they appear three times.
- class harmolab.rwg.rwg1.DataManager_rwg1[source]#
Bases :
object- static save_data(path, points_data, triangles_data, edges_data)[source]#
Saves mesh data (points, triangles, edges, etc.) into a MAT file.
This method takes the mesh data, organizes it into a dictionary, and saves it as a MAT file in the specified folder.
- Parameters:
filename (str): The original file name (used to generate the save file name).
save_folder_name (str): The folder where the save file will be stored.
points_data (Points): A Points object containing the mesh point data.
triangles_data (Triangles): A Triangles object containing the mesh triangle data.
edges_data (Edges): An Edges object containing the mesh edge data.
- Returns:
str: The name of the saved file.
- static load_data(filename)[source]#
Loads mesh data from a MAT file and returns corresponding Points, Triangles, and Edges objects.
This method loads data from the MAT file, decompresses it, creates objects for points, triangles, and edges, and initializes them with the loaded data.
- Parameters:
filename (str): The file name to load.
- Returns:
tuple: A tuple containing Points, Triangles, and Edges objects.
- Raises:
- MeshDataError: if the file is missing or its contents are malformed
(missing/invalid keys). Chained from the original exception.
rwg2 — vecteurs ρ#
- class harmolab.rwg.rwg2.Vecteurs_Rho[source]#
Bases :
objectClass to calculate and manage the Rho vectors associated with the « plus » and « minus » triangles of edges in a mesh.
The Rho vectors represent vectors connecting a specific point of a triangle (opposite to the considered edge) to its geometric center.
Initializes the attributes to store the Rho vectors.
- class harmolab.rwg.rwg2.DataManager_rwg2[source]#
Bases :
objectClass to save and load mesh-related data and its properties in MAT files.
- Provides static methods to:
Save enriched data into a MAT file.
Load data from an existing MAT file.
- static save_data(path, vecteurs_rho_data)[source]#
Saves the data into a MAT file after enriching it.
- Parameters:
path (Path) : Path object containing the file path information.
vecteurs_rho_data (Vecteurs_Rho) : Rho vectors data.
- Returns:
save_file_name (str) : Name of the saved MAT file.
- static load_data(filename)[source]#
Loads data from a MAT file and initializes the associated objects.
- Parameters:
filename (str) : Path to the MAT file containing the data.
- Returns:
(tuple) : Contains the objects Points, Triangles, Edges, and Vecteurs_Rho.
- Exceptions:
FileNotFoundError : If the file does not exist.
KeyError : If an expected key is missing in the data.
ValueError : If the data is malformed.
rwg3 — matrice d’impédance#
- harmolab.rwg.rwg3.calculate_z_matrice(points, triangles, edges, frequency, use_gpu=None, fill_mode=None)[source]#
Calculate the electromagnetic impedance matrix for a given mesh.
For a large enough mesh, this dispatches to the batched, GPU-capable impedance_matrix_z_sweep_gpu (as a one-frequency « sweep ») instead of the plain per-pair impedance_matrix_z: the O(E^2) fill is the dominant cost of a single simulation too once E is large, not just for a frequency sweep. Below harmolab.utils.impedance.compute_backend.DEFAULT_GPU_EDGE_THRESHOLD RWG edges, the batched path’s fixed overhead outweighs its benefit and is measured SLOWER than the plain loop, so small meshes keep using it – see workflow.md, « GPU acceleration (CuPy) » for the measured crossover (loses at E=39, wins from E=57 up through E=1007, 1.6-5.3x).
- Paramètres:
points (Points object (physical vertex coordinates))
triangles (Triangles object)
edges (Edges object)
frequency (float (Hz))
use_gpu (bool or None None (default) = auto: GPU only if available) – AND the mesh is above the size threshold. True forces GPU regardless of size (raises if no GPU is available); False forces the plain CPU per-pair implementation regardless of size.
fill_mode (None / "full_sym" (default), "mirror" or "full" -- see) – harmolab.utils.impedance.impmet.FILL_MODES. The default fills every (m, n) pair and symmetrises, which keeps the scalar-potential term exactly charge-neutral on loop currents; « mirror » is the former behaviour, kept for comparison only.
- Renvoie:
omega, mu, epsilon, light_speed_c, eta, matrice_z
- harmolab.rwg.rwg3.calculate_z_matrice_sweep(points, triangles, edges, frequencies, use_gpu=None, fill_mode=None)[source]#
Calculate the electromagnetic impedance matrix at MULTIPLE frequencies in a single pass, for use by a frequency sweep.
Unlike calling calculate_z_matrice once per frequency, this reuses every frequency-independent triangle-pair quantity (quadrature points, rho vectors, pairwise distances, Duffy nodes) across the whole sweep instead of recomputing it at each frequency – see harmolab.utils.impedance.impmet.impedance_matrix_z_sweep and workflow.md, « frequency_sweep one-time precompute ».
For a large enough mesh (same threshold and rationale as calculate_z_matrice – a sweep only ever has MORE total work to amortise GPU overhead against, never less), the assembly runs through impedance_matrix_z_sweep_gpu, which batches the dominant FAR/EDGE/VERTEX pair categories into large tensor operations on the GPU (measured ~10x faster than CPU on the reference T600 benchmark in workflow.md, « GPU acceleration (CuPy) »). Below the threshold (or with use_gpu=False), this calls the plain impedance_matrix_z_sweep instead: the batched restructuring’s payoff comes specifically from amortising GPU kernel- launch overhead across large batches, and was measured SLOWER than the original per-pair loop for small meshes – so those keep using the already-optimised per-pair implementation rather than the GPU-oriented one.
- Paramètres:
points (Points object (physical vertex coordinates))
triangles (Triangles object)
edges (Edges object)
frequencies (array-like (N_freq,) sweep frequencies in Hz)
use_gpu (bool or None None (default) = auto: GPU only if available) – AND the mesh is above the size threshold (harmolab.utils.impedance.compute_backend.DEFAULT_GPU_EDGE_THRESHOLD). True forces GPU regardless of size (raises if unavailable); False forces CPU regardless of size.
fill_mode (None / "full_sym" (default), "mirror" or "full", as in) – calculate_z_matrice.
- Renvoie:
omega (N_freq,), mu, epsilon, light_speed_c, eta, matrice_z (N_freq, E, E)
- harmolab.rwg.rwg3.compute_lumped_impedance(load_values, omega)[source]#
Computes Z = jωL + 1/(jωC) + R from load_values (3, N), with special handling: - C = None ⇒ replaced by a very large value (C = 1e64) - C = 0 ⇒ raises an explicit error - L, R : None or 0 ⇒ treated as 0 (no inductance or resistance)
- harmolab.rwg.rwg3.calculate_z_matrice_lumped_elements(points, triangles, edges, frequency, LoadPoint, LoadValue, LoadDir, use_gpu=None, fill_mode=None)[source]#
Computes the electromagnetic impedance matrix for a given system with lumped elements.
- Parameters:
triangles : Object representing the mesh triangles.
edges : Object representing the mesh edges.
barycentric_triangles : Object containing barycentric data of the triangles.
vecteurs_rho : Object containing Rho vectors associated with the triangles.
frequency : Electromagnetic signal frequency (Hz).
LoadPoint : Locations of lumped elements.
LoadValue : Values of L, C, R for lumped elements (3, LNumber).
LoadDir : Directions of the lumped elements (3, LNumber).
- use_gpubool or None – same size-thresholded GPU/CPU dispatch
as calculate_z_matrice (None=auto, True/False force); the base EFIE assembly is the same O(E^2) bottleneck here, the lumped- element terms are a cheap O(LNumber) patch applied afterwards regardless of which implementation built the base matrix.
- fill_modeNone / « full_sym » (default), « mirror » or « full », as in
calculate_z_matrice.
- Returns:
omega : Angular frequency (rad/s).
mu : Magnetic permeability of free space (H/m).
epsilon : Permittivity of free space (F/m).
light_speed_c : Speed of light in vacuum (m/s).
eta : Characteristic impedance of free space (Ω).
matrice_z : Calculated impedance matrix.
ImpArray : Indices of edges where lumped elements are applied.
- class harmolab.rwg.rwg3.DataManager_rwg3[source]#
Bases :
objectA class to manage saving and loading electromagnetic data related to the impedance matrix.
- This class provides two main methods:
save_data : to save computed data into a .mat file.
load_data : to load saved data from a .mat file.
- static save_data(path, frequency, omega, mu, epsilon, light_speed_c, eta, matrice_z)[source]#
Saves the computed data into a .mat file.
- Parameters:
path (Path) : Path object containing the file path information.
save_folder_name : str, folder where the data should be saved.
frequency : float, frequency used for electromagnetic computation (Hz).
omega : float, angular frequency (rad/s).
mu : float, magnetic permeability of free space (H/m).
epsilon : float, permittivity of free space (F/m).
light_speed_c : float, speed of light in vacuum (m/s).
eta : float, characteristic impedance of free space (Ω).
matrice_z : n-d-array, computed impedance matrix.
- Returns:
save_file_name : str, name of the saved file.
- Behavior:
Adds a “_impedance” suffix to the base name of the source file.
Saves the data in a .mat file at the specified path.
Creates the specified folder if it does not exist yet.
- static load_data(filename)[source]#
Loads data from a .mat file.
- Parameters:
filename : str, path to the .mat file to load.
- Returns:
- tuple containing the following data:
frequency (float), omega (float), mu (float), epsilon (float), light_speed_c (float), eta (float), matrice_z (n-d-array).
- Raises:
- MeshDataError: if the file is missing or its contents are
malformed (missing/invalid keys). Chained from the original exception.
rwg4 — résolution de Z I = V#
- harmolab.rwg.rwg4.calculate_current_scattering(filename_mesh_2, filename_impedance, wave_incident_direction, polarization)[source]#
Computes the current and voltage vector resulting from the scattering of an incident wave on a structure.
This function uses meshed data and calculated impedance data to solve the method of moments (MoM) equations, modeling the electromagnetic response of a structure.
- Parameters:
filename_mesh_2 : str, path to the file containing the meshed data (_mesh2 file).
filename_impedance : str, path to the file containing the impedance data (_impedance file).
wave_incident_direction : n-d-array (3,), direction of propagation of the incident wave (unit vector).
polarization : n-d-array (3,), vector describing the polarization of the incident electric field (e.g., “x” or “y” direction).
- Returns:
frequency : float, frequency used in the electromagnetic calculation (Hz).
omega : float, associated angular frequency (rad/s).
mu : float, magnetic permeability of free space (H/m).
epsilon : float, permittivity of free space (F/m).
light_speed_c : float, speed of light in vacuum (m/s).
eta : float, characteristic impedance of free space (Ω).
voltage : n-d-array, voltage vector resulting from the MoM equations (Z * I = V).
current : n-d-array, current vector solving the MoM equations.
- Behavior:
Loads the meshed data and impedance data from the specified files.
Computes the wave vector kv from the incident wave direction and the wave number “k”.
Initializes a “voltage” vector (MoM RHS) from edge contributions and scalar products related to associated triangles.
Solves the linear system of MoM equations to obtain the “current” vector.
Displays computation time for solving the linear system.
- Notes:
The method relies on the accuracy of the provided meshed and impedance data.
The incident wave direction (“wave_incident_direction”) and polarization must be properly normalized to ensure consistent results.
- harmolab.rwg.rwg4.calculate_current_radiation(path, ports, voltages, lossy_conductor=False, impedance_zs=None, verbose=True)[source]#
Solve Z I = V for the given ports and voltages; per-port Z_in, current and power. Parameters: path : object with path.mat_mesh2 and path.mat_impedance (setup_save_file_paths). ports : list of port specifications (EnhancedGap, DeltaGapCut, DeltaGapEdge, harmolab.utils.ports), placed here on the saved mesh; or ports already placed on that same mesh (resolve_ports), as radiation_algorithm passes. voltages : one complex voltage per port (V), amplitude * np.exp(1j * phase), phase in radians, in the order of `ports`. lossy_conductor : bool, add the surface-impedance term impedance_zs * Gram. impedance_zs : complex, surface impedance (Ohm) when lossy_conductor is True. verbose : bool, print the total input power and P, Q, Z_in of every port. Returns: frequency : float (Hz) voltage : complex (N,), the excitation vector V = B v current : complex (N,), the solution I port_results : list of PortResult (name, voltage, current, impedance, power, reactive_power), in the order of `ports`
- harmolab.rwg.rwg4.print_port_results(voltage, current, results)[source]#
Total input power 0.5 Re(V.I*) and P, Q, Z_in of every port.
- class harmolab.rwg.rwg4.DataManager_rwg4[source]#
Bases :
objectA class to manage saving and loading data related to electromagnetic wave problems, such as scattering or radiation, using MATLAB files.
- Methods:
save_data_for_scattering : Save data related to wave scattering.
save_data_for_radiation : Save data related to radiation.
load_data : Load data from a MATLAB file.
- static save_data_for_scattering(filename_mesh2, save_folder_name, frequency, omega, mu, epsilon, light_speed_c, eta, wave_incident_direction, polarization, voltage, current)[source]#
Saves data related to electromagnetic wave scattering into a MATLAB file.
- Parameters:
filename_mesh2 (str) : Name of the mesh file used for simulation.
save_folder_name (str) : Directory where data will be saved.
frequency (float) : Wave frequency.
omega (float) : Angular frequency.
mu (float) : Magnetic permeability of the medium.
epsilon (float) : Electric permittivity of the medium.
light_speed_c (float) : Speed of light in the medium.
eta (float) : Impedance of the medium.
wave_incident_direction (np.n-d-array) : Direction of the incident wave.
polarization (np.n-d-array) : Polarization of the incident wave.
voltage (np.n-d-array) : Simulated voltages.
current (np.n-d-array) : Simulated currents.
Returns: save_file_name (str) : Name of the generated save file.
- static save_data_for_radiation(path, frequency, omega, mu, epsilon, light_speed_c, eta, voltage, current, gap_currents, gap_voltages, impedances, feed_powers)[source]#
Saves electromagnetic radiation data for one or multiple ports into a MATLAB file.
- Parameters:
path : object, contains path.mat_current attribute. frequency, omega, mu, epsilon, light_speed_c, eta : float, physical constants and frequency. voltage : np.ndarray, global excitation vector (Z-matrix RHS). current : np.ndarray, global solved current vector. gap_currents : np.ndarray, array of complex currents for each port. gap_voltages : np.ndarray, array of complex voltages for each port. impedances : np.ndarray, array of complex input impedances for each port. feed_powers : np.ndarray, array of active power values for each port.
- Returns:
None
- static load_data(filename, radiation=False, scattering=False)[source]#
Loads data from a MATLAB file, handling either radiation or scattering results. Parameters: filename (str) : Full path to the file to load. radiation (bool) : If True, expects and returns antenna feed port data. scattering (bool) : If True, expects and returns incident wave data. Returns: tuple : Extracted data in the order defined by the saving process. Raises: ValueError: if neither `radiation` nor `scattering` is set. MeshDataError: if the file is missing or its contents are malformed (missing/invalid keys). Chained from the original exception.
rwg5 — densité de courant de surface#
- harmolab.rwg.rwg5.calculate_current_density(current, triangles, edges, vecteurs_rho)[source]#
Calculates the surface current density for each triangle in a mesh. Parameters: * current : n-d-array, vector of currents computed for each edge (A). * triangles : object containing triangle information of the mesh: % total_of_triangles : int, total number of triangles. % triangles_plus : n-d-array, indices of triangles associated with the "plus" side of edges. % triangles_minus : n-d-array, indices of triangles associated with the "minus" side of edges. % triangles_area : n-d-array, areas of triangles (m²). * edges : object containing edge information: % total_number_of_edges : int, total number of edges. % edges_length : n-d-array, edge lengths (m). * vecteurs_rho : object containing ρ vectors associated with triangles and edges: % vecteur_rho_plus : n-d-array, ρ vectors for the "plus" side of edges. % vecteur_rho_minus : n-d-array, ρ vectors for the "minus" side of edges. Behavior: 1. Initializes an array `surface_current_density` to store the norm of the current density for each triangle. 2. Iterates over each triangle in the mesh. 3. For each triangle, accumulates contributions from currents on edges associated with the triangle: % Multiplies current by edge length to obtain a weighted contribution. % Adds this contribution depending on the edge's association with the triangle ("plus" or "minus"). 4. Normalizes this contribution by the area of the corresponding triangle. 5. Computes the norm of the current density for this triangle. 6. Determines the maximum current density over all triangles. 7. Prints the maximum surface current density in amperes per meter (A/m). Returns: surface_current_density : n-d-array, norms of the current density for each triangle (A/m). surface_current_density_vector : complex n-d-array, shape (3, total_of_triangles), the per-triangle current density vector (before taking its norm) -- used by visualize_surface_current() to draw current-direction arrows. Example: For a given mesh, this function allows analyzing the distribution of current over the surface of the triangles. Note: Surface current density is a measure of current intensity per unit area, useful for studying antennas or conductive surfaces.
- harmolab.rwg.rwg5.compute_aspect_ratios(points)[source]#
Computes aspect ratios for 3D visualization of data.
Parameters: points : tuple or n-d-array, coordinates of points in 3D space as (x, y, z).
Returns: dict : Dictionary containing normalized aspect ratios for “x”, “y”, and “z” axes.
- Functionality:
Extracts x, y, and z coordinates from points.
Computes the range (max — min) for each axis.
Determines the global scale as the largest range among the three axes.
Normalizes each range by the global scale to obtain aspect ratios.
Example: If the data spans different scales along the axes, this function adjusts the proportions for consistent 3D visualization.
- harmolab.rwg.rwg5.visualize_surface_current(points_data, triangles_data, surface_current_density, feed_point=None, title='Antennas Surface Current', current_vector=None, arrow_scale=1.0)[source]#
Visualizes the surface current density on a triangulated 3D surface using Plotly.
This function renders a 3D mesh (trisurf) where each triangle’s color represents its surface current density. It automatically handles cases with uniform data (to prevent Plotly errors) and adjusts the scene’s aspect ratio for accurate physical proportions.
- Paramètres:
points_data (object) – An object or dataclass containing the mesh vertices. Must have a .points attribute with shape (3, N) or (N, 3).
triangles_data (object) – An object or dataclass containing the connectivity matrix. Must have a .triangles attribute where the first 3 rows contain the vertex indices for each triangle.
surface_current_density (array-like) – A 1D array of shape (n_triangles,) containing the magnitude of the surface current density for each face.
feed_point (array-like, optional) – Coordinates of the excitation point(s). Can be a single point (3,) or multiple points (N, 3). If provided, they are rendered as red markers.
title (str, optional) – The title of the generated Plotly figure. Defaults to « Antennas Surface Current ».
current_vector (complex array-like, optional) – Shape (3, n_triangles), the per-triangle current density vector returned by calculate_current_density(). When provided, a black arrow is drawn at each triangle’s centroid along Re(current_vector) – the instantaneous current direction at the excitation’s reference phase – with length proportional to that triangle’s share of the peak current magnitude.
arrow_scale (float, optional) – Multiplier on the (auto-computed) arrow length, to shrink/grow the arrows without touching the underlying data. Defaults to 1.0.
- Renvoie:
plotly.graph_objects.Figure – A Plotly Figure object containing the 3D trisurf plot and optional markers.
Notes
The function includes a safety check for vmin >= vmax. If the current density is uniform (e.g., all zeros), a micro-epsilon (1e-15) is added to the data range to prevent a PlotlyError.
Aspect ratios are calculated based on the bounding box of the mesh to ensure the antenna geometry is not distorted visually.
Exemple
>>> fig = visualize_surface_current(mesh_pts, mesh_tris, j_density, feed_pt=[0, 0, 0]) >>> fig.show()
rwg6 — distribution du courant de surface#
- harmolab.rwg.rwg6.surface_calculate_current_density(current, triangles, edges, vecteurs_rho)[source]#
- harmolab.rwg.rwg6.plot_surface_current_distribution(path, mode='scattering')[source]#
Plots the surface current distribution along the dipole length with the aesthetic style of the S11 plot (Adelle font, clean grid).
- Args:
path (object, optional): An object containing .mat_mesh2 and .mat_current attributes. mode (str): Mode of operation, either “scattering” or “radiation”.