Skip to content

Commit

Permalink
Add plot recipe for theta pinch.
Browse files Browse the repository at this point in the history
  • Loading branch information
michakraus committed Oct 2, 2020
1 parent a097704 commit 4b423ee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/src/analytic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


40 changes: 40 additions & 0 deletions src/analytic/theta_pinch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Parameters:
"""
module ThetaPinch

using RecipesBase
using LaTeXStrings

import ..ElectromagneticFields
import ..ElectromagneticFields: CartesianEquilibrium, ZeroPerturbation
import ..ElectromagneticFields: load_equilibrium, generate_equilibrium_code
Expand Down Expand Up @@ -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

0 comments on commit 4b423ee

Please sign in to comment.