From 4b423ee935ea8384c3e198e9cd1612f22c51a775 Mon Sep 17 00:00:00 2001 From: Michael Kraus Date: Fri, 2 Oct 2020 22:05:18 +0200 Subject: [PATCH] Add plot recipe for theta pinch. --- docs/src/analytic.md | 21 +++++++++++++++++++ src/analytic/theta_pinch.jl | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/docs/src/analytic.md b/docs/src/analytic.md index f880e0f..fb00af7 100644 --- a/docs/src/analytic.md +++ b/docs/src/analytic.md @@ -216,3 +216,24 @@ Vector potential in ITER and NSTX: +## Theta Pinch + +```@docs +ThetaPinch +``` +```@eval +using Plots +using ElectromagneticFields + +eq_thp = ElectromagneticFields.ThetaPinch.init() +plot(eq_thp) +savefig("theta_pinch.png") + +nothing +``` + +Vector potential components: + +![](theta_pinch.png) + + diff --git a/src/analytic/theta_pinch.jl b/src/analytic/theta_pinch.jl index 8f085a1..119f8de 100644 --- a/src/analytic/theta_pinch.jl +++ b/src/analytic/theta_pinch.jl @@ -14,6 +14,9 @@ Parameters: """ module ThetaPinch + using RecipesBase + using LaTeXStrings + import ..ElectromagneticFields import ..ElectromagneticFields: CartesianEquilibrium, ZeroPerturbation import ..ElectromagneticFields: load_equilibrium, generate_equilibrium_code @@ -64,4 +67,41 @@ module ThetaPinch return equilibrium end + + @recipe function f(equ::ThetaPinchEquilibrium; + nx = 100, ny = 100, levels = 20, size = (800,400), + xlims = (-1., +1.), + ylims = (-1., +1.)) + + xgrid = LinRange(xlims[1], xlims[2], nx) + ygrid = LinRange(ylims[1], ylims[2], ny) + pot1 = [A₁(0, xgrid[i], ygrid[j], 0.0) for i in eachindex(xgrid), j in eachindex(ygrid)] + pot2 = [A₂(0, xgrid[i], ygrid[j], 0.0) for i in eachindex(xgrid), j in eachindex(ygrid)] + + seriestype := :contour + aspect_ratio := :equal + layout := (1,2) + size := size + xlims := xlims + ylims := ylims + levels := levels + legend := :none + + @series begin + subplot := 1 + title := L"A_x (x,y)" + xguide := L"x" + yguide := L"y" + (xgrid, ygrid, pot1) + end + + @series begin + subplot := 2 + title := L"A_y (x,y)" + xguide := L"x" + yguide := L"y" + (xgrid, ygrid, pot2) + end + end + end