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, m_theta=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. m_theta=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., m_theta=m_theta)

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

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: attrdict

Store physical parameters for the eigenvalue problem.

Set the parameters for the plasma device, such as temperature and axial mode number. Create a radial grid object across the plane of the plasma.

get_omega0()
property 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. Dependent parameters calculated include the ion-ion viscosity, magnetized ion-ion viscosity and unmagnetized ion-ion viscosity.

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

Bases: object

Summary of the class SymbolicEq

Defines the differential equations in symbolic form. The class creates the three equations for density (N), parallel electron velocity (v_par) and potential (phi). The symbolic variables are initially defined and used to create symbolic equations for these three quantities via the Braginskii fluid equations. The equations are then linearized, i.e. only terms containing the perturbation factor (epsilon) are considered to create the final equations. Finally, terms with the frequency (omega0) are saved as LHS terms while all remaining terms are saved as RHS terms. The RHS and LHS notation exists to setup the eigenvalue matrix calculation later on.

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,v_par,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,v_par,phi)

Parameters

p: the package of all variable and symbols for the equations

Returns

Lin_eq

Array of the linearized version of each of the three equations

compile_function(sf, p, pvalues)

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

Arguments: 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)

Parameters

eq: The lin

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=’m_theta’, 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