Replies: 2 comments
-
It is also easy to see that (if required), the constitutive laws can be split by protocols into different families of constitutive laws, relating to different physics. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This makes a lot of sense. I think we should explore the possibility of families. This sounds like a user project over summer. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Existing (and newly created) models have an excessive declaration of class members (methods & attributes) for satisfying mypy and helping developers to get the correct mixed-in members.
This drives the numbers of lines of codes up, as well as the maintenance of names, typing of signatures and documentation.
With on-going development and refactoring, we already have multiple inconsistencies of either missing declaration of mixed-in methods, or missing docs of respective declarations.
Also, if a user wants to implement a new model, navigation through the declared members and required mixed-ins is hell.
All that is not required by introducing a Protocol-class, which contains declarations of respective members, but bundled and usable by all models.
As an example for fluid mass balance:
(Motivated by mypy docs)
This example covers covers all models (in the porepy-sense) and I think it is easy to see that it can in principle be applied to every method and attribute, provided by any mixin class.
With Python > 3.12, class typing instead of typing
self
will be availableProposal
Since PorePy aims for having a modular multi-physics modelling framework, we can start with implementing a single Protocol-class, which contains a declaration of methods of all constitutive laws.
We can proceed to include also all members provided by single-physics models, like fluid mass balance or energy balance (all-in-one solution).
But we can also design protocols for individual physics. Models using multiple physics, must respectively use combined protocols to have methods from different physics declared as members of their classes.
We would then have a Protocol-class covering the constitutive laws, and a Protocol-class for each physics-block.
Multi-physics models can then be typed with a multi-protocol class. This idea is illustrated by below example:
Beta Was this translation helpful? Give feedback.
All reactions