Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/example_config_files/ivc_inactivelayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ detectors:
value: -1e10cm^-3
charge_drift_model:
model: InactiveLayerChargeDriftModel
temperature: 90K

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe still allow for this syntax (to make this non-breaking), but check that it matches the temperature of the semiconductor, if any was given (?)

neutral_impurity_density:
name: constant
value: 5.6769e15cm^-3
Expand Down
1 change: 0 additions & 1 deletion examples/example_config_files/public_TrueCoaxial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ detectors:
value: -1e10cm^-3
charge_drift_model:
model: InactiveLayerChargeDriftModel
temperature: 90K
neutral_impurity_density:
name: constant
value: 5.6769e15cm^-3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ function _calculate_mobility_with_impurities(
end

function InactiveLayerChargeDriftModel{T}(config::AbstractDict,
imp_model::AbstractImpurityDensity, input_units::NamedTuple,
imp_model::AbstractImpurityDensity, input_units::NamedTuple, temperature::RealQuantity
) where {T <: SSDFloat}

temperature = _parse_value(T, get(config, "temperature", 90u"K"), input_units.temperature)
temperature::T = _parse_value(T, temperature, input_units.temperature)

if temperature < 50 || temperature > 150
@warn "Temperature = $(temperature) K is outside the typical validated range (50–150 K)."
end
Comment on lines +66 to +73

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at maximum compatibility: how about still being able to define the temperature in the charge drift model, especially for the case where no temperature was explicitly defined for the semiconductor (and maybe throwing an error here in case two non-matching temperatures are defined in the semiconductor and the charge drift model)?

neutral_imp_model = if haskey(config, "neutral_impurity_density")
ImpurityDensity(T, config["neutral_impurity_density"], input_units)
else
Expand Down Expand Up @@ -98,4 +101,4 @@ end

@fastmath function getVh(fv::SVector{3, T}, cdm::InactiveLayerChargeDriftModel{T}, current_pos::CartesianPoint{T} = zero(CartesianPoint{T})) where {T <: SSDFloat}
calculate_mobility(cdm, current_pos, Hole) * fv
end
end
9 changes: 4 additions & 5 deletions src/ChargeTrapping/ChargeTrapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Charge trapping model presented in [Boggs _et al._ (2023)](https://doi.org/10.10
## Fields
* `nσe::T`: Trapping product for electrons (default: `(nσe)^-1 = 1020cm`).
* `nσh::T`: Trapping product for holes (default: `(nσh)^-1 = 2040cm`).
* `temperature::T`: Temperature of the crystal (default: `78K`).

See also [Charge Trapping Models](@ref).
"""
Expand Down Expand Up @@ -124,7 +123,7 @@ end


BoggsChargeTrappingModel(args...; T::Type{<:SSDFloat}, kwargs...) = BoggsChargeTrappingModel{T}(args...; kwargs...)
function BoggsChargeTrappingModel{T}(config_dict::AbstractDict = Dict(); temperature::RealQuantity = T(78)) where {T <: SSDFloat}
function BoggsChargeTrappingModel{T}(temperature::RealQuantity, config_dict::AbstractDict = Dict()) where {T <: SSDFloat}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a breaking change..
Any way that we can keep config_dict as the first argument?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe give temperature a default value missing, and only read it from the config file if it is missing (?)

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 All @@ -147,7 +146,7 @@ function BoggsChargeTrappingModel{T}(config_dict::AbstractDict = Dict(); tempera
if haskey(parameters, "nσh-1") nσh = inv(_parse_value(T, parameters["nσh-1"], internal_length_unit)) end
if haskey(parameters, "meffe") meffe = _parse_value(T, parameters["meffe"], Unitful.NoUnits) end
if haskey(parameters, "meffh") meffh = _parse_value(T, parameters["meffh"], Unitful.NoUnits) end
if haskey(parameters, "temperature") temperature = _parse_value(T, parameters["temperature"], internal_temperature_unit) end

BoggsChargeTrappingModel{T}(nσe, nσh, meffe, meffh, temperature)
end

Expand Down Expand Up @@ -330,7 +329,7 @@ end


CombinedChargeTrappingModel(args...; T::Type{<:SSDFloat}, kwargs...) = CombinedChargeTrappingModel{T}(args...; kwargs...)
function CombinedChargeTrappingModel{T}(config_dict::AbstractDict = Dict(); temperature::RealQuantity = T(78)) where {T <: SSDFloat}
function CombinedChargeTrappingModel{T}(temperature::RealQuantity, config_dict::AbstractDict = Dict()) where {T <: SSDFloat}

if haskey(config_dict, "model") && config_dict["model"] !== nothing && !(haskey(config_dict, "parameters"))
throw(ConfigFileError("`CombinedChargeTrappingModel` does not have `parameters`"))
Expand All @@ -347,7 +346,7 @@ function CombinedChargeTrappingModel{T}(config_dict::AbstractDict = Dict(); temp
if isnothing(model)
throw(ConfigFileError("`model` is defined but empty in config. Remove it or provide a valid name."))
elseif model == "Boggs"
BoggsChargeTrappingModel{T}(config_dict; temperature)
BoggsChargeTrappingModel{T}(temperature, config_dict)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BoggsChargeTrappingModel{T}(temperature, config_dict)
BoggsChargeTrappingModel{T}(config_dict, temperature)

?

elseif model == "ConstantLifetime"
ConstantLifetimeChargeTrappingModel{T}(config_dict)
else
Expand Down
6 changes: 3 additions & 3 deletions src/SolidStateDetector/Semiconductor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Semiconductor{T}(dict::AbstractDict, input_units::NamedTuple, outer_tra
model = Symbol(dict["charge_drift_model"]["model"])
cdm = if isdefined(SolidStateDetectors, model) && getfield(SolidStateDetectors, model) <: AbstractChargeDriftModel
if model == :InactiveLayerChargeDriftModel
InactiveLayerChargeDriftModel{T}(dict["charge_drift_model"], impurity_density_model, input_units)
InactiveLayerChargeDriftModel{T}(dict["charge_drift_model"], impurity_density_model, input_units, temperature)
else
getfield(SolidStateDetectors, model){T}(dict["charge_drift_model"], input_units, temperature = temperature)
end
Expand Down Expand Up @@ -98,11 +98,11 @@ function Semiconductor{T}(dict::AbstractDict, input_units::NamedTuple, outer_tra
ctm_dict["parameters"]==ctm_dict["parameters_inactive"] && ctm_dict["model"] == "ConstantLifetime"
ConstantLifetimeChargeTrappingModel{T}(ctm_dict)
else
CombinedChargeTrappingModel{T}(ctm_dict, temperature = temperature)
CombinedChargeTrappingModel{T}(temperature, ctm_dict)
end

elseif haskey(ctm_dict, "model") && !haskey(ctm_dict, "model_inactive") && ctm_dict["model"] == "Boggs"
BoggsChargeTrappingModel{T}(ctm_dict, temperature = temperature)
BoggsChargeTrappingModel{T}(temperature, ctm_dict)

elseif haskey(ctm_dict, "model") && !haskey(ctm_dict, "model_inactive") && ctm_dict["model"] == "ConstantLifetime"
ConstantLifetimeChargeTrappingModel{T}(ctm_dict)
Expand Down
14 changes: 5 additions & 9 deletions test/test_charge_drift_models.jl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the changes you are proposing would be breaking changes, requiring a new minor version 0.12..
Is there any way this can be avoided? Is it because the temperature needs a default value?
Maybe set it to nothing and deal with it in the functions (if it is nothing, use the one from the config. If it has a value, it was passed from the semiconductor or by the user -- or something like that)?

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end
end

@timed_testset "Charge Trapping: BoggsChargeTrappingModel" begin
sim.detector = SolidStateDetector(sim.detector, BoggsChargeTrappingModel{T}())
sim.detector = SolidStateDetector(sim.detector, BoggsChargeTrappingModel{T}(sim.detector.semiconductor.temperature))
evt = Event(pos, Edep)
timed_simulate!(evt, sim)
signalsum = T(0)
Expand All @@ -92,15 +92,13 @@ end
"model" => "Boggs",
"parameters" => Dict(
"nσe" => "0.001cm^-1",
"nσh" => "0.0005cm^-1",
"temperature" => "78K"
"nσh" => "0.0005cm^-1"
)
)
simA = @test_nowarn Simulation{T}(config_dict)
@test simA.detector.semiconductor.charge_trapping_model isa BoggsChargeTrappingModel{T}
@test simA.detector.semiconductor.charge_trapping_model.nσe == T(0.1)
@test simA.detector.semiconductor.charge_trapping_model.nσh == T(0.05)
@test simA.detector.semiconductor.charge_trapping_model.temperature == T(78)
end
@testset "Parse config file 2" begin
config_dict["detectors"][1]["semiconductor"]["charge_trapping_model"] = Dict(
Expand All @@ -109,8 +107,7 @@ end
"nσe-1" => "500cm",
"nσh-1" => "500cm",
"meffe" => 0.1,
"meffh" => 0.2,
"temperature" => "100K"
"meffh" => 0.2
)
)
simB = @test_nowarn Simulation{T}(config_dict)
Expand All @@ -119,7 +116,6 @@ end
@test simB.detector.semiconductor.charge_trapping_model.nσh == T(0.2)
@test simB.detector.semiconductor.charge_trapping_model.meffe == T(0.1)
@test simB.detector.semiconductor.charge_trapping_model.meffh == T(0.2)
@test simB.detector.semiconductor.charge_trapping_model.temperature == T(100)

end
end
Expand Down Expand Up @@ -175,7 +171,7 @@ end
for (τ,τ_inactive) in zip(τ_list, τ_inactive_list)
parameters = Dict("model" => "ConstantLifetime", "model_inactive" => "ConstantLifetime", "parameters" => Dict("τh" => τ, "τe" => τ), "parameters_inactive" => Dict("τh" => τ_inactive, "τe" => τ_inactive),
"inactive_layer_geometry" => simA_inactive_layer_geometry)
trapping_model=CombinedChargeTrappingModel{T}(parameters)
trapping_model=CombinedChargeTrappingModel{T}(simA.detector.semiconductor.temperature, parameters)
simA.detector = SolidStateDetector(simA.detector, trapping_model)
evt_bulk = Event(pos_bulk , Edep)
timed_simulate!(evt_bulk, simA)
Expand Down Expand Up @@ -205,7 +201,7 @@ end
τ, τ_inactive = 1u"ms", 100u"ns"
parameters = Dict("model" => "ConstantLifetime", "model_inactive" => "ConstantLifetime", "parameters" => Dict("τh" => τ, "τe" => τ), "parameters_inactive" => Dict("τh" => τ_inactive, "τe" => τ_inactive),
"inactive_layer_geometry" => simA_inactive_layer_geometry)
trapping_model=CombinedChargeTrappingModel{T}(parameters)
trapping_model=CombinedChargeTrappingModel{T}(simA.detector.semiconductor.temperature, parameters)
simA.detector = SolidStateDetector(simA.detector, trapping_model)
signalsum_list_inactive = T[]
for depth in (0.1:0.1:0.9)/1000
Expand Down
Loading