Skip to content

Generalize droplet mixture calculations#613

Merged
baperry2 merged 14 commits intoAMReX-Combustion:developmentfrom
d-montgomery:gcm-dev
Aug 28, 2025
Merged

Generalize droplet mixture calculations#613
baperry2 merged 14 commits intoAMReX-Combustion:developmentfrom
d-montgomery:gcm-dev

Conversation

@d-montgomery
Copy link
Copy Markdown
Contributor

This PR creates mixture property functions within the MPLiqProps struct for the following:

  • boiling point boilT_mix
  • critical temp critT_mix
  • specific heat cp_mix
  • thermal conductivity lambda_mix
  • dynamic viscosity mu_mix
  • surface tension sigma_mix

Note that rho_mix was included in #602. Managing the mixture averaged molecular weight of the spray is still a work in progress and not included here.

@d-montgomery d-montgomery requested a review from baperry2 August 25, 2025 22:52
@baperry2
Copy link
Copy Markdown
Contributor

Can you explain what's going on with the different versions of each function with and without cBoilT? Could they be combined into a single implementation where the cBoilT argument defaults to a huge value to reduce repeated code?

Also, maybe we should be adding some documentation for the liqProps stuff now, before a documentation debt builds up too much.

@d-montgomery
Copy link
Copy Markdown
Contributor Author

d-montgomery commented Aug 25, 2025

Can you explain what's going on with the different versions of each function with and without cBoilT? Could they be combined into a single implementation where the cBoilT argument defaults to a huge value to reduce repeated code?

The idea behind the overloaded functions was a result of some mixture density calls that used a single droplet temp like this one, while many others used a limited component-specific temperature minT = amrex::min(T_part, cBoilT[spf]). The later case was the most common and is used for all other mixture properties.

Also, maybe we should be adding some documentation for the liqProps stuff now, before a documentation debt builds up too much.

Everything we've done so far has been organizational and hasn't changed how the spray module is called from LMeX or C. I can add a brief overview of the liquid property functions used for the PeleMP method if you'd like.

@d-montgomery
Copy link
Copy Markdown
Contributor Author

I updated all the mixture functions to include a null_ptr for the third argument cBoilT, which defaults to AMREX_REAL_MAX if no pointer is passed in. This allows for a single function to handle both calls with and without cBoilT. I tested the changes with the SingleDropEvap test in LMeX and everything works as expected. This should be good to go now.

@baperry2
Copy link
Copy Markdown
Contributor

The RealArrayLike templates are designed to work for any data type that returns amrex::Real from the [] operator. Should we be more explicit about this requirement in the code?

One strategy would to be to create a helper struct:

  // Helper trait to check if T has operator[] returning amrex::Real& or const amrex::Real&
  template <typename T>
  struct is_real_array_like {
    template <typename U>
    static auto test(U* u) -> std::integral_constant<
      bool,
      std::is_same<decltype((*u)[0]), amrex::Real&>::value ||
      std::is_same<decltype((*u)[0]), const amrex::Real&>::value>;
    template <typename>
    static auto test(...) -> std::false_type;
    static constexpr bool value = decltype(test<T>(0))::value;
  };

And then in each template include a static assert:

static_assert(is_real_array_like<RealArrayLike1>::value,
               "RealArrayLike1 must have an operator[] that returns const amrex::Real&");

This has no effect on code behavior or what can compile, but makes expectations more explicit/might increase readability of the code. But it also adds significant verbosity and can potentially add confusion rather than reduce it if the reader isn't as familiar with C++.

@d-montgomery d-montgomery requested a review from Copilot August 27, 2025 19:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors droplet mixture calculations by creating dedicated mixture property functions within the MPLiqProps struct. It generalizes the calculation of various thermophysical properties for liquid fuel mixtures in spray simulations, improving code reusability and maintainability.

  • Adds new mixture property functions for boiling point, critical temperature, specific heat, thermal conductivity, dynamic viscosity, and surface tension
  • Removes parameter reference indicators (&) from function signatures to simplify the interface
  • Refactors existing code to use the new mixture functions instead of manual loop-based calculations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Source/Spray/SprayProperties.H Adds new mixture property functions and removes reference parameters from existing functions
Source/Spray/Drag.H Replaces manual mixture calculations with new mixture property functions
Source/Spray/BreakupSplash/WallFilm.H Refactors to use mixture property functions for film calculations
Source/Spray/BreakupSplash/TABBreakup.H Updates breakup calculations to use mixture functions
Source/Spray/BreakupSplash/ReitzKHRT.H Modernizes breakup model to use mixture property functions
Source/Spray/BreakupSplash/AhamedSplash.H Updates splashing model to use mixture functions
Docs/sphinx/Spray.rst Reorganizes documentation and adds dedicated section for liquid spray properties

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Helper function to get effective temperature considering boiling point
template <typename cBoilTLike>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real effectiveT(
const amrex::Real& T, const int spf, const cBoilTLike& cBoilT) const
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the template typename "cBoilTLike" - the reader probably has no idea what that means and it's redundant with the variable name. cBoilT just has to be RealArrayLike as defined here - it could be a GpuArray of amrex::Real, a pointer to amrex::Real, or in principal even something else like amrex::CellData.

I'm also not wild about this helper function in general because it doesn't actually simplify the code, but I'm fine with leaving it in if you think it makes the intent of the code more clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. I removed the helper function and replaced cBoilTLike with RealArrayLike2 per your previous implementation idea.

@baperry2 baperry2 enabled auto-merge (squash) August 28, 2025 18:12
@baperry2 baperry2 merged commit ef85246 into AMReX-Combustion:development Aug 28, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants