Skip to content

Initialization - #1686

Closed
jwboth wants to merge 13 commits into
developfrom
initialization
Closed

Initialization#1686
jwboth wants to merge 13 commits into
developfrom
initialization

Conversation

@jwboth

@jwboth jwboth commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Three-fold extension:

  • Distinction between reference, relative and absolute variables (explicitly defined for each physics - only considering HM cases so far). If reference states are not set/updated the simulations should run as initially.
  • Constitutive laws in terms of relative variables.
  • Standardized initialization strategy as part of the simulation preparation - seamless transition from initialization to simulation.

The latter is defined for initialization of quasi-static initial conditions as well as reference states.

Types of changes

What types of changes does this PR introduce to PorePy?
Put an x in the boxes that apply.

  • Minor change (e.g., dependency bumps, broken links).
  • Bugfix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Testing (contribution related to testing of existing or new functionality).
  • Documentation (contribution related to adding, improving, or fixing documentation).
  • Maintenance (e.g., improve logic and performance, remove obsolete code).
  • Other:

Checklist

Put an x in the boxes that apply or explain briefly why the box is not relevant.

  • The documentation is up-to-date.
  • Static typing is included in the update.
  • This PR does not duplicate existing functionality.
  • The update is covered by the test suite (including tests added in the PR).
  • If new skipped tests have been introduced in this PR, pytest was run with the --run-skipped flag.

@jwboth
jwboth marked this pull request as draft June 1, 2026 04:43

@jwboth jwboth left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvarStefansson @keileg I tried highlighting the pieces in the code that I suspect to require a critical look. Hope it helps for reviewing the suggested concepts.

Comment on lines +420 to +421
has_momentum_balance_reference_state: bool = False
"""Flag whether reference states have been defined."""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this class are representative for changes in other core model classes. Be critical about:

  • explicit introduction of essentially three versions of a variable (the absolute one derives from the others by addition)
  • the concept behind updating and shifting values including the flag above - it feels like one should have maybe the possibility to do this in a more global way and not model by model. Is it possible to utilize some decorators or collect variables in respective containers? Bit like with previous_timestep(). Argument against a global approach would possibly be memory. One could also argue for (like @IvarStefansson did yesterday) that we could ignore reference states in the remaining physics (pressure, temperature etc) since displacements are the only singular object and require correct treatment in terms of modelling, while the remaining once may instead only impact the numerical properties like conditioning.
  • the imposed DataSavingMixin that always exports all three variants for the variables (maybe too much?). Reference variables should for instance also not change over time and could be handled as constants (see the not so much used functionality of the Exporter)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there seems to be unnecessary amount of boilerplate.

Comment on lines +36 to +43
class MechanicalAperture:
"""Mechanical aperture of fractures wrt reference configuration."""

normal_component: Callable[[list[pp.Grid]], pp.ad.Operator]
"""Operator giving the normal component of a vector on fractures."""

displacement_jump: Callable[[list[pp.Grid]], pp.ad.Operator]
"""Displacement jump on fractures wrt reference ."""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be critical about the handling of the difference apertures and the now explicit use of relative displacements.

Comment on lines +2993 to +2999
NOTE: The implementation of the mechanical stress below is in absolute terms.
The stress could be formulated wrt a reference configuration, in which case
a reference (background) stress would be required, only depending on the reference
displacement. Under the assumption of linearity, the summation of the reference and
the linear mechanical stress below cancels the reference contributions. For
simplicity, background stress is not supported in the current implementation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should one think more about including explicit background stress measurements or possibly a homogeneous background stress and then formulate the mechanical stress in terms of relative quantities?

Comment thread src/porepy/models/constitutive_laws.py Outdated
@@ -4549,7 +4619,7 @@ def porosity(self, subdomains: list[pp.Grid]) -> pp.ad.Operator:


class PoroMechanicsPorosity(pp.PorePyModel):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I did not cover all constitutive laws, e.g. code related to BartonBandis , damage etc.

What should be the right strategy? Coverage or sanity checks throwing an error/warning if reference states are used e.g. for unsupported constitutive laws or models.

Comment on lines +382 to +383
def relative_contact_traction(self, subdomains: list[pp.Grid]) -> pp.ad.Operator:
"""Fracture contact traction increment [-].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be critical here: Do we really need reference and relative versions of all variables? There is no constitutive law that will benefit from contact traction changes, or? Same would apply for saturation-type variables in multiphase flow settings. If there should really be an impact on the linear/nonlinear conditioning of the problem by solving for increments, one should maybe consider solving for increments wrt the previous time step?

"""
return Scalar(0.0, "reference_mechanical_aperture")

def mechanical_aperture(self, subdomains: list[pp.Grid]) -> pp.ad.Operator:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider if this makes reference fracture gap redundant/is already covered by that.



class DisplacementJumpAperture(DimensionReduction):
class DisplacementJumpAperture(DimensionReduction, MechanicalAperture):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be very careful about what this does to the interpretation of aperture (hydraulic vs mechanical)

Comment thread src/porepy/models/constitutive_laws.py Outdated
Comment thread src/porepy/models/contact_mechanics.py Outdated
"""See :class:`VariablesSinglePhaseFlow`."""

interface_darcy_flux: Callable[
relative_interface_darcy_flux: Callable[

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need relative fluxes?

Comment on lines +420 to +421
has_momentum_balance_reference_state: bool = False
"""Flag whether reference states have been defined."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there seems to be unnecessary amount of boilerplate.

@jwboth jwboth mentioned this pull request Jun 19, 2026
13 tasks
@keileg

keileg commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@jwboth Have I understood correctly that this PR is being replaced by the series of newer PRs on the same topic?

@jwboth

jwboth commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@keileg yes, it was kept for reference, but it was hopeless to base a solution for the identified weak points based on the herein presented implementation.

@jwboth Have I understood correctly that this PR is being replaced by the series of newer PRs on the same topic?

@keileg

keileg commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Superseded by #1696, #1707 #1708 etc.

@keileg keileg closed this Jul 6, 2026
@keileg
keileg deleted the initialization branch September 3, 2026 06:20
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

Successfully merging this pull request may close these issues.

3 participants