HeliumSurfaceFreeFEM#
- class zeroheliumkit.fem.heliumsurface.HeliumSurfaceFreeFEM(fem_config: dict, save_edp: bool = False)[source]#
Bases:
objectA class to interface with FreeFEM for simulating helium surface displacement using finite element methods (FEM). This class provides methods to generate FreeFEM scripts, run simulations via pyFreeFem, save scripts to file, and visualize mesh and results. It is designed to work with mesh files generated by GMSH and supports custom boundary conditions and mesh adaptation.
- Parameters:
fem_config (dict) – Configuration dictionary containing mesh and simulation parameters.
save_edp (bool, optional) – If True, saves the generated FreeFEM script to a file. Defaults to False.
Methods
Generates the FreeFEM script for the helium surface problem.
get_code_config([bulk_helium_distances, ...])Returns a configuration dictionary for code execution, including script and simulation parameters.
get_displacement(ff_output[, ...])Returns the displacement at a given location on the helium surface (units are 'xy' coordinate units).
plot_1D(ff_output[, bulk_helium_distance, ...])Plots a 1D cut of the displacement field along a specified axis at a given value.
plot_mesh(ff_output[, ax, color, ...])Plots the mesh of the helium surface from the FreeFEM simulation.
plot_results(ff_output[, ...])Plots the helium surface displacement results from the FreeFEM simulation.
Runs the FreeFEM simulation using pyFreeFem and returns the output dictionary.
save_edp(filename)Saves the generated FreeFEM script to a file.
- create_edp()[source]#
Generates the FreeFEM script for the helium surface problem.
- Parameters:
meshfile_path (str, optional) – The path to the directory containing the mesh file.
- save_edp(filename: str)[source]#
Saves the generated FreeFEM script to a file.
- Parameters:
filename (str) – The name of the file to save the script to (without extension).
- get_code_config(bulk_helium_distances: float | list = 0, surface_helium_level: float = 0)[source]#
Returns a configuration dictionary for code execution, including script and simulation parameters.
- Parameters:
bulk_helium_distances (float|list, optional) – Distance(s) from the bulk helium surface. Defaults to 0.
surface_helium_level (float, optional) – Level of the helium surface. Defaults to 0.
- Returns:
Configuration dictionary containing the FreeFEM script and simulation parameters.
- Return type:
dict
- run_pyfreefem()[source]#
Runs the FreeFEM simulation using pyFreeFem and returns the output dictionary.
- plot_mesh(ff_output: dict, ax: Axes = None, color: str = 'black', plot_boundaries: bool = True, boundary_color: str = None)[source]#
Plots the mesh of the helium surface from the FreeFEM simulation.
- Parameters:
ff_output (dict) – The output dictionary from the FreeFEM calculation.
ax (plt.Axes, optional) – Matplotlib Axes object to plot on. If None, a new figure and axes are created. Defaults to None.
color (str, optional) – Color of the mesh lines. Defaults to ‘black’.
plot_boundaries (bool, optional) – If True, plots the boundaries of the mesh. Defaults to True.
boundary_color (str, optional) – Color of the boundary lines. If None, uses the same color as the mesh. Defaults to None.
- plot_results(ff_output: dict, bulk_helium_distance: float = 0.1, ax: Axes = None, cmap: str = 'RdYlBu', levels: int = 7, plot_mesh: bool = True)[source]#
Plots the helium surface displacement results from the FreeFEM simulation.
- Parameters:
ff_output (dict) – The output dictionary from the FreeFEM calculation.
bulk_helium_distance (float, optional) – The distance from the bulk helium surface. Defaults to 1e-1.
ax (plt.Axes, optional) – Matplotlib Axes object to plot on. If None, a new figure and axes are created. Defaults to None.
cmap (str, optional) – Colormap to use for the displacement plot. Defaults to “RdYlBu”.
levels (int, optional) – Number of contour levels. Defaults to 7.
plot_mesh (bool, optional) – If True, overlays the mesh on the displacement plot. Defaults to True.
- plot_1D(ff_output: dict, bulk_helium_distance: float = 0.1, ax: Axes = None, marker: str = None, color: str = 'black', cut_axis: str = 'x', cut_value: float = 0, xlist: list = None, **kwargs)[source]#
Plots a 1D cut of the displacement field along a specified axis at a given value.
- Parameters:
ff_output (dict) – The output dictionary from the FreeFEM calculation.
bulk_helium_distance (float, optional) – The distance from the bulk helium surface. Defaults to 1e-1.
ax (plt.Axes, optional) – Matplotlib Axes object to plot on. If None, a new figure and axes are created. Defaults to None.
marker (str, optional) – Marker style for the plot. Defaults to None.
color (str, optional) – Color of the plot line. Defaults to ‘black’.
cut_axis (str, optional) – Axis along which to make the cut (‘x’ or ‘y’). Defaults to ‘x’.
cut_value (float, optional) – The value along the cut axis where the cut is made. Defaults to 0.
xlist (list, optional) – List of x-coordinates for the cut. If None, defaults to np.linspace(-100, 100, 500). Defaults to None.
**kwargs – Additional keyword arguments passed to the plot function.
- get_displacement(ff_output: dict, bulk_helium_distance: float = 0.1, location: tuple = (0, 0))[source]#
Returns the displacement at a given location on the helium surface (units are ‘xy’ coordinate units).
- Parameters:
ff_output (dict) – The output dictionary from the freefem calculation.
bulk_helium_distance (float) – The distance from the bulk helium surface.
location (tuple) – The location coordinates (x, y) where the displacement is calculated.