EDPpreparer#

class zeroheliumkit.fem.freefemer.EDPpreparer(config_file: str)[source]#

Bases: object

Class for creating and running FreeFEM scripts.

Parameters:

config (str) – filepath containing FreeFEM config yaml file.

Methods

add_helium_curvature_edp(extract_cfg)

Adds the helium curvature script to the FreeFEM script if the curvature configuration is provided.

make_edp_content(electrode_name)

Returns the contents of an electrode_k.edp file with the desired electrode name in the place of 'k'.

script_create_coupling_const_matrix()

Creates the coupling constant matrix for the FreeFEM script, which is used to define the interaction between electrodes.

script_create_savefiles(electrode_name)

Creates the necessary files for saving results based on the configuration and electrode index.

script_declare_variables()

Declares the necessary variables for the FreeFEM script, including physical surfaces and volumes.

script_include_charge(coordinate)

script_load_packages_and_mesh()

Loads the necessary FreeFEM packages and the mesh file into the script.

script_mesh_adaptation(electrode_name, ...)

Generates mesh adaptation loop code using mshmet and tetgen.

script_problem_definition(electrode_name[, ...])

Defines the problem for the electrostatic potential in FreeFEM, including the finite element space and the dielectric constants.

script_save_cmatrix(electrode_name)

Saves the capacitance matrix based on the provided parameters and the FreeFEM object name.

script_save_data(config)

Generates a code block for extracting 2D slice data based on the provided configuration.

write_edpScript()

Creates the main FreeFEM script based on the configuration and physical surfaces.

add_helium_curvature_edp(extract_cfg: ExtractConfig) str[source]#

Adds the helium curvature script to the FreeFEM script if the curvature configuration is provided.

Parameters:

extract_cfg (dict) – Dictionary containing the extraction configuration.

Returns:

code containing the helium curvature script.

Return type:

code (str)

write_edpScript()[source]#

Creates the main FreeFEM script based on the configuration and physical surfaces.

make_edp_content(electrode_name: int) str[source]#

Returns the contents of an electrode_k.edp file with the desired electrode name in the place of ‘k’.

Parameters:

electrode_name (str) – Name of the electrode to generate .edp file content for.

Returns:

code containing the entire edp content written for electrode_name.

Return type:

code (str)

script_create_savefiles(electrode_name: str)[source]#

Creates the necessary files for saving results based on the configuration and electrode index.

Parameters:

electrode_name (str) – Name of the electrode for which the files are being created.

Returns:

string containing the necessary lines of code to save the data.

Return type:

code (str)

script_load_packages_and_mesh() str[source]#

Loads the necessary FreeFEM packages and the mesh file into the script.

Returns:

code containing the necessary FreeFEM packages and mesh file declarations.

Return type:

code (str)

script_declare_variables() str[source]#

Declares the necessary variables for the FreeFEM script, including physical surfaces and volumes.

Returns:

code containing the necessary variable declarations.

Return type:

code (str)

script_create_coupling_const_matrix() str[source]#

Creates the coupling constant matrix for the FreeFEM script, which is used to define the interaction between electrodes.

Returns:

code containing the coupling constant matrix.

Return type:

code (str)

script_problem_definition(electrode_name: str, mesh_adaptation: bool = False, declare_globals: bool = True, indented: int = 0) str[source]#

Defines the problem for the electrostatic potential in FreeFEM, including the finite element space and the dielectric constants.

Parameters:
  • electrode_name (str) – Name of the electrode for which the problem is being defined.

  • mesh_adaptation (bool) – If True, skips the final Electro; call so that script_mesh_adaptation() can call it on the adapted mesh instead. Default is False.

  • declare_globals (bool) – If True, emits the eps constant and macro definitions. Set to False when these have already been declared earlier in the script (e.g. during the final solve of mesh adaptation). Default is True.

Returns:

code containing the problem definition.

Return type:

code (str)

script_save_data(config: dict) str[source]#

Generates a code block for extracting 2D slice data based on the provided configuration.

Returns:

A string containing the generated code block for 2D slice data extraction.

Return type:

str

script_save_cmatrix(electrode_name: str) str[source]#

Saves the capacitance matrix based on the provided parameters and the FreeFEM object name.

Parameters:

electrode_name (str) – Name of the electrode for the capacitance matrix extraction.

Returns:

code containing the Capacitance Matrix.

Return type:

code (str)

script_mesh_adaptation(electrode_name: str, adaptation_config: MeshAdaptationConfig) str[source]#

Generates mesh adaptation loop code using mshmet and tetgen. Solves iteratively on progressively refined meshes, concentrating elements in regions of high field gradient, then performs a final solve on the adapted mesh.

Parameters:
  • electrode_name (str) – Name of the active electrode.

  • adaptation_config (MeshAdaptationConfig) – mesh adaptation configuration dataclass

Returns:

FreeFEM code containing the mesh adaptation loop.

Return type:

code (str)