Skip to content
Snippets Groups Projects
Unverified Commit 68916b6c authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Replace qval with qvec where appropriate

parent d91ffef9
No related branches found
No related tags found
1 merge request!2Define variables through new @defvar macro
...@@ -20,13 +20,13 @@ If the `orientation` is set an [`InstantGradient1D`](@ref) is returned, otherwis ...@@ -20,13 +20,13 @@ If the `orientation` is set an [`InstantGradient1D`](@ref) is returned, otherwis
""" """
abstract type InstantGradient{N} <: EventComponent end abstract type InstantGradient{N} <: EventComponent end
function (::Type{InstantGradient})(; orientation=nothing, group=nothing, qval=nothing, variables...) function (::Type{InstantGradient})(; orientation=nothing, group=nothing, variables...)
if isnothing(orientation) if isnothing(orientation)
res = InstantGradient3D(get_free_variable.(qval), group) res = InstantGradient3D(nothing, group)
else else
res = InstantGradient1D(get_free_variable(qval), orientation, group) res = InstantGradient1D(nothing, orientation, group)
if !(res.qval isa Number) if !(res.qvec isa Number)
@constraint global_model() res.qval >= 0 @constraint global_model() res.qvec >= 0
end end
end end
set_simple_constraints!(res, variables) set_simple_constraints!(res, variables)
...@@ -52,11 +52,11 @@ struct InstantGradient3D <: InstantGradient{3} ...@@ -52,11 +52,11 @@ struct InstantGradient3D <: InstantGradient{3}
group :: Union{Nothing, Symbol} group :: Union{Nothing, Symbol}
end end
function InstantGradient3D(; qval=[nothing, nothing, nothing], group=nothing, variables...) function InstantGradient3D(; qvec=nothing, group=nothing, variables...)
if isnothing(qval) if isnothing(qvec)
qval = [nothing, nothing, nothing] qvec = [nothing, nothing, nothing]
end end
res = InstantGradient3D(get_free_variable.(qval), group) res = InstantGradient3D(get_free_variable.(qvec), group)
set_simple_constraints!(res, variables) set_simple_constraints!(res, variables)
return res return res
end end
......
...@@ -55,7 +55,7 @@ function EPIReadout(; resolution::AbstractVector{<:Integer}, recenter=false, gro ...@@ -55,7 +55,7 @@ function EPIReadout(; resolution::AbstractVector{<:Integer}, recenter=false, gro
apply_simple_constraint!(variables.qvec(res.recenter_gradient), VariableType[sign * variables.qvec(pos)[1]/2, -ky_lines[end] * res.ky_step, 0.]) apply_simple_constraint!(variables.qvec(res.recenter_gradient), VariableType[sign * variables.qvec(pos)[1]/2, -ky_lines[end] * res.ky_step, 0.])
end end
for shift in unique(ky_lines[2:end] - ky_lines[1:end-1]) for shift in unique(ky_lines[2:end] - ky_lines[1:end-1])
res.blips[shift] = Trapezoid(orientation=[0, shift > 0 ? 1 : -1, 0], group=group, qval=abs(shift) * res.ky_step) res.blips[shift] = Trapezoid(qvec=[0., shift * res.ky_step, 0.], group=group)
end end
set_simple_constraints!(res, vars) set_simple_constraints!(res, vars)
return res return res
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment