Skip to content

Conversation

@hyeoksu-lee
Copy link
Contributor

@hyeoksu-lee hyeoksu-lee commented Nov 25, 2025

User description

User description

Description

In the broader context, I'm working on integrating the initialization process and generalizing the normalization of EE/EL bubbles. This PR is the first step toward reducing redundancy and inconsistency across the bubble modules.

  • Removing a hard coded gas constant Ru defined in s_initialize_nonpoly, which is already defined as 'R_uniinm_constants.fpp`
  • Removing a hard coded diffusion coefficient D_m defined in s_initialize_nonpoly, which is an input parameter lag_params%diffcoefvap used for EL bubbles. Moved it to fluid_pp%D_v to make it available for both of EE/EL bubbles.

Examples and tests are updated accordingly.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Scope

  • This PR comprises a set of related changes with a common goal

If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.

How Has This Been Tested?

  • test suite on MacBook M4 Pro

Test Configuration:

Checklist

  • I have added comments for the new code
  • I added Doxygen docstrings to the new code
  • I have made corresponding changes to the documentation (docs/)
  • I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • I have added example cases in examples/ that demonstrate my new feature performing as expected.
    They run to completion and demonstrate "interesting physics"
  • I ran ./mfc.sh format before committing my code
  • New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

If your code changes any code source files (anything in src/simulation)

To make sure the code is performing as expected on GPU devices, I have:

  • Checked that the code compiles using NVHPC compilers
  • Checked that the code compiles using CRAY compilers
  • Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
  • Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
  • Enclosed the new feature via nvtx ranges so that they can be identified in profiles
  • Ran a Nsight Systems profile using ./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR
  • Ran a Rocprof Systems profile using ./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.
  • Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature

PR Type

Bug fix, Enhancement


Description

  • Moved vapor diffusivity from lag_params%diffcoefvap to fluid_pp%D_v

    • Eliminates redundancy between EE and EL bubble models
    • Makes diffusivity available for both bubble types
  • Replaced hardcoded gas constant Ru with R_uni from constants

    • Removes duplicate definition in initialization code
  • Updated all related initialization, MPI broadcast, and example configurations


Diagram Walkthrough

flowchart LR
  A["lag_params%diffcoefvap"] -->|Move to| B["fluid_pp%D_v"]
  C["Hardcoded Ru"] -->|Replace with| D["R_uni constant"]
  B -->|Available for| E["EE/EL Bubbles"]
  D -->|Centralized| F["All bubble models"]
Loading

File Walkthrough

Relevant files
Enhancement
5 files
m_derived_types.fpp
Add vapor diffusivity field to physical parameters             
+2/-1     
m_global_parameters.fpp
Initialize D_v field in fluid parameters                                 
+1/-0     
m_mpi_proxy.fpp
Add D_v to MPI broadcast for fluid parameters                       
+1/-0     
m_global_parameters.fpp
Initialize D_v field in fluid parameters                                 
+1/-0     
m_mpi_proxy.fpp
Add D_v to MPI broadcast for fluid parameters                       
+2/-2     
Bug fix
4 files
m_helper.fpp
Replace hardcoded constants with centralized definitions 
+3/-6     
m_bubbles_EL.fpp
Replace lag_params diffusivity with fluid_pp D_v                 
+3/-3     
m_global_parameters.fpp
Remove diffcoefvap, add D_v to fluid parameters                   
+1/-1     
m_mpi_proxy.fpp
Remove diffcoefvap, add D_v to MPI broadcast                         
+2/-2     
Configuration changes
4 files
case.py
Update example to use fluid_pp D_v parameter                         
+2/-0     
case.py
Update example to use fluid_pp D_v parameter                         
+1/-1     
case.py
Update example to use fluid_pp D_v parameter                         
+1/-1     
case_dicts.py
Remove diffcoefvap, add D_v to parameter definitions         
+4/-4     
Tests
2 files
case.py
Remove diffcoefvap from test case defaults                             
+0/-1     
cases.py
Update test cases to use fluid_pp D_v parameter                   
+5/-3     


CodeAnt-AI Description

Treat vapor diffusivity as a fluid property for bubble calculations

What Changed

  • Bubble initialization and mass/mass-transfer coefficients now use the diffusivity stored in each fluid’s parameters and rely on the shared universal gas constant, removing the redundant hard-coded values.
  • MPI broadcasts and default-value routines now cover the vapor diffusivity field so parallel runs share the same value that the bubble calculations rely on.
  • Example and test configurations now populate vapor diffusivity through the bubble gas fluid entries, making the required input explicit.

Impact

✅ Consistent vapor diffusion across bubble setups
✅ Accurate mass-transfer behavior in parallel bubble simulations
✅ Example cases capture vapor diffusivity input requirements

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Refactor

    • Moved vapor diffusivity into per-fluid properties and removed the legacy Lagrangian diffusion parameter for unified diffusivity handling.
    • Ensured the new per-fluid diffusivity is propagated across distributed runs for consistent multi-process behavior.
  • Chores

    • Updated configuration presets and test cases to reflect the new parameter layout.
  • Documentation

    • Added guidance for the new per-fluid diffusivity parameter and removed references to the old diffusion parameter.

✏️ Tip: You can customize this high-level summary in your review settings.

@hyeoksu-lee hyeoksu-lee requested review from a team November 25, 2025 23:15
@codeant-ai
Copy link

codeant-ai bot commented Nov 25, 2025

CodeAnt AI is reviewing your PR.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Move vapor diffusion coefficient from Lagrangian bubble parameter lag_params%diffcoefvap into a per-fluid parameter fluid_pp(i)%D_v; update derived types, initializations, MPI broadcasts, physics calculations, examples, toolchain mappings, tests, and documentation to use D_v instead.

Changes

Cohort / File(s) Summary
Derived types
src/common/m_derived_types.fpp
Add D_v (real(wp)) to physical_parameters; remove diffcoefvap from bubbles_lagrange_parameters.
Global parameter init
src/pre_process/m_global_parameters.fpp, src/simulation/m_global_parameters.fpp, src/post_process/m_global_parameters.fpp
Initialize fluid_pp(i)%D_v = dflt_real in per-fluid loops; remove default/assignments for lag_params%diffcoefvap.
MPI broadcast / proxy
src/pre_process/m_mpi_proxy.fpp, src/simulation/m_mpi_proxy.fpp, src/post_process/m_mpi_proxy.fpp
Add fluid_pp(i)%D_v to per-fluid broadcast lists; remove diffcoefvap from lagrange broadcast lists.
Physics helper
src/common/m_helper.fpp
Replace hard-coded/previous diffusivity initialization with fluid_pp(2)%D_v; update universal gas constant symbol usage to R_uni/... where adjusted.
Bubble dynamics
src/simulation/m_bubbles_EL.fpp
Replace uses of lag_params%diffcoefvap with fluid_pp(... )%D_v in diffusion/transfer calculations (Pe, betaC, related formulas).
Examples
examples/1D_qbmm/case.py, examples/3D_lagrange_bubblescreen/case.py, examples/3D_lagrange_shbubcollapse/case.py
Add fluid_pp(2)%D_v entries with respective values; remove or stop using lag_params%diffcoefvap.
Toolchain mappings
toolchain/mfc/run/case_dicts.py
Add D_v to real attributes for fluid_pp in PRE_PROCESS / SIMULATION / POST_PROCESS; remove diffcoefvap from lag parameter lists.
Tests
toolchain/mfc/test/case.py, toolchain/mfc/test/cases.py
Remove lag_params%diffcoefvap from BASE_CFG; add fluid_pp(2)%D_v entries in bubble-related test cases.
Docs
docs/documentation/case.md
Document new D_v (vapor diffusivity) under sub-grid bubble model; remove diffcoefvap mention from volume-averaged bubble model section.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Config as Config / Examples
  participant Pre as Pre-process
  participant MPI as MPI proxy
  participant Sim as Simulation
  participant Phys as m_helper / m_bubbles_EL

  rect rgb(240,248,255)
    Config->>Pre: supply `fluid_pp(2)%D_v` or use default
    Pre->>MPI: include `fluid_pp(i)%D_v` in broadcast set
    MPI->>Sim: broadcast `fluid_pp(i)%D_v` to all ranks
  end

  rect rgb(245,255,240)
    Sim->>Phys: request diffusivity for computations
    Phys-->>Sim: use `fluid_pp(... )%D_v` in Pe, betaC, D_m calculations
  end

  note right of Phys `#f7f7c9`: `lag_params%diffcoefvap` removed — replaced by `fluid_pp% D_v`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring attention:
    • MPI broadcast lists and consistent ordering/layout across ranks.
    • Units/normalization where D_v replaces previous diffcoefvap values.
    • Example/test numeric values and defaults to ensure parity with prior behavior.

Suggested labels

size:L

Poem

🐰 I hopped a value from nest to stream,
D_v now wanders through every scheme,
Bubbles sniff a fresher breeze,
Diffusion flows with subtler ease,
Carrots clap for tidy code and dream.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'reduce redundancy in bubbles' is vague and does not clearly convey the specific changes made in the PR. Use a more descriptive title that specifies the key changes, such as 'Move vapor diffusivity to fluid parameters and consolidate gas constants' or 'Centralize bubble diffusivity and gas constant parameters'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers the changes, includes clear motivation (reducing redundancy between EE and EL bubble models), specifies type of change, scope, and provides detailed file-level walkthrough with diagrams and test notes.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review qodo-code-review bot changed the title reduce redundancy in bubbles reduce redundancy in bubbles Nov 25, 2025
@qodo-code-review
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The code uses fluid_pp(num_fluids)%D_v for PeG and gas_betaC, which assumes the bubble gas is always the last fluid. Verify that num_fluids consistently indexes the bubble gas across EE/EL cases; otherwise use the established id_bubbles/id_host indexing to avoid mismatches.

PeG = bub_R0(bub_id)**2._wp*omegaN_local/fluid_pp(num_fluids)%D_v
call s_transcoeff(1._wp, PeG, Re_trans, Im_trans)
gas_betaC(bub_id) = Re_trans*(massflag)*fluid_pp(num_fluids)%D_v
Unit Scaling

D_v is rescaled in-place on fluid_pp(id_bubbles)%D_v. Confirm that D_v is defined in dimensional form in inputs and that no other code paths assume unscaled D_v later in the run, to prevent double-scaling or inconsistent units between modules.

fluid_pp(id_bubbles)%D_v = fluid_pp(id_bubbles)%D_v/(x0*c0)
ss = fluid_pp(id_host)%ss/(rho0*x0*c0*c0)
mul0 = fluid_pp(id_host)%mul0/(rho0*x0*c0)
Init Default

fluid_pp(i)%D_v is initialized with dflt_Real; ensure the exact case matches the declared constant (elsewhere dflt_real). A mismatch could cause build or unintended defaults.

    fluid_pp(i)%D_v = dflt_Real
end do

@codeant-ai codeant-ai bot added the size:S This PR changes 10-29 lines, ignoring generated files label Nov 25, 2025
@codeant-ai codeant-ai bot changed the title reduce redundancy in bubbles reduce redundancy in bubbles Nov 25, 2025
@codeant-ai
Copy link

codeant-ai bot commented Nov 25, 2025

CodeAnt AI finished reviewing your PR.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
src/simulation/m_bubbles_EL.fpp (1)

389-391: Migration from lag_params to fluid_pp is correct, but consider using id_bubbles for consistency.

The replacement of lag_params%diffcoefvap with fluid_pp(num_fluids)%D_v properly implements the migration to per-fluid vapor diffusivity parameters. However, there is an inconsistency in identifier usage:

  • Line 181 in s_start_lagrange_inputs uses id_bubbles (where id_bubbles = num_fluids)
  • Lines 389 and 391 in s_add_bubbles use num_fluids directly

For improved clarity and maintainability, consider using id_bubbles consistently throughout both subroutines, as suggested in the previous review comment. This would make the code's intent more explicit: accessing bubble gas properties specifically, rather than "the last fluid."

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11375f3 and 74c2257.

📒 Files selected for processing (15)
  • examples/1D_qbmm/case.py (2 hunks)
  • examples/3D_lagrange_bubblescreen/case.py (2 hunks)
  • examples/3D_lagrange_shbubcollapse/case.py (2 hunks)
  • src/common/m_derived_types.fpp (1 hunks)
  • src/common/m_helper.fpp (1 hunks)
  • src/post_process/m_global_parameters.fpp (1 hunks)
  • src/post_process/m_mpi_proxy.fpp (1 hunks)
  • src/pre_process/m_global_parameters.fpp (1 hunks)
  • src/pre_process/m_mpi_proxy.fpp (1 hunks)
  • src/simulation/m_bubbles_EL.fpp (2 hunks)
  • src/simulation/m_global_parameters.fpp (1 hunks)
  • src/simulation/m_mpi_proxy.fpp (2 hunks)
  • toolchain/mfc/run/case_dicts.py (4 hunks)
  • toolchain/mfc/test/case.py (0 hunks)
  • toolchain/mfc/test/cases.py (2 hunks)
💤 Files with no reviewable changes (1)
  • toolchain/mfc/test/case.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{fpp,f90}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{fpp,f90}: Use 2-space indentation; continuation lines align beneath &
Use lower-case keywords and intrinsics (do, end subroutine, etc.)
Name modules with m_ pattern (e.g., m_transport)
Name public subroutines with s_ pattern (e.g., s_compute_flux)
Name public functions with f
_ pattern
Keep subroutine size ≤ 500 lines, helper subroutines ≤ 150 lines, functions ≤ 100 lines, files ≤ 1000 lines
Limit routine arguments to ≤ 6; use derived-type params struct if more are needed
Forbid goto statements (except in legacy code), COMMON blocks, and save globals
Every argument must have explicit intent; use dimension/allocatable/pointer as appropriate
Call s_mpi_abort() for errors, never use stop or error stop

**/*.{fpp,f90}: Indent 2 spaces; continuation lines align under &
Use lower-case keywords and intrinsics (do, end subroutine, etc.)
Name modules with m_<feature> prefix (e.g., m_transport)
Name public subroutines as s_<verb>_<noun> (e.g., s_compute_flux) and functions as f_<verb>_<noun>
Keep private helpers in the module; avoid nested procedures
Enforce size limits: subroutine ≤ 500 lines, helper ≤ 150, function ≤ 100, module/file ≤ 1000
Limit subroutines to ≤ 6 arguments; otherwise pass a derived-type 'params' struct
Avoid goto statements (except unavoidable legacy); avoid global state (COMMON, save)
Every variable must have intent(in|out|inout) specification and appropriate dimension / allocatable / pointer
Use s_mpi_abort(<msg>) for error termination instead of stop
Use !> style documentation for header comments; follow Doxygen Fortran format with !! @param and !! @return tags
Use implicit none statement in all modules
Use private declaration followed by explicit public exports in modules
Use derived types with pointers for encapsulation (e.g., pointer, dimension(:,:,:) => null())
Use pure and elemental attributes for side-effect-free functions; combine them for array ...

Files:

  • src/common/m_derived_types.fpp
  • src/post_process/m_mpi_proxy.fpp
  • src/common/m_helper.fpp
  • src/simulation/m_global_parameters.fpp
  • src/pre_process/m_mpi_proxy.fpp
  • src/pre_process/m_global_parameters.fpp
  • src/simulation/m_mpi_proxy.fpp
  • src/post_process/m_global_parameters.fpp
  • src/simulation/m_bubbles_EL.fpp
src/**/*.fpp

📄 CodeRabbit inference engine (.cursor/rules/mfc-agent-rules.mdc)

src/**/*.fpp: Use .fpp file extension for Fypp preprocessed files; CMake transpiles them to .f90
Start module files with Fypp include for macros: #:include 'macros.fpp'
Use the fypp ASSERT macro for validating conditions: @:ASSERT(predicate, message)
Use fypp macro @:ALLOCATE(var1, var2) for device-aware allocation instead of standard Fortran allocate
Use fypp macro @:DEALLOCATE(var1, var2) for device-aware deallocation instead of standard Fortran deallocate

Files:

  • src/common/m_derived_types.fpp
  • src/post_process/m_mpi_proxy.fpp
  • src/common/m_helper.fpp
  • src/simulation/m_global_parameters.fpp
  • src/pre_process/m_mpi_proxy.fpp
  • src/pre_process/m_global_parameters.fpp
  • src/simulation/m_mpi_proxy.fpp
  • src/post_process/m_global_parameters.fpp
  • src/simulation/m_bubbles_EL.fpp
src/simulation/**/*.{fpp,f90}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/simulation/**/*.{fpp,f90}: Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)
Allocate large GPU arrays with managed memory or move them into persistent !$acc enter data regions at start-up
Avoid stop/error stop inside GPU device code
Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers

src/simulation/**/*.{fpp,f90}: Mark GPU-callable helpers with $:GPU_ROUTINE(function_name='...', parallelism='[seq]') immediately after declaration
Do not use OpenACC or OpenMP directives directly; use Fypp macros from src/common/include/parallel_macros.fpp instead
Wrap tight loops with $:GPU_PARALLEL_FOR(private='[...]', copy='[...]') macro; add collapse=n for safe nested loop merging
Declare loop-local variables with private='[...]' in GPU parallel loop macros
Allocate large arrays with managed or move them into a persistent $:GPU_ENTER_DATA(...) region at start-up
Do not place stop or error stop inside device code

Files:

  • src/simulation/m_global_parameters.fpp
  • src/simulation/m_mpi_proxy.fpp
  • src/simulation/m_bubbles_EL.fpp
🧠 Learnings (7)
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight GPU loops with !$acc parallel loop gang vector default(present) reduction(...); add collapse(n) when safe; declare loop-local variables with private(...)

Applied to files:

  • src/post_process/m_mpi_proxy.fpp
  • src/pre_process/m_mpi_proxy.fpp
  • src/simulation/m_mpi_proxy.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Wrap tight loops with `$:GPU_PARALLEL_FOR(private='[...]', copy='[...]')` macro; add `collapse=n` for safe nested loop merging

Applied to files:

  • src/post_process/m_mpi_proxy.fpp
  • src/simulation/m_mpi_proxy.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Keep private helpers in the module; avoid nested procedures

Applied to files:

  • src/common/m_helper.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Declare loop-local variables with `private='[...]'` in GPU parallel loop macros

Applied to files:

  • src/pre_process/m_mpi_proxy.fpp
  • src/simulation/m_mpi_proxy.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Do not use OpenACC or OpenMP directives directly; use Fypp macros from `src/common/include/parallel_macros.fpp` instead

Applied to files:

  • src/simulation/m_mpi_proxy.fpp
📚 Learning: 2025-11-24T21:50:16.684Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T21:50:16.684Z
Learning: Applies to src/simulation/**/*.{fpp,f90} : Ensure GPU code compiles with Cray ftn, NVIDIA nvfortran, GNU gfortran, and Intel ifx/ifort compilers

Applied to files:

  • src/simulation/m_mpi_proxy.fpp
📚 Learning: 2025-11-24T21:50:46.879Z
Learnt from: CR
Repo: MFlowCode/MFC PR: 0
File: .cursor/rules/mfc-agent-rules.mdc:0-0
Timestamp: 2025-11-24T21:50:46.879Z
Learning: Applies to **/*.{fpp,f90} : Use `wp` (working precision) parameter from `m_precision_select` instead of hardcoded precision like `real*8`

Applied to files:

  • src/post_process/m_global_parameters.fpp
🪛 GitHub Actions: Lint Toolchain
examples/3D_lagrange_bubblescreen/case.py

[error] 1-1: pylint: invalid non-printable character U+000D (syntax-error) detected at line 1.

examples/3D_lagrange_shbubcollapse/case.py

[error] 1-1: pylint: invalid non-printable character U+000D (syntax-error) detected at line 1.

🪛 Ruff (0.14.5)
examples/3D_lagrange_bubblescreen/case.py

1-1: Shebang is present but file is not executable

(EXE001)

examples/3D_lagrange_shbubcollapse/case.py

1-1: Shebang is present but file is not executable

(EXE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
  • GitHub Check: Github (ubuntu, mpi, no-debug, true)
  • GitHub Check: Github (ubuntu, mpi, no-debug, false)
  • GitHub Check: Github (ubuntu, mpi, debug, true)
  • GitHub Check: Github (ubuntu, mpi, debug, false)
  • GitHub Check: Code Cleanliness Check
  • GitHub Check: Coverage Test on CodeCov
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Build & Publish
🔇 Additional comments (20)
examples/3D_lagrange_shbubcollapse/case.py (1)

181-181: D_v wiring for bubble gas fluid looks consistent with the new design

Using diffVapor to populate "fluid_pp(2)%D_v" aligns with the refactor to treat vapor diffusivity as a per‑fluid property and to associate it with the bubble gas phase (second fluid). This matches the PR objective and keeps the example in sync with the Fortran-side changes.

src/common/m_helper.fpp (2)

154-154: Good refactor: eliminates magic number.

Replacing the hardcoded diffusion coefficient 0.242e-4_wp with fluid_pp(2)%D_v improves maintainability and aligns with the PR's goal to centralize vapor diffusivity.


161-162: The repository is currently inaccessible in the sandbox environment due to cloning failures. I'm unable to verify:

  1. Whether R_uni is defined in m_constants
  2. Whether m_constants is imported in m_helper.fpp
  3. The actual context and scope of the code at lines 161-162

Unable to verify R_uni definition and accessibility due to repository access limitations.

The review comment's verification request cannot be completed without access to the repository files. Manual verification of the following is required:

  • Confirm R_uni is declared in m_constants module
  • Confirm use m_constants statement exists in m_helper.fpp
  • Validate that R_uni is properly accessible at the code location
src/common/m_derived_types.fpp (1)

360-361: LGTM!

The addition of D_v to the physical_parameters type is well-placed and consistent with existing fluid property fields.

src/pre_process/m_global_parameters.fpp (1)

587-587: LGTM!

The initialization of D_v with dflt_real is correct and consistent with other fluid parameter defaults in the loop.

src/post_process/m_mpi_proxy.fpp (1)

136-136: LGTM!

The MPI broadcast of fluid_pp(i)%D_v correctly propagates the vapor diffusivity parameter to all processes, maintaining consistency with other fluid property broadcasts.

src/pre_process/m_mpi_proxy.fpp (2)

147-149: LGTM!

The addition of D_v to the fluid physical parameters MPI broadcast ensures proper distribution across processes.


155-157: LGTM!

The inclusion of D_v in the simplex noise and fluid physical parameters broadcast maintains consistency with the first broadcast loop.

examples/3D_lagrange_bubblescreen/case.py (1)

179-179: LGTM!

The addition of fluid_pp(2)%D_v correctly maps the vapor diffusivity to the gas fluid parameters, replacing the removed diffcoefvap from lag_params.

src/simulation/m_mpi_proxy.fpp (2)

143-146: LGTM!

The removal of diffcoefvap from the lag_params MPI broadcast aligns with the migration to fluid_pp(i)%D_v.


192-194: LGTM!

The addition of D_v to the fluid parameters MPI broadcast ensures proper synchronization of the vapor diffusivity across all processes.

toolchain/mfc/test/cases.py (2)

521-523: LGTM! D_v parameter added to bubble test configuration.

The addition of fluid_pp(2)%D_v with value 0.242e-4 properly extends the test configuration for Eulerian bubble models, consistent with the migration of vapor diffusivity from lag_params to per-fluid parameters.


850-850: LGTM! D_v parameter added to Lagrangian bubble test configuration.

The addition of fluid_pp(2)%D_v with value 2.5e-5 properly extends the test configuration for Lagrangian bubble models.

src/simulation/m_global_parameters.fpp (1)

685-685: LGTM! D_v initialized with default value.

The initialization of fluid_pp(i)%D_v = dflt_real follows the established pattern for other fluid properties and ensures proper default values before user configuration is applied.

examples/1D_qbmm/case.py (1)

28-28: LGTM! D_v parameter added to example configuration.

The addition of vapor diffusivity D_v for the bubble gas (fluid 2) properly extends the example configuration. The value 0.242e-4 is consistent with typical air vapor diffusivity values.

Also applies to: 167-167

toolchain/mfc/run/case_dicts.py (4)

154-154: LGTM! D_v added to PRE_PROCESS fluid parameters.

The addition of "D_v" to the real attributes list for fluid_pp in PRE_PROCESS properly extends the parameter schema to support vapor diffusivity as a per-fluid property.


352-354: LGTM! Obsolete diffcoefvap parameter removed.

The removal of 'diffcoefvap' from lag_params real variables is correct, as this parameter has been migrated to the per-fluid fluid_pp(...)%D_v structure.


417-417: LGTM! D_v added to SIMULATION fluid parameters.

Consistent with PRE_PROCESS changes, properly extending the SIMULATION parameter schema.


537-537: LGTM! D_v added to POST_PROCESS fluid parameters.

Completes the consistent addition of D_v across all three processing stages.

src/simulation/m_bubbles_EL.fpp (1)

181-181: LGTM! D_v properly normalized in lagrange inputs.

The nondimensionalization of fluid_pp(id_bubbles)%D_v by (x0*c0) correctly applies the reference scaling for vapor diffusivity in the Lagrangian bubble model initialization.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 15 files

Prompt for AI agents (all 3 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="examples/3D_lagrange_shbubcollapse/case.py">

<violation number="1" location="examples/3D_lagrange_shbubcollapse/case.py:1">
The shebang now ends with a carriage return, so executing the script directly will fail because `/usr/bin/env` looks for an interpreter named `python3\r`. Remove the `\r` so the shebang is POSIX-compatible.</violation>
</file>

<file name="examples/3D_lagrange_bubblescreen/case.py">

<violation number="1" location="examples/3D_lagrange_bubblescreen/case.py:1">
The shebang now has a Windows-style carriage return, so executing `./case.py` on Unix fails because `/usr/bin/env` cannot find `python3\r`. Use a Unix newline for the interpreter line.</violation>
</file>

<file name="src/simulation/m_bubbles_EL.fpp">

<violation number="1" location="src/simulation/m_bubbles_EL.fpp:181">
Do not overwrite the global fluid diffusivity with the nondimensional value here; other modules (e.g., m_helper) still expect fluid_pp%D_v to stay in dimensional units, so this line now feeds a scaled diffusivity into the common Peclet-number calculations.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 15 files

Prompt for AI agents (all 2 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/common/m_helper.fpp">

<violation number="1" location="src/common/m_helper.fpp:161">
`R_uni` is referenced without being imported into `m_helper`, so the code no longer compiles after removing the local `Ru` constant.</violation>
</file>

<file name="src/simulation/m_bubbles_EL.fpp">

<violation number="1" location="src/simulation/m_bubbles_EL.fpp:181">
Existing cases still provide the diffusion coefficient via `lag_params%diffcoefvap`, so `fluid_pp(num_fluids)%D_v` stays at its default sentinel and `PeG` now divides by an unset value. Add a fallback that populates `fluid_pp% D_v` from `lag_params` when it has not been provided to avoid dividing by zero for current inputs.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

! gas constants
R_n = Ru/M_n
R_v = Ru/M_v
R_n = R_uni/M_n
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 25, 2025

Choose a reason for hiding this comment

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

R_uni is referenced without being imported into m_helper, so the code no longer compiles after removing the local Ru constant.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/common/m_helper.fpp, line 161:

<comment>`R_uni` is referenced without being imported into `m_helper`, so the code no longer compiles after removing the local `Ru` constant.</comment>

<file context>
@@ -154,15 +151,15 @@ contains
         ! gas constants
-        R_n = Ru/M_n
-        R_v = Ru/M_v
+        R_n = R_uni/M_n
+        R_v = R_uni/M_v
         ! phi_vn &amp; phi_nv (phi_nn = phi_vv = 1)
</file context>
Fix with Cubic

R_v = (R_uni/fluid_pp(id_bubbles)%M_v)*(T0/(c0*c0))
R_n = (R_uni/fluid_pp(id_host)%M_v)*(T0/(c0*c0))
lag_params%diffcoefvap = lag_params%diffcoefvap/(x0*c0)
fluid_pp(id_bubbles)%D_v = fluid_pp(id_bubbles)%D_v/(x0*c0)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 25, 2025

Choose a reason for hiding this comment

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

Existing cases still provide the diffusion coefficient via lag_params%diffcoefvap, so fluid_pp(num_fluids)%D_v stays at its default sentinel and PeG now divides by an unset value. Add a fallback that populates fluid_pp% D_v from lag_params when it has not been provided to avoid dividing by zero for current inputs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/simulation/m_bubbles_EL.fpp, line 181:

<comment>Existing cases still provide the diffusion coefficient via `lag_params%diffcoefvap`, so `fluid_pp(num_fluids)%D_v` stays at its default sentinel and `PeG` now divides by an unset value. Add a fallback that populates `fluid_pp% D_v` from `lag_params` when it has not been provided to avoid dividing by zero for current inputs.</comment>

<file context>
@@ -178,7 +178,7 @@ contains
         R_v = (R_uni/fluid_pp(id_bubbles)%M_v)*(T0/(c0*c0))
         R_n = (R_uni/fluid_pp(id_host)%M_v)*(T0/(c0*c0))
-        lag_params%diffcoefvap = lag_params%diffcoefvap/(x0*c0)
+        fluid_pp(id_bubbles)%D_v = fluid_pp(id_bubbles)%D_v/(x0*c0)
         ss = fluid_pp(id_host)%ss/(rho0*x0*c0*c0)
         mul0 = fluid_pp(id_host)%mul0/(rho0*x0*c0)
</file context>
Fix with Cubic

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 15 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 15 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/documentation/case.md (1)

748-748: Add descriptive documentation for the new D_v parameter.

The D_v parameter is now added to the table (line 748), but the explanatory bullet-point block (lines 765–768) does not mention it. Users need clarity on when this parameter is used and how it relates to the bubble models.

Consider updating the descriptive text to document D_v alongside the other vapor properties. For example:

- `mu_l0`, `ss`, and `pv`, `gamma_v`, `M_v`, `mu_v`, `k_v`, and `cp_v` specify simulation parameters for the non-polytropic gas compression model.
+ `mu_l0`, `ss`, and `pv`, `gamma_v`, `M_v`, `mu_v`, `k_v`, `cp_v`, and `D_v` specify simulation parameters for the non-polytropic gas compression model.
  `mu_l0`, `ss`, and `pv` correspond to the liquid viscosity, surface tension, and vapor pressure, respectively.
- `gamma_v`, `M_v`, `mu_v`, `k_v`, and `cp_v` specify the specific heat ratio, molecular weight, viscosity, thermal conductivity and specific heat capacity of a chosen component (`cp_v` only for ``bubbles_lagrange = 'T'``).
+ `gamma_v`, `M_v`, `mu_v`, `k_v`, `cp_v`, and `D_v` specify the specific heat ratio, molecular weight, viscosity, thermal conductivity, specific heat capacity (`cp_v` only for ``bubbles_lagrange = 'T'``), and vapor diffusivity of a chosen component.

Also applies to: 765-768

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e39f0fd and 6e3e4b1.

📒 Files selected for processing (1)
  • docs/documentation/case.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Code Cleanliness Check
  • GitHub Check: Github (ubuntu, no-mpi, single, no-debug, false)
  • GitHub Check: Github (ubuntu, mpi, no-debug, true)
  • GitHub Check: Github (ubuntu, mpi, debug, true)
  • GitHub Check: Github (ubuntu, mpi, debug, false)
  • GitHub Check: Github (ubuntu, mpi, no-debug, false)
  • GitHub Check: Coverage Test on CodeCov
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Build & Publish

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 44.36%. Comparing base (11375f3) to head (6e3e4b1).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_bubbles_EL.fpp 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1062   +/-   ##
=======================================
  Coverage   44.35%   44.36%           
=======================================
  Files          71       71           
  Lines       20587    20588    +1     
  Branches     1993     1993           
=======================================
+ Hits         9132     9134    +2     
+ Misses      10310    10309    -1     
  Partials     1145     1145           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson merged commit e29d8e1 into MFlowCode:master Nov 27, 2025
58 of 61 checks passed
@hyeoksu-lee hyeoksu-lee deleted the bubnorm branch November 28, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 size:S This PR changes 10-29 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

2 participants