Getting Started with cooldata

This shows you how to get started with the cooldata package.

First, install it with:

pip install cooldata

The PyVista dataset is the main format to use the cooldata library. It allows you to load and visualize the samples from the dataset in its original format, which is CGNS files. Let us now load a few samples from Hugging Face:

from cooldata.pyvista_flow_field_dataset import PyvistaFlowFieldDataset

ds_pv = PyvistaFlowFieldDataset.load_from_huggingface(
    num_samples=12, data_dir="datasets/pyvista"
)
Loaded 12 samples from '/Users/ole/Documents/software/flow_field_dataset/docs/usage/datasets/pyvista'.
Loaded 12 samples from 'datasets/pyvista'.

Next, let us explore the first sample of the dataset:

ds_pv[0]

Design ID: 125002

Quader 1\nTemp: 24.8\nPos: (0.02, 0.07)\nSize: (0.15, 0.05) Quader 2\nTemp: 72.1\nPos: (0.08, 0.09)\nSize: (0.14, 0.06) Quader 3\nTemp: 40.7\nPos: (0.20, 1.00)\nSize: (0.05, 0.01) Quader 4\nTemp: 29.5\nPos: (0.12, 0.03)\nSize: (0.08, 0.01) Cylinder 1\nTemp: 70.8\nPos: (0.07, 1.00)\nRadius: 0.00 Cylinder 2\nTemp: 79.8\nPos: (0.11, 1.00)\nRadius: 0.01

Bounding Box (xmin, xmax, ymin, ymax): (-0.00, 0.50, 0.00, 0.10)

We can see a 2d projection of the sample: The flow comes in from the left, there are three rectangular obstacles in the flow, and the flow exits on the right side. Now, let us visualize the sample in 3D:

Hide code cell content

import pyvista as pv
pv.set_jupyter_backend('static')
ds_pv[0].plot_volume("Pressure")
../_images/11aaf65f11d75cab5ee1321e69e25738124ad294b6a3b0c9ab1335dc46322bdf.png

We can now explore all the data stored in the sample:

ds_pv[0].metadata
SystemParameters(V=1.4626069901096383, Quads=[Quader(T=24.795703504009577, Pos=Position(x=0.018249944958045404, y=0.06611177279292552, z=0.0), Size=(0.1542503652893203,0.05499632681045156,0.016728866350987515)), Quader(T=72.13221452936163, Pos=Position(x=0.08315818417399129, y=0.08644018438488871, z=0.0), Size=(0.13550081561748564,0.05539239193604516,0.0010947800005462244)), Quader(T=40.687050706967995, Pos=Position(x=0.20406612028393045, y=1.0, z=0.0), Size=(0.05244352457224315,0.009513245853355834,0.005394400102415295)), Quader(T=29.463879851447047, Pos=Position(x=0.1218932063793058, y=0.026242579476390363, z=0.0), Size=(0.08232690355562347,0.012072830018052226,0.01293103689992766))], Cylinders=[Cylinder(T=70.77853091451576, Pos=Position(x=0.06680530419385315, y=1.0, z=0.0), R=0.00340009194521868, H=0.012298788960518715), Cylinder(T=79.75310612993478, Pos=Position(x=0.11484837821122404, y=1.0, z=0.0), R=0.009343639447153376, H=0.017957435919084004)])
ds_pv[0].volume_data[0][0]
InformationBlocks
MultiBlockValues
N Blocks:2
X Bounds:-4.337e-19, 5.000e-01
Y Bounds:0.000e+00, 1.000e-01
Z Bounds:0.000e+00, 2.000e-02
IndexNameType
0InternalUnstructuredGrid
1PatchesMultiBlock
ds_pv[0].volume_data[0][0][0]
HeaderData Arrays
UnstructuredGridInformation
N Cells187194
N Points205437
X Bounds-4.337e-19, 5.000e-01
Y Bounds0.000e+00, 1.000e-01
Z Bounds0.000e+00, 2.000e-02
N Arrays10
NameFieldTypeN CompMinMax
PressureCellsfloat641-9.924e+001.036e+01
TemperatureCellsfloat6412.931e+023.449e+02
TurbulentDissipationRateCellsfloat6417.667e-091.722e+03
TurbulentKineticEnergyCellsfloat6411.000e-107.283e-01
Velocity_0Cellsfloat641-1.501e+004.269e+00
Velocity_1Cellsfloat641-2.486e+001.829e+00
Velocity_2Cellsfloat641-5.805e-013.984e+00
VolumeCellsfloat6411.368e-119.567e-09
Base/ZoneFields1nannan
ispatchFieldsint3210.000e+000.000e+00

You can now work with these fields. For example, let us look at the average velocity in the flow in the x-direction:

ds_pv[0].volume_data[0][0][0].cell_data["Velocity_0"].mean()
0.7326225377343115

You may see this is good for exploration, but not well-suited for training a model. Therefore, in the next section, we will explore how to convert the data to a voxelized format.