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

Do not consider NoGradient for ndim_grad

parent 1e3f8562
No related branches found
No related tags found
No related merge requests found
Pipeline #23579 passed
......@@ -56,7 +56,7 @@ function waveform_sequence(bb::BaseBuildingBlock)
end
function ndim_grad(bb::BaseBuildingBlock)
g = [ws[2] for ws in waveform_sequence(bb)]
g = [ws for (_, ws) in waveform_sequence(bb) if !(ws isa NoGradient)]
if iszero(length(g))
return 0
end
......@@ -86,17 +86,18 @@ function waveform(bb::BaseBuildingBlock)
else
return []
end
tol = sqrt(eps(Float64))
for (_, block) in waveform_sequence(bb)
new_time = result[end][1] + max(duration(block), 0)
prev_grad = result[end][2]
if block isa NoGradient
@assert all(abs.(prev_grad) <= 1e-12) "$(typeof(bb)) inserts NoGradient before the gradient is zero. This is probably caused by an improper implementation of this BuildingBlock."
@assert all(abs.(prev_grad) .<= 1e-12) "$(typeof(bb)) inserts NoGradient before the gradient is zero. This is probably caused by an improper implementation of this BuildingBlock."
push!(result, (new_time, prev_grad))
elseif block isa ConstantGradient
@assert all(gradient_strength(block) . prev_grad) "$(typeof(bb)) inserts ConstantGradient that does not match previous gradient strength. This is probably caused by an improper implementation of this BuildingBlock."
@assert all(isapprox.(gradient_strength(block), prev_grad, atol=tol, rtol=tol)) "$(typeof(bb)) inserts ConstantGradient that does not match previous gradient strength. This is probably caused by an improper implementation of this BuildingBlock."
push!(result, (new_time, prev_grad))
elseif block isa ChangingGradient
@assert all(block.gradient_strength_start . prev_grad) "$(typeof(bb)) inserts ChangingGradient that does not match previous gradient strength. This is probably caused by an improper implementation of this BuildingBlock."
@assert all(isapprox.(block.gradient_strength_start, prev_grad, atol=tol, rtol=tol)) "$(typeof(bb)) inserts ChangingGradient that does not match previous gradient strength. This is probably caused by an improper implementation of this BuildingBlock."
push!(result, (new_time, prev_grad .+ slew_rate(block) .* duration(block)))
else
error("Unrecognised block type in BuildingBlock: $(typeof(bb)).")
......
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