cholla-hydro / cholla

A GPU-based hydro code
https://github.com/cholla-hydro/cholla/wiki
MIT License
60 stars 32 forks source link

Introducing ``ParameterMap`` #393

Closed mabruzzo closed 2 weeks ago

mabruzzo commented 1 month ago

Adds a new ParameterMap class to assist with parameter parsing.

Motivation

Currently, Cholla works by storing runtime parameters within a global Parameters struct/class and then the instance of the Parameters struct gets passed around to various parts of the code, which read needed values from the struct. While there is nothing wrong with our current system (it definitely gets the job done!), there are a couple of drawbacks.

For example:

Athena++ (and more recently, Enzo-E) adopt a cool solution where they initialize an instance of a class that stores all the arbitrary collection of specified parameters and their values (Athena++ calls it ParameterInput).

This PR doesn't try to do all of that. Instead, we essentially take the first step towards that system. We introduce a class like ParameterInput.

Overview

This class introduces the ParameterMap class. This class is used to store the contents of a parameter file like a "map" (or a python dictionary). It provide methods to access the values associated with a given parameter along with the expected type. It also has the ability to specify a default value.

In the future, the idea would be to pass around an instance of this map to configure various "submodules". For example, it would be easy to do this to specify runtime args for the feedback module introduced by PR #386 or the galaxy ICs in #387 or configuring the grackle module.

mabruzzo commented 1 month ago

From the failing tests, I assume I made a logical error somewhere. My best guess is that it's related to reading in options passed on the command line? (if so that could have happened during the rebase)

I need to fix that issue. But otherwise, I think people can still review this PR (I don't think anything will change much)