From ff4591a3ee836a76267dce448eaca1f1ae63d3cd Mon Sep 17 00:00:00 2001 From: acrovato <a.crovato@uliege.be> Date: Fri, 8 Mar 2024 10:22:00 +0100 Subject: [PATCH] Clean utils --- dart/api/internal/polar.py | 2 +- dart/api/internal/trim.py | 2 +- dart/utils.py | 6 +++--- dart/validation/agard.py | 2 +- dart/validation/crm.py | 2 +- dart/validation/onera.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dart/api/internal/polar.py b/dart/api/internal/polar.py index 695312c..a780f31 100644 --- a/dart/api/internal/polar.py +++ b/dart/api/internal/polar.py @@ -109,7 +109,7 @@ class Polar: Cp = dU.extract(self.bnd.groups[0].tag.elems, self.sol.Cp) tU.write(Cp, f'Cp_{self.msh.name}_airfoil{acs}.dat', '%1.5e', ', ', 'alpha = '+str(alpha*180/math.pi)+' deg\nx, y, z, Cp', '') elif self.dim == 3 and self.format == 'vtk' and self.slice: - dU.writeSlices(self.msh.name, self.slice, self.tag, acs) + dU.write_slices(self.msh.name, self.slice, self.tag, acs) # extract force coefficients self.Cls.append(self.sol.Cl) self.Cds.append(self.sol.Cd) diff --git a/dart/api/internal/trim.py b/dart/api/internal/trim.py index fd25625..976e882 100644 --- a/dart/api/internal/trim.py +++ b/dart/api/internal/trim.py @@ -121,7 +121,7 @@ class Trim: Cp = dU.extract(self.bnd.groups[0].tag.elems, self.sol.Cp) tU.write(Cp, f'Cp_{self.msh.name}_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') elif self.dim == 3 and self.format == 'vtk' and self.slice: - dU.writeSlices(self.msh.name, self.slice, self.tag) + dU.write_slices(self.msh.name, self.slice, self.tag) def disp(self): """Display the results diff --git a/dart/utils.py b/dart/utils.py index 4f268a9..6d846bf 100644 --- a/dart/utils.py +++ b/dart/utils.py @@ -19,7 +19,7 @@ ## Utilities for dart # Adrien Crovato -def computeAeroCoef(_x, _y, _Cp, _alpha): +def compute_aero_coeff(_x, _y, _Cp, _alpha): """Compute 2D aerodynamic coefficients The coefficients are computed from Cp averaged at nodes, which might leads to innacurate results For accurate results, use coefficients from solver or body objects @@ -65,7 +65,7 @@ def convex_sort(vNodes, vData): angle = np.zeros((vNodes.size())) i = 0 while i < len(data[:,0]): - angle[i] = math.atan2(data[i,1]-cg[1],data[i,0]-cg[0]) + angle[i] = np.arctan2(data[i,1]-cg[1], data[i,0]-cg[0]) if angle[i] < 0: angle[i] = 2 * np.pi + angle[i] i+=1 @@ -111,7 +111,7 @@ def extract(vElems, vData): i += 1 return data -def writeSlices(mshName, ys, wId, sfx=''): +def write_slices(mshName, ys, wId, sfx=''): """Write slice data for each ys coordinate along the span (only works with VTK) Parameters diff --git a/dart/validation/agard.py b/dart/validation/agard.py index bda122b..9d48d8e 100644 --- a/dart/validation/agard.py +++ b/dart/validation/agard.py @@ -83,7 +83,7 @@ def main(): # post process tms['post'].start() if canPost: - floU.writeSlices(msh.name,[0.01, 0.37, 0.75],5) + floU.write_slices(msh.name,[0.01, 0.37, 0.75],5) data = tbxU.read('agard445_slice_1.dat') floD.plot(data[:,3], data[:,4], {'xlabel': 'x', 'ylabel': 'Cp', 'title': 'Pressure distribution at MAC', 'invert': True}) tms['post'].stop() diff --git a/dart/validation/crm.py b/dart/validation/crm.py index c773d86..dbc5234 100644 --- a/dart/validation/crm.py +++ b/dart/validation/crm.py @@ -106,7 +106,7 @@ def main(): # post tms['pos'].start() if hasVTK: - utils.writeSlices(msh.name, [3.81973, 5.8765, 8.2271, 11.753, 14.6913, 17.6295, 19.0986, 21.4492, 24.9751, 27.91338], 12) + utils.write_slices(msh.name, [3.81973, 5.8765, 8.2271, 11.753, 14.6913, 17.6295, 19.0986, 21.4492, 24.9751, 27.91338], 12) for i in range(10): data = np.loadtxt(f'{msh.name}_slice_{i}.dat', delimiter=',', skiprows=1) # read plt.plot(data[:,3], data[:,4], lw=2) # plot results diff --git a/dart/validation/onera.py b/dart/validation/onera.py index e06d623..8eb19eb 100644 --- a/dart/validation/onera.py +++ b/dart/validation/onera.py @@ -81,7 +81,7 @@ def main(): # post process tms['post'].start() if canPost: - floU.writeSlices(msh.name,[0.01, 0.239, 0.526, 0.777, 0.957, 1.076, 1.136, 1.184],5) + floU.write_slices(msh.name,[0.01, 0.239, 0.526, 0.777, 0.957, 1.076, 1.136, 1.184],5) data = tbxU.read('oneraM6_slice_2.dat') floD.plot(data[:,3], data[:,4], {'xlabel': 'x', 'ylabel': 'Cp', 'title': 'Pressure distribution at MAC', 'invert': True}) tms['post'].stop() -- GitLab