pmgbergen / porepy

Python Simulation Tool for Fractured and Deformable Porous Media
GNU General Public License v3.0
252 stars 88 forks source link

Numerical parameters #1150

Closed IvarStefansson closed 3 days ago

IvarStefansson commented 7 months ago

We might want to collect numerical parameters in some dedicated object, possibly of the MaterialConstants type. @keileg's comments copied from other discussion:

Agree! I can think of a few reasons for revisiting this:

  1. Cleanliness.
  2. Getting an overview of such numerical parameters in use.
  3. (hopefully) introduce scaling of numerical parameters, just as with physical ones.
IvarStefansson commented 3 months ago

Note that this may affect both model parameters and solver parameters as defined in #1210.

jwboth commented 2 months ago

Task: Map out "all" numerical constant which are potentially in use. Provide a new object (my suggestion would be to follow the naming style and use NumericalConstants) - check out models/material_constants.py as well. In the process, we will determine how subclasses can be designed to better indicate the thematic grouping of constants. The priority for the first should be the two reasons mentioned by Ivar. Scaling will follow in a second step.

isakhammer commented 2 months ago

Work in progress of Overview of Potential Parameters classes PorePy

Below is a list of parameters that are less frequently used but could be valuable to incorporate into the class.

  1. Where and what these parameters are used
    (Based on the source code)

  2. How these parameters are tested
    (Based on the testing framework, tutorials and run scripts)

Suggestions from Eirik:

Candidates for contact mechanics

Todo

Newton solver

Todo

Physical parameters

test_thermoporomechanics.py

    variable_units = [
        "Pa",
        "Pa * m^2 * s^-1",
        "m",
        "m",
        "K",
        "m^-1 * s^-1 * J",
        "m^-1 * s^-1 * J",
    ]
    compare_scaled_primary_variables(setup_0, setup_1, variables, variable_units)
    secondary_variables = ["darcy_flux", "fluid_flux", "stress", "porosity"]
    secondary_units = ["Pa * m^2 * s^-1", "kg * m^-1 * s^-1", "Pa * m", "-"]
    domain_dimensions = [None, None, 2, None]
    compare_scaled_model_quantities(
        setup_0, setup_1, secondary_variables, secondary_units, domain_dimensions
    )

test_thermoporomechanics.py 2

    params = {
        "times_to_export": [],  # Suppress output for tests
        "fracture_indices": [0],
        "cartesian": True,
        "uy_north": -1e-5,
        "material_constants": {"solid": solid, "fluid": fluid},
    }

Candidates for mesh arguments og grids

Todo

  1. test_refinement 1

    mesh_args = {"mesh_size_frac": 1, "mesh_size_bound": 1, "mesh_size_min": 0.1}
    num_ref = 3
    params = {
        "mode": "nested",
        "num_refinements": num_ref,
        "mesh_param": mesh_args,
    }
    
        params = {
        "mode": "nested",
        "num_refinements": num_ref,
        "mesh_param": mesh_args,
        # The fracture is a constraint
        "grid_param": {"constraints": np.array([0])},
    }
    
  2. test_mdg_generation

    
        def lower_level_extra_args_data_2d(self) -> List[dict]:
        """Admissible keys for 2d cases"""
        simplex_extra_args: dict = {
            "mesh_size_min": 0.5,
            "mesh_size_bound": 1.0,
            "mesh_size_frac": 0.5,
        }
        cartesian_extra_args: dict = {"nx": [10, 10], "physdims": [5, 5]}
        tensor_grid_extra_args: dict = {
            "x": np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]),
            "y": np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]),
        }
       ...
    
    def higher_level_extra_args_data_3d(self) -> List[dict]:
        """Admissible keys in pp.create_mdg for 3d cases"""
        simplex_extra_args: dict = {
            "cell_size_min": 0.5,
            "cell_size_boundary": 1.0,
            "cell_size_fracture": 0.5,
        }
        cartesian_extra_args: dict = {
            "cell_size_x": 0.5,
            "cell_size_y": 0.5,
            "cell_size_z": 0.5,
        }
    
  3. test_mdg_generation 2

            cell_size_args = ["cell_size", "cell_size_x", "cell_size_y", "cell_size_z"]
        meshing_args: dict = {
            "cell_size": 0.1,
            "cell_size_x": 0.1,
            "cell_size_y": 0.1,
            "cell_size_z": 0.1,
        }
    
jwboth commented 1 month ago

Initial tasks identified during discussion: