Skip to content

Commit

Permalink
Allow units when setting a contact potential
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann committed Nov 15, 2024
1 parent 464b1d2 commit 93bb4ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/SolidStateDetector/SolidStateDetector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function SolidStateDetector(det::SolidStateDetector{T}, charge_trapping_model::A
det.name, sc, det.contacts, det.passives, det.virtual_drift_volumes
)
end
function SolidStateDetector(det::SolidStateDetector{T}; contact_id::Int, contact_potential::Real) where {T <: SSDFloat}
function SolidStateDetector(det::SolidStateDetector{T}; contact_id::Int, contact_potential::RealQuantity) where {T <: SSDFloat}
oc = det.contacts[contact_id]
nc = Contact(T(contact_potential), oc.material, oc.id, oc.name, oc.geometry )
nc = Contact(_parse_value(T, contact_potential, internal_voltage_unit), oc.material, oc.id, oc.name, oc.geometry )
contacts = [c.id == contact_id ? nc : c for c in det.contacts]
SolidStateDetector{T}( det.name, det.semiconductor, contacts, det.passives, det.virtual_drift_volumes )
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ end
display(testtimer())

@timed_testset "Depletion estimation" begin
include("depletion_test.jl")
include("test_depletion.jl")
end
8 changes: 4 additions & 4 deletions test/depletion_test.jl → test/test_depletion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ T = Float32
calculate_weighting_potential!(sim, id, refinement_limits=0.01)
SolidStateDetectors._adapt_weighting_potential_to_electric_potential_grid!(
sim, id)
U_est = ustrip(estimate_depletion_voltage(sim)) # around 2600
ΔU = 50
U_est = estimate_depletion_voltage(sim) # around 2600
ΔU = 50u"V"
# 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=id, contact_potential=U₊)
calculate_electric_potential!(sim, refinement_limits=0.01, depletion_handling=true)
undepleted = !is_depleted(sim.point_types)
sim.detector = SolidStateDetector(sim.detector, contact_id=1, contact_potential=U₋)
sim.detector = SolidStateDetector(sim.detector, contact_id=id, contact_potential=U₋)
calculate_electric_potential!(sim, refinement_limits=0.01, depletion_handling=true)
depleted = is_depleted(sim.point_types)
@test undepleted && depleted
Expand Down

0 comments on commit 93bb4ce

Please sign in to comment.