Cut a DNS field
Exercise 06
The cutting process of an entire field can be useful in different situations. Generally, zooming in a specific region of the flow-field helps getting results without having to handle the entire, really heavy dataset.
In this tutorial we will cut the dataset that was initialized in the previous exercise (so make sure to read it in case you jumped straight here; sorry for this, but I ensure it won't take you more than 5 minutes).
"""
Created on Fri May 24 14:50:44 2024
@author: lorenzo piu
"""
Import and field initialization
>>> import os
>>> import aPrioriDNS as ap
>>> import json
>>> directory = os.path.join('.','Lifted_H2_subdomain') # change this with your path to the data folder
>>> print(f"\nChecking the path \'{T_path}\' is correct...")
>>> if not os.path.exists(T_path):
>>> raise ValueError("The path '{T_path}' does not exist in your system. Check to have the correct path to your data folder in the code")
Checking the path '../data/Lifted_H2_subdomain/data/T_K_id000.dat' is correct...
>>> DNS_field = ap.Field3D(directory)
---------------------------------------------------------------
Initializing 3D Field
Checking files inside folder ../data/Lifted_H2_subdomain...
Folder structure OK
---------------------------------------------------------------
Building mesh attribute...
Mesh fields read correctly
---------------------------------------------------------------
Reading kinetic mechanism...
Kinetic mechanism file found: ../data/Lifted_H2_subdomain/chem_thermo_tran/li_h2.yaml
Species:
['H2', 'O2', 'H2O', 'H', 'O', 'OH', 'HO2', 'H2O2', 'N2']
---------------------------------------------------------------
Building scalar attributes...
Field attributes:
+-----------+------------------------------------------------------+
| Attribute | Path |
+-----------+------------------------------------------------------+
| P | ../data/Lifted_H2_subdomain/data/P_Pa_id000.dat |
| RHO | ../data/Lifted_H2_subdomain/data/RHO_kgm-3_id000.dat |
| T | ../data/Lifted_H2_subdomain/data/T_K_id000.dat |
| U_X | ../data/Lifted_H2_subdomain/data/UX_ms-1_id000.dat |
| U_Y | ../data/Lifted_H2_subdomain/data/UY_ms-1_id000.dat |
| U_Z | ../data/Lifted_H2_subdomain/data/UZ_ms-1_id000.dat |
| YH2 | ../data/Lifted_H2_subdomain/data/YH2_id000.dat |
| YO2 | ../data/Lifted_H2_subdomain/data/YO2_id000.dat |
| YH2O | ../data/Lifted_H2_subdomain/data/YH2O_id000.dat |
| YH | ../data/Lifted_H2_subdomain/data/YH_id000.dat |
| YO | ../data/Lifted_H2_subdomain/data/YO_id000.dat |
| YOH | ../data/Lifted_H2_subdomain/data/YOH_id000.dat |
| YHO2 | ../data/Lifted_H2_subdomain/data/YHO2_id000.dat |
| YH2O2 | ../data/Lifted_H2_subdomain/data/YH2O2_id000.dat |
| YN2 | ../data/Lifted_H2_subdomain/data/YN2_id000.dat |
+-----------+------------------------------------------------------+
Now we are going to cut the field and see what happens in our folder:
>>> cut_field_name = DNS_field.cut([20,20,10])
---------------------------------------------------------------
Cutting Field '../data/Lifted_H2_subdomain'...
Done cutting Field '../data/Lifted_H2_subdomain'.
This command acts directly on the folder, creating another folder with cut data formatted in the same way as the original ones. This makes the procedure of initializing again another field with the cut data very easy.
If you followed this procedure, this is what your folder should look like:

Read the cut field and compare it with the original
>>> DNS_field_cut = ap.Field3D(cut_field_name)
>>> DNS_field.plot_z_midplane('U_X',vmin=100,vmax=280)
>>> DNS_field_cut.plot_z_midplane('U_X',vmin=100,vmax=280)


Last updated