-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into compathelper/new_version/2024-08-09-00-40-…
…44-455-03316379457
- Loading branch information
Showing
8 changed files
with
122 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
KomaMRICore/src/simulation/SimMethods/Bloch/KernelFunctions.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using KernelAbstractions: @kernel, @Const, @index, @uniform, @groupsize, @localmem | ||
|
||
## COV_EXCL_START | ||
|
||
@kernel function apply_excitation!(Mxy, Mz, @Const(φ), @Const(B1), @Const(Bz), @Const(B), @Const(ΔT1), @Const(ΔT2), @Const(ρ)) | ||
i_g = @index(Global) | ||
i_l = @index(Local) | ||
|
||
@uniform T = eltype(φ) | ||
@uniform N = @groupsize()[1] | ||
@uniform N_Δt = size(φ, 2) | ||
|
||
s_α_r = @localmem T (N,) | ||
s_α_i = @localmem T (N,) | ||
s_β_i = @localmem T (N,) | ||
s_β_r = @localmem T (N,) | ||
s_Mxy_r = @localmem T (N,) | ||
s_Mxy_i = @localmem T (N,) | ||
s_Mxy_new_r = @localmem T (N,) | ||
s_Mxy_new_i = @localmem T (N,) | ||
s_Mz = @localmem T (N,) | ||
s_Mz_new = @localmem T (N,) | ||
s_ρ = @localmem T (N,) | ||
|
||
@inbounds s_Mxy_r[i_l] = real(Mxy[i_g]) | ||
@inbounds s_Mxy_i[i_l] = imag(Mxy[i_g]) | ||
@inbounds s_Mz[i_l] = Mz[i_g] | ||
@inbounds s_ρ[i_l] = ρ[i_g] | ||
|
||
@inbounds for t = 1 : N_Δt | ||
sin_φ = sin(φ[i_g, t]) #TO-DO: use sincos once oneAPI releases version with https://github.com/JuliaGPU/oneAPI.jl/commit/260a4dda0ea223dbf0893de7b4a13d994ae27bd1 | ||
cos_φ = cos(φ[i_g, t]) | ||
s_α_r[i_l] = cos_φ | ||
if (iszero(B[i_g, t])) | ||
s_α_i[i_l] = -(Bz[i_g, t] / (B[i_g, t] + eps(T))) * sin_φ | ||
s_β_r[i_l] = (imag(B1[t]) / (B[i_g, t] + eps(T))) * sin_φ | ||
s_β_i[i_l] = -(real(B1[t]) / (B[i_g, t] + eps(T))) * sin_φ | ||
else | ||
s_α_i[i_l] = -(Bz[i_g, t] / B[i_g, t]) * sin_φ | ||
s_β_r[i_l] = (imag(B1[t]) / B[i_g, t]) * sin_φ | ||
s_β_i[i_l] = -(real(B1[t]) / B[i_g, t]) * sin_φ | ||
end | ||
s_Mxy_new_r[i_l] = 2 * (s_Mxy_i[i_l] * (s_α_r[i_l] * s_α_i[i_l] - s_β_r[i_l] * s_β_i[i_l]) + | ||
s_Mz[i_l] * (s_α_i[i_l] * s_β_i[i_l] + s_α_r[i_l] * s_β_r[i_l])) + | ||
s_Mxy_r[i_l] * (s_α_r[i_l]^2 - s_α_i[i_l]^2 - s_β_r[i_l]^2 + s_β_i[i_l]^2) | ||
s_Mxy_new_i[i_l] = -2 * (s_Mxy_r[i_l] * (s_α_r[i_l] * s_α_i[i_l] + s_β_r[i_l] * s_β_i[i_l]) - | ||
s_Mz[i_l] * (s_α_r[i_l] * s_β_i[i_l] - s_α_i[i_l] * s_β_r[i_l])) + | ||
s_Mxy_i[i_l] * (s_α_r[i_l]^2 - s_α_i[i_l]^2 + s_β_r[i_l]^2 - s_β_i[i_l]^2) | ||
s_Mz_new[i_l] = s_Mz[i_l] * (s_α_r[i_l]^2 + s_α_i[i_l]^2 - s_β_r[i_l]^2 - s_β_i[i_l]^2) - | ||
2 * (s_Mxy_r[i_l] * (s_α_r[i_l] * s_β_r[i_l] - s_α_i[i_l] * s_β_i[i_l]) + | ||
s_Mxy_i[i_l] * (s_α_r[i_l] * s_β_i[i_l] + s_α_i[i_l] * s_β_r[i_l])) | ||
s_Mxy_r[i_l] = s_Mxy_new_r[i_l] * ΔT2[i_g, t] | ||
s_Mxy_i[i_l] = s_Mxy_new_i[i_l] * ΔT2[i_g, t] | ||
s_Mz[i_l] = s_Mz_new[i_l] * ΔT1[i_g, t] + s_ρ[i_l] * (1 - ΔT1[i_g, t]) | ||
end | ||
|
||
@inbounds Mxy[i_g] = s_Mxy_r[i_l] + 1im * s_Mxy_i[i_l] | ||
@inbounds Mz[i_g] = s_Mz[i_l] | ||
end | ||
|
||
## COV_EXCL_STOP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* For hiding the standard output from literate examples */ | ||
.documenter-example-output {display: none;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters