Quickstart through high-level interface
Limace.jl
provides a high-level interface to setup and solve the linear problem. The four main steps to solve for hydromagnetic modes are outlined here:
Definition/Choice of appropriate bases.
Chose a polynomial truncation, e.g. N=10
, and appropriate bases (see Bases for implemented bases) for the velocity (and magnetic field). Let us use the Inviscid
basis for the velocity and the PerfectlyConducting
for the magnetic field.
N = 10
u = Inviscid(N)
b = PerfectlyConducting(N)
bases = [u,b]
Chose forcings, background state and parameters.
We can chose a background magnetic field (or flow) and an appropriate non-dimensional parameter (e.g. Lehnert number)
B0 = BasisElement(b, Toroidal, (1,0,0), 2sqrt(2pi/15)) # corresponds to B_0 = s e_z
Le = 1e-2 #Lehnert number
The forcings considered in the problem are collected in a list to be included
forcings = [Limace.Inertial(u),
Limace.Inertial(b),
Limace.Coriolis(u, 1/Le),
Limace.Lorentz(u,b,B0),
Limace.InductionB0(b,u,B0)]
In this way, one can adapt the problem setup to include the relevant physical ingredients in a flexible way. Each of the defined forcings will be assembled to a linear operator (sparse matrix) that is then combined to the total sparse matrix used to solve the defined problem. For the available terms that are currently implemented see the Forces section.
We can combine the bases
and forcings
in a Limace.LimaceProblem
.
problem = LimaceProblem(bases, forcings)
Limace.LimaceProblem
— Typemutable struct LimaceProblem{T}
bases::Any
forcings::Any
RHS::SparseArrays.SparseMatrixCSC
LHS::SparseArrays.SparseMatrixCSC
sol::Union{LinearAlgebra.Eigen{T, T, Matrix{T}, Vector{T}}, LinearAlgebra.GeneralizedEigen{T, T, Matrix{T}, Vector{T}}} where T
preassembled::Bool
assembled::Bool
solved::Bool
Assembly of Galerkin projection matrices.
The assembly of the linear operators within the problem
is then simply:
Limace.assemble!(problem)
We can use a keyword threads=true
to assemble the matrices using multithreading on a single computer (see Limace.assemble!
).
Limace.assemble!
— Functionassemble!(problem::LimaceProblem; threads=false, kwargs...)
Assemble the problem matrices problem.LHS
and problem.RHS
from the forcing matrices that may or may not be preassembled. For now, only Limace.Inertial
are added to the LHS
matrix. When threads=true
the assembly is done using Threads.nthreads()
threads.
Compute solution(s) of (generalized) eigen problem.
Solving the eigen problem can be done through a high-level function
Limace.solve!(problem)
We can then access the eigenvalues λ
, and eigenvectors x
within problem.sol
:
λ, x = problem.sol.values, problem.sol.vectors
Limace.solve!
— Functionsolve!(problem::LimaceProblem; method=:dense, kwargs...)
Solve problem
using the specified method. The default method is :dense
, which transforms the problem matrices to dense matrices. Other methods are :sparse
, which uses the sparse matrices directly.
Solutions are stored in problem.sol
and problem.solved
is set to true
.
More details on the choices of method and the underlying methodology is outlined in the section on Solving the eigenvalue problem.
From here, we can plot the solutions or process the spectrum of modes. See the examples and Postprocessing for more details.