Skip to content

Commit ab60739

Browse files
committed
small fix to plot of pf coil currents
1 parent 6ebfa00 commit ab60739

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/plot.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ NOTE: Current plots are for the total current flowing in the coil (ie. it is mul
3030
end
3131

3232
currents = [get_time_array(c.current, :data, time0) * getproperty(c.element[1], :turns_with_sign, 1.0) for c in pfa.coil]
33-
3433
CURRENT = maximum((maximum(abs, c.current.data[index] * getproperty(c.element[1], :turns_with_sign, 1.0)) for c in pfa.coil))
3534
if maximum(currents) > 1e6
3635
currents = currents ./ 1e6
3736
CURRENT = CURRENT ./ 1e6
3837
c_unit = "MA"
38+
elseif maximum(currents) > 1e3
39+
currents = currents ./ 1e3
40+
CURRENT = CURRENT ./ 1e3
41+
c_unit = "kA"
3942
else
4043
c_unit = "A"
4144
end
@@ -77,7 +80,7 @@ NOTE: Current plots are for the total current flowing in the coil (ie. it is mul
7780
linestyle --> :dash
7881
marker --> :circle
7982
ylabel := "[$c_unit]"
80-
["$k" for k in 1:length(currents)], currents
83+
["$k" for k in eachindex(currents)], currents
8184
end
8285

8386
Imax = []
@@ -98,12 +101,14 @@ NOTE: Current plots are for the total current flowing in the coil (ie. it is mul
98101
@series begin
99102
marker --> :cross
100103
label := "Max current"
101-
["$k" for k in 1:length(currents)], Imax
104+
ylabel := "[$c_unit]"
105+
["$k" for k in eachindex(currents)], Imax
102106
end
103107
@series begin
104108
marker --> :cross
105109
primary := false
106-
["$k" for k in 1:length(currents)], -Imax
110+
ylabel := "[$c_unit]"
111+
["$k" for k in eachindex(currents)], -Imax
107112
end
108113
end
109114

@@ -1810,7 +1815,7 @@ end
18101815
controller = IMAS.parent(controller_outputs)
18111816

18121817
data = controller.inputs.data[1, :]
1813-
integral = cumsum((data[k+1] + data[k]) / 2.0 * (controller.inputs.time[k+1] - controller.inputs.time[k]) for k in 1:length(controller.inputs.time)-1)
1818+
integral = cumsum((data[k+1] + data[k]) / 2.0 * (controller.inputs.time[k+1] - controller.inputs.time[k]) for k in eachindex(controller.inputs.time)-1)
18141819
derivative = diff(data) ./ diff(controller.inputs.time)
18151820

18161821
@series begin

0 commit comments

Comments
 (0)