From 82b5113051f650dbd1c37422804f2dc62a26c975 Mon Sep 17 00:00:00 2001 From: Arthur Butorev Date: Thu, 14 Nov 2024 09:44:03 +0100 Subject: [PATCH] incorporate changes --- src/Simulation/DepletionVoltage.jl | 2 +- test/depletion_test.jl | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Simulation/DepletionVoltage.jl b/src/Simulation/DepletionVoltage.jl index 9f48d56b5..84074990a 100644 --- a/src/Simulation/DepletionVoltage.jl +++ b/src/Simulation/DepletionVoltage.jl @@ -110,7 +110,7 @@ function estimate_depletion_voltage(sim::Simulation{T}, bulk = findall(sim.point_types.data .& bulk_bit .> 0) U_min_max = filter(in(Urng), _find_depletion_voltage_candidates(ϕρ, ϕV, bulk)) U2 = isempty(U_min_max) ? U : only(U_min_max) - U = U > 0 ? min(U, U2) : min(U, U2) + U = U > 0 ? max(U, U2) : min(U, U2) if verbose @info "The depletion voltage is around $(round(U, digits = Int(ceil(-log10(tolerance))))) ± $(tolerance) V applied to contact $(contact_id)." if (potential_range[2] - U) < tolerance || (U - potential_range[1]) < tolerance diff --git a/test/depletion_test.jl b/test/depletion_test.jl index cc085ad8b..3d8cebc2b 100644 --- a/test/depletion_test.jl +++ b/test/depletion_test.jl @@ -9,16 +9,21 @@ T = Float32 calculate_electric_potential!(sim, refinement_limits=0.01) id = SolidStateDetectors.determine_bias_voltage_contact_id(sim.detector) calculate_weighting_potential!(sim, id, refinement_limits=0.01) - SolidStateDetectors._adapt_weighting_potential_to_electric_potential_grid!(sim, id) + SolidStateDetectors._adapt_weighting_potential_to_electric_potential_grid!( + sim, id) U_est = ustrip(estimate_depletion_voltage(sim)) # around 2600 ΔU = 50 # simulate over and under depletion voltage U₋ = U_est - ΔU U₊ = U_est + ΔU - sim.detector = SolidStateDetector(sim.detector, contact_id=1, contact_potential=U₊) + sim.detector = SolidStateDetector( + sim.detector, contact_id=1, contact_potential=U₊, + depletion_handling=true) calculate_electric_potential!(sim, refinement_limits=0.01) undepleted = is_depleted(sim.point_types) - sim.detector = SolidStateDetector(sim.detector, contact_id=1, contact_potential=U₋) + sim.detector = SolidStateDetector( + sim.detector, contact_id=1, contact_potential=U₋, + depletion_handling=true) calculate_electric_potential!(sim, refinement_limits=0.01) depleted = is_depleted(sim.point_types) @test undepleted && depleted