Skip to content
Snippets Groups Projects
Verified Commit e0b8f424 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Avoid divisions in ChangingGradientBlocks

parent 04ef3c11
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ import ...BuildingBlocks: GradientBlock, fixed, RFPulseBlock
struct AbstractChangingGradientBlock{T<:VariableType} <: GradientBlock
gradient_strength_start :: SVector{3, T}
gradient_strength_end :: SVector{3, T}
slew_rate :: SVector{3, T}
duration :: T
rotate :: Union{Nothing, Symbol}
scale :: Union{Nothing, Symbol}
......@@ -34,7 +34,9 @@ const FixedChangingGradientBlock = AbstractChangingGradientBlock{Float64}
duration(cgb::AbstractChangingGradientBlock) = cgb.duration
slew_rate(cgb::AbstractChangingGradientBlock) = (cgb.gradient_strength_end .- cgb.gradient_strength_start) ./ duration(cgb)
grad_start(cgb::AbstractChangingGradientBlock) = cgb.gradient_strength_start
slew_rate(cgb::AbstractChangingGradientBlock) = cgb.slew_rate
grad_end(cgb::AbstractChangingGradientBlock) = gradient_strength(cgb) .+ slew_rate(cgb) .* duration(cgb)
gradient_strength(cgb::AbstractChangingGradientBlock) = max.(cgb.gradient_strength_start, cgb.gradient_strength_start)
qvec(cgb::AbstractChangingGradientBlock) = (cgb.gradient_strength_start .+ cgb.gradient_strength_end) .* (duration(cgb)/2)
......
......@@ -85,9 +85,9 @@ function PulsedGradient(model::Model; orientation=nothing, rise_time=nothing, fl
res = PulsedGradient(
model,
ChangingGradientBlock(zeros(3), grad, rise_time, rotate, scale),
ChangingGradientBlock(zeros(3), slew_rate, rise_time, rotate, scale),
ConstantGradientBlock(grad, flat_time, rotate, scale),
ChangingGradientBlock(grad, zeros(3), rise_time, rotate, scale),
ChangingGradientBlock(grad, -slew_rate, rise_time, rotate, scale),
slew_rate,
rate_1d,
rotate,
......
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