Repository navigation
Conversation
… the relaxations - A hyperbolic flux file may define riemann(qL, qR, uL, uR, p, h, dim, GL, GR) to receive the size h of the cells of the face (fluxes_kernel already has it): common.py reads the arguments of its riemann function (ast, function_arguments) and passes h only to the solvers that take it. The dispatch riemann(hyperbolic, ...) of loops.py takes h. - A relaxation file may define relaxation(w, qn, p, dt, dim): a relaxation of finite rate (stiff source of the cell solved exactly over the time step), besides the instantaneous projections relaxation(w, qn, p, dim). The C++ already passed dt to Physics.relaxations; relaxations_kernel now receives it and gives it to the files that take it. It still applies once, after the time integration: split from the other terms, first order in time where it acts. - Docstrings of hyperbolic_fluxes/ and relaxations/ of the three models, and the description of physics.relaxation in canoP studio. The existing solvers and relaxations keep their signatures: the 54 regression cases of the three models are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, states, EOS) Port of the model PorousFluid of canoP 2.x (branch 38-correct-diffusion-flux-discretization-SEL) as physics/porousflow/. - Equations: the onephase equations of the fluid in the pores weighted by the porosity eps(x), fixed in time, with the pressure term eps grad P as a non-conservative product (nonconservative: True) and the Darcy-Forchheimer drag of the Kozeny-Carman permeability k = eps^3 / ((1 - eps)^2 rp_2C). - Variables: conservative em, emE, emV, eps (em = eps m, ...), primitive m, P, T, V, eps; eps is advected by no flux. - Parameters (section [param], names of canoP 2.x): eosFluid.gamma, q, b, pinf, Cv (Noble-Abel stiffened gas as onephase), mu, eta, kappa, rp_2C, gravity_x/y/z, K (impedance coefficient), lowmach_correction_enabled, lowmach_correction_scheme, darcy_correction_enabled. - model.py: states Prim, Cons, Params; cons_to_prim and prim_to_cons in the order of operations of canoP 2.x; Kozeny-Carman inverse permeability and Forchheimer coefficient C_F = 1.75 eps / sqrt(150 eps^5); slopes, walls and fluxes of the porosity; time step of the hyperbolic fluxes. With eps = 1 everywhere the model gives the results of onephase bit for bit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hyperbolic_fluxes/allregime.py, port of the flux of PorousFluid of canoP 2.x: - acoustic solver on the superficial velocity v = eps u of the face states, impedance a = K max(mL cL / epsL, mR cR / epsR); - darcy_correction_enabled: the Darcy-Forchheimer drag over the cell size h in the interface velocity, v* = a (vL + vR - (PR - PL) / a) / (2 a + (mu/k) h + beta), with the face means of the porosity, density, speed and mu / k (the solver takes h: riemann(qL, qR, uL, uR, p, h, dim, GL, GR)); - low Mach correction theta of P*: min(|v*| / c, 1), or with the Darcy correction lowmach_correction_scheme 2 (entropy satisfying, Chalons et al. 2014) or 3 (semi-discrete acoustic entropy satisfying); - m, m V, m E upwinded and carried by v*; the momentum takes P* times the porosity of each cell (non-conservative eps grad P), so that a fluid at rest at uniform pressure stays at rest across a jump of porosity. Differences with canoP 2.x, documented in the file: |V| of the Darcy correction has its three components in 3D, and mu / k is computed from 1 / k (no division by zero for eps = 1 or mu = 0). The gravity term of the Darcy corrected v* (zero in canoP 2.x) is not ported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- relaxations/darcy.py: the Darcy-Forchheimer drag solved exactly after the time step. Only the momentum changes (m, eps and the direction of V stay): the speed follows ds/dt = -a s - b s^2, a = eps mu / (k m), b = eps^2 C_F / sqrt(k), whose solution V exp(-a dt) / (1 + b |V| (1 - exp(-a dt)) / a) is applied (series for small a dt, a = 0 included). Split from the fluxes: first order in time where the drag acts, the order of time_order elsewhere, exact for any stiffness. - sources/darcy.py: gravity then the drag at each stage, exponential with |V| of the beginning of the stage, as in canoP 2.x (kept for the comparison): with Runge-Kutta 2 a stiff drag damps a velocity by (1 + exp(-2 a dt)) / 2 per step instead of exp(-a dt), hence the relaxation. - sources/gravity.py: eps m g and eps m g.V. - diffusion_fluxes/viscosity.py and conductivity.py: the onephase stress and heat flux times the porosity of the face, with the compact face gradients of canoP (not the centred gradients of canoP 2.x: differences of 4e-3 to 2e-2 on viscous cases, as onephase against monofluid). In 3D the whole stress is multiplied by the porosity (canoP 2.x leaves out the terms in z). The energy is unchanged by the drag: the kinetic energy lost heats the fluid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Initial conditions: - riemann_problem (porosities eps_left, eps_right), blast (eps), gresho, rayleigh_taylor, conduction (eps = 1): as onephase, with the porosity; - poiseuille: fluid at rest at the pressure P0 + gradP x in a channel with a porous block of porosity eps0 between x_1 and x_2 (tanh transitions of width about 2 / tau); - plug_flow: fluid at rest in a channel with a porous plug (Betchen, Straatman and Thompson 2006); - beavers_joseph: fluid at rest at the pressure P0 + gradP x over a porous layer y < y0 (Beavers and Joseph 1967); - backward_facing_step: fluid at rest in a channel whose step is a porous block of porosity eps0, centre (x_c, y_c), sides Lx, Ly; - flow_around_cylinder: fluid at rest around a porous cylinder of porosity eps0. Boundary conditions: - neuman, reflective, noslip (as onephase), dirichlet (+ face<f>.eps); - poiseuille, beavers_joseph: imposed pressure P0 + gradP x at the centre of the ghost cells of the x faces (kind 5), no-slip walls elsewhere; - plug_flow: inflow Vx_in with the pressure and porosity of the inner cell (kind 4), outflow (kind 3), reflective walls; - backward_facing_step: parabolic inflow above y_step, imposed pressure at the outlet, no-slip walls; - flow_around_cylinder: inflow U_m, imposed pressure at the outlet. Refinement criteria: gradients of em, emE, emV, eps (conservative), of m, P, T, V (primitive), and any_gradient (emV, emE, em, eps). zero_gap_design_second_step of canoP 2.x (specific to an application, without settings) is not ported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
settings/settings_porousflow_*.ini, with the parameters of the settings of canoP 2.x where they exist: - riemann_problem: shock tube from a fluid (eps 1) into a porous medium (eps 0.5), second order; - poiseuille: flow driven by the pressure through a porous block in a channel (settings plug_darcy0.01 of canoP 2.x: viscosity, Darcy correction of the flux, first order); - beavers_joseph: channel flow over a porous layer, second order; - backward_facing_step: channel flow over a porous step. The drag of the three porous flows is the relaxation darcy (exact after the time step) instead of the source of canoP 2.x. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Readme.md and docs/index.md: porousflow in the list of the models. - docs/user-guide/models.md: four models; section porousflow (equations, variables, flux, Darcy-Forchheimer drag as relaxation or source, examples). The physics reference (docs/_generated) is generated from the sources. - docs/tutorial/build.md: porousflow among the values of simulation.model. - CHANGELOG.md (Unreleased): the model, h of the Riemann solvers and dt of the relaxations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/regression/cases.py: the conservative variables of porousflow (em, emE, emV, eps) and the cases: - porous shock tube (porosities 0.8 and 0.5, transverse velocity, periodic in y): second and first order, Darcy correction of the flux with the drag as a relaxation, with the drag as the source of canoP 2.x (time_order 1), the three low Mach corrections, no-slip walls with gravity and conduction, Dirichlet faces, AMR (any_gradient, levels 3 to 6, RK2), 3D; - the examples poiseuille (uniform and AMR on eps), beavers_joseph, backward_facing_step, and the plug_flow and flow_around_cylinder conditions. The flux and sources match canoP 2.x (porousfluid of the branch 38-correct-diffusion-flux-discretization-SEL, with eps_left and eps_right in its riemann_problem) to 3e-14, with the same numbers of time steps, on the porous shock tubes at time_order 1 (orders 1 and 2 in space, low Mach, Darcy with the three low Mach schemes, gravity) and on a 2D blast; the viscous cases differ by 4e-3 to 2e-2 (compact gradients of canoP), as onephase against monofluid. The references are produced by canoP f5c28be. The 71 regression cases pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/physics/physics.py porous (CTest physics_porous): - porous_rest: fluid at rest at uniform pressure in the channel with a porous block (eps 1 to 0.7), AMR on eps, second order, viscosity, Darcy correction and relaxation: |V| / c and |P - P0| / P0 stay below 1e-13 (4e-16); - porous_darcy: uniform flow in a medium of porosity 0.5 (periodic), relaxation darcy with Runge-Kutta 2: V(t) follows the exact solution of the Darcy-Forchheimer ODE to 1e-12 (4e-16); - porous_darcy_source: the same with the source darcy and forward Euler, exact for a frozen |V| only: 2e-3 (6.5e-4); - porous_conservation: porous shock tube between reflective walls: the integrals of em and emE are conserved to 1e-13 (2e-16). outflow: the porous shock tube stays uniform along y with neuman faces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2.
New model
porousflow: compressible flow in a porous medium of variable porosity, port of the model PorousFluid of canoP 2.x (branch38-correct-diffusion-flux-discretization-SEL).Model
eps(x);eps grad Pas a non-conservative product; Darcy-Forchheimer drag of the Kozeny-Carman permeabilityk = eps^3 / ((1 - eps)^2 rp_2C).allregimeon the superficial velocity, with the Darcy correction of the interface velocity (darcy_correction_enabled) and the three low Mach corrections of canoP 2.x.darcy, solved exactly after the time step (first order in time where it acts, the order oftime_orderelsewhere, exact for any stiffness), or sourcedarcyat each stage as in canoP 2.x.Shared change
h, a relaxation the time stepdt. Both are detected from the arguments of the function, and the existing files are unchanged.Validation
eps = 1, the results are bitwise those of onephase.porous: rest across porosity jumps 4e-16, exact Darcy-Forchheimer decay 4e-16 (relaxation, RK2), conservation 2e-16.outflowcovers porousflow.Not ported / known issues
zero_gap_design_second_step(application specific) and the gravity term of the Darcy-correctedv*(zero in canoP 2.x).h^2 / (2D)at cfl 0.5 is unstable in 2D (limith^2 / (4D)), for every model.🤖 Generated with Claude Code