pmgbergen / porepy

Python Simulation Tool for Fractured and Deformable Porous Media

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor constitutive_laws

IvarStefansson opened this issue · comments

The module porepy/models/constitutive_laws.py currently contains 3.5k lines, motivating a refactoring. I suggest a two-level approach:

  1. Identifying if there is something which is not (primarily) a constitutive law. Such code should be moved elsewhere (e.g. to a discretization module).
  2. Designing a subdivision of what are constitutive laws (new package). Candidate designs are:
  • "type of physics" (mechanics, fluid flow). This might not work, as "coupled physics are coupled"...
  • mathematical structure (diffusion, advection).
  • material type (fluid, rock/solid...). Not everything fits this division - some laws are either agnostic to the material or defined for the compound porous medium.
  • More levels of the type constitutive_laws.name_of_quantity.NameOfLawInstance. E.g. stress.py containing classes like LinearElastic, PoroMechanical and ThermoPoroMechanical.
  • OTHER!

We should keep #943 in mind when designing the new structure and naming of modules/packages.

As a first step, we could identify parameters that may be classified as solid, fluid, and solid-fluid:

  • Solid: Includes permeability, conductivity, porosity, functionality for dimension reduction, friction, Barton-Bandis etc.
  • Fluid: Viscostiy, density, conductivity, ...
  • Solid-Fluid: Capillary pressure, relative permeability etc.

If we move these into separate files, my rough estimate is that this will take care of perhaps half the file. In addition, functionality relating to multiphase flow etc., that is coming up in the next few months, would enter fluid.py instead of constitutive laws.py (though this is rather a further argument for the refactoring).

For the remaining terms, looking only at class names, I would group these as relating to

  • Darcy's law (includes the new differentiable-tpfa scheme, which is really more general): ~1000 LOC
  • Fourier's law: 300 LOC
  • Advective flux; ~200LOC
  • Stress in various forms: 500+LOC

So, perhaps a division diffusion, advection, 'stress-related' could work.

Are your "remaining terms" somehow classified as pertaining to discretization?
And do you think it would make sense to put dimension reduction into the Geometry class?

Are your "remaining terms" somehow classified as pertaining to discretization?

It seems so, yes, but I have no firm opinions on this matter.

And do you think it would make sense to put dimension reduction into the Geometry class?

I had not thought of a geometry class, but yes, that makes sense.