uob-positron-imaging-centre / up4

Post-processor for particle data.
https://uob-positron-imaging-centre.github.io/up4/
GNU General Public License v3.0
9 stars 1 forks source link

Velocity scalar and velocity vector fields are flipped #33

Closed WJPeace1 closed 8 months ago

WJPeace1 commented 11 months ago

1 6VVM_VelVectorXZ_Slice 1 6VVM_VelScalarXZ_Slice

The attached files show a velocity vector and a velocity scalar field in the same plane at the same location. As seen by the heatmap, the velocities are flipped about the centre of the image. This is true for all data in any axis view.

DanW97 commented 11 months ago

Oops!

I will investigate.

DanW97 commented 10 months ago

Hi @WJPeace1 can you share the script you were using for the plots?

WJPeace1 commented 10 months ago

Hi @DanW97, here you go!

`

Velocity Fields

from math import inf from re import template import numpy as np import plotly as p import plotly.express as pexp import plotly.graph_objects as go import up4 from collections import defaultdict

Import data

hdf_name = '16_190_trajectories.hdf5'

Extract values for plots and tip speed calculation

filename_final = hdf_name.split(".hdf5")[0] variables = filenamefinal.split("")

if int(variables[0]) > 0: vvm = str(int(variables[0])/10) + str("VVM") else: vvm = str("Ungassed") print(vvm)

speed = int(variables[1]) speed_rpm = str(int(variables[1])) + str("RPM") statement = str(vvm) + str(" - ") + str(speed_rpm) tip_speed = (2 np.pi speed (1/60) 0.033) save_statement = str(speedrpm) + str("") + str(vvm)

Data Load-In

data = up4.Data(hdf_name)

Dimension Statistics

dim = data.dimensions() xmin = dim['xmin'] xmax = dim['xmax'] ymin = dim['ymin'] ymax = dim['ymax'] zmin = dim['zmin'] zmax = dim['zmax'] xmed = (xmin + xmax) 0.5 # midpoint in x-axis ymed = (ymin + ymax) 0.5 # midpoint in y-axis zimpeller = zmin + ((zmax - zmin)/3) # impeller level in the tank

Forming a Grid

cx = 25 cy = cx cz = cx

grid = up4.Grid.cartesian3d_from_data(data, cells = [cx,cy,cz]) # cartesian co-ordinates field = data.velocityfield(grid) xpos,ypos,zpos = field.cell_positions()

CENTRE SLICES

YMed Slice

vel_slice_ymed = np.rot90(field.slice_pos(axis = 1, position = ymed),3) fig = go.Figure() fig.add_trace(go.Heatmap(z = vel_slice_ymed, zmin = 0)) fig.update_layout( title = str(f"{statement}" + ": Central Slice Velocity Field: XZ Plane "), title_x = 0.5, width = 1000, height = 1000, xaxis_title = " r/R ", yaxis_title = " z/H ", xaxis = dict( tickmode = 'array', tickvals = [0,int(cx/4),int(cx/2),int((3cx)/4),int(cx-1)], ticktext = [" -1 ", " -0.5 "," 0 ", " 0.5 "," 1 "], ), yaxis = dict( tickmode = 'array', tickvals = [0,int(cx/4),int(cx/2),int((3cx)/4),int(cx-1)], ticktext = [" 0 ", " 0.25 "," 0.5 ", " 0.75 "," 1 "], ), template = "plotly_white", font = dict( family = "Arial", size = 20, color = "black", ) )

fig.show()

`