Check if a point is inside the semiconductor #464
-
Hello, new user of SSD here! I am trying to check if a given cartesian point is inside the semiconductor geometry. I saw that in Event.jl (line 101) you check directly for that using @assert charge_center in det.semiconductor "The center of the charge cloud ($(charge_center)) is not inside the semiconductor." If I try something like this, what I get is julia> point in sim.detector.semiconductor
ERROR: MethodError: no method matching iterate(::SolidStateDetectors.Semiconductor{…})
The function `iterate` exists, but no method is defined for this combination of argument types.
Closest candidates are:
iterate(::Pkg.Types.Manifest)
@ Pkg /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/Pkg/src/Types.jl:308
iterate(::Pkg.Types.Manifest, ::Int64)
@ Pkg /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/Pkg/src/Types.jl:309
iterate(::LLVM.FunctionParameterSet)
@ LLVM ~/.julia/packages/LLVM/b3kFs/src/core/function.jl:209
...
Stacktrace:
[1] in(x::CartesianPoint{…}, itr::SolidStateDetectors.Semiconductor{…})
@ Base ./operators.jl:1305
[2] top-level scope
@ REPL[44]:1
Some type information was truncated. Use `show(err)` to see complete types.
Is there any way of checking this using a built-in feature that I did not noticed? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
In principle, this should work. Which version of Julia are you using? You could try point in sim.detector.semiconductor.geometry or if in.(point, Ref(sim.detector.semiconductor.geometry)) Otherwise: can it be that the Point and Semiconductor are of different type (Flot32 and Float64)? |
Beta Was this translation helpful? Give feedback.
-
Hi, so my Julia version is 1.11.2 . In principle I am defining the point as a single cartesian point, like point = CartesianPoint(0.02,0.01,0.0) and then doing point in sim.detector.semiconductor.geometry The idea was to check the points on a grid before drifting the charges, otherwise it will crash if the point is outside the semiconductor. |
Beta Was this translation helpful? Give feedback.
-
That was it! Thank you very much! I did not realized that the float types were different. |
Beta Was this translation helpful? Give feedback.
Then, the types might not match. Could you try
or replace
Float32
by whatever type yourSimulation
is.