### Post

2 followers Follow # Working with Python: Query of through-plane flow of multiple clips in one plot

Hello everyone.

I am working with 3D velocity data. Since I need to evaluate parameters such as through-plane flow, wall shear stress etc. in several clips (n>10) I am looking for (semi-)automatic evaluation of the flow data. For that reason I am working on a python script. In doing so, I have two major questions regarding python and the implementation of a python script in Ensight. At the moment I am using Ensight 10.02(h).

1. Question:
I would like to plot the through-plane flow in several (previously calulated) 2D-clips (perpendicular to the aorta) as a time vs. flow curve. The final goal is the plot of several curves in one graph by pushing only one button.
I calculated the through-plane flow in this python script:

[quote]#Calculate the plane normals of the clip
ensight.variables.evaluate("N_plane=Normal(plist)")

#Calculate the through-plane velocity (VEL= 3D velocity field)
ensight.variables.evaluate("vel_plane=DOT(VEL,N_plane)")

#Through-plane flow = surface integral of through-plane velocity values
ensight.variables.evaluate("flow_plane=IntegralSurface(plist,vel_plane)")
[/quote]

After calculating flow_plane I plot the through-plane flow as a function of time by using the query function.
I would like to achieve this for several clips (n>10) in the most time-efficient way and I would like to have the data in one large *csv file so I can import all data at once into Excel, Matlab etc.

However, I couldn't find any useful solution to achieve this since Ensight seems to only allow queries of one clip at a time. My first idea was to achieve such a plot in a for loop over the clips. Unfortunately, since the variable flow_plane is updated with each clip and the query of the last clip is always overwritten with the values of the next clip, this solution does not work. So my question is: How can I achieve that Ensight keeps different queries of the same variable (flow_plane), even when the variable is updated with each clip.

2. Question:
For further evaluations I also need to determine the plane normals and the coordinates of the center of the clip. At the moment I am using the plane tool (right click -> edit) and copy and paste the coordinates into a python script. However, since the goal is to have a (semi-) automatic evaluation of the flow data, this solution is not optimal. So my second questions is: What are the python commands to get the important coordinates of a clip (i.e., plane normals, plane center coordinates)?

I am thanking everyone who has a useful solution for my problem or has at least some advices for me.

### 1 comment Hi Patrick,

1. There are a couple of notes here on how you're doing the analysis. First, you are calculating the flow by first getting the normal, then the normal component of the velocity, and finally integrating over the clip. All of these steps can be done by using the Flow() calculator function. If you use this function, indeed, it will do exactly the steps you are now doing manually. Give a looks at the User Manual, ch. 7.3 for a description of Flow()

Now, about your question on how to not-overwrite the variables. This is possible in 10.1.6 (and prior), but it is easier to do with the latest version, 10.2.

If you're using EnSight 10.2, you will see that it contains a new kind of variable: Constant per part. This is a variable that return a single value for each part it is calculated on. So, if you select all your clips, calculate Flow() on them and set the output to be Constant per part, you now have the Flow() variable that, for each clip, returns a single value the flow of that clip.

You can right-click on the Flow variable on the variable list (bottom-left) -> Plot vs. Time. This will create the plot with all the queries of Flow vs. time, for all the clip parts.

Now, you want to export the queries as single .csv file. Simply right-click on Flow in the variable list -> Export constant to csv

2. If you need to get the values of the plane tool used to create a plane clip, use the following commands:

from ensight.objs import core

core.PARTS[i].CLIPPLANEPT1

core.PARTS[i].CLIPPLANEPT2

core.PARTS[i].CLIPPLANEPT3

core.PARTS[i] will be the part corresponding to the clip plane part - set "i" to be the correct index. This will return the three points that are used to define the plane tool. From these points, you should be able to extract origin and normal of the plane tool.

Let us know if you have questions or need more help.
Bests,

Marina