MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / EigenvalueProblem

Class EigenvalueProblem

dedalus/core/problems.py:429–500  ·  view source on GitHub ↗

Linear eigenvalue problems. Parameters ---------- variables : list of Field objects Problem variables to solve for. eigenvalue : Field object Field object representing the eigenvalue. namespace : dict-like, optional Dictionary for namespace additions

Source from the content-addressed store, hash-verified

427
428
429class EigenvalueProblem(ProblemBase):
430 """
431 Linear eigenvalue problems.
432
433 Parameters
434 ----------
435 variables : list of Field objects
436 Problem variables to solve for.
437 eigenvalue : Field object
438 Field object representing the eigenvalue.
439 namespace : dict-like, optional
440 Dictionary for namespace additions to use when parsing strings as equations
441 (default: None). It is recommended to pass "locals()" from the user script.
442
443 Notes
444 -----
445 This class supports linear eigenvalue problems of the form:
446 λ*M.X + L.X = 0
447 The LHS terms must be linear in the specified variables and affine in the eigenvalue.
448 The RHS must be zero.
449 """
450
451 solver_class = solvers.EigenvalueSolver
452
453 def __init__(self, variables, eigenvalue, **kw):
454 super().__init__(variables, **kw)
455 if any(eigenvalue.domain.nonconstant):
456 raise ValueError("Eigenvalue field cannot have any bases.")
457 self.eigenvalue = eigenvalue
458
459 def _check_equation_conditions(self, eqn):
460 """Check equation conditions."""
461 # Cast LHS to operand
462 LHS = Operand.cast(eqn['LHS'], self.dist, tensorsig=eqn['tensorsig'], dtype=eqn['dtype'])
463 # Check conditions
464 LHS.require_linearity(*self.variables, allow_affine=False,
465 self_name='EVP LHS', vars_name='problem variables', error=UnsupportedEquationError)
466 LHS.require_linearity(self.eigenvalue, allow_affine=True,
467 self_name='EVP LHS', vars_name='the eigenvalue', error=UnsupportedEquationError)
468 if eqn['RHS'] != 0:
469 raise UnsupportedEquationError("EVP RHS must be identically zero.")
470
471 def _build_matrix_expressions(self, eqn):
472 """Build LHS matrix expressions."""
473 vars = self.variables
474 # Extract matrix expressions
475 M, L = eqn['LHS'].split(self.eigenvalue)
476 # Drop eigenvalue
477 if M:
478 M = M.replace(self.eigenvalue, 1)
479 # Reinitialize and prep NCCs
480 if M:
481 M = M.reinitialize(ncc=True, ncc_vars=vars)
482 M.prep_nccs(vars=vars)
483 if L:
484 L = L.reinitialize(ncc=True, ncc_vars=vars)
485 L.prep_nccs(vars=vars)
486 # Convert to same domain

Callers 1

build_EVPMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected