Skip to content

[Hotfix 25.2]: Add examples for Liquid related classes (#1127) #1129

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions flow360/component/simulation/models/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,34 @@ class SolidMaterial(MaterialBase):
)


<<<<<<< HEAD
=======
class Water(MaterialBase):
"""
Water material used for :class:`LiquidOperatingCondition`

Example
-------

>>> fl.Water(
... name="Water",
... density=1000 * fl.u.kg / fl.u.m**3,
... dynamic_viscosity=0.001002 * fl.u.kg / fl.u.m / fl.u.s,
... )

====
"""

type: Literal["water"] = pd.Field("water", frozen=True)
name: str = pd.Field(frozen=True, description="Custom name of the water with given property.")
density: Optional[DensityType.Positive] = pd.Field(
1000 * u.kg / u.m**3, frozen=True, description="Density of the water."
)
dynamic_viscosity: ViscosityType.NonNegative = pd.Field(
0.001002 * u.kg / u.m / u.s, frozen=True, description="Dynamic viscosity of the water."
)


>>>>>>> a94fa980 (Add examples for Liquid related classes (#1127) (#1128))
SolidMaterialTypes = SolidMaterial
FluidMaterialTypes = Air
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,64 @@ def flow360_reynolds_number(self, length_unit: LengthType.Positive):
).value


<<<<<<< HEAD
=======
class LiquidOperatingCondition(Flow360BaseModel):
"""
Operating condition for simulation of water as the only material.

Example
-------

>>> fl.LiquidOperatingCondition(
... velocity_magnitude=10 * fl.u.m / fl.u.s,
... alpha=-90 * fl.u.deg,
... beta=0 * fl.u.deg,
... material=fl.Water(name="Water"),
... reference_velocity_magnitude=5 * fl.u.m / fl.u.s,
... )

====
"""

type_name: Literal["LiquidOperatingCondition"] = pd.Field(
"LiquidOperatingCondition", frozen=True
)
alpha: AngleType = ConditionalField(0 * u.deg, description="The angle of attack.", context=CASE)
beta: AngleType = ConditionalField(0 * u.deg, description="The side slip angle.", context=CASE)
velocity_magnitude: Optional[VelocityType.NonNegative] = ConditionalField(
context=CASE,
description="Incoming flow velocity magnitude. Used as reference velocity magnitude"
+ " when :py:attr:`reference_velocity_magnitude` is not specified. Cannot change once specified.",
frozen=True,
)
reference_velocity_magnitude: Optional[VelocityType.Positive] = CaseField(
None,
description="Reference velocity magnitude. Is required when :py:attr:`velocity_magnitude` is 0."
" Used as the velocity scale for nondimensionalization.",
frozen=True,
)
material: Water = pd.Field(
Water(name="Water"),
description="Type of liquid material used.",
)

@pd.model_validator(mode="after")
@context_validator(context=CASE)
def check_valid_reference_velocity(self) -> Self:
"""Ensure reference velocity is provided when inflow velocity is 0."""
if (
self.velocity_magnitude is not None
and self.velocity_magnitude.value == 0
and self.reference_velocity_magnitude is None
):
raise ValueError(
"Reference velocity magnitude must be provided when inflow velocity magnitude is 0."
)
return self


>>>>>>> a94fa980 (Add examples for Liquid related classes (#1127) (#1128))
# pylint: disable=fixme
# TODO: AutomotiveCondition
OperatingConditionTypes = Union[GenericReferenceCondition, AerospaceCondition]
Expand Down