From 7b4d5eff30ef0c7dd01d55dd25b3ed2ce9f9874e Mon Sep 17 00:00:00 2001 From: Paul Dechamps <paul.dechamps@uliege.be> Date: Wed, 8 Jan 2025 15:57:01 +0100 Subject: [PATCH] (refactor) Refactor validation cases Small modifs on validation cases and add them to the validation job on the pipeline --- .gitlab-ci.yml | 12 +++++--- blast/coupler.py | 6 ++-- blast/validation/agard_3D.py | 54 ++++++++++++++++++--------------- blast/validation/highlift_2D.py | 31 +++++++++++-------- blast/validation/lann_3D.py | 13 ++++---- blast/validation/oneraM6_3D.py | 23 +++++++------- blast/validation/rae2822_2D.py | 4 +-- 7 files changed, 79 insertions(+), 64 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d071ba1..fa9868a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,15 +79,19 @@ cvalidation: stage: validation script: - set +e - - python3 run.py blast/validation/raeValidation.py -v; RAE_STATUS=$? - - python3 run.py blast/validation/oneraValidation.py -v; ONERA_STATUS=$? - - python3 run.py blast/validation/lannValidation.py -v; LANN_STATUS=$? + - python3 run.py blast/validation/highlift_2D.py -v; HIGHLIFT_STATUS=$? + - python3 run.py blast/validation/rae2822_2D.py -v; RAE_STATUS=$? + - python3 run.py blast/validation/oneraM6_3D.py -v; ONERA_STATUS=$? + - python3 run.py blast/validation/lann_3D.py -v; LANN_STATUS=$? + - python3 run.py blast/validation/agard_3D.py -v; AGARD_STATUS=$? - set -e - | + echo "HIGHLIFT Validation Status: $HIGHLIFT_STATUS" echo "RAE Validation Status: $RAE_STATUS" echo "ONERA Validation Status: $ONERA_STATUS" echo "LANN Validation Status: $LANN_STATUS" - - if [ $RAE_STATUS -ne 0 ] || [ $ONERA_STATUS -ne 0 ] || [ $LANN_STATUS -ne 0 ]; then exit 1; fi + echo "AGARD Validation Status: $AGARD_STATUS" + - if [ $HIGHLIFT_STATUS -ne 0 ] || [ $RAE_STATUS -ne 0 ] || [ $ONERA_STATUS -ne 0 ] || [ $LANN_STATUS -ne 0 ] || [ $AGARD_STATUS -ne 0 ]; then exit 1; fi dependencies: - build when: manual diff --git a/blast/coupler.py b/blast/coupler.py index 4d7cfa0..b641072 100644 --- a/blast/coupler.py +++ b/blast/coupler.py @@ -120,10 +120,10 @@ class Coupler: return aeroCoeffs cdPrev = cd - if couplIter == 0: + if couplIter == 0 or (self.isol.getVerbose() > 0 and couplIter % self.iterPrint == 0): print('') print('{:>5s}| {:>7s} {:>7s} {:>7s} | {:>6s} {:>6s} | {:>5s} {:>5s} | {:>6s}'.format('It', 'Cl', 'Cd', 'Cdwake', 'xtrT', 'xtrB', 'iOut', 'vOut', 'Error')) - print(' ----------------------------------------------------------') + print(' --------------------------------------------------------------------') if couplIter % self.iterPrint == 0: print(' {:>4.0f}| {:>7.5f} {:>7.5f} {:>7.5f} | {:>6.4f} {:>6.4f} | {:>5.0f} {:>5.0f} | {:>6.3f}'.format(couplIter, self.isol.getCl(), self.isol.getCd()+self.vsol.Cdf, self.vsol.Cdt, self.vsol.getAverageTransition(0), self.vsol.getAverageTransition(1), iEc, vEc, np.log10(error))) if self.isol.getVerbose() != 0 or self.vsol.verbose != 0: @@ -133,7 +133,7 @@ class Coupler: print(ccolors.ANSI_RED, 'Maximum number of {:<.0f} coupling iterations reached'.format(self.maxIter), ccolors.ANSI_RESET) print('') print('{:>5s}| {:>7s} {:>7s} {:>7s} | {:>6s} {:>8s} | {:>6s}'.format('It', 'Cl', 'Cd', 'Cdwake', 'xtrT', 'xtrB', 'Error')) - print(' ----------------------------------------------------------') + print(' --------------------------------------------------------------------') print(ccolors.ANSI_RED, '{:>4.0f}| {:>7.5f} {:>7.5f} {:>7.5f} | {:>6.4f} {:>7.4f} | {:>6.3f}\n'.format(couplIter-1, self.isol.getCl(), self.isol.getCd()+self.vsol.Cdf, self.vsol.Cdt, self.vsol.getAverageTransition(0), self.vsol.getAverageTransition(1), np.log10(error)), ccolors.ANSI_RESET) if write: self.isol.writeCp(sfx='_viscous'+self.filesfx) diff --git a/blast/validation/agard_3D.py b/blast/validation/agard_3D.py index 6308e83..64748ff 100644 --- a/blast/validation/agard_3D.py +++ b/blast/validation/agard_3D.py @@ -55,29 +55,29 @@ def cfgInviscid(nthrds, verb): 'Tes' : ['te'], # LIST of names of physical group containing the trailing edge 'Upstream' : 'upstream', # Freestream - 'M_inf' : 0.96, # freestream Mach number - 'AoA' : 0., # freestream angle of attack + 'M_inf' : 0.96, # freestream Mach number + 'AoA' : 0., # freestream angle of attack # Geometry - 'S_ref' : 0.35, # reference surface length - 'c_ref' : 0.47, # reference chord length - 'x_ref' : 0.0, # reference point for moment computation (x) - 'y_ref' : 0.0, # reference point for moment computation (y) - 'z_ref' : 0.0, # reference point for moment computation (z) + 'S_ref' : 0.35, # reference surface length + 'c_ref' : 0.47, # reference chord length + 'x_ref' : 0.0, # reference point for moment computation (x) + 'y_ref' : 0.0, # reference point for moment computation (y) + 'z_ref' : 0.0, # reference point for moment computation (z) # Numerical - 'LSolver' : 'GMRES', # inner solver (Pardiso, MUMPS or GMRES) - 'G_fill' : 2, # fill-in factor for GMRES preconditioner - 'G_tol' : 1e-5, # tolerance for GMRES - 'G_restart' : 50, # restart for GMRES - 'Rel_tol' : 1e-6, # relative tolerance on solver residual - 'Abs_tol' : 1e-8, # absolute tolerance on solver residual - 'Max_it' : 75 # solver maximum number of iterations + 'LSolver' : 'PARDISO', # inner solver (Pardiso, MUMPS or GMRES) + 'G_fill' : 2, # fill-in factor for GMRES preconditioner + 'G_tol' : 1e-5, # tolerance for GMRES + 'G_restart' : 50, # restart for GMRES + 'Rel_tol' : 1e-6, # relative tolerance on solver residual + 'Abs_tol' : 1e-8, # absolute tolerance on solver residual + 'Max_it' : 75 # solver maximum number of iterations } def cfgBlast(verb): return { - 'Re' : 5.96e5, # Freestream Reynolds number - 'Minf' : 0.96, # Freestream Mach number (used for the computation of the time step only) - 'CFL0' : 1, # Inital CFL number of the calculation + 'Re' : 5.96e5, # Freestream Reynolds number + 'Minf' : 0.96, # Freestream Mach number (used for the computation of the time step only) + 'CFL0' : 1, # Inital CFL number of the calculation 'sections' : np.linspace(0.026, 0.73, 15), 'writeSections': np.linspace(0.01, 0.76, 15), @@ -95,8 +95,7 @@ def cfgBlast(verb): 'couplTol' : 1e-3, # Tolerance of the VII methodology 'iterPrint': 1, # int, number of iterations between outputs 'resetInv' : True, # bool, flag to reset the inviscid calculation at every iteration. - 'xtrF' : [0., 0.], # Forced transition location - 'nDim' : 3 + 'xtrF' : [0., 0.] # Forced transition location } def main(): @@ -109,6 +108,13 @@ def main(): icfg = cfgInviscid(args.k, args.verb) vcfg = cfgBlast(args.verb) + try: + import tbox + _ = tbox.Pardiso() + except: + print('PARDISO not found, using GMRES') + icfg['LSolver'] = 'GMRES' + #AoAVec = [-.01, 0.0, .01] #sfxVec = ['_a1-', '_a0', '_a1'] AoAVec = [0.0] @@ -150,7 +156,7 @@ def main(): cps_i = [] import os # Get file dir - dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + '/workspace/blast_validation_agardValidation/' + dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + '/workspace/blast_validation_agard_3D/' for s in sfxVec: cps_s_v = [] @@ -165,9 +171,9 @@ def main(): for i in range(len(vcfg['writeSections'])): plt.figure(i) for j in range(len(sfxVec)): - plt.plot(cps_i[j][i][:,3], cps_i[j][i][:,4], label=sfxVec[j].replace('_', ' ')+'_invicid') + plt.plot(cps_i[j][i][:,0], cps_i[j][i][:,2], label=sfxVec[j].replace('_', ' ')+'_invicid') for j in range(len(sfxVec)): - plt.plot(cps_v[j][i][:,3], cps_v[j][i][:,4], label=sfxVec[j].replace('_', ' ')+'_viscous') + plt.plot(cps_v[j][i][:,0], cps_v[j][i][:,2], label=sfxVec[j].replace('_', ' ')+'_viscous') plt.legend() plt.gca().invert_yaxis() plt.title('Section ' + str(i)) @@ -180,8 +186,8 @@ def main(): print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() tests.add(CTest('Cl', isol.getCl(), 0.0, 1e-3)) - tests.add(CTest('Cd', isol.getCd()+vsol.Cdf, 0.00564, 1e-3, forceabs=True)) - tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 5, 0, forceabs=True)) + tests.add(CTest('Cd', isol.getCd()+vsol.Cdf, 0.0057, 1e-3, forceabs=True)) + tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 4, 1, forceabs=True)) tests.run() # eof diff --git a/blast/validation/highlift_2D.py b/blast/validation/highlift_2D.py index c4b391b..1d71dac 100644 --- a/blast/validation/highlift_2D.py +++ b/blast/validation/highlift_2D.py @@ -63,10 +63,10 @@ def cfgInviscid(nthrds, verb): 'y_ref' : 0.0, # reference point for moment computation (y) 'z_ref' : 0.0, # reference point for moment computation (z) # Numerical - 'LSolver' : 'SparseLU', # inner solver (Pardiso, MUMPS or GMRES) - 'Rel_tol' : 1e-8, # relative tolerance on solver residual - 'Abs_tol' : 1e-6, # absolute tolerance on solver residual - 'Max_it' : 30 # solver maximum number of iterations + 'LSolver' : 'PARDISO', # inner solver (Pardiso, MUMPS or GMRES) + 'Rel_tol' : 1e-8, # relative tolerance on solver residual + 'Abs_tol' : 1e-6, # absolute tolerance on solver residual + 'Max_it' : 30 # solver maximum number of iterations } def cfgBlast(verb): @@ -93,6 +93,13 @@ def main(): icfg = cfgInviscid(args.k, args.verb) vcfg = cfgBlast(args.verb) + try: + import tbox + _ = tbox.Pardiso() + except: + print('PARDISO not found, using SparseLu') + icfg['LSolver'] = 'SparseLU' + tms['pre'].start() coupler, isol, vsol = vutils.initBlast(icfg, vcfg) tms['pre'].stop() @@ -120,14 +127,14 @@ def main(): # Test solution print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - tests.add(CTest('Cl', isol.getCl(), 0.230, 5e-2)) # XFOIL 0.2325 - tests.add(CTest('Cd wake', vsol.Cdt, 0.0057, 1e-3, forceabs=True)) # XFOIL 0.00531 - tests.add(CTest('Cd integral', vsol.Cdf + isol.getCd(), 0.0058, 1e-3, forceabs=True)) # XFOIL 0.00531 - tests.add(CTest('Cdf', vsol.Cdf, 0.0047, 1e-3, forceabs=True)) # XFOIL 0.00084, Cdf = 0.00447 - tests.add(CTest('xtr_top', vsol.getAverageTransition(0), 0.196, 0.03, forceabs=True)) # XFOIL 0.1877 - tests.add(CTest('xtr_bot', vsol.getAverageTransition(1), 0.40, 0.01, forceabs=True)) # XFOIL 0.4998 - tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 20, 0, forceabs=True)) - #tests.run() + tests.add(CTest('Cl', isol.getCl(), 1.634, 5e-2)) + tests.add(CTest('Cd wake', vsol.Cdt, 0.0166, 1e-3, forceabs=True)) + tests.add(CTest('Cd integral', vsol.Cdf + isol.getCd(), 0.0212, 1e-3, forceabs=True)) + tests.add(CTest('Cdf', vsol.Cdf, 0.0043, 1e-3, forceabs=True)) + tests.add(CTest('xtr_top', vsol.getAverageTransition(0), 0.0084, 0.002, forceabs=True)) + tests.add(CTest('xtr_bot', vsol.getAverageTransition(1), 1.0, 0.01, forceabs=True)) + tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 33, 0, forceabs=True)) + tests.run() # Plot results if not args.nogui: diff --git a/blast/validation/lann_3D.py b/blast/validation/lann_3D.py index c0c4815..58debc7 100644 --- a/blast/validation/lann_3D.py +++ b/blast/validation/lann_3D.py @@ -90,13 +90,12 @@ def cfgBlast(verb): 'neighbors': 10, 'saveTag': 1, - 'Verb': verb, # Verbosity level of the solver - 'couplIter': 100, # Maximum number of iterations - 'couplTol' : 1e-3, # Tolerance of the VII methodology - 'iterPrint': 1, # int, number of iterations between outputs - 'resetInv' : True, # bool, flag to reset the inviscid calculation at every iteration. - 'xtrF' : [0.05, 0.05],# Forced transition location - 'nDim' : 3 + 'Verb': verb, # Verbosity level of the solver + 'couplIter': 100, # Maximum number of iterations + 'couplTol' : 1e-3, # Tolerance of the VII methodology + 'iterPrint': 1, # int, number of iterations between outputs + 'resetInv' : True, # bool, flag to reset the inviscid calculation at every iteration. + 'xtrF' : [0.05, 0.05] # Forced transition location } def main(): diff --git a/blast/validation/oneraM6_3D.py b/blast/validation/oneraM6_3D.py index 260aaf3..0a8f104 100644 --- a/blast/validation/oneraM6_3D.py +++ b/blast/validation/oneraM6_3D.py @@ -75,7 +75,7 @@ def cfgInviscid(nthrds, verb): def cfgBlast(verb): return { - 'Re' : 11.72*10e6, # Freestream Reynolds number + 'Re' : 11.72e6, # Freestream Reynolds number 'Minf' : 0.839, # Freestream Mach number (used for the computation of the time step only) 'CFL0' : 1, # Inital CFL number of the calculation @@ -90,13 +90,12 @@ def cfgBlast(verb): 'neighbors': 10, 'saveTag': 5, - 'Verb': verb, # Verbosity level of the solver - 'couplIter': 50, # Maximum number of iterations - 'couplTol' : 5e-4, # Tolerance of the VII methodology - 'iterPrint': 5, # int, number of iterations between outputs - 'resetInv' : True, # bool, flag to reset the inviscid calculation at every iteration. - 'xtrF' : [0.01, 0.01],# Forced transition location - 'nDim' : 3 + 'Verb': verb, # Verbosity level of the solver + 'couplIter': 50, # Maximum number of iterations + 'couplTol' : 5e-4, # Tolerance of the VII methodology + 'iterPrint': 5, # int, number of iterations between outputs + 'resetInv' : True, # bool, flag to reset the inviscid calculation at every iteration. + 'xtrF' : [0.01, 0.01], # Forced transition location } def main(): @@ -142,10 +141,10 @@ def main(): # Test solution print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - tests.add(CTest('Cl', isol.getCl(), 0.279, 5e-2)) - tests.add(CTest('Cd wake', vsol.Cdt, 0.00471, 1e-3, forceabs=True)) - tests.add(CTest('Cd int', isol.getCd() + vsol.Cdf, 0.01519, 1e-3, forceabs=True)) - tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 13, 0, forceabs=True)) + tests.add(CTest('Cl', isol.getCl(), 0.283, 5e-2)) + tests.add(CTest('Cd wake', vsol.Cdt, 0.00640, 1e-3, forceabs=True)) + tests.add(CTest('Cd int', isol.getCd() + vsol.Cdf, 0.0167, 1e-3, forceabs=True)) + tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 14, 0, forceabs=True)) tests.run() # eof diff --git a/blast/validation/rae2822_2D.py b/blast/validation/rae2822_2D.py index 581ed75..0a629d7 100644 --- a/blast/validation/rae2822_2D.py +++ b/blast/validation/rae2822_2D.py @@ -30,7 +30,6 @@ import fwk from fwk.testing import * from fwk.coloring import ccolors import os.path -import tbox import math @@ -100,6 +99,7 @@ def main(): vcfg = cfgBlast(args.verb) try: + import tbox _ = tbox.Pardiso() except: print('PARDISO not found, using SparseLu') @@ -137,7 +137,7 @@ def main(): tests.add(CTest('Cd integral', isol.getCd() + vsol.Cdf, 0.0126, 1e-3, forceabs=True)) tests.add(CTest('Cdf', vsol.Cdf, 0.0067, 1e-3, forceabs=True)) tests.add(CTest('Iterations', len(aeroCoeffs['Cl']), 34, 0, forceabs=True)) - #tests.run() + tests.run() # Plot results if not args.nogui: -- GitLab