JuliaPhysics / JuliaPhysics/SolidStateDetectors.jl

Update `sim.config_dict` when saving a `Simulation` to a file

Open
#435 2 comments 0 reactions 0 assignees View on GitHub
convenience enhancement good first issue
Dominant language
Julia
Stars
178
Forks
59
Avg merge
1d 20h
Merged PRs (30d)
4

Description

A `Simulation` is usually created from a `config_dict`, which is saved under `sim.config_dict`.
However, when properties of a `Simulation` are changed within the code, e.g.
```julia
sim.detector = SolidStateDetector(sim.detector, ADLChargeDriftModel())
sim.detector = SolidStateDetector(sim.detector, BoggsChargeTrappingModel())
sim.detector = SolidStateDetector(sim.detector, contact_id = 1, contact_potential = 4000u"V")
sim.detector = SolidStateDetector(sim.detector, ConstantImpurityDensity(-1e15))
```
this is not updated in the `sim.config_dict`.

This is, in general, not a big issue. However, when saving a `Simulation` to an LH5 file and reading it back in, the `SolidStateDetector` will be constructed from the `sim.config_dict` and will have forgotten about the settings set interactively.

How I envision this:
When saving, we could add a check which constructs a new `Simulation` from the current `sim.config_dict`.
It, then, compares all initial fields of the new `Simulation` (excluding e.g. `electric_potential`, `electric_field`, `weighting_potentials`, ... which may or may not have been calculated) to the existing ones. If there is a mismatch, it should update the `sim.config_dict` accordingly, before saving it to a file.

Up for discussion would be whether such a `config_dict` up-to-date test should be optional or not.
And if so, whether it should be on by default or not.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.