Skip to content
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

Refactor constitutive_laws #1089

Open
IvarStefansson opened this issue Jan 2, 2024 · 3 comments
Open

Refactor constitutive_laws #1089

IvarStefansson opened this issue Jan 2, 2024 · 3 comments
Assignees

Comments

@IvarStefansson
Copy link
Contributor

IvarStefansson commented Jan 2, 2024

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.

@keileg
Copy link
Contributor

keileg commented Jan 15, 2024

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.

@IvarStefansson
Copy link
Contributor Author

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?

@keileg
Copy link
Contributor

keileg commented Jan 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants