-
Notifications
You must be signed in to change notification settings - Fork 34
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to plot sim.electric_field in 3d #454
Comments
Not with the current plot recipes, but you can have a lot at either Plots.jl or Makie.jl, to see if they allow to plot this. You would then need to access the (probably unevenly spaced) grid points and the data using If you have an example plot that you want to reproduce, I also can look into this myself and see if I can provide something |
I just had a quick look at this, and can provide you something. using SolidStateDetectors
using Plots; pyplot()
using LinearAlgebra
using Unitful
T = Float32
sim = Simulation{T}(SSD_examples[:CGD])
simulate!(sim)
clims = (0,1000)
# Cross-section in xz-plane at y = 0
y = 0
yidx = SolidStateDetectors.searchsortednearest(sim.electric_field.grid[2], T(y))
y = sim.electric_field.grid[2][yidx]
xs = sim.electric_field.grid[1].ticks
ys = sim.electric_field.grid[2].ticks
zidx = findall(z -> z >= -0.00275, sim.electric_field.grid[3].ticks)
zs = sim.electric_field.grid[3].ticks[zidx]
xx, yy, zz = xs' .* ones(length(zs)) * u"m", (xs' .* zeros(length(zs)) .+ y) * u"m", zs .* ones(length(xs))' * u"m"
surface(xx, yy, zz, fill_z = clamp.(norm.(sim.electric_field.data[:,yidx,zidx])' ./ 1000, clims...), clims = clims)
# Cross-section in xy-plane at z = -0.00275
z = -0.00275
zidx = SolidStateDetectors.searchsortednearest(sim.electric_field.grid[3], T(z))
z = sim.electric_field.grid[3][zidx]
xs = sim.electric_field.grid[1].ticks
yidx = findall(y -> y <= 0, sim.electric_field.grid[2].ticks)
ys = sim.electric_field.grid[2].ticks[yidx]
zs = sim.electric_field.grid[3].ticks
xx, yy, zz = xs' .* ones(length(ys)) * u"m", (ones(length(xs))' .* ys) * u"m", (xs' .* zeros(length(ys)) .+ z) * u"m"
surface!(xx, yy, zz, fill_z = clamp.(norm.(sim.electric_field.data[:,yidx,zidx])' ./ 1000, clims...), clims = clims) The |
If this turns out to be useful, we can think about including a plot recipe for plotting cross-sections of the potentials and fields in the SolidStateDetectors package. |
Thanks for the right direction , this looks good. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
How can i plot sim.electric_field in 3D, and is it possible to set values above and below certain range transparent ?
or oblique slices (horizontal and vertical ) in 3d plot
Thanks
The text was updated successfully, but these errors were encountered: