Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

Allow Global Defaults for Constants to be Locally Overridden

Open smiths opened this issue 1 year ago • 8 comments

As discussed in #3300, If we change g for one example (say to 9.81 for more precision, or to 10 for less precision, or to a value for high (or low) elevation, or for a change of units (like 32.2 ft/s^2 for imperial units), we change it for all code that depends on g (https://github.com/JacquesCarette/Drasil/blob/f81c9a7188767a6a0446285d8f817c7ea01a246e/code/drasil-data/lib/Data/Drasil/Quantities/Physics.hs#L147-L148)

smiths avatar Mar 08 '23 14:03 smiths

Ignoring the theory approach to finding particular gravity constants, are we able to have a custom "gravity" ConstQDef added to the _constants field of the case study's SystemInformation to override it without affecting the other examples?

https://github.com/JacquesCarette/Drasil/blob/e4b3354f1d8586ff25fec845ea9618af4bff25fe/code/drasil-sysinfo/lib/SysInfo/Drasil/SystemInformation.hs#L37-L66

balacij avatar Mar 09 '23 23:03 balacij

Note that the above solution might be suboptimal (i.e., "hacky") because we're sharing UIDs but have different data (so if we have references to the original gravity, we would be referring to that while seeing the "new" one).

balacij avatar Mar 09 '23 23:03 balacij

Whether how you define the local constants is a good approach is a question for @JacquesCarette. However, from a usability point of view, this solution seems usable and simple to me.

smiths avatar Mar 10 '23 16:03 smiths

There is no need to use gravitionalAccelConst verbatim. We could define our own. The problem with that is that if we re-use anything in our standard definitions that do rely on gravitatationalAccelConst, now things will stop working. So we'd have to rebuild everything that uses that.

This is where we really want to have a proper "theory" system, as well as a proper system of concepts and quantities. We want theories that are explicitly parametric in certain concepts (like acceleration due to gravity) that we can explicitly refine ourselves. It would make sense to have some of them exist pre-refined in our knowledge base, but also others that are ready to be refined.

This example alone reinforces two things:

  • we need to move to theories and refinements
  • we need to have a better split between concepts and quantities

It also seems to nudge us towards taking some things that currently sit outside theories and to put them inside a theory. I think I'd want the above two items implemented first before deciding.

JacquesCarette avatar Mar 10 '23 20:03 JacquesCarette

I'll also add this to the next in-person meeting (specifically for the 'theory' discussion). :smile:

balacij avatar Mar 11 '23 20:03 balacij

Does anyone remember what we spoke about in the meeting? :sweat_smile:

balacij avatar May 04 '23 02:05 balacij

If we came up with a design then... no.

JacquesCarette avatar May 04 '23 17:05 JacquesCarette

@balacij I'm fairly sure that nothing new came up in the meeting. I don't remember the details, but I also don't remember that feeling of "now we got it!". I think Jacques comment above is essentially where we left this topic.

smiths avatar May 04 '23 17:05 smiths