eigentools.criticalfinder
¶
Module Contents¶
- logger¶
- class CriticalFinder(eigenproblem, param_names, comm=MPI.COMM_WORLD, find_freq=False)¶
finds critical parameters for eigenvalue problems.
This class provides simple tools for finding the critical parameters for the linear (in)stability of a given flow. The parameter space must be 2D; typically this will be (k, Re), where k is a wavenumber and Re is some control parameter (e. g. Reynolds or Rayleigh). The parameters are defined by the underlying Eigenproblem object.
- Parameters
eigenproblem (Eigenproblem) – An eigentools eigenproblem object over which to find critical parameters
param_names (tuple of str) – The names of parameters to search over
comm (mpi4py.MPI.Intracomm, optional) – The MPI comm group to share jobs across (default: MPI.COMM_WORLD)
find_freq (bool, optional) – If True, also find frequency at critical point
- Variables
parameter_grids – NumPy mesh grids containing the parameter values for the EVP
evalue_grid – NumPy array of complex values, containing the maximum growth rates of the EVP for the corresponding input values.
roots (ndarray) – Array of roots along axis 1 of parameter_grid
- grid_generator(self, points, sparse=False)¶
Generates a grid of eigenvalues over the specified parameter space of an eigenvalue problem.
- Parameters
points (tuple of ndarray) – The parameter values over which to find the critical value
- load_grid(self, filename)¶
Load a grid file, in the format as created in save_grid.
- Parameters
filename (str) – The name of the .h5 file containing the grid data
- save_grid(self, filename)¶
Saves the grids of all input parameters as well as the growth rate grid that has been solved for.
- Parameters
filename (str) – A file stem, which DOES NOT include the file type extension. The grid will be saved to a file called filen.h5
- crit_finder(self, polish_roots=False, polish_sparse=True, tol=0.001, method='Powell', maxiter=200, **kwargs)¶
returns parameters at which critical eigenvalue occurs and optionally frequency at that value.
The critical parameter is defined as the absolute minimum of the growth rate, defined in the Eigenproblem via its grow_func. If frequency is to be found also, returns the frequnecy defined in the Eigenproblem via its freq_func.
If find_freq is True, returns (critical parameter 1, critical parameter 2, frequency); otherwise returns (critical parameter 1, critical parameter 2)
- Parameters
polish_roots (bool, optional) – If true, use optimization routines to polish critical value (default: False)
polish_sparse (bool, optional) – If true, use the sparse solver when polishing roots (default: True)
tol (float, optional) – Tolerance for polishing routine (default: 1e-3)
method (str, optional) – Method for scipy.optimize used for polishing (default: Powell)
maxiter (int, optional) – Maximum number of optimization iterations used for polishing (default: 200)
- Returns
- Return type
tuple
- critical_polisher(self, guess, sparse=True, tol=0.001, method='Powell', maxiter=200, **kwargs)¶
Polishes a guess for the critical value using scipy’s optimization routines to find a more precise location of the critical value.
- Parameters
guess (complex) – Initial guess for optimization routines
sparse (bool, optional) – If true, use the sparse solver when polishing roots (default: True)
tol (float, optional) – Tolerance for polishing routine (default: 1e-3)
method (str, optional) – Method for scipy.optimize used for polishing (default: Powell)
maxiter (int, optional) – Maximum number of optimization iterations used for polishing (default: 200)
- plot_crit(self, axes=None, transpose=False, xlabel=None, ylabel=None, zlabel='growth rate', cmap='viridis')¶
Create a 2D colormap of the grid of growth rates.
If available, the root values that have been found will be plotted over the colormap.
- Parameters
transpose (bool, optional) – If True, plot dim 0 on the y axis and dim 1 on the x axis.
xlabel (str, optional) – If not None, the x-label of the plot. Otherwise, use parameter name from EVP
ylabel (str, optional) – If not None, the y-label of the plot. Otherwise, use parameter name from EVP
zlabel (str, optional) – Label for the colorbar. (default: growth rate)
cmp (str, optional) – matplotlib colormap name (default: viridis)