SolidStateDetectors.jl icon indicating copy to clipboard operation
SolidStateDetectors.jl copied to clipboard

Allow for contact_id to be any Int

Open SebastianRuffert opened this issue 2 years ago • 10 comments

This should solve issue #288

SebastianRuffert avatar May 12 '22 11:05 SebastianRuffert

Thank you. I saw that also changes in the I/O. Will this change allow to read in saved simulations (so no changes for the user)?

fhagemann avatar May 12 '22 12:05 fhagemann

And what happens if two contacts have the same ID in the config file?

fhagemann avatar May 12 '22 12:05 fhagemann

Can you add tests where the contact IDs are not in order? And maybe also a case in which two contacts have the same ID and running the code fails.

fhagemann avatar May 16 '22 09:05 fhagemann

Thank you. I saw that also changes in the I/O. Will this change allow to read in saved simulations (so no changes for the user)?

Partly yes. Before, the different weighting potentials were initialized inside a list, while now that is being done in a dictionary, so now changes for the user in the rea-in of a config file. At least not ones, that I can think of now. What changes is the final struct. Meaning, if the user wants to access sim.weighting potentials a dict will be returned instead of a list.

SebastianRuffert avatar May 17 '22 07:05 SebastianRuffert

And what happens if two contacts have the same ID in the config file?

No error is thrown right now, when reading in a config file with two contacts of id: 1 and using simulate()

julia> sim = Simulation{Float32}("Software/SolidStateDetectors.jl/examples/example_config_files/contact_id_same_id.yaml")
julia> simulate!(sim)
Simulation{Float32, Cartesian} - Coordinate system: Cartesian
  Environment Material: High Purity Germanium
  Detector: Contact ID test file
  Electric potential: (58, 34, 34)
  Charge density: (58, 34, 34)
  Impurity scale: (58, 34, 34)
  Fix Charge density: (58, 34, 34)
  Dielectric distribution: (59, 35, 35)
  Point types: (58, 34, 34)
  Electric field: (58, 34, 34)
  Weighting potentials: 
    Contact 1: (14, 12, 12)
    Contact 1: (14, 12, 12)

But when accessing the weighting potentials directly, only one is shown

julia> sim.weighting_potentials
OrderedCollections.OrderedDict{Int64, Union{Missing, WeightingPotential}} with 1 entry:
  1 => [0.999674 0.999675 … 0.999684 0.999682; 0.999672 0.999676 … 0.999684 0.999681; … ; 0.999682 0.999686 … 0.999696 0.999692; 0.999684 0.999687 ……

How do we want to handle that case? We can throw an error if there is ambiguity in the contact ids. Another option is changing the ambigous contact id internally, maybe by adding one to the id or multiplying by 10.

SebastianRuffert avatar May 17 '22 10:05 SebastianRuffert

I get an error in

sim = Simulation(SSD_examples[:ContactIDTest])
simulate!(sim)
calculate_capacitance_matrix(sim)

lmh91 avatar May 24 '22 11:05 lmh91

Also,

sim = Simulation(SSD_examples[:ContactIDTest])
simulate!(sim)
calculate_weighting_potential!(sim, 4)

does actually calculate some field and stores it into the dict. This should throw an error.

lmh91 avatar May 24 '22 11:05 lmh91

And what happens if two contacts have the same ID in the config file?

How do we want to handle that case? We can throw an error if there is ambiguity in the contact ids. Another option is changing the ambigous contact id internally, maybe by adding one to the id or multiplying by 10.

No, we should throw an error in the construction of the SolidStateDetector.

lmh91 avatar May 24 '22 11:05 lmh91

sim = Simulation(SSD_examples[:ContactIDTest])
simulate!(sim)
calculate_weighting_potential!(sim, 4)

All calls of this function already use contact.id

SebastianRuffert avatar Jun 07 '22 10:06 SebastianRuffert

calculate_weighting_potential!(sim, 4)

But there is no contact with id == 4. That's the issue.

lmh91 avatar Jun 07 '22 10:06 lmh91