Add contractor method and scale function to BouleImpurityDensity#484
Add contractor method and scale function to BouleImpurityDensity#484fhagemann merged 6 commits intoJuliaPhysics:mainfrom
Conversation
src/Simulation/Simulation.jl
Outdated
| max_tick_distance::Union{Missing, LengthQuantity, Tuple{LengthQuantity, <:Union{LengthQuantity, AngleQuantity}, LengthQuantity}} = missing, | ||
| max_distance_ratio::Real = 5, | ||
| depletion_handling::Bool = false, | ||
| depletion_tol = 0.1, |
There was a problem hiding this comment.
Maybe final comment: can you allow for this to also have units, so that you can pass depletion_tol = 0.1u“V“, using to_internal_units in the function below?
And add a short description to the docstring what it does.
src/Simulation/Simulation.jl
Outdated
| minimum_applied_potential = minimum(broadcast(c -> c.potential, sim.detector.contacts)) | ||
| @inbounds for i in eachindex(sim.electric_potential.data) | ||
| if sim.electric_potential.data[i] < minimum_applied_potential # p-type | ||
| if sim.electric_potential.data[i] < minimum_applied_potential - depletion_tol# p-type |
There was a problem hiding this comment.
I think you can use something like to_internal_units or _parse_value here.
(To internal units probably only makes sense if you force the type of depletion_tol to be eather a Real or a Quantity of dimension voltage)
There was a problem hiding this comment.
Do we need this check at all? It seems to me it slows down the EP calculation just to give a warning that we would like to mostly get rid of. Maybe we could have another keyword like check_for_depletion_overshoots::Bool = false
There was a problem hiding this comment.
We could do both: add a depletion_tol and adding a keyword to avoid this check
There was a problem hiding this comment.
This check was initially implemented to check for obvious overshoots.
If the detector is not fully depleted but the potential calculation is run with depletion_handling = false, this warning should be more useful. However, it looks like we're only checking for this with depletion_handling = true.
I just ran an example where we expect the detector to NOT be depleted and where such a warning might be useful:
using SolidStateDetectors
# create inverted coax with 0V at point contact and 500V at outer contact
sim = Simulation(SSD_examples[:InvertedCoax])
sim.detector = SolidStateDetector(sim.detector, contact_id = 2, contact_potential = 500)
# calculate electric potential with explicit depletion_handling = false
calculate_electric_potential!(sim, depletion_handling = false)
# check for extreme values in the electric potential
extrema(sim.electric_potential.data)(-1192.5739f0, 500.00302f0)
There was a problem hiding this comment.
Also, if you are sure that your detector is fully depleted, you can just set depletion_handling = false here to avoid the check and displaying the warning.
|
To speed this PR up: can you split this into two PRs? This one JUST having the scaling of These two are code-wise unrelated. |
src/Simulation/Simulation.jl
Outdated
| minimum_applied_potential = minimum(broadcast(c -> c.potential, sim.detector.contacts)) | ||
| @inbounds for i in eachindex(sim.electric_potential.data) | ||
| if sim.electric_potential.data[i] < minimum_applied_potential # p-type | ||
| if sim.electric_potential.data[i] < minimum_applied_potential - depletion_tol# p-type |
There was a problem hiding this comment.
Also, if you are sure that your detector is fully depleted, you can just set depletion_handling = false here to avoid the check and displaying the warning.
|
I don't think we need to add tests or documentations just yet. I would like for it to be fully stable first |
|
But then in general, we should have put this on a separate branch then and merged it once it is finalized.. |
|
Yes, I already removed the changes to |
User can now construct BouleImpurityDensities from a unitfull vector and value like so:
Then units are automatically converted to SSD internal units.
Scaling of BouleImpurityDensities is also now possible with:
scale*idmWhich will scale the correct parameters in the
BouleImpurityDensitysuch the numerical value calculated by get_impurity_density would be scaled accordingly.I also added a tolerance for the warning when using depletion handling:
""Detector seems not to be not fully depleted at a bias voltage of""...This warning appears almost every time and should be dropped unless it falls out of the given tolerance