-
Notifications
You must be signed in to change notification settings - Fork 150
feat(FluidDynamics): Adding more fluid dynamics - continuation of PR #949 and #1112 , #1125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jstoobysmith
merged 24 commits into
leanprover-community:master
from
FloWsnr:feat/fluid_dynamics_2
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1814f75
feat(FluidDynamics): add incompressibility predicates
FloWsnr 0682a2f
refactor(FluidDynamics): extract shared continuity and momentum
FloWsnr 8ed0eaf
feat(FluidDynamics): add Euler Bernoulli setup
FloWsnr 7c9c03a
feat(FluidDynamics): record Bernoulli force convention
FloWsnr 06ec89d
refactor(FluidDynamics): inline Euler convective form
FloWsnr 1129852
refactor(FluidDynamics): rename Euler predicates
FloWsnr d21b193
refactor(FluidDynamics): introduce Cauchy flow data
FloWsnr 0d2876e
refactor(FluidDynamics): rename fluid flow carrier
FloWsnr 829268d
refactor(FluidDynamics): add shared Cauchy momentum
FloWsnr f2633bf
refactor(FluidDynamics): use Cauchy flows in Euler theory
FloWsnr eeaa8b1
refactor(FluidDynamics): express Navier-Stokes via Cauchy momentum
FloWsnr 4cfc19a
refactor(FluidDynamics): clarify force and viscosity names
FloWsnr be7d803
feat(FluidDynamics): relate inviscid stress to pressure gradient
FloWsnr 1bee3d0
refactor(FluidDynamics): move flow time-independence predicates
FloWsnr e183042
refactor(FluidDynamics): namespace flow-derived APIs
FloWsnr 3370f7a
refactor(FluidDynamics): address review naming and docs
FloWsnr 46146e6
refactor(FluidDynamics): move flow-derived scalar APIs
FloWsnr b80c852
refactor(FluidDynamics): rename flow core module
FloWsnr 434a419
refactor(FluidDynamics): organize flow APIs by structure
FloWsnr fc8cddb
rename of theorems
FloWsnr 9b4c995
address restructuring review comments
FloWsnr 1edccf4
refactor(FluidDynamics): reuse convective momentum LHS
FloWsnr 6b9287b
refactor(FluidDynamics): remove momentum LHS definitions
FloWsnr be4b145
add more documentation
FloWsnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /- | ||
| Copyright (c) 2026 Florian Wiesner. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Florian Wiesner | ||
| -/ | ||
| module | ||
|
|
||
| public import Physlib.FluidDynamics.FluidFlow.Basic | ||
| /-! | ||
|
|
||
| # Basic API for Cauchy flows | ||
|
|
||
| ## i. Overview | ||
|
|
||
| This module defines `CauchyFlow`, the momentum-balance layer of the fluid API. | ||
| Specialized predicates and equations for Cauchy flows are organized in sibling modules. | ||
|
|
||
| A local Cauchy momentum balance needs two kinds of force data beyond density and velocity. The | ||
| stress tensor encodes contact forces through its divergence, while the specific body force encodes | ||
| volumetric forces per unit mass and therefore contributes mass density times specific body force. | ||
| Together these fields are sufficient to state the balance without choosing a material model. | ||
|
|
||
| The momentum equation constrains the flow and forces but does not define a constitutive relation | ||
| between them. Pressure and viscosity are therefore not stored as additional fields. | ||
| They enter through constitutive stress laws, such as the inviscid and Newtonian predicates, | ||
| which avoids duplicating data and imposing consistency conditions inside the carrier. | ||
| Thermodynamic data is deferred to `ThermodynamicCauchyFlow` because it is not needed | ||
| for momentum balance alone. | ||
|
|
||
| ## ii. Key results | ||
|
|
||
| - `CauchyFlow` : A fluid flow with Cauchy stress and specific body force. | ||
|
|
||
| ## iii. Table of contents | ||
|
|
||
| - A. Cauchy-flow structure | ||
|
|
||
| ## iv. References | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| namespace FluidDynamics | ||
|
|
||
| /-! | ||
|
|
||
| ## A. Cauchy-flow structure | ||
|
|
||
| -/ | ||
|
|
||
| /-- A fluid flow equipped with Cauchy stress and specific body-force fields. | ||
|
|
||
| These are the additional independent fields needed to state a local momentum balance. The Cauchy | ||
| stress represents contact forces, and the specific body force represents volumetric force per unit | ||
| mass. Pressure and viscosity enter through stress laws rather than as redundant fields of | ||
| `CauchyFlow` itself. -/ | ||
| structure CauchyFlow (d : ℕ) extends FluidFlow d where | ||
| /-- The Cauchy stress tensor field. -/ | ||
| stress : StressTensor d | ||
| /-- The specific body-force field, i.e. force per unit mass. -/ | ||
| specificBodyForce : VectorField d | ||
|
|
||
| end FluidDynamics |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /- | ||
| Copyright (c) 2026 Florian Wiesner. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Florian Wiesner, Michał Mogielnicki | ||
| -/ | ||
| module | ||
|
|
||
| public import Physlib.FluidDynamics.CauchyFlow.Basic | ||
| public import Physlib.SpaceAndTime.Space.Derivatives.Grad | ||
| /-! | ||
|
|
||
| # Body-force predicates for Cauchy flows | ||
|
|
||
| ## i. Overview | ||
|
|
||
| This module defines predicates for conservative specific body forces on `CauchyFlow`. | ||
|
|
||
| ## ii. Key results | ||
|
|
||
| - `CauchyFlow.HasBodyForcePotential` : Predicate encoding the convention | ||
| `specificBodyForce = -grad Phi`. | ||
| - `CauchyFlow.HasConservativeBodyForce` : Predicate saying the specific body force has some | ||
| potential. | ||
|
|
||
| ## iii. Table of contents | ||
|
|
||
| - A. Conservative-force convention | ||
|
|
||
| ## iv. References | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Space | ||
|
|
||
| namespace FluidDynamics | ||
|
|
||
| namespace CauchyFlow | ||
|
|
||
| /-! | ||
|
|
||
| ## A. Conservative-force convention | ||
|
|
||
| -/ | ||
|
|
||
| /-- A flow has body-force potential `Phi` when its specific body force is minus the gradient of | ||
| `Phi`. -/ | ||
| def HasBodyForcePotential (d : ℕ) (flow : CauchyFlow d) (potential : Space d → ℝ) : Prop := | ||
| ∀ t x, flow.specificBodyForce t x = -(∇ potential x) | ||
|
|
||
| /-- A flow has conservative body force when its specific body force has some potential. -/ | ||
| def HasConservativeBodyForce (d : ℕ) (flow : CauchyFlow d) : Prop := | ||
| ∃ potential : Space d → ℝ, HasBodyForcePotential d flow potential | ||
|
|
||
| end CauchyFlow | ||
|
|
||
| end FluidDynamics |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /- | ||
| Copyright (c) 2026 Florian Wiesner. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Florian Wiesner, Michał Mogielnicki | ||
| -/ | ||
| module | ||
|
|
||
| public import Physlib.FluidDynamics.CauchyFlow.Basic | ||
| public import Physlib.SpaceAndTime.Space.Derivatives.MatrixDiv | ||
| /-! | ||
|
|
||
| # Inviscid stress laws for Cauchy flows | ||
|
|
||
| ## i. Overview | ||
|
|
||
| This module defines the inviscid stress law for `CauchyFlow` and the corresponding | ||
| matrix-divergence identity for pressure stress. | ||
|
|
||
| ## ii. Key results | ||
|
|
||
| - `CauchyFlow.IsInviscid` : Predicate saying the Cauchy stress is the inviscid pressure stress. | ||
| - `CauchyFlow.matrixDiv_stress_eq_neg_grad_pressure_of_is_inviscid` : The inviscid stress | ||
| contributes the usual pressure-gradient force term. | ||
|
|
||
| ## iii. Table of contents | ||
|
|
||
| - A. Inviscid stress law | ||
|
|
||
| ## iv. References | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Space | ||
|
|
||
| namespace FluidDynamics | ||
|
|
||
| namespace CauchyFlow | ||
|
|
||
| /-! | ||
|
|
||
| ## A. Inviscid stress law | ||
|
|
||
| -/ | ||
|
|
||
| /-- A Cauchy flow is inviscid with pressure `p` when its stress is the isotropic pressure stress | ||
| `-p I`. | ||
|
|
||
| In this formulation, inviscid means that the Cauchy stress has no viscous or shear contribution. | ||
| It does not rule out body forces; those are carried separately by `CauchyFlow.specificBodyForce`. | ||
| -/ | ||
| def IsInviscid (d : ℕ) (flow : CauchyFlow d) (pressure : ScalarField d) : Prop := | ||
| ∀ t x, flow.stress t x = (-(pressure t x)) • (1 : Matrix (Fin d) (Fin d) ℝ) | ||
|
|
||
| /-- The matrix divergence of the inviscid pressure stress `-p I` is `-grad p`. -/ | ||
| lemma matrixDiv_inviscid_pressure_stress (d : ℕ) (pressureAtTime : Space d → ℝ) : | ||
| matrixDiv d (fun x => (-(pressureAtTime x)) • (1 : Matrix (Fin d) (Fin d) ℝ)) = | ||
| -∇ pressureAtTime := by | ||
| ext x i | ||
| rw [matrixDiv_apply] | ||
| rw [Finset.sum_eq_single i] | ||
| · simp [grad, Space.deriv_eq] | ||
| · intro j _ hji | ||
| have hij : i ≠ j := fun h => hji h.symm | ||
| simp [hij] | ||
| · intro hi | ||
| simp at hi | ||
|
|
||
| /-- In an inviscid Cauchy flow, the stress-divergence force is the usual | ||
| negative pressure-gradient term. -/ | ||
| theorem matrixDiv_stress_eq_neg_grad_pressure_of_is_inviscid | ||
| (d : ℕ) (flow : CauchyFlow d) (pressure : ScalarField d) | ||
| (hInviscid : IsInviscid d flow pressure) : | ||
| ∀ t, matrixDiv d (flow.stress t) = -∇ (pressure t) := by | ||
| intro t | ||
| rw [show flow.stress t = | ||
| fun x => (-(pressure t x)) • (1 : Matrix (Fin d) (Fin d) ℝ) by | ||
| funext x | ||
| exact hInviscid t x] | ||
| exact matrixDiv_inviscid_pressure_stress d (pressure t) | ||
|
|
||
| end CauchyFlow | ||
|
|
||
| end FluidDynamics |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.