Skip to content

Commit

Permalink
Add simple tests for charge trapping models
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann committed Sep 23, 2024
1 parent e64b2d4 commit ab5b6f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ChargeTrapping/ChargeTrapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end


BoggsChargeTrappingModel(args...; T::Type{<:SSDFloat}, kwargs...) = BoggsChargeTrappingModel{T}(args...; kwargs...)
function BoggsChargeTrappingModel{T}(config_dict::AbstractDict; temperature::RealQuantity = T(78)) where {T <: SSDFloat}
function BoggsChargeTrappingModel{T}(config_dict::AbstractDict = Dict(); temperature::RealQuantity = T(78)) where {T <: SSDFloat}
nσe::T = ustrip(u"m^-1", inv(1020u"cm"))
nσh::T = ustrip(u"m^-1", inv(2040u"cm"))
meffe::T = 0.12
Expand Down
41 changes: 28 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,41 @@ T = Float32
end
end

@timed_testset "Diffusion and Self-Repulsion" begin
@timed_testset "Charge Drift" begin
sim = Simulation{T}(SSD_examples[:InvertedCoax])
timed_simulate!(sim, convergence_limit = 1e-5, device_array_type = device_array_type, refinement_limits = [0.2, 0.1, 0.05], verbose = false)

pos = CartesianPoint{T}(0.02,0,0.05); Edep = 1u"eV"
nbcc = NBodyChargeCloud(pos, Edep, 40, radius = T(0.0005), number_of_shells = 2)

evt = Event(nbcc)
timed_simulate!(evt, sim, self_repulsion = true, diffusion = true)
signalsum = T(0)
for i in 1:length(evt.waveforms)
signalsum += abs(ustrip(evt.waveforms[i].signal[end]))
@timed_testset "Diffusion and Self-Repulsion" begin
evt = Event(nbcc)
timed_simulate!(evt, sim, self_repulsion = true, diffusion = true)
signalsum = T(0)
for i in 1:length(evt.waveforms)
signalsum += abs(ustrip(evt.waveforms[i].signal[end]))
end
signalsum *= inv(ustrip(SolidStateDetectors._convert_internal_energy_to_external_charge(sim.detector.semiconductor.material)))
@info signalsum
@test isapprox( signalsum, T(2), atol = 5e-3 )
end

@timed_testset "Charge Trapping" begin
sim.detector = SolidStateDetector(sim.detector, BoggsChargeTrappingModel{T}())
evt = Event(pos, Edep)
timed_simulate!(evt, sim)
signalsum = T(0)
for i in 1:length(evt.waveforms)
signalsum += abs(ustrip(evt.waveforms[i].signal[end]))
end
signalsum *= inv(ustrip(SolidStateDetectors._convert_internal_energy_to_external_charge(sim.detector.semiconductor.material)))
@info signalsum
@test signalsum < T(2)
end

@timed_testset "ADLChargeDriftModel" begin
include("ADLChargeDriftModel.jl")
end
signalsum *= inv(ustrip(SolidStateDetectors._convert_internal_energy_to_external_charge(sim.detector.semiconductor.material)))
@info signalsum
@test isapprox( signalsum, T(2), atol = 5e-3 )
end

@timed_testset "Fano factor" begin
Expand Down Expand Up @@ -357,10 +376,6 @@ end
@test all(broadcast(dp -> dp.e_path[end] in sim.detector.contacts[2], ev.drift_paths))
end

@timed_testset "ADLChargeDriftModel" begin
include("ADLChargeDriftModel.jl")
end

@timed_testset "IO" begin
include("IO.jl")
end
Expand Down

0 comments on commit ab5b6f8

Please sign in to comment.