ElectromagneticFields.jl – Modules
ElectromagneticFields.code — Function
code(equ, pert = ZeroPerturbation(); export_parameters = true, escape = false, output = 0, cse = true)Generate code for evaluating analytic equilibria: an Expr defining the field functions of equ, which @code splices into the calling module and load_equilibrium evaluates into one.
export_parametersalso emits the equilibrium's scalar parameters as constants.escapeescapes the generated names, which a macro splicing this into another module needs.outputis 0, 1 or 2: silent, one line per function, or the generated body as well.csenames each repeated subexpression once instead of emitting it in full every time it occurs. This is on by default and is value-preserving to the last bit — subexpressions are named, never rewritten — but the generated code is easier to read against a paper with it off. It matters: SymEngine shares nothing, sodb₁dx₁of the ITER Solov'ev equilibrium with an X-point contains 108 separate evaluations oflog(ξ₁)without it, and is 6.8 times slower.
The @code macros take these as key = value arguments, after the equilibrium's parameters: ThetaPinch.@code(B₀, cse = false), or just ThetaPinch.@code cse = false for the defaults.
ElectromagneticFields.code_arguments — Method
code_arguments(args)Split the arguments a @code macro was called with into the equilibrium's parameters and the options destined for code, returned as (parameters, options).
Macros cannot take keyword arguments, so an option is written as key = value among the arguments — @code cse = false or @code(R₀, B₀, q₀, cse = false). A ; key = value tail is accepted too.
ElectromagneticFields.connection — Method
Returns the l-th component of the Levi-Civita connection
ElectromagneticFields.contravariant_to_covariant — Method
Returns the i-th component of the one-form corresponding to the vector v
ElectromagneticFields.contravariant_to_physical — Method
Returns the i-th component of the physical coordinate representation of the one-form α
ElectromagneticFields.covariant_to_contravariant — Method
Returns the i-th component of the vector corresponding to the one-form α
ElectromagneticFields.covariant_to_physical — Method
Returns the i-th component of the physical coordinate representation of the one-form α
ElectromagneticFields.crossproduct — Method
Returns the m-th component of the cross-product between the vectors v and w
ElectromagneticFields.eliminate_common_subexpressions — Method
eliminate_common_subexpressions(body::Expr; prefix = "_cse")Rewrite a generated function body so that every repeated subexpression is evaluated once and read from a local afterwards. Returns a begin ... end block whose value is that of body, and whose locals are named prefix * n.
Value-preserving to the last bit: subexpressions are named, not rewritten.
ElectromagneticFields.generate_equilibrium_functions — Method
Generate functions for evaluating analytic equilibria.
ElectromagneticFields.hodge²¹ — Method
Returns the m-th component of the one-form corresponding to the two-form β
ElectromagneticFields.load_equilibrium — Function
load_equilibrium(equ, pert = ZeroPerturbation(); target_module = Main, output = 0, cse = true)Evaluate functions for evaluating analytic equilibria: generate the field functions of equ with code and evaluate them into target_module.
output and cse are passed on to code — in particular cse = false emits every repeated subexpression in full, which is slower but easier to read against a paper.
ElectromagneticFields.magnitude — Method
Returns the length of the vector v
ElectromagneticFields.normalize! — Method
Normalises the vector v in the metric g
ElectromagneticFields.normalize — Method
Normalises the vector v in the metric g
ElectromagneticFields.Γ — Method
Returns the Christoffel symbol Γⱼₖˡ