FEKO Integration Module#

The FEKO module contains components for integrating with FEKO electromagnetic simulation software.

Helper class to run FEKO simulations.

class EMFieldML.FEKO.FEKORunner.FekoRunner#

Bases: object

Class for running FEKO simulations and managing STL files.

This class provides methods to run FEKO simulations using Lua scripts, manage input and output files, and handle the generation of STL files.

To fully automate a simulation in FEKO, you’d implement a workflow that adjusts for model complexity. The process can be summarized as:

1. Model Setup: Define the parameters for the shield and coils to create the initial model.

2. Initial Inductance Calculation: Run a simulation to calculate the inductance of the model. This value is crucial for determining the starting point for resistance.

3. Optimal Resistance Simulation: Use the calculated inductance to set an initial optimal resistance value. A second simulation is then performed with this value.

4. Iterative Refinement (for complex models): If the initial optimal resistance fails to produce a stable or accurate result (common with complex models), the resistance value is iteratively adjusted. This fine-tuning process, typically completed in a few steps (up to five), ensures the simulation converges properly.

5. Final Magnetic Field Simulation: With the final, verified component values, the magnetic field is simulated to produce the desired results.

static run_feko(lua_script_path: Path, input_data: Path, num_trial: int = EMFieldML.config.config.lua_trial) None#

Run FEKO by lua file.

Parameters:
  • lua_script_path (str) – The path of the lua file.

  • input_data (str) – The input data for the lua file.

  • num_trial (int) – The number of trials to run the lua file.

Returns:

no return

static make_coil_stl(num_trial: int = EMFieldML.config.config.lua_trial) None#

Run a lua file “coil_stl.lua” to create STL file.

Parameters:

num_trial (int) – The number of trials to run the lua file.

Returns:

no return

Note

This function corresponds to Supplementary Figure 1a in the paper.

static make_stl(n_shield_shape: int, num_trial: int = EMFieldML.config.config.lua_trial, path_circle_dir: Path = EMFieldML.config.paths.CIRCLE_DIR, path_save_dir: Path = EMFieldML.config.paths.CIRCLE_STL_DIR, path_circle_file: str = EMFieldML.config.template.circle_param, path_save_file: str = EMFieldML.config.template.circle_stl) None#

Run a lua file “make_stl.lua” to create STL file.

Creating an STL file supports performing shape modeling of an Aligned-edge Polycube mesh.

Parameters:
  • n_shield_shape – Number of shield shapes to process

  • num_trial – Number of trials for FEKO execution

  • path_circle_dir – Directory containing circle parameter files

  • path_save_dir – Directory to save STL files

  • path_circle_file – Template for circle parameter file names

  • path_save_file – Template for STL file names

Note

This function corresponds to Figure 4 in the paper.

static make_stl_list(n_shield_shape: int = EMFieldML.config.config.n_shield_shape) None#

Run a lua file in FEKO to create STL files (372 types) from ferrite shield parameters.

static make_stl_test_list(n_shield_shape: int = EMFieldML.config.config.n_test_data) None#

Run a lua file in FEKO to create STL files (372 types) from ferrite shield parameters.

static check_validity(input_path_check: Path, efficiency: float) int#

Check validity of FEKO simulation results.

This function checks the validity of the FEKO simulation results by comparing the real efficiency with the expected efficiency and the phase of the voltage source.

Parameters:
  • input_path_check – Path to the FEKO output file to check

  • efficiency – Expected efficiency value for comparison

Returns:

0 if the results are valid, 1 if they are invalid

static run_solver(number: int, path_save_dir: Path = EMFieldML.config.paths.CIRCLE_FEKO_RAW_DIR, path_circle_dir: Path = EMFieldML.config.paths.CIRCLE_DIR, path_circle_file: str = EMFieldML.config.template.circle_move_param, num_trial: int = EMFieldML.config.config.lua_trial) None#

Run a simulation of ferrite shield. Firstly, run simulation_s2p.lua to calculate Sparameter. Secondly, calculate some parameter for resonance.

Parameters:
  • number – Shield number to process

  • path_save_dir – Directory to save FEKO raw data

  • path_circle_dir – Directory containing circle parameter files

  • path_circle_file – Template for circle parameter file names

  • num_trial – Number of trials for FEKO execution

static delete_warning(number: int, path_save_dir: Path = EMFieldML.config.paths.CIRCLE_FEKO_RAW_DIR) None#

Delete error sentences.

You use this to eliminate the errors that appear in the log during a FEKO simulation, which happen in areas where the calculations are difficult.

Parameters:
  • number – File number to process

  • path_save_dir – Directory containing files to clean

static run_simulation_list(x_train_list: list[int]) None#

Run a simulation of ferrite shield.

Parameters:

x_train_list – The list of the number used train data.

Returns:

no return

static run_simulation_test_list(x_train_list: list[int]) None#

Run a simulation of ferrite shield.

Parameters:

x_train_list – The list of the number used train data.

Returns:

no return