This video is part of the Tecplot for Barracuda Training Videos collection.
This training video shows how to calculate spatial average axial profiles from Tecplot for Barracuda using PyTecplot. It is necessary to have Python installed in order to perform this analysis.
Concepts covered in this video:
- Enabling PyTecplot connections
- Analyzing 3D visualization data to create a reduced-order xy plot
Related references of interest for the topics discussed in this video include:
The contents of the Python script shown in the video are included below for easy copy-and-paste.
#!/usr/bin/env python
import tecplot as tp
import numpy as np
from scipy import stats
tp.session.connect()
with tp.session.suspend():
dataset = tp.active_frame().dataset
# Get cell-center values for z-position
tp.data.operate.execute_equation(equation='{zCenter} = {z}', value_location=tp.constant.ValueLocation.CellCentered)
z = dataset.zone('Cells').values('zCenter').as_numpy_array()
# Get the time-average particle volume fraction
aveParticleVolFrac = dataset.zone('Cells').values('Time-averaged particle volume fraction').as_numpy_array()
# Calculate the spatially averaged profile
bin_means, bin_edges, binnumber = stats.binned_statistic(z, aveParticleVolFrac, statistic='mean', bins=20)
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2
# Export the calculated profile to an SFF file so it can be plotted with Tecplot
headerText = "# Spatial average calculation results\n"
headerText += "#\n"
headerText += "#@ 1 \"Time-averaged particle volume fraction\" \"\"\n"
headerText += "#@ 2 \"Height\" \"m\""
np.savetxt('time_and_spatial_average_profile_particle_volume_fraction.sff', np.transpose([bin_means, bin_centers]),
fmt='%3.6e', comments='', header=headerText)
#!/usr/bin/env python
import tecplot as tp
import numpy as np
from scipy import stats
tp.session.connect()
with tp.session.suspend():
dataset = tp.active_frame().dataset
# Get cell-center values for z-position
tp.data.operate.execute_equation(equation='{zCenter} = {z}', value_location=tp.constant.ValueLocation.CellCentered)
z = dataset.zone('Cells').values('zCenter').as_numpy_array()
# Get the time-average particle volume fraction
aveParticleVolFrac = dataset.zone('Cells').values('Time-averaged particle volume fraction').as_numpy_array()
# Calculate the spatially averaged profile
bin_means, bin_edges, binnumber = stats.binned_statistic(z, aveParticleVolFrac, statistic='mean', bins=20)
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2
# Export the calculated profile to an SFF file so it can be plotted with Tecplot
headerText = "# Spatial average calculation results\n"
headerText += "#\n"
headerText += "#@ 1 \"Time-averaged particle volume fraction\" \"\"\n"
headerText += "#@ 2 \"Height\" \"m\""
np.savetxt('time_and_spatial_average_profile_particle_volume_fraction.sff', np.transpose([bin_means, bin_centers]),
fmt='%3.6e', comments='', header=headerText)
#!/usr/bin/env python import tecplot as tp import numpy as np from scipy import stats tp.session.connect() with tp.session.suspend(): dataset = tp.active_frame().dataset # Get cell-center values for z-position tp.data.operate.execute_equation(equation='{zCenter} = {z}', value_location=tp.constant.ValueLocation.CellCentered) z = dataset.zone('Cells').values('zCenter').as_numpy_array() # Get the time-average particle volume fraction aveParticleVolFrac = dataset.zone('Cells').values('Time-averaged particle volume fraction').as_numpy_array() # Calculate the spatially averaged profile bin_means, bin_edges, binnumber = stats.binned_statistic(z, aveParticleVolFrac, statistic='mean', bins=20) bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2 # Export the calculated profile to an SFF file so it can be plotted with Tecplot headerText = "# Spatial average calculation results\n" headerText += "#\n" headerText += "#@ 1 \"Time-averaged particle volume fraction\" \"\"\n" headerText += "#@ 2 \"Height\" \"m\"" np.savetxt('time_and_spatial_average_profile_particle_volume_fraction.sff', np.transpose([bin_means, bin_centers]), fmt='%3.6e', comments='', header=headerText)