Skip to content

Commit

Permalink
ADI: add GetDiskAvgVel to regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Dec 19, 2024
1 parent 1ac5f89 commit 2052f62
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
42 changes: 40 additions & 2 deletions modules/aerodyn/python-lib/aerodyn_inflow_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ def _initialize_routines(self):
self.ADI_C_GetRotorLoads.restype = c_int


self.ADI_C_GetDiskAvgVel.argtypes = [
POINTER(c_int), # iturb
POINTER(c_float), # Disk average vel vector
POINTER(c_int), # ErrStat_C
POINTER(c_char) # ErrMsg_C
]
self.ADI_C_GetDiskAvgVel.restype = c_int


self.ADI_C_CalcOutput.argtypes = [
POINTER(c_double), # Time_C
POINTER(c_float), # Output Channel Values
Expand Down Expand Up @@ -497,7 +506,7 @@ def adi_setrotormotion(self, iturb, \
self.check_error()


# adi_calcOutput ------------------------------------------------------------------------------------------------------------
# adi_getrotorloads ---------------------------------------------------------------------------------------------------------
def adi_getrotorloads(self, iturb, meshFrcMom, hhVel=None):
# Resulting Forces/moments -- [Fx1,Fy1,Fz1,Mx1,My1,Mz1, Fx2,Fy2,Fz2,Mx2,My2,Mz2 ...]
_meshFrc_flat_c = (c_float * (6 * self.numMeshPts))(0.0,)
Expand Down Expand Up @@ -532,6 +541,28 @@ def adi_getrotorloads(self, iturb, meshFrcMom, hhVel=None):
hhVel[1] = _hhVel_flat_c[1]
hhVel[2] = _hhVel_flat_c[2]


# adi_getdiskavgvel ---------------------------------------------------------------------------------------------------------
def adi_getdiskavgvel(self, iturb, diskAvgVel):
# Resulting disk average velocity [Vx,Vy,Vz]
_diskAvgVel_flat_c = (c_float * 3)(0.0,)

# Run ADI_GetDiskAvgVel
self.ADI_C_GetDiskAvgVel(
c_int(iturb), # IN: iturb -- current turbine number
_diskAvgVel_flat_c, # OUT: disk average velocity [Vx, Vy, Vz]
byref(self.error_status_c), # OUT: ErrStat_C
self.error_message_c # OUT: ErrMsg_C
)

self.check_error()

## Disk average wind speed
diskAvgVel[0] = _diskAvgVel_flat_c[0]
diskAvgVel[1] = _diskAvgVel_flat_c[1]
diskAvgVel[2] = _diskAvgVel_flat_c[2]


# adi_calcOutput ------------------------------------------------------------------------------------------------------------
def adi_calcOutput(self, time, outputChannelValues):

Expand Down Expand Up @@ -914,6 +945,9 @@ def __init__(self,filename,numMeshPts):
self.DbgFile.write(f_string.format(f_num+"Mx" ))
self.DbgFile.write(f_string.format(f_num+"My" ))
self.DbgFile.write(f_string.format(f_num+"Mz" ))
self.DbgFile.write(f_string.format(f_num+"DskAvgVx" ))
self.DbgFile.write(f_string.format(f_num+"DskAvgVy" ))
self.DbgFile.write(f_string.format(f_num+"DskAvgVz" ))
self.DbgFile.write("\n")
self.DbgFile.write(" (s) ")
for i in range(1,self.numMeshPts+1):
Expand Down Expand Up @@ -941,10 +975,13 @@ def __init__(self,filename,numMeshPts):
self.DbgFile.write(f_string.format("(N-m)" ))
self.DbgFile.write(f_string.format("(N-m)" ))
self.DbgFile.write(f_string.format("(N-m)" ))
self.DbgFile.write(f_string.format("(m/s)" ))
self.DbgFile.write(f_string.format("(m/s)" ))
self.DbgFile.write(f_string.format("(m/s)" ))
self.DbgFile.write("\n")
self.opened = True

def write(self,t,meshPos,meshVel,meshAcc,meshFrc):
def write(self,t,meshPos,meshVel,meshAcc,meshFrc,DiskAvgVel):
t_string = "{:10.4f}"
f_string3 = "{:25.7e}"*3
f_string6 = "{:25.7e}"*6
Expand All @@ -954,6 +991,7 @@ def write(self,t,meshPos,meshVel,meshAcc,meshFrc):
self.DbgFile.write(f_string6.format(*meshVel[i,:]))
self.DbgFile.write(f_string6.format(*meshAcc[i,:]))
self.DbgFile.write(f_string6.format(*meshFrc[i,:]))
self.DbgFile.write(f_string3.format(*DiskAvgVel[:]))
self.DbgFile.write("\n")

def end(self):
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/r-test

0 comments on commit 2052f62

Please sign in to comment.