Skip to content

Commit b3348f3

Browse files
Fix class example and reorg API reference (#615)
* Correct wrong examples * Add documentation for TimeAverageProbe and SurfaceProbe Output * Unify formatting * Fix reference * Add another wall example * Fix UDD text --------- Co-authored-by: Ben <[email protected]>
1 parent 822c174 commit b3348f3

File tree

6 files changed

+310
-169
lines changed

6 files changed

+310
-169
lines changed

flow360/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@
102102
SurfaceIntegralOutput,
103103
SurfaceOutput,
104104
SurfaceProbeOutput,
105+
TimeAverageProbeOutput,
105106
TimeAverageSliceOutput,
106107
TimeAverageSurfaceOutput,
108+
TimeAverageSurfaceProbeOutput,
107109
TimeAverageVolumeOutput,
108110
UserDefinedField,
109111
VolumeOutput,
@@ -230,4 +232,6 @@
230232
"VolumeMesh",
231233
"UserDefinedFarfield",
232234
"Geometry",
235+
"TimeAverageProbeOutput",
236+
"TimeAverageSurfaceProbeOutput",
233237
]

flow360/component/simulation/models/surface_models.py

+79-68
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,20 @@ class TotalPressure(SingleAttributeModel):
114114

115115
class Pressure(SingleAttributeModel):
116116
"""
117-
:class:`Pressure` class to specify the pressure for `Outflow`
117+
:class:`Pressure` class to specify the static pressure for `Outflow`
118118
boundary condition via :py:attr:`Outflow.spec`.
119119
120120
Example
121121
-------
122122
123-
>>> fl.TotalPressure(value = 1.01e6 * fl.u.Pa)
123+
>>> fl.Pressure(value = 1.01e6 * fl.u.Pa)
124124
125125
====
126126
"""
127127

128128
type_name: Literal["Pressure"] = pd.Field("Pressure", frozen=True)
129129
# pylint: disable=no-member
130-
value: PressureType.Positive = pd.Field(description="The pressure value.")
130+
value: PressureType.Positive = pd.Field(description="The static pressure value.")
131131

132132

133133
class MassFlowRate(SingleAttributeModel):
@@ -199,28 +199,39 @@ class Wall(BoundaryBase):
199199
Example
200200
-------
201201
202-
- :code:`Wall` with wall function:
202+
- :code:`Wall` with wall function and prescribed velocity:
203203
204-
>>> fl.Wall(
205-
... entities=geometry["wall_function"],
206-
... use_wall_function=True,
207-
... )
204+
>>> fl.Wall(
205+
... entities=geometry["wall_function"],
206+
... velocity = ["min(0.2, 0.2 + 0.2*y/0.5)", "0", "0.1*y/0.5"],
207+
... use_wall_function=True,
208+
... )
209+
210+
>>> fl.Wall(
211+
... entities=volume_mesh["8"],
212+
... velocity = (
213+
... f"{OMEGA[1]} * (z - {CENTER[2]}) - {OMEGA[2]} * (y - {CENTER[1]})",
214+
... f"{OMEGA[2]} * (x - {CENTER[0]}) - {OMEGA[0]} * (z - {CENTER[2]})",
215+
... f"{OMEGA[0]} * (y - {CENTER[1]}) - {OMEGA[1]} * (x - {CENTER[0]})",
216+
... ),
217+
... use_wall_function=True,
218+
... )
208219
209220
- Define isothermal wall boundary condition on entities
210221
with the naming pattern :code:`"fluid/isothermal-*"`:
211222
212-
>>> fl.Wall(
213-
... entities=volume_mesh["fluid/isothermal-*"],
214-
... heat_spec=fl.Temperature(350 * fl.u.K),
215-
... )
223+
>>> fl.Wall(
224+
... entities=volume_mesh["fluid/isothermal-*"],
225+
... heat_spec=fl.Temperature(350 * fl.u.K),
226+
... )
216227
217228
- Define isoflux wall boundary condition on entities
218229
with the naming pattern :code:`"solid/isoflux-*"`:
219230
220-
>>> fl.Wall(
221-
... entities=volume_mesh["solid/isoflux-*"],
222-
... heat_spec=fl.HeatFlux(1.0 * fl.u.W/fl.u.m**2),
223-
... )
231+
>>> fl.Wall(
232+
... entities=volume_mesh["solid/isoflux-*"],
233+
... heat_spec=fl.HeatFlux(1.0 * fl.u.W/fl.u.m**2),
234+
... )
224235
225236
====
226237
"""
@@ -252,20 +263,20 @@ class Freestream(BoundaryBaseWithTurbulenceQuantities):
252263
253264
- Define freestream boundary condition with velocity expression:
254265
255-
>>> fl.Freestream(
256-
... surfaces=[volume_mesh["blk-1/zblocks"],
257-
... volume_mesh["blk-1/xblocks"]],
258-
... velocity = ["min(0.2, 0.2 + 0.2*y/0.5)", "0", "0.1*y/0.5"]
259-
... )
266+
>>> fl.Freestream(
267+
... surfaces=[volume_mesh["blk-1/zblocks"],
268+
... volume_mesh["blk-1/xblocks"]],
269+
... velocity = ["min(0.2, 0.2 + 0.2*y/0.5)", "0", "0.1*y/0.5"]
270+
... )
260271
261272
- Define freestream boundary condition with turbulence quantities:
262273
263-
>>> fl.Freestream(
264-
... entities=[volume_mesh['freestream']],
265-
... turbulence_quantities= fl.TurbulenceQuantities(
266-
... modified_viscosity_ratio=10,
267-
... )
268-
... )
274+
>>> fl.Freestream(
275+
... entities=[volume_mesh['freestream']],
276+
... turbulence_quantities= fl.TurbulenceQuantities(
277+
... modified_viscosity_ratio=10,
278+
... )
279+
... )
269280
270281
====
271282
"""
@@ -293,24 +304,24 @@ class Outflow(BoundaryBase):
293304
-------
294305
- Define outflow boundary condition with pressure:
295306
296-
>>> fl.Outflow(
297-
... surfaces=volume_mesh["fluid/outlet"],
298-
... spec=fl.Pressure(value = 0.99e6 * fl.u.Pa)
299-
... )
307+
>>> fl.Outflow(
308+
... surfaces=volume_mesh["fluid/outlet"],
309+
... spec=fl.Pressure(value = 0.99e6 * fl.u.Pa)
310+
... )
300311
301312
- Define outflow boundary condition with Mach number:
302313
303-
>>> fl.Outflow(
304-
... surfaces=volume_mesh["fluid/outlet"],
305-
... spec=fl.Mach(value = 0.2)
306-
... )
314+
>>> fl.Outflow(
315+
... surfaces=volume_mesh["fluid/outlet"],
316+
... spec=fl.Mach(value = 0.2)
317+
... )
307318
308319
- Define outflow boundary condition with mass flow rate:
309320
310-
>>> fl.Outflow(
311-
... surfaces=volume_mesh["fluid/outlet"],
312-
... spec=fl.MassFlowRate(123 * fl.u.lb / fl.u.s)
313-
... )
321+
>>> fl.Outflow(
322+
... surfaces=volume_mesh["fluid/outlet"],
323+
... spec=fl.MassFlowRate(123 * fl.u.lb / fl.u.s)
324+
... )
314325
315326
====
316327
"""
@@ -332,29 +343,29 @@ class Inflow(BoundaryBaseWithTurbulenceQuantities):
332343
333344
- Define inflow boundary condition with pressure:
334345
335-
>>> fl.Inflow(
336-
... entities=[geometry["inflow"]],
337-
... total_temperature=300 * fl.u.K,
338-
... spec=fl.TotalPressure(1.028e6 * fl.u.Pa),
339-
... )
346+
>>> fl.Inflow(
347+
... entities=[geometry["inflow"]],
348+
... total_temperature=300 * fl.u.K,
349+
... spec=fl.TotalPressure(1.028e6 * fl.u.Pa),
350+
... )
340351
341352
- Define inflow boundary condition with mass flow rate:
342353
343-
>>> fl.Inflow(
344-
... entities=[volume_mesh["fluid/inflow"]],
345-
... total_temperature=300 * fl.u.K,
346-
... spec=fl.MassFlowRate(123 * fl.u.lb / fl.u.s),
347-
... )
354+
>>> fl.Inflow(
355+
... entities=[volume_mesh["fluid/inflow"]],
356+
... total_temperature=300 * fl.u.K,
357+
... spec=fl.MassFlowRate(123 * fl.u.lb / fl.u.s),
358+
... )
348359
349360
- Define inflow boundary condition with turbulence quantities:
350361
351-
>>> fl.Inflow(
352-
... entities=[volume_mesh["fluid/inflow"]],
353-
... turbulence_quantities= fl.TurbulenceQuantities(
354-
... turbulent_kinetic_energy=2.312e-3 * fl.u.m **2 / fl.u.s**2,
355-
... specific_dissipation_rate= 1020 / fl.u.s,
356-
... )
357-
... )
362+
>>> fl.Inflow(
363+
... entities=[volume_mesh["fluid/inflow"]],
364+
... turbulence_quantities= fl.TurbulenceQuantities(
365+
... turbulent_kinetic_energy=2.312e-3 * fl.u.m **2 / fl.u.s**2,
366+
... specific_dissipation_rate= 1020 / fl.u.s,
367+
... )
368+
... )
358369
359370
====
360371
"""
@@ -433,21 +444,21 @@ class Periodic(Flow360BaseModel):
433444
434445
- Define a translationally periodic boundary condition using :class:`Translational`:
435446
436-
>>> fl.Periodic(
437-
... surface_pairs=[
438-
... (volume_mesh["VOLUME/BOTTOM"], volume_mesh["VOLUME/TOP"]),
439-
... (volume_mesh["VOLUME/RIGHT"], volume_mesh["VOLUME/LEFT"]),
440-
... ],
441-
... spec=fl.Translational(),
442-
... )
447+
>>> fl.Periodic(
448+
... surface_pairs=[
449+
... (volume_mesh["VOLUME/BOTTOM"], volume_mesh["VOLUME/TOP"]),
450+
... (volume_mesh["VOLUME/RIGHT"], volume_mesh["VOLUME/LEFT"]),
451+
... ],
452+
... spec=fl.Translational(),
453+
... )
443454
444455
- Define a rotationally periodic boundary condition using :class:`Rotational`:
445456
446-
>>> fl.Periodic(
447-
... surface_pairs=[(volume_mesh["VOLUME/PERIODIC-1"],
448-
... volume_mesh["VOLUME/PERIODIC-2"])],
449-
... spec=fl.Rotational()
450-
... )
457+
>>> fl.Periodic(
458+
... surface_pairs=[(volume_mesh["VOLUME/PERIODIC-1"],
459+
... volume_mesh["VOLUME/PERIODIC-2"])],
460+
... spec=fl.Rotational()
461+
... )
451462
452463
====
453464
"""

flow360/component/simulation/operating_condition/operating_condition.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,16 @@ class GenericReferenceCondition(MultiConstructorBaseModel):
188188
Example
189189
-------
190190
191-
Define :class:`GenericReferenceCondition` with :py:meth:`from_mach`:
191+
- Define :class:`GenericReferenceCondition` with :py:meth:`from_mach`:
192192
193-
>>> fl.GenericReferenceCondition.from_mach(
194-
... mach=0.2,
195-
... thermal_state=ThermalState(),
196-
... )
193+
>>> fl.GenericReferenceCondition.from_mach(
194+
... mach=0.2,
195+
... thermal_state=ThermalState(),
196+
... )
197197
198-
Define :class:`GenericReferenceCondition` with :py:attr:`velocity_magnitude`:
198+
- Define :class:`GenericReferenceCondition` with :py:attr:`velocity_magnitude`:
199199
200-
>>> fl.GenericReferenceCondition(velocity_magnitude=40 * fl.u.m / fl.u.s)
200+
>>> fl.GenericReferenceCondition(velocity_magnitude=40 * fl.u.m / fl.u.s)
201201
202202
====
203203
"""
@@ -259,18 +259,18 @@ class AerospaceCondition(MultiConstructorBaseModel):
259259
Example
260260
-------
261261
262-
- Define :class:`AerospaceCondition` with :py:meth:`from_mach`:
262+
- Define :class:`AerospaceCondition` with :py:meth:`from_mach`:
263263
264-
>>> fl.AerospaceCondition.from_mach(
265-
... mach=0,
266-
... alpha=-90 * fl.u.deg,
267-
... thermal_state=fl.ThermalState(),
268-
... reference_mach=0.69,
269-
... )
264+
>>> fl.AerospaceCondition.from_mach(
265+
... mach=0,
266+
... alpha=-90 * fl.u.deg,
267+
... thermal_state=fl.ThermalState(),
268+
... reference_mach=0.69,
269+
... )
270270
271-
- Define :class:`AerospaceCondition` with :py:attr:`velocity_magnitude`:
271+
- Define :class:`AerospaceCondition` with :py:attr:`velocity_magnitude`:
272272
273-
>>> fl.AerospaceCondition(velocity_magnitude=40 * fl.u.m / fl.u.s)
273+
>>> fl.AerospaceCondition(velocity_magnitude=40 * fl.u.m / fl.u.s)
274274
275275
====
276276
"""

0 commit comments

Comments
 (0)