7  Elmer Simulation

aka majordome_simulation.elmer

7.1 TimeStepAccumulator

NoteTimeStepAccumulator
TimeStepAccumulator(*time_steps : ConstantTimeStepInterval): -> None:

Helper for creating cumulative time steps in Elmer SIF files.


Parameters
*time_steps : ConstantTimeStepInterval
    
Variable number of time step intervals to accumulate.
Noteadd_block
add_block(
    self : Any,
    *,
    duration : float | None = None,
    end_time : float | None = None,
    **kws : Any
    ) -> None:

Add a new block of time steps with the given parameters.


Parameters
duration : float | None = None
    
Duration of the new time step block. If not provided, then end_time must be provided.
end_time : float | None = None
    
End time of the new time step block. If not provided, then duration must be provided. If provided, the duration of the new block will be calculated as end_time - self.duration.
kws :  = None
    
Additional keyword arguments to pass to the ConstantTimeStepInterval constructor.
Noteappend
append(
    self : Any,
    time_step : ConstantTimeStepInterval
    ) -> None:

Append a new time step to the accumulator.


Parameters
time_step : ConstantTimeStepInterval
    
The time step interval to append to the accumulator.
Noteto_dataframe
to_dataframe(self : Any): -> DataFrame:

Convert the accumulated time steps into a table.

In general the usage of the TimeStepAccumulator is as follows:

! >> Total duration: 0.001 << !
! Step Duration(3)     =         1e-05         9e-05        0.0009
Timestep Sizes(3)      =  1.000000e-06  1.000000e-05  1.000000e-04
Timestep Intervals(3)  =            10             9             9
Output Intervals(3)    =            10             9             9

7.2 ConstantTimeStepInterval

In some special cases, when using TimeStepAccumulator you might want to add time steps one by one, which can be done using the append method in combination with the ConstantTimeStepInterval described below.

NoteConstantTimeStepInterval
ConstantTimeStepInterval(
    duration : float,
    time_step : float | None = None,
    save_interval : float | None = None,
    *,
    min_steps : int = 2
    ) -> None:

Create a constant time step interval for a simulation.


Parameters
duration : float
    
Total duration of the time step interval.
time_step : float | None = None
    
Size of each time step. If not provided, it will be calculated based on the duration and min_steps parameters.
save_interval : float | None = None
    
Interval at which to save results. If not provided, it will be set equal to time_step.
min_steps : int = 2
    
Minimum number of time steps to use if time_step is not provided. Must be at least 1. Default is 2.
Noteinto_formatted_data
into_formatted_data(self : Any): -> list[str]:

Format the time step data for output in an Elmer SIF file.

7.3 ElmerConvergenceData

NoteElmerConvergenceData
ElmerConvergenceData(file_path : str | pathlib.Path): -> None:

Class for handling convergence data from Elmer simulations.


Parameters
file_path : str | pathlib.Path
    
Path to the file containing convergence data, typically output by Elmer’s SaveLine solver.
Noteget_solver_data
get_solver_data(
    self : Any,
    solver_id : int
    ) -> DataFrame:

Get convergence data for a specific solver.


Parameters
solver_id : int
    
The ID of the solver to filter by.
Noteplot_solver_convergence
plot_solver_convergence(
    self : Any,
    *,
    solver_id : int,
    final_iter : bool = False,
    time_axis : numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[~_ScalarT]] | None = None,
    plot : majordome_utilities.plotting.MajordomePlot | None = None
    ) -> MajordomePlot:

Plot convergence data for a specific solver.


Parameters
solver_id : int
    
The ID of the solver to plot.
final_iter : bool = False
    
If True, only plot the final iteration for each timestep.
time_axis : numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[~_ScalarT]] | None = None
    
Optional array of time values to use as the x-axis. If not provided, the timestep numbers will be used.
plot : majordome_utilities.plotting.MajordomePlot | None = None
    
Placeholder for plot object provided by decorator.
Notetracked_solvers
tracked_solvers(self : Any): -> list[int]:

List of unique solvers tracked in the data.

7.4 ElmerTabularData

NoteElmerTabularData
ElmerTabularData(
    fname : str | pathlib.Path,
    *,
    fmeta : str | pathlib.Path | None = None
    ):

Class to represent the data of a SaveLine results file.


Parameters
fname : str | pathlib.Path
    
The path to the data file output of Elmer’s SaveLine solver.
fmeta : str | pathlib.Path | None = None
    
The path to the associated metadata file. If not provided, the class will attempt to find a metadata file in the same directory as the data file, with the same name but with a .names extension. If still not found, it will look for the metadata file one level above the data file directory.
Notemetadata
metadata(self : Any): -> ElmerTabularMetadata:

Provides access to the metadata of the save line data.

Notedata
data(self : Any): -> DataFrame:

Provides access to the data of the save line.

7.5 ElmerTabularMetadata

NoteElmerTabularMetadata
ElmerTabularMetadata(filepath : str | pathlib.Path)::

Class to hold metadata from Elmer SaveLine .names file.


Parameters
filepath : str | pathlib.Path
    
Path to the .names metadata file.
Notemetadata
metadata(self : Any): -> dict:

Return the metadata as a dictionary.

Notecolumns
columns(self : Any): -> dict:

Return the column definitions as a dictionary.