mtnlion.tools.helpers module¶
Assorted useful helper functions
-
class
mtnlion.tools.helpers.
Timer
[source]¶ Bases:
object
Convenient class for measuring time with with operators.
-
mtnlion.tools.helpers.
build_expression_class
(class_name: str, eval_expr: str, **kwargs)[source]¶ Create a FEniCS C++ expression from a template
- Parameters
class_name – Name of the expression
eval_expr – Expression to evaluate
kwargs – Required arguments
-
mtnlion.tools.helpers.
create_solution_matrices
(num_rows: int, num_cols: int, num_solutions: int) → Tuple[numpy.ndarray, ...][source]¶ Create numpy arrays for storing data.
- Parameters
num_rows –
num_cols –
num_solutions –
- Returns
-
mtnlion.tools.helpers.
gather_expressions
() → Mapping[str, str][source]¶ Collect C++ based expressions :return: Dictionary of C++ strings
-
mtnlion.tools.helpers.
get_1d
(func: dolfin.Function) → numpy.ndarray[source]¶ Fetch the one-dimensional solution from a FEniCS function
- Parameters
func – FEniCS function
V – Function space
-
mtnlion.tools.helpers.
norm_rmse
(estimated: numpy.ndarray, true: numpy.ndarray)[source]¶ Calculate the normalized RMSE
- Parameters
estimated – Estimated quantity
true – True quantity
-
mtnlion.tools.helpers.
overlay_plt
(xdata: numpy.ndarray, sample_time: numpy.ndarray, title: str, *ydata, figsize: Tuple[int, int] = (15, 9), linestyles: Tuple[str, str] = ('-', '--'))[source]¶ Plot solution data at multiple time slices against a comparison data set.
- Parameters
xdata – Common x axis
sample_time – Sample times
title – Title of the plot
ydata – One or more sets of data in both space and time
figsize – Size of the figure
linestyles – style of the lines