From 637e58a195c0bc3f73bfd5a97d5206cc7461c8df Mon Sep 17 00:00:00 2001 From: Angran Li Date: Tue, 21 Jan 2025 02:46:50 +0000 Subject: [PATCH 1/2] Add porous medium example --- .../simulation/models/volume_models.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/flow360/component/simulation/models/volume_models.py b/flow360/component/simulation/models/volume_models.py index 07cb9ac6c..d8cd2cc45 100644 --- a/flow360/component/simulation/models/volume_models.py +++ b/flow360/component/simulation/models/volume_models.py @@ -699,11 +699,15 @@ def _ensure_entities_have_sufficient_attributes(cls, value: EntityList): class PorousMedium(Flow360BaseModel): """ :class:`PorousMedium` class for specifying porous media settings.`. - For further information please refer to the :ref:`porous media knowledge base ` + For further information please refer to the :ref:`porous media knowledge base `. Example ------- + Define a porous medium model :code:`porous_zone` with the :py:class:`Box` entity. + The center and size of the `porous_zone` box is (0, 0, 0) * fl.u.m and (0.2, 0.3, 2) * fl.u.m, respectively. + The axes of the :code:`porous_zone` is set as (0, 1, 0) and (0, 0, 1). + >>> fl.PorousMedium( ... entities=[ ... fl.Box.from_principal_axes( @@ -718,6 +722,19 @@ class PorousMedium(Flow360BaseModel): ... volumetric_heat_source=1.0 * fl.u.W/ fl.u.m **3, ... ) + Define a porous medium model :code:`porous_zone` with the :code:`volume_mesh["porous_zone"]` volume. + The axes of entity must be specified for the :class:`PorousMedium` model, and we set the axes of + the :code:`porous_zone` as (1, 0, 0) and (0, 1, 0). + + >>> porous_zone = volume_mesh["porous_zone"] + >>> porous_zone.axes = [(1, 0, 0), (0, 1, 0)] + >>> porous_medium_model = fl.PorousMedium( + ... entities=[porous_zone], + ... darcy_coefficient=(1e6, 0, 0) / fl.u.m **2, + ... forchheimer_coefficient=(1, 0, 0) / fl.u.m, + ... volumetric_heat_source=1.0 * fl.u.W/ fl.u.m **3, + ... ) + ==== """ @@ -726,7 +743,8 @@ class PorousMedium(Flow360BaseModel): entities: EntityList[GenericVolume, Box] = pd.Field( alias="volumes", description="The entity list for the `PorousMedium` model. " - + "The entity should be :class:`Box` type.", + + "The entity should be defined by :class:`Box` or zones from the geometry/volume mesh." + + "The axes of entity must be specified for the :class:`PorousMedium` model.", ) darcy_coefficient: InverseAreaType.Point = pd.Field( From b9ee718521adc08dab92320bf1b35d9dbd06dc7b Mon Sep 17 00:00:00 2001 From: Angran Li Date: Tue, 21 Jan 2025 14:21:08 +0000 Subject: [PATCH 2/2] Address comments --- .../component/simulation/models/volume_models.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flow360/component/simulation/models/volume_models.py b/flow360/component/simulation/models/volume_models.py index d8cd2cc45..1f2c058ef 100644 --- a/flow360/component/simulation/models/volume_models.py +++ b/flow360/component/simulation/models/volume_models.py @@ -698,15 +698,15 @@ def _ensure_entities_have_sufficient_attributes(cls, value: EntityList): class PorousMedium(Flow360BaseModel): """ - :class:`PorousMedium` class for specifying porous media settings.`. + :class:`PorousMedium` class for specifying porous media settings. For further information please refer to the :ref:`porous media knowledge base `. Example ------- Define a porous medium model :code:`porous_zone` with the :py:class:`Box` entity. - The center and size of the `porous_zone` box is (0, 0, 0) * fl.u.m and (0.2, 0.3, 2) * fl.u.m, respectively. - The axes of the :code:`porous_zone` is set as (0, 1, 0) and (0, 0, 1). + The center and size of the `porous_zone` box are (0, 0, 0) * fl.u.m and (0.2, 0.3, 2) * fl.u.m, respectively. + The axes of the :code:`porous_zone` are set as (0, 1, 0) and (0, 0, 1). >>> fl.PorousMedium( ... entities=[ @@ -723,8 +723,8 @@ class PorousMedium(Flow360BaseModel): ... ) Define a porous medium model :code:`porous_zone` with the :code:`volume_mesh["porous_zone"]` volume. - The axes of entity must be specified for the :class:`PorousMedium` model, and we set the axes of - the :code:`porous_zone` as (1, 0, 0) and (0, 1, 0). + The axes of entity must be specified to serve as the the principle axes of the porous medium + material model, and we set the axes of the :code:`porous_zone` as (1, 0, 0) and (0, 1, 0). >>> porous_zone = volume_mesh["porous_zone"] >>> porous_zone.axes = [(1, 0, 0), (0, 1, 0)] @@ -744,7 +744,8 @@ class PorousMedium(Flow360BaseModel): alias="volumes", description="The entity list for the `PorousMedium` model. " + "The entity should be defined by :class:`Box` or zones from the geometry/volume mesh." - + "The axes of entity must be specified for the :class:`PorousMedium` model.", + + "The axes of entity must be specified to serve as the the principle axes of the " + + "porous medium material model.", ) darcy_coefficient: InverseAreaType.Point = pd.Field( @@ -759,7 +760,6 @@ class PorousMedium(Flow360BaseModel): volumetric_heat_source: Optional[Union[StringExpression, HeatSourceType]] = pd.Field( None, description="The volumetric heat source." ) - # Note: Axes will always come from the entity @pd.field_validator("entities", mode="after") @classmethod