Skip to content

Runtime-defined fluid properties #148

@jasonlharvey

Description

@jasonlharvey

Add the ability for users to define custom bulk fluid types and their properties (FluidProperties class) and make these usable in fluid networks, all via the input file, without needing to recompile any GUNNS code or networks or the Trick sim.

This is similar in concept to how we can add custom Trace Compounds to a network in the input file.

Currently, GUNNS networks can only use bulk fluid properties defined in the DefinedFluidProperties class (FluidProperties.hh). When projects need a new fluid type, they either must ask the GUNNS development team to add it, or modify the FluidProperties code themselves and then run with that fork. This upgrade would allow users an easier option that doesn't create code conflicts or poke any eyes out, or as a temporary workaround until we can add it to the repo.

Minimize impact to the rest of the fluid aspect. The fluid network (PolyFluid class, etc.) accesses fluid properties by requesting their type via the FluidProperties::FluidType enumeration in DefinedFluidProperties::getProperties(const FluidProperties::FluidType&). I don't want to change that - even overloading it with a different argument like a string name would bloat PolyFluid and I don't know what else to the point that it wouldn't be worth it We used an enumeration following the 'make it hard to use wrong' tenet of OOAD, but that sacrificed customization. Enumerations can't be changed in runtime, so we'd either need to add a fixed range of enumerators at the end (like GUNNS_CUSTOM_0 ... _9, etc.), or change FluidType from an enumeration to some fancy custom enumeration-like template class or such, but something like the latter would still require some sim rebuild to use. So probably just going to add a fixed range of 'custom' enumerators to the existing enumeration. All the code changes will be limited to FluidProperties and DefinedFluidProperties.

Another problem is that DefinedFluidProperties is declared const in generated fluid network code, but we need to be able to extend its internal FluidProperties array with runtime-defined FluidProperties prior to init. It was intended to be immutable in runtime so users couldn't break it. That was 15 years ago, and nowadays we are less strict and I don't care if they break it. We can change the GunnsDraw export templates to no longer declare it const, with a disclaimer on this whole new feature that you use custom fluid properties at your own risk and probably won't get support for problems with them.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions