Skip to content

Update sim.config_dict when saving a Simulation to a file #435

@fhagemann

Description

@fhagemann

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions