Skip to content

Add optional multiphase support (Shan-Chen & phase-field) with I/O, initialization and utilities - #64

Open
gaoak wants to merge 2 commits into
masterfrom
codex
Open

Add optional multiphase support (Shan-Chen & phase-field) with I/O, initialization and utilities#64
gaoak wants to merge 2 commits into
masterfrom
codex

Conversation

@gaoak

@gaoak gaoak commented Mar 21, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Introduce optional multiphase physics to the solver so users can run single-phase, Shan‑Chen pseudo-potential, or phase‑field simulations and output phase/density fields per block.
  • Add robust parsing for an optional MultiPhase block in input files and include multiphase parameters in parameter dumps for reproducibility.
  • Fix a couple of indexing/validation issues in body placement and probe output selection.

Description

  • Added MPModelNone/MPModelShanChen/MPModelPhaseField constants in ConstParams and new multiphase fields to FlowCondType in FlowCondition with defaults, and implemented parsing of an optional MultiPhase keyword using a new found_keyword_optional utility.
  • Implemented multiphase data structures and algorithms in FluidDomain: allocate phi, phi_new, and chemPot for phase‑field, initialize phi and block densities (or mixed density for Shan‑Chen), update densities in collision, and added per-block routines apply_shan_chen_force, advance_phase_field, apply_phase_field_force, pseudopotential, and helpers for neighbours/gradients/laplacian.
  • Enhanced I/O: write_flow_ now writes a Phase*****_b*** file when multiphase is enabled (density and phase indicator for phase‑field), adjusted output indexing/filename handling, and extended write_continue_/read_continue_ to save/load phase data when present.
  • Added parameter printing of multiphase settings in write_parameter_check_file and a new optional keyword search routine found_keyword_optional in Util.f90.
  • Minor fixes: corrected multi-dimensional placement indexing in Solidbody.f90 (lineY/lineZ computation) and added bounds checking for flow%inWhichBlock in main.f90 to avoid invalid probe access.

Testing

  • Project compiled successfully with gfortran -O3 after the changes and no compile errors were reported.
  • Executed short smoke simulations: a single‑phase baseline run completed and produced unchanged DatFlow outputs, and small multiphase smoke cases for both MPModelShanChen and MPModelPhaseField produced Phase..._b... files with density and phase fields as expected.
  • Reading/writing of continue files including phase data was exercised in an automated short restart test and succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant