dedalus.core.solvers ==================== .. py:module:: dedalus.core.solvers .. autoapi-nested-parse:: Solver classes. Module Contents --------------- .. py:class:: EigenvalueSolver(problem, **kw) Linear eigenvalue problem solver. :Parameters: * **problem** (*Problem object*) -- Dedalus eigenvalue problem. * **\*\*kw** -- Other options passed to ProblemBase. :ivar state: Problem variables containing solution (after set_state method is called). :vartype state: list of Field objects :ivar eigenvalues: Vector of eigenvalues. :vartype eigenvalues: ndarray :ivar eigenvectors: Array of eigenvectors. The eigenvector corresponding to the i-th eigenvalues is eigenvectors[:, i]. :vartype eigenvectors: ndarray :ivar eigenvalue_subproblem: The subproblem for which the EVP has een solved. :vartype eigenvalue_subproblem: Subproblem object .. py:method:: print_subproblem_ranks(subproblems=None, target=0) Print rank of each subproblem LHS. .. py:method:: set_state(index, subsystem=0) Set state vector to the specified eigenmode. :Parameters: * **index** (*int*) -- Index of desired eigenmode. * **subsystem** (*Subsystem object or int, optional*) -- Subsystem that will be set to the corresponding eigenmode. If an integer, the corresponding subsystem of the last specified eigenvalue_subproblem will be used. Default: 0. .. py:method:: solve_dense(subproblem, rebuild_matrices=False, left=False, normalize_left=True, **kw) Perform dense eigenvector search for selected subproblem. This routine finds all eigenvectors but is computationally expensive. :Parameters: * **subproblem** (*Subproblem object*) -- Subproblem for which to solve the EVP. * **rebuild_matrices** (*bool, optional*) -- Rebuild LHS matrices if coefficients have changed (default: False). * **left** (*bool, optional*) -- Solve for the left eigenvectors of the system in addition to the right eigenvectors. The left eigenvectors are the right eigenvectors of the conjugate-transposed problem. Follows same definition described in scipy.linalg.eig documentation (default: False). * **normalize_left** (*bool, optional*) -- Normalize the left eigenvectors such that the modified left eigenvectors form a biorthonormal (not just biorthogonal) set with respect to the right eigenvectors (default: True). * **\*\*kw** -- Other keyword options passed to scipy.linalg.eig. .. py:method:: solve_sparse(subproblem, N, target, rebuild_matrices=False, left=False, normalize_left=True, raise_on_mismatch=True, v0=None, **kw) Perform targeted sparse eigenvector search for selected subproblem. This routine finds a subset of eigenvectors near the specified target. :Parameters: * **subproblem** (*Subproblem object*) -- Subproblem for which to solve the EVP. * **N** (*int*) -- Number of eigenvectors to solve for. Note: the dense method may be more efficient for finding large numbers of eigenvectors. * **target** (*complex*) -- Target eigenvalue for search. * **rebuild_matrices** (*bool, optional*) -- Rebuild LHS matrices if coefficients have changed (default: False). * **left** (*bool, optional*) -- Solve for the left eigenvectors of the system in addition to the right eigenvectors. The left eigenvectors are the right eigenvectors of the conjugate-transposed problem. Follows same definition described in scipy.linalg.eig documentation (default: False). * **normalize_left** (*bool, optional*) -- Normalize the left eigenvectors such that the modified left eigenvectors form a biorthonormal (not just biorthogonal) set with respect to the right eigenvectors (default: True). * **raise_on_mismatch** (*bool, optional*) -- Raise a RuntimeError if the left and right eigenvalues do not match (default: True). * **v0** (*ndarray, optional*) -- Initial guess for eigenvector, e.g. from subsystem.gather (default: None). * **\*\*kw** -- Other keyword options passed to scipy.sparse.linalg.eig. .. py:attribute:: matrices :value: ['M', 'L'] .. py:attribute:: matsolver_default :value: 'MATRIX_FACTORIZER' .. py:class:: InitialValueSolver(problem, timestepper, enforce_real_cadence=100, warmup_iterations=10, profile=PROFILE_DEFAULT, parallel_profile=PARALLEL_PROFILE_DEFAULT, **kw) Initial value problem solver. :Parameters: * **problem** (*Problem object*) -- Dedalus problem. * **timestepper** (*Timestepper class or str*) -- Timestepper to use in evolving initial conditions. * **enforce_real_cadence** (*int, optional*) -- Iteration cadence for enforcing Hermitian symmetry on real variables (default: 100). * **warmup_iterations** (*int, optional*) -- Number of warmup iterations to disregard when computing runtime statistics (default: 10). * **profile** (*bool, optional*) -- Save accumulated profiles with cProfile (default: False). * **parallel_profile** (*bool, optional*) -- Save per-process and accumulated profiles with cProfile (default: False). * **\*\*kw** -- Other options passed to ProblemBase. :ivar state: Problem variables containing solution. :vartype state: list of Field objects :ivar stop_sim_time: Simulation stop time, in simulation units. :vartype stop_sim_time: float :ivar stop_wall_time: Wall stop time, in seconds from instantiation. :vartype stop_wall_time: float :ivar stop_iteration: Stop iteration. :vartype stop_iteration: int :ivar sim_time: Current simulation time. :vartype sim_time: float :ivar iteration: Current iteration. :vartype iteration: int :ivar dt: Last timestep. :vartype dt: float .. py:method:: dump_profiles(profiler, name) Save profiling data to disk. .. py:method:: enforce_hermitian_symmetry(fields) Transform fields to grid and back. .. py:method:: evaluate_handlers(handlers=None, dt=0) Evaluate specified list of handlers (all by default). .. py:method:: evaluate_handlers_now(dt, handlers=None) .. py:method:: evolve(timestep_function, log_cadence=100) Advance system until stopping criterion is reached. .. py:method:: load_state(path, index=-1, allow_missing=False) Load state from HDF5 file. Currently can only load grid space data. :Parameters: * **path** (*str or pathlib.Path*) -- Path to Dedalus HDF5 savefile * **index** (*int, optional*) -- Local write index (within file) to load (default: -1) * **allow_missing** (*bool, optional*) -- Do not raise an error if state variables are missing from the savefile (default: False). :returns: * **write** (*int*) -- Global write number of loaded write * **dt** (*float*) -- Timestep at loaded write .. py:method:: log_stats(format='.4g') Log timing statistics with specified string formatting (optional). .. py:method:: print_subproblem_ranks(subproblems=None, dt=1) Print rank of each subproblem LHS. .. py:method:: step(dt) Advance system by one iteration/timestep. .. py:attribute:: F :value: [] .. py:attribute:: dist .. py:attribute:: init_time .. py:attribute:: matrices :value: ['M', 'L'] .. py:attribute:: matsolver_default :value: 'MATRIX_FACTORIZER' .. py:property:: proceed Check that current time and iteration pass stop conditions. .. py:property:: sim_time .. py:attribute:: stop_iteration .. py:attribute:: stop_sim_time .. py:attribute:: stop_wall_time .. py:attribute:: timestepper .. py:attribute:: total_modes .. py:property:: wall_time Seconds ellapsed since instantiation. .. py:attribute:: warmup_iterations :value: 10 .. py:property:: world_time .. py:class:: LinearBoundaryValueSolver(problem, **kw) Linear boundary value problem solver. :Parameters: * **problem** (*Problem object*) -- Dedalus problem. * **\*\*kw** -- Other options passed to ProblemBase. :ivar state: Problem variables containing solution (after solve method is called). :vartype state: list of Field objects .. py:method:: evaluate_handlers(handlers=None) Evaluate specified list of handlers (all by default). .. py:method:: print_subproblem_ranks(subproblems=None) Print rank of each subproblem LHS. .. py:method:: solve(subproblems=None, rebuild_matrices=False) Solve BVP over selected subproblems. :Parameters: * **subproblems** (*Subproblem object or list of Subproblem objects, optional*) -- Subproblems for which to solve the BVP (default: None (all)). * **rebuild_matrices** (*bool, optional*) -- Rebuild LHS matrices if coefficients have changed (default: False). .. py:attribute:: F :value: [] .. py:attribute:: iteration :value: 0 .. py:attribute:: matrices :value: ['L'] .. py:attribute:: matsolver_default :value: 'MATRIX_FACTORIZER' .. py:attribute:: subproblem_matsolvers .. py:class:: NonlinearBoundaryValueSolver(problem, **kw) Nonlinear boundary value problem solver. :Parameters: * **problem** (*Problem object*) -- Dedalus problem. * **\*\*kw** -- Other options passed to ProblemBase. :ivar state: Problem variables containing solution. :vartype state: list of Field objects :ivar perturbations: Perturbations to problem variables from each Newton iteration. :vartype perturbations: list of Field objects :ivar iteration: Current iteration. :vartype iteration: int .. py:method:: evaluate_handlers(handlers=None) Evaluate specified list of handlers (all by default). .. py:method:: newton_iteration(damping=1) Update solution with a Newton iteration. .. py:method:: print_subproblem_ranks(subproblems=None) Print rank of each subproblem LHS. .. py:attribute:: F :value: [] .. py:attribute:: iteration :value: 0 .. py:attribute:: matrices :value: ['dF'] .. py:attribute:: matsolver_default :value: 'MATRIX_SOLVER' .. py:attribute:: perturbations .. py:class:: SolverBase(problem, ncc_cutoff=1e-06, max_ncc_terms=None, entry_cutoff=1e-12, matrix_coupling=None, matsolver=None, bc_top=None, tau_left=None, interleave_components=None, store_expanded_matrices=None) Base class for PDE solvers. :Parameters: * **problem** (*Problem object*) -- Dedalus problem. * **ncc_cutoff** (*float, optional*) -- Mode amplitude cutoff for LHS NCC expansions (default: 1e-6) * **max_ncc_terms** (*int, optional*) -- Maximum terms to include in LHS NCC expansions (default: None (no limit)) * **entry_cutoff** (*float, optional*) -- Matrix entry cutoff to avoid fill-in from cancellation errors (default: 1e-12) * **matrix_coupling** (*tuple of bool, optional*) -- Matrix coupling override. * **matsolver** (*str or Matsolver class, optional*) -- Matrix solver. Default taken from config. * **bc_top** (*bool, optional*) -- Whether to place boundary conditions at top of matrices. Default taken from config. * **tau_left** (*bool, optional*) -- Whether to place tau columns at left of matrices. Default taken from config. * **interleave_components** (*bool, optional*) -- Whether to interleave components before variables. Default taken from config. * **store_expanded_matrices** (*bool, optional*) -- Whether to store right-preconditioned matrices. Default taken from config. .. py:method:: build_matrices(subproblems=None, matrices=None) Build matrices for selected subproblems. .. py:attribute:: bc_top :value: None .. py:attribute:: dist .. py:attribute:: dtype .. py:attribute:: entry_cutoff :value: 1e-12 .. py:attribute:: evaluator .. py:attribute:: interleave_components :value: None .. py:attribute:: matrix_coupling :value: None .. py:attribute:: matrix_dependence .. py:attribute:: matsolver :value: None .. py:attribute:: max_ncc_terms :value: None .. py:attribute:: ncc_cutoff :value: 1e-06 .. py:attribute:: problem .. py:attribute:: state .. py:attribute:: store_expanded_matrices :value: None .. py:attribute:: subproblems .. py:attribute:: subproblems_by_group .. py:attribute:: subsystems .. py:attribute:: tau_left :value: None .. py:data:: PARALLEL_PROFILE_DEFAULT .. py:data:: PROFILE_DEFAULT .. py:data:: PROFILE_DIRECTORY .. py:data:: logger