Closed fhagemann closed 2 years ago
It looks like this is because the filter!
method in get_scale
results in points
being empty.
https://github.com/JuliaPhysics/SolidStateDetectors.jl/blob/f1bc27859b38a1e70d61a1f1826964f137dded8d/src/ConstructiveSolidGeometry/CSG.jl#L221
A quick-and-dirty fix would be to add
if isempty(points) points = [point for p in primitives(csg) for s in surfaces(p) for point in vertices(s, 4)] end
in the line after, which results in
But there might be more elegant solutions to solve this.
There also seems to be a problem with get_world_limits_from_objects
if theaxes
of the grid
are not specified in the configuration file but determined from the objects.
Detector configuration file:
units:
length: mm
angle: deg
grid: cartesian
medium: vacuum
detectors:
- semiconductor:
material: HPGe
geometry:
intersection:
- box:
widths: [2,2,2]
- sphere:
r: 1.41421356237
contacts:
- id: 1
potential: 100
geometry:
tube:
r: 1
h: 0
origin: [0,0,1]
- id: 2
potential: 0
geometry:
tube:
r: 1
h: 0
origin: [0,0,-1]
using SolidStateDetectors
sim = Simulation("MWE.yaml")
DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
[1] _bcs1(a::StaticArrays.SOneTo{4}, b::StaticArrays.SOneTo{6})
@ StaticArrays ~/.julia/packages/StaticArrays/DkWdL/src/broadcast.jl:44
[2] _bcs(shape::Tuple{StaticArrays.SOneTo{4}}, newshape::Tuple{StaticArrays.SOneTo{6}})
@ Base.Broadcast ./broadcast.jl:510
[3] broadcast_shape(::Tuple{StaticArrays.SOneTo{4}}, ::Tuple{StaticArrays.SOneTo{6}})
@ Base.Broadcast ./broadcast.jl:504
[4] combine_axes
@ ./broadcast.jl:499 [inlined]
[5] combine_axes (repeats 5 times)
@ ./broadcast.jl:498 [inlined]
[6] instantiate
@ ./broadcast.jl:281 [inlined]
[7] materialize(bc::Base.Broadcast.Broadcasted{StaticArrays.StaticArrayStyle{1}, Nothing, typeof(hcat), Tuple{StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{4, CartesianPoint{Float32}}, StaticArrays.SVector{6, CartesianPoint{Float32}}}})
@ Base.Broadcast ./broadcast.jl:904
[8] get_world_limits_from_objects(#unused#::Type{Cartesian}, det::SolidStateDetector{Float32, SolidStateDetectors.Semiconductor{Float32, SolidStateDetectors.ConstructiveSolidGeometry.CSGIntersection{Float32, SolidStateDetectors.ConstructiveSolidGeometry.Box{Float32, SolidStateDetectors.ConstructiveSolidGeometry.ClosedPrimitive}, SolidStateDetectors.ConstructiveSolidGeometry.Ellipsoid{Float32, SolidStateDetectors.ConstructiveSolidGeometry.ClosedPrimitive, Float32, Nothing, Nothing}}, NamedTuple{(:E_ionisation, :f_fano, :Ďľ_r, :Ď, :name, :ml, :mt, :diffusion_fieldvector_electrons, :diffusion_fieldvector_holes), Tuple{Unitful.Quantity{Float64, đ^2 đ đ^-2, Unitful.FreeUnits{(eV,), đ^2 đ đ^-2, nothing}}, Float64, Float64, Unitful.Quantity{Float64, đ đ^-3, Unitful.FreeUnits{(g, cm^-3), đ đ^-3, nothing}}, String, Float64, Float64, Int64, Int64}}, ElectricFieldChargeDriftModel{Float32}, SolidStateDetectors.ConstantImpurityDensity{Float32}}, Vector{SolidStateDetectors.Contact{Float32, SolidStateDetectors.ConstructiveSolidGeometry.Cone{Float32, SolidStateDetectors.ConstructiveSolidGeometry.ClosedPrimitive, Float32, Nothing}, NamedTuple{(:E_ionisation, :f_fano, :Ďľ_r, :Ď, :name, :ml, :mt, :diffusion_fieldvector_electrons, :diffusion_fieldvector_holes), Tuple{Unitful.Quantity{Float64, đ^2 đ đ^-2, Unitful.FreeUnits{(eV,), đ^2 đ đ^-2, nothing}}, Float64, Float64, Unitful.Quantity{Float64, đ đ^-3, Unitful.FreeUnits{(g, cm^-3), đ đ^-3, nothing}}, String, Float64, Float64, Int64, Int64}}}}, Missing, Missing})
@ SolidStateDetectors ~/Software/SolidStateDetectors.jl/src/SolidStateDetector/SolidStateDetector.jl:79
[9] (Simulation{Float32})(dict::Dict{Any, Any})
@ SolidStateDetectors ~/Software/SolidStateDetectors.jl/src/Simulation/Simulation.jl:161
[10] Simulation
@ ~/Software/SolidStateDetectors.jl/src/Simulation/Simulation.jl:171 [inlined]
[11] Simulation(config_file::String)
@ SolidStateDetectors ~/Software/SolidStateDetectors.jl/src/Simulation/Simulation.jl:174
[12] top-level scope
@ In[2]:1
[13] eval
@ ./boot.jl:373 [inlined]
[14] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
The function
get_scale
that scales the distance between points for:samplesurface
plotting does not work for geometries, for which the important points are not in the final geometry (excluded inCSGDifference
orCSGIntersection
).Minimum working example
Detector configuration file
Plotting the detector works for
:csg
,:mesh3d
and:wireframe
:but fails for
:samplesurface
: