integration_param dictionary input deletes existing defaults
Closed this issue · 2 comments
When specifying an integration_param input dictionary manually for a HOPS trajectory calculation, the default dictionary is completely overwritten, removing any non-specified settings entirely. For example, in the quickstart guide, integration parameters are set in the following dictionary:
integration_param = {"INTEGRATOR": "RUNGE_KUTTA"}
However, if running a hops trajectory:
from mesohops.dynamics.hops_trajectory import HopsTrajectory as HOPS
hops = HOPS(
sys_param,
noise_param=noise_param,
hierarchy_param=hierarchy_param,
eom_param=eom_param,
integration_param=integration_param,
)
in which all other dictionaries are satisfied, this will result in a key error for a missing "EARLY_ADAPTIVE_INTEGRATOR" dictionary entry rather than maintaining the default dictionary
integration_param=dict(
INTEGRATOR="RUNGE_KUTTA",
EARLY_ADAPTIVE_INTEGRATOR='INCH_WORM',
EARLY_INTEGRATOR_STEPS=5,
INCHWORM_CAP=5,
STATIC_BASIS=None,
EFFECTIVE_NOISE_INTEGRATION=False,
)
in any portion.
Thank you for raising this issue. The error here is in the hops_trajectory.py. The problem is that unlike all of the other dictionaries, we don't define a default for the integration_param dictionary. It looks like this was an oversight when we implemented all of the extensions on the integration options.
The simplest solution would probably be to construct a default dictionary in the hops_trajectory.py file and then use the dictionary update() method to override the default values with the user selections. It might be worth putting out a small patch to fix this specific problem since it should be a pretty minimal change and - as you noted - the tutorials don't currently work. We should also add a couple of tests to make sure the defaults are working for each of the input dictionaries.
MesoHOPS 1.4.2 solves the issue using the default dictionary solution and adds a test!