bapsf_eigsolver.eigsolver

Example: Drift wave:

import eigsolver reload(eigsolver)

metric = ‘cyl’ # choose cylindrical (‘cyl’) or slab (‘cart’) geometry equation = eigsolver.SymbolicEq(metric) # Derive the eigenvalue equation in symbolic form

p = eigsolver.PhysParams(Nr=100, np=3, mtheta=27.625) # define a set of physical
# parameters for the problem (size, profiles, etc)

esolver = eigsolver.EigSolve(equation, p) # Solve the eigenvalue problem eigsolver.plot_omega(esolver) # Plot profiles and eigenmodes

# Result: # Fastest growing mode: omega= (0.0355033868707+0.0105688086074j)

Example: Interchange instability

import eigsolver from misctools import attrdict

metric = ‘cyl’ equation = eigsolver.SymbolicEq(metric) # Derive the eigenvalue equation in symbolic form

w = 20. mtheta=1. p = eigsolver.PhysParams(Nr=100, rmin_m=0.001, rmax_m=0.45,

np=5, tp=0, pp=4, param=attrdict(w=w, x0=0.5, n2=0.9, ra=0.001, rb=0.45), phi0v=50., nz=0., mtheta=mtheta)

co

esolver = eigsolver.EigSolve(equation, p) # Solve the eigenvalue problem eigsolver.plot_omega(esolver) # Plot profiles and eigenmodes

# Fastest growing mode: omega= (0.0123935824817+0.00236358432211j)

class bapsf_eigsolver.eigsolver.BlockingMouseInput

Bases: object

Class that stops the program execution until mouse click(s)

callback = None
on_click(event)

Event handler to process mouse click

verbose = False
class bapsf_eigsolver.eigsolver.EigSolve(equation, pvalues, sortby='gamma_asc')

Bases: object

Find the eigenvalue of the equation LHS = omega0 RHS

exp()
fdiff_matrix(sortby)

Construct the finite difference matrix of the equations

i_lkp(ir, iv)

Lookup index in the FD matrix: ir is the radial index, iv is the variable/equation index

ni_phi_phase()
class bapsf_eigsolver.eigsolver.PhysParams(device='LAPD', **keywords)

Bases: object

Store physical parameters for the eigenvalue problem

get_omega0()
omega0
pprint()

Print the values stored

set_omega0(omega0)
update_omega0()

Update the values that depend on omega0

update_params()

Calculate the dependent parameters when the independent values change

class bapsf_eigsolver.eigsolver.SymbolicEq(metric='cyl')

Bases: object

Derive the eigenvalue equation in symbolic form

apply_params(pvalues)

Compile the symbolic functions (coefficients) into callable functions using the values from “pvalues” object Construct the arrays LHS/RHS of the form [i_eq, i_var, i_order], with indices i_eq – equation index, i_var – variable index (N,vpar,phi), i_order – derivative index (0,1,2) Elements of array: callable functions f(r,ni,te,phi,nu_e,mu_ii,dummyvec)

build_symb_eq(p)

Construct the linear equations for all variables (N,vpar,phi)

compile_function(sf, p, pvalues)

Compile a symbolic function (sf) info a callable function using the values given. Result: f(r,ni,te,phi0) Input:

sf – symbolic function (representing the coefficient of the equations) p – pack of all symbols pvalues – numerical values
get_Dvar_coeffs(eq, f, r)

Extract the coefficients (symbolic) at D[f, {r, i=0..2}] in the expression of the form eq = c2(r)*f’‘(r) + c1(r)*f’(r) + c0(r)*f(r)

bapsf_eigsolver.eigsolver.blendparams(p1, p2, frac, flog=False)

Calculate an intermediate set of values based on p1,p2 sets and a fraction “frac” Gradual change p1 -> p2 Returns: p = p1*(1.-frac) + p2*frac

or

p = p1**(1.-frac)*p2**frac

bapsf_eigsolver.eigsolver.combine_scans(*d, **darg)

Combine several scans and sort them according to the sortparam value Syntax: combine_scans(d1,d2,…, sortparam=’mtheta’, finclude=lambda x: x>10.) If finclude is specified, only finclude(x)=True elements will be included (only used when sortparam is specified)

bapsf_eigsolver.eigsolver.load_scan(fname='trace_scan.dat')

Load the results of a scan

bapsf_eigsolver.eigsolver.plot_omega(esolver, ommin=None, ommax=None, interactive=False, pos=-1)

Plot the eigenvalues (omega0) on the complex plane, and eigenfunctions for max(Im(omega))

bapsf_eigsolver.eigsolver.save_scan(scanres, fname='trace_scan.dat')

Save the results of a scan (from trace_root function)

bapsf_eigsolver.eigsolver.trace_root(equation, p1, p2, nfrac=100, accumulate=1.0, flog=False, max=False, plotparam=None, execfunc=None, noplots=False)

Trace one root from p1 set of paramters to p2