-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRecipes.jl
146 lines (138 loc) · 4.06 KB
/
Recipes.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@recipe function f(sim::T, mode=:ψ) where T <: Union{Calc, Sim}
# Set Defaults
res_x --> 500
res_t --> 500
n_lines --> 10
skip --> 1
# Extract Values
res_x = plotattributes[:res_x]
res_t = plotattributes[:res_t]
skip = plotattributes[:skip]
n_lines = plotattributes[:n_lines]
# Compute sampling interval
xₛ = Int(ceil(sim.box.Nₓ/res_x))
tₛ = Int(ceil(sim.box.Nₜ/res_t))
if mode==:ψ
# Downsample
x_ax = sim.box.t[1:tₛ:end]
y_ax = sim.box.x[1:xₛ:end]
ψ = sim.ψ[1:tₛ:end, 1:xₛ:end]
xguide --> L"t"
yguide --> L"x"
colorbar_title --> L"|\psi|"
seriescolor --> :viridis
fontfamily --> "Computer Modern"
tick_direction --> :out
s = get(plotattributes, :seriestype, :auto)
if s == :surface
zguide --> L"|\psi|"
colorbar --> false
camera --> (35, 75)
grid --> false
end
@series begin
# return series data
x_ax, y_ax, abs.(ψ)'
end
elseif mode==:ψ̃
s = get(plotattributes, :seriestype, :auto)
if s == :auto
# Downsample
y_ax = sim.box.x[1:xₛ:end]
#ψ̃ = sim.ψ̃[1:tₛ:end, 1:xₛ:end]
# Extract Lines
start = sim.box.Nₜ÷2 + 1
ψ̃ = sim.ψ̃[start:skip:start+skip*n_lines-1, 1:xₛ:end]
labs = reshape([L"\tilde{\psi}_{%$(i-1)}" for i in 1:skip:skip*n_lines], 1, :)
tick_direction --> :out
linewidth --> 1.5
xguide --> L"x"
yguide --> L"\log|\tilde{\psi}|"
fontfamily --> "Computer Modern"
tick_direction --> :out
#margin --> 4mm
legend --> :outertopright
for i=1:size(ψ̃)[1]
@series begin
label --> labs[i]
y_ax, log.(abs.(ψ̃[i, :]))
end
end
else
# Downsample
x_ax = sim.box.ω[1:tₛ:end]
y_ax = sim.box.x[1:xₛ:end]
ψ̃ = sim.ψ̃[1:tₛ:end, 1:xₛ:end]
xguide --> L"\omega"
yguide --> L"x"
colorbar_title --> L"\log|\tilde{\psi}|"
seriescolor --> :viridis
fontfamily --> "Computer Modern"
tick_direction --> :out
@series begin
seriestype := s
# return series data
x_ax, y_ax, log.(abs.(ψ̃'))
end
end
elseif mode==:IoM
# Downscale
x = sim.box.x[1:xₛ:end]
E = sim.E[1:xₛ:end]
KE = sim.KE[1:xₛ:end]
PE = sim.PE[1:xₛ:end]
δE = sim.E[1:xₛ:end] .- sim.E[1]
δP = sim.P[1:xₛ:end] .- sim.P[1]
δN = sim.N[1:xₛ:end] .- sim.N[1]
layout --> (2, 2)
fontfamily --> "Computer Modern"
tick_direction --> :out
@series begin
linewidth --> 1.5
subplot := 1
label --> L"E"
x, E
end
@series begin
linewidth --> 1.5
subplot := 1
label --> L"K"
x, KE
end
@series begin
linewidth --> 1.5
subplot := 1
xguide := L"x"
yguide := L"E"
label --> L"V"
x, PE
end
@series begin
linewidth --> 1.5
subplot := 2
xguide := L"x"
yguide := L"\delta E"
label --> ""
x, δE
end
@series begin
linewidth --> 1.5
subplot := 3
xguide := L"x"
yguide := L"\delta P"
label --> ""
x, δP
end
@series begin
linewidth --> 1.5
subplot := 4
xguide := L"x"
yguide := L"\delta N"
label --> ""
x, δN
end
else
@error "Unknown Plotting Mode for NonlinearSchrodinger.jl Objects $mode"
end
return nothing
end