# How to calculate/report torque acting on a rotor's shaft?

 Torque acting on a shaft is always an important quantity user often wants to caculate and monitor from a simulation. Fluent postprocessing REPORT panel allows users to report moment of the face acting on a face around a specified point. If a shaft is aligned with any of the X, Y or Z coordinates, then the torque acting on the shaft will be the same as the moment reported for the alligned axis. If the shaft is not aligned with any coordinates, user has to do some hand calculations. First, user must choose a moment center (any point that axis os the shaft passes through), then calculate torque using dot product of two vectors (the moment vector reported in the fluent console window and the shaft directional vector).For many pump applications, as rotor rotates, the openning of the flow passage is changing as well. As a result, flow rate, torque and force acting on a rotor will change with time. During unsteady simulations, user often wants to monitor torque and force, and want to save such information in a file for future postprocessing.For such purpose, if the shaft is aligned with any coordinates, user can use Solve/Monitor/Force Monitor panel to monitor or save force or moment. For each force or moment, user has to define a separate monitor. If shafe is not alighed with coordinates or user wants to extract all force/moment information into a data file for any future use, the following udf can be used:/* the following udf will calculate force and torque acting on a shaft and write out all the information in a data file */#include "udf.h"#include "f_wall.h"int flag=0;DEFINE_ADJUST(adjust_torque, domain){ Thread *face_rotor,*face_inlet,*face_outlet; face_t f; FILE *fp; real force_rotor,moment_rotor; real point_rotor={0.0, 0.0, 0.0}; /* Any point at shaft axis */ real axis_rotor = {-3.42020143, 0.0, 9.3969262}; /* shaft axis directional vector */ real mag_rotor,torque_rotor,flowrate_inlet,flowrate_outlet;face_rotor = Lookup_Thread(domain,NUM1); /* NUM1 is the rotor face ID number, can be found in the Define/Boundary Condition panel */face_inlet = Lookup_Thread(domain,NUM2); /* NUM2 is the inlet face ID number, can be found in the Define/Boundary Condition panel */face_outlet = Lookup_Thread(domain,NUM3); /* NUM3 is the outlet face ID number, can be found in the Define/Boundary Condition panel */if ( flag !=N_TIME){fp=fopen("report.dat","a+");if(flag==0) { fprintf(fp,"time inlet_flow_rate outlet_flow_rate torque_rotor F_x F_y F_z n"); }flag=N_TIME;/* calcaulate torque/force acting on rotors */Compute_Force_And_Moment (domain, face_rotor, point_rotor, force_rotor, moment_rotor,1);mag_rotor = NV_MAG(axis_rotor);NV_S (axis_rotor, *=, 1.0/mag_rotor);torque_rotor = NV_DOT(moment_rotor, axis_rotor);/* calculate the inelt and outlet mass flow rate */flowrate_inlet = 0.0;flowrate_outlet = 0.0;begin_f_loop(f, face_inlet) { flowrate_inlet += F_FLUX(f, face_inlet); }end_f_loop(f, face_inlet)begin_f_loop(f, face_outlet) { flowrate_outlet += F_FLUX(f, face_outlet); }end_f_loop(f, face_outlet)fprintf(fp," %gt%gt%gt%gt%gt%gt%gt%gt%gt%gt%gn",CURRENT_TIME,flowrate_inlet,flowrate_outlet, torque_rotor,force_rotor,force_rotor,force_rotor);Message(" time=%ft (s)",CURRENT_TIME);Message(" force on the rotor=%ft%ft%fn",force_rotor,force_rotor,force_rotor);Message(" Moment on the rotor=%ft%ft%fn",moment_rotor,moment_rotor,moment_rotor);Message(" Torque on upper rotor=%fn",torque_rotor);Message(" mass flow rate at inlet =%fn",flowrate_inlet);Message(" mass flow rate at outlet =%fn",flowrate_outlet);fclose(fp);}}