Skip to content

Commit

Permalink
incorporate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
apmypb committed Nov 15, 2024
1 parent ba934fc commit 82b5113
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Simulation/DepletionVoltage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions test/depletion_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82b5113

Please sign in to comment.