From 50d998c39a40b1a09266cf3ea31b494ac366553c Mon Sep 17 00:00:00 2001 From: Dechamps Paul <paul.dechamps@student.uliege.be> Date: Sun, 5 Dec 2021 00:08:15 +0100 Subject: [PATCH] Improvements and reduced output. --- dart/tests/bliHighLift.py | 56 +++++++++----------------- dart/tests/bliLowRe.py | 46 +++++++--------------- dart/tests/bliNonLift.py | 46 +++++++--------------- dart/tests/bliSeparated.py | 45 +++++++-------------- dart/tests/bliTransonic.py | 48 +++++++--------------- dart/viscous/Drivers/DDriver.py | 59 ++++++++++++---------------- dart/viscous/Master/DCoupler.py | 37 +++++++---------- dart/viscous/Solvers/DIntegration.py | 2 +- dart/viscous/Solvers/DSolver.py | 30 ++++++++------ 9 files changed, 134 insertions(+), 235 deletions(-) diff --git a/dart/tests/bliHighLift.py b/dart/tests/bliHighLift.py index 2b8cf1e..e578367 100755 --- a/dart/tests/bliHighLift.py +++ b/dart/tests/bliHighLift.py @@ -59,15 +59,14 @@ def main(): tms['total'].start() # define flow variables - Re = 1e7 - alpha = 12.*math.pi/180 - M_inf = 0. - #user_xtr=[0.012,1] - user_xtr=[None, 1] + Re = 3e6 + alpha = 10.*math.pi/180 + M_inf = 0.15 + user_xtr=[0, 0] user_Ti=None mapMesh = 1 - nFactor = 2 + nFactor = 3 # Time solver parameters Time_Domain=True # True for unsteady solver, False for steady solver @@ -85,7 +84,7 @@ def main(): # mesh the geometry print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() - pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1, 'msTe' : 0.01, 'msLe' : 0.0005} + pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1, 'msTe' : 0.01, 'msLe' : 0.001} msh, gmshWriter = floD.mesh(dim, 'models/n0012.geo', pars, ['field', 'airfoil', 'downstream']) tms['msh'].stop() @@ -124,44 +123,27 @@ def main(): print('CPU statistics') print(tms) - # visualize solution and plot results - floD.initViewer(pbl) - tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) - - val=validation.Validation(case) - val.main(isolver.Cl,vsolver.wData) # check results print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - if Re == 1e7 and M_inf == 0 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.58 - tests.add(CTest('Cd', vsolver.Cd, 0.0062, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0018, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.061, 0.03, forceabs=True)) # Xfoil 0.056 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.740, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0.5 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.65, 5e-2)) # Xfoil 0.69 - tests.add(CTest('Cd', vsolver.Cd, 0.0067, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0025, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.049, 0.03, forceabs=True)) # Xfoil 0.038 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.736, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0 and alpha == 12*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 1.30, 5e-2)) # Xfoil 1.39 - tests.add(CTest('Cd', vsolver.Cd, 0.011, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0064, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.010, 0.03, forceabs=True)) # Xfoil 0.008 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 1.000, 0.03, forceabs=True)) - elif Re==1e7 and M_inf==0 and alpha==5*math.pi/180 and user_xtr==[0.01, 0.3]: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.5687 - tests.add(CTest('Cd', vsolver.Cd, 0.0077, 1e-3, forceabs=True)) # Xfoil 0.00777 - tests.add(CTest('Cdp', vsolver.Cdp, 0.002, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.01, 1e-3, forceabs=True)) - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.3, 1e-3, forceabs=True)) + if Re==3e6 and M_inf==0.15 and alpha==10*math.pi/180 and user_xtr==[0., 0.]: + tests.add(CTest('Cl', isolver.Cl, 1.08, 5e-2)) # RANS 1.1 Xfoil 1.077 + tests.add(CTest('Cd', vsolver.Cd, 0.0134, 1e-3, forceabs=True)) # RANS 0.0132 XFOIL 0.0128 + tests.add(CTest('Cdp', vsolver.Cdp, 0.0058, 1e-3, forceabs=True)) + tests.add(CTest('xtr_top', vsolver.xtr[0], 0, 1e-3, forceabs=True)) + tests.add(CTest('xtr_bot', vsolver.xtr[1], 0, 1e-3, forceabs=True)) else: raise Exception('Test not defined for this flow') tests.run() + # visualize solution and plot results + floD.initViewer(pbl) + tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) + + val=validation.Validation(case) + val.main(isolver.Cl,vsolver.wData) + # eof print('') diff --git a/dart/tests/bliLowRe.py b/dart/tests/bliLowRe.py index 10d9536..98f0ce3 100755 --- a/dart/tests/bliLowRe.py +++ b/dart/tests/bliLowRe.py @@ -68,7 +68,7 @@ def main(): user_xtr=[None, None] user_Ti=None - mapMesh = 0 + mapMesh = 1 nFactor = 2 # Time solver parameters @@ -126,46 +126,28 @@ def main(): print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) print('CPU statistics') print(tms) - - # visualize solution and plot results - floD.initViewer(pbl) - tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) - - val=validation.Validation(case) - val.main(isolver.Cl,vsolver.wData) # check results print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - if Re == 1e7 and M_inf == 0 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.58 - tests.add(CTest('Cd', vsolver.Cd, 0.0062, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0018, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.061, 0.03, forceabs=True)) # Xfoil 0.056 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.740, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0.5 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.65, 5e-2)) # Xfoil 0.69 - tests.add(CTest('Cd', vsolver.Cd, 0.0067, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0025, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.049, 0.03, forceabs=True)) # Xfoil 0.038 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.736, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0 and alpha == 12*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 1.30, 5e-2)) # Xfoil 1.39 - tests.add(CTest('Cd', vsolver.Cd, 0.011, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0064, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.010, 0.03, forceabs=True)) # Xfoil 0.008 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 1.000, 0.03, forceabs=True)) - elif Re==1e7 and M_inf==0 and alpha==5*math.pi/180 and user_xtr==[0.01, 0.3]: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.5687 - tests.add(CTest('Cd', vsolver.Cd, 0.0077, 1e-3, forceabs=True)) # Xfoil 0.00777 - tests.add(CTest('Cdp', vsolver.Cdp, 0.002, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.01, 1e-3, forceabs=True)) - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.3, 1e-3, forceabs=True)) + if Re == 5e5 and M_inf == 0.2 and alpha == 2*math.pi/180: + tests.add(CTest('Cl', isolver.Cl, 0.2303, 5e-2)) # XFOIL 0.2135 + tests.add(CTest('Cd', vsolver.Cd, 0.0089, 1e-3, forceabs=True)) # XFOIL 0.00706 + tests.add(CTest('Cdp', vsolver.Cdp, 0.0041, 1e-3, forceabs=True)) # 0.00238 + tests.add(CTest('xtr_top', vsolver.xtr[0], 0.574, 0.03, forceabs=True)) # XFOIL 0.5642 + tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.89, 0.03, forceabs=True)) # XFOIL 0.9290 else: raise Exception('Test not defined for this flow') tests.run() + # visualize solution and plot results + floD.initViewer(pbl) + tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) + + val=validation.Validation(case) + val.main(isolver.Cl,vsolver.wData) + # eof print('') diff --git a/dart/tests/bliNonLift.py b/dart/tests/bliNonLift.py index 996c967..9fdd94c 100755 --- a/dart/tests/bliNonLift.py +++ b/dart/tests/bliNonLift.py @@ -68,7 +68,7 @@ def main(): user_xtr=[None,None] user_Ti=None - mapMesh = 0 + mapMesh = 1 nFactor = 2 # Time solver parameters @@ -126,46 +126,28 @@ def main(): print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) print('CPU statistics') print(tms) - - # visualize solution and plot results - floD.initViewer(pbl) - tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) - - val=validation.Validation(case) - val.main(isolver.Cl,vsolver.wData) # check results print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - if Re == 1e7 and M_inf == 0 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.58 - tests.add(CTest('Cd', vsolver.Cd, 0.0062, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0018, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.061, 0.03, forceabs=True)) # Xfoil 0.056 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.740, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0.5 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.65, 5e-2)) # Xfoil 0.69 - tests.add(CTest('Cd', vsolver.Cd, 0.0067, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0025, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.049, 0.03, forceabs=True)) # Xfoil 0.038 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.736, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0 and alpha == 12*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 1.30, 5e-2)) # Xfoil 1.39 - tests.add(CTest('Cd', vsolver.Cd, 0.011, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0064, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.010, 0.03, forceabs=True)) # Xfoil 0.008 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 1.000, 0.03, forceabs=True)) - elif Re==1e7 and M_inf==0 and alpha==5*math.pi/180 and user_xtr==[0.01, 0.3]: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.5687 - tests.add(CTest('Cd', vsolver.Cd, 0.0077, 1e-3, forceabs=True)) # Xfoil 0.00777 - tests.add(CTest('Cdp', vsolver.Cdp, 0.002, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.01, 1e-3, forceabs=True)) - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.3, 1e-3, forceabs=True)) + if Re == 1e7 and M_inf == 0.2 and alpha == 5*math.pi/180: + tests.add(CTest('Cl', isolver.Cl, 0.56, 5e-2)) # XFOIL 0.58 + tests.add(CTest('Cd', vsolver.Cd, 0.0063, 1e-3, forceabs=True)) # XFOIL 0.00617 + tests.add(CTest('Cdp', vsolver.Cdp, 0.0019, 1e-3, forceabs=True)) # XFOIL 0.00176 + tests.add(CTest('xtr_top', vsolver.xtr[0], 0.059, 0.03, forceabs=True)) # XFOIL 0.0510 + tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.738, 0.03, forceabs=True)) # XFOIL 0.7473 else: raise Exception('Test not defined for this flow') tests.run() + # visualize solution and plot results + floD.initViewer(pbl) + tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) + + val=validation.Validation(case) + val.main(isolver.Cl,vsolver.wData) + # eof print('') diff --git a/dart/tests/bliSeparated.py b/dart/tests/bliSeparated.py index 6593b48..7b3ef44 100755 --- a/dart/tests/bliSeparated.py +++ b/dart/tests/bliSeparated.py @@ -61,7 +61,7 @@ def main(): # define flow variables Re = 1e7 alpha = 15.*math.pi/180 - M_inf = 0 + M_inf = 0.2 user_xtr=[None,None] user_Ti=None @@ -123,44 +123,27 @@ def main(): print('CPU statistics') print(tms) - # visualize solution and plot results - floD.initViewer(pbl) - tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) - - val=validation.Validation(case) - val.main(isolver.Cl,vsolver.wData) # check results print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - if Re == 1e7 and M_inf == 0 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.58 - tests.add(CTest('Cd', vsolver.Cd, 0.0062, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0018, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.061, 0.03, forceabs=True)) # Xfoil 0.056 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.740, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0.5 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.65, 5e-2)) # Xfoil 0.69 - tests.add(CTest('Cd', vsolver.Cd, 0.0067, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0025, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.049, 0.03, forceabs=True)) # Xfoil 0.038 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.736, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0 and alpha == 12*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 1.30, 5e-2)) # Xfoil 1.39 - tests.add(CTest('Cd', vsolver.Cd, 0.011, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0064, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.010, 0.03, forceabs=True)) # Xfoil 0.008 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 1.000, 0.03, forceabs=True)) - elif Re==1e7 and M_inf==0 and alpha==5*math.pi/180 and user_xtr==[0.01, 0.3]: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.5687 - tests.add(CTest('Cd', vsolver.Cd, 0.0077, 1e-3, forceabs=True)) # Xfoil 0.00777 - tests.add(CTest('Cdp', vsolver.Cdp, 0.002, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.01, 1e-3, forceabs=True)) - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.3, 1e-3, forceabs=True)) + if Re == 1e7 and M_inf == 0.2 and alpha == 15*math.pi/180: + tests.add(CTest('Cl', isolver.Cl, 1.60, 5e-2)) # Xfoil 1.6654 + tests.add(CTest('Cd', vsolver.Cd, 0.0154, 1e-3, forceabs=True)) # XFOIL 0.01640 + tests.add(CTest('Cdp', vsolver.Cdp, 0.0115, 1e-3, forceabs=True)) # XFOIL 0.01255 + tests.add(CTest('xtr_top', vsolver.xtr[0], 0.00676, 0.003, forceabs=True)) # XFOIL 0.0067 + tests.add(CTest('xtr_bot', vsolver.xtr[1], 1, 0.03, forceabs=True)) # XFOIL 1.0000 else: raise Exception('Test not defined for this flow') tests.run() + # visualize solution and plot results + floD.initViewer(pbl) + tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) + + val=validation.Validation(case) + val.main(isolver.Cl,vsolver.wData) + # eof print('') diff --git a/dart/tests/bliTransonic.py b/dart/tests/bliTransonic.py index 673a825..f67b686 100755 --- a/dart/tests/bliTransonic.py +++ b/dart/tests/bliTransonic.py @@ -63,13 +63,11 @@ def main(): alpha = 2*math.pi/180 M_inf = 0.715 - #user_xtr=[0.41,0.41] - #user_xtr=[0,None] user_xtr=[None, None] user_Ti=None mapMesh = 1 - nFactor = 2 + nFactor = 5 # Time solver parameters Time_Domain = True # True for unsteady solver, False for steady solver @@ -80,7 +78,7 @@ def main(): U_inf = [math.cos(alpha), math.sin(alpha)] # norm should be 1 c_ref = 1 dim = 2 - tol = 1e-4 # tolerance for the VII (usually one drag count) + tol = 1e-3 # tolerance for the VII (usually one drag count) case='Case1FreeTrans.dat' # File containing results from XFOIL of the considered case # mesh the geometry @@ -129,46 +127,28 @@ def main(): print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) print('CPU statistics') print(tms) - - # visualize solution and plot results - floD.initViewer(pbl) - tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) - - val=validation.Validation() - val.main(isolver.Cl,vsolver.wData) # check results print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() - if Re == 1e7 and M_inf == 0 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.58 - tests.add(CTest('Cd', vsolver.Cd, 0.0062, 1e-3, forceabs=True)) + if Re == 1e7 and M_inf == 0.715 and alpha == 2*math.pi/180: + tests.add(CTest('Cl', isolver.Cl, 0.686, 5e-2)) + tests.add(CTest('Cd', vsolver.Cd, 0.0057, 1e-3, forceabs=True)) tests.add(CTest('Cdp', vsolver.Cdp, 0.0018, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.061, 0.03, forceabs=True)) # Xfoil 0.056 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.740, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0.5 and alpha == 5*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 0.65, 5e-2)) # Xfoil 0.69 - tests.add(CTest('Cd', vsolver.Cd, 0.0067, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0025, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.049, 0.03, forceabs=True)) # Xfoil 0.038 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.736, 0.03, forceabs=True)) - elif Re == 1e7 and M_inf == 0 and alpha == 12*math.pi/180: - tests.add(CTest('Cl', isolver.Cl, 1.30, 5e-2)) # Xfoil 1.39 - tests.add(CTest('Cd', vsolver.Cd, 0.011, 1e-3, forceabs=True)) - tests.add(CTest('Cdp', vsolver.Cdp, 0.0064, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.010, 0.03, forceabs=True)) # Xfoil 0.008 - tests.add(CTest('xtr_bot', vsolver.xtr[1], 1.000, 0.03, forceabs=True)) - elif Re==1e7 and M_inf==0 and alpha==5*math.pi/180 and user_xtr==[0.01, 0.3]: - tests.add(CTest('Cl', isolver.Cl, 0.55, 5e-2)) # Xfoil 0.5687 - tests.add(CTest('Cd', vsolver.Cd, 0.0077, 1e-3, forceabs=True)) # Xfoil 0.00777 - tests.add(CTest('Cdp', vsolver.Cdp, 0.002, 1e-3, forceabs=True)) - tests.add(CTest('xtr_top', vsolver.xtr[0], 0.01, 1e-3, forceabs=True)) - tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.3, 1e-3, forceabs=True)) + tests.add(CTest('xtr_top', vsolver.xtr[0], 0.34, 0.03, forceabs=True)) + tests.add(CTest('xtr_bot', vsolver.xtr[1], 0.5, 0.03, forceabs=True)) else: raise Exception('Test not defined for this flow') tests.run() + # visualize solution and plot results + floD.initViewer(pbl) + tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, vsolver.Cd, isolver.Cm, 4), True) + + val=validation.Validation() + val.main(isolver.Cl,vsolver.wData) + # eof print('') diff --git a/dart/viscous/Drivers/DDriver.py b/dart/viscous/Drivers/DDriver.py index 5f5b2fa..2eea39b 100644 --- a/dart/viscous/Drivers/DDriver.py +++ b/dart/viscous/Drivers/DDriver.py @@ -164,72 +164,61 @@ class Driver: if self.it == 0: print('+------------------------------- Solver setup ---------------------------------+') + print('- Reynolds number: {:>1.2e}'.format(self.Re)) if self.mapMesh: - print('| - Mesh mapped from {:>5.0f} to {:>5.0f} points.{:>37s}'.format(len(cMeshDict['locCoord']), var.nN, '|')) - print('| - Number of elements: {:>5.0f}. {:>49s}'.format(var.nN,'|')) + print('- Mesh mapped from {:>5.0f} to {:>5.0f} points.'.format(len(cMeshDict['locCoord']), var.nN)) + print('- Number of elements: {:>5.0f}.'.format(var.nN)) if var.xtrF[0] is None: - print('| - Free transition on the upper side. {:>41}'.format('|')) + print('- Free transition on the upper side.') else: - print('| - Forced transition on the upper side; x/c = {:<.4f}. {:>25s}'.format(var.xtrF[0], '|')) + print('- Forced transition on the upper side; x/c = {:<.4f}.'.format(var.xtrF[0])) if var.xtrF[1] is None: - print('| - Free transition on the lower side. {:>41}'.format('|')) + print('- Free transition on the lower side.') else: - print('| - Forced transition on the lower side; x/c = {:<.4f}. {:>25s}'.format(var.xtrF[1], '|')) - print('| - Critical amplification ratio: {:<.2f}. {:>40s}'.format(var.Ncrit,'|')) + print('- Forced transition on the lower side; x/c = {:<.4f}.'.format(var.xtrF[1])) + print('- Critical amplification ratio: {:<.2f}.'.format(var.Ncrit)) - print('|{:>79}'.format('|')) - print('| Numerical parameters {:>57}'.format('|')) - print('| - CFL0: {:<3.2f} {:>65}'.format(tSolver.integrator.GetCFL0(),'|')) - print('| - Tolerance: {:<3.0f} {:>61}'.format(np.log10(tSolver.integrator.Gettol()),'|')) - print('| - Solver maximum iterations: {:<5.0f} {:>43}'.format(tSolver.integrator.GetmaxIt(),'|')) - print('|{:>79}'.format('|')) + print('') + print('Numerical parameters') + print('- CFL0: {:<3.2f}'.format(tSolver.integrator.GetCFL0())) + print('- Tolerance: {:<3.0f}'.format(np.log10(tSolver.integrator.Gettol()))) + print('- Solver maximum iterations: {:<5.0f}'.format(tSolver.integrator.GetmaxIt())) + print('+------------------------------------------------------------------------------+') # Output preprocessing satut. - print('+------------------------------ Preprocessing ---------------------------------+') - - print('| - Maximum Mach number: {:<.2f}. {:>49s}'.format(np.max((var.extPar[0::var.nExtPar])),'|')) + print('- Mach max: {:<.2f}. IC:'.format(np.max((var.extPar[0::var.nExtPar]))), end = ' ') # Solver setup. if self.uPrevious is None or self.nbrElmUpper != var.bNodes[1]: # Typically for the first iteration. tSolver.initSln = 1 # Flag to use time solver initial condition. - - #tSolver.integrator.itFrozenJac0 = 1 # Continuous Jacobian evaluation. - tSolver.integrator.SetCFL0(0.5) # Low starting CFL. + tSolver.integrator.SetCFL0(1) # Low starting CFL. + print('Restart.') if self.it != 0 and self.nbrElmUpper != var.bNodes[1]: - print('| - Stagnation point moved. {:>29}'.format('|')) - print('| - Time solver will provide the initial solution. {:>29}'.format('|')) + print(ccolors.ANSI_BLUE, '- Stagnation point moved.',ccolors.ANSI_RESET) else: # If we use a solution previously obtained. var.u = self.uPrevious.copy() # Use previous solution. - print('| - Using previous solution as initial guess. {:>34}'.format('|')) + print('Updating.') self.nbrElmUpper = var.bNodes[1] DirichletBC.airfoilBC(var) # Reset boundary condition. # Run the time integration - print('+------------------------------- Solver begin ---------------------------------+') + #print('+------------------------------- Solver begin ---------------------------------+') convergedPoints = tSolver.Run(var) - print('+-------------------------------- Solver Exit ---------------------------------+') + #print('+-------------------------------- Solver Exit ---------------------------------+') # Output time solver status. if np.any(convergedPoints != 0): - print('|', ccolors.ANSI_YELLOW + 'Some point(s) did not converge.', ccolors.ANSI_RESET, '{:>45s}'.format('|')) - - elif np.all(convergedPoints == 0): - print('|', ccolors.ANSI_GREEN + 'All points converged.', ccolors.ANSI_RESET, '{:>55s}'.format('|')) - print('|{:>79}'.format('|')) - + print(ccolors.ANSI_YELLOW + 'Some point(s) did not converge.', ccolors.ANSI_RESET) # Save solution to use it as initial condition the next iteration. - var.u[4::var.nVar][var.flowRegime == 0] = 0. # Reset Ct in the laminar portion of the flow. - # (This quantity is not defined for a laminar flow) - self.uPrevious=var.u.copy() # Copy solution. # Compute blowing velocities and sort the boundary layer parameters. @@ -265,4 +254,6 @@ class Driver: # Sort the following results in reference frame. groups[1].deltaStar = groups[1].deltaStar[groups[1].connectListNodes.argsort()] groups[1].xx = groups[1].xx[groups[1].connectListNodes.argsort()] - groups[1].u = blwVelWk[groups[1].connectListElems.argsort()] \ No newline at end of file + groups[1].u = blwVelWk[groups[1].connectListElems.argsort()] + + pass \ No newline at end of file diff --git a/dart/viscous/Master/DCoupler.py b/dart/viscous/Master/DCoupler.py index c2c0e83..91c3831 100755 --- a/dart/viscous/Master/DCoupler.py +++ b/dart/viscous/Master/DCoupler.py @@ -21,6 +21,7 @@ from dart.viscous.Master.DAirfoil import Airfoil from dart.viscous.Master.DWake import Wake +from matplotlib import pyplot as plt import numpy as np @@ -48,13 +49,10 @@ class Coupler: CdOld = self.vsolver.Cd print('+---------------------------- VII Solver begin --------------------------------+') - print('+------------------------------------------------------------------------------+') - print('|{:>79s}'.format('|')) + print('') while converged == 0: - print('|', ccolors.ANSI_BLUE + 'Iteration: {:<3.0f}'.format(it), ccolors.ANSI_RESET, '{:>62s}'.format('|')) - # Run inviscid solver print('+----------------------------- Inviscid solver --------------------------------+') self.isolver.run() @@ -74,7 +72,6 @@ class Coupler: # Write inviscid pressure distribution on the first iteration Cp = floU.extract(self.bnd.groups[0].tag.elems, self.isolver.Cp) tboxU.write(Cp, 'Cpinv_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') - # Run viscous solver print('+------------------------------ Viscous solver --------------------------------+') self.vsolver.run(self.group) @@ -83,29 +80,25 @@ class Coupler: for i in range(0, self.group[n].nE): self.group[n].boundary.setU(i, self.group[n].u[i]) - # Output coupling iteration. - xtrT_type='forced' if self.vsolver.xtrF[0] is not None else 'free' - xtrB_type='forced' if self.vsolver.xtrF[1] is not None else 'free' - print('+------------------------------- Postprocessing -------------------------------+') + # Check convergence and output coupling iteration. error = abs(self.vsolver.Cd - CdOld)/self.vsolver.Cd - print('|{0:>6s}| {1:>14s}| {2:>18s}| {3:>18s}| {4:>14s}|'.format('Iter', 'Cd', - f'Top xtr ({xtrT_type})', - f'Bot xtr ({xtrB_type})', - 'Error')) + if error <= self.tol: + print('') + print(ccolors.ANSI_GREEN, 'It: {:<3.0f} Cd = {:<6.5f}. Error = {:<2.3f} < {:<2.3f}' + .format(it, self.vsolver.Cd, np.log10(error), np.log10(self.tol)), ccolors.ANSI_RESET) + print('') - print('|{0:>6d}| {1:>14f}| {2:>18f}| {3:>18f}| {4:>14f}|'.format(it, self.vsolver.Cd, - self.vsolver.xtr[0], self.vsolver.xtr[1], - np.log10(error))) - print('|{:>79}'.format('|')) - - # Check convergence. - if abs(self.vsolver.Cd - CdOld)/self.vsolver.Cd < self.tol: - converged = 1 + converged = 1 else: - CdOld = self.vsolver.Cd + print('') + print(ccolors.ANSI_BLUE, 'It: {:<3.0f} Cd = {:<6.5f}. Error = {:<2.3f} > {:<2.3f}' + .format(it, self.vsolver.Cd, np.log10(error), np.log10(self.tol)), ccolors.ANSI_RESET) + print('') + + CdOld = self.vsolver.Cd # Prepare next iteration. it += 1 diff --git a/dart/viscous/Solvers/DIntegration.py b/dart/viscous/Solvers/DIntegration.py index ca63840..2c7f63a 100644 --- a/dart/viscous/Solvers/DIntegration.py +++ b/dart/viscous/Solvers/DIntegration.py @@ -39,7 +39,7 @@ class Integration: self.sysMatrix = _sysMatrix self.__CFL0=_Cfl0 - self.__maxIt = 10000 + self.__maxIt = 1500 self.__tol = 1e-6 self.itFrozenJac0 = 5 diff --git a/dart/viscous/Solvers/DSolver.py b/dart/viscous/Solvers/DSolver.py index c0f7465..bd7493c 100644 --- a/dart/viscous/Solvers/DSolver.py +++ b/dart/viscous/Solvers/DSolver.py @@ -66,19 +66,22 @@ class Solver: DFlow.u[iMarker * DFlow.nVar + 4] = 0.03 if iMarker == bNodes[0] + 1: # Upper side start. - print('| - Computing upper side. {:>54}'.format('|')) + print('- Upper side,', end = ' ') if iMarker == bNodes[1]: # Lower side start. + if lockTrans == 0: + print('no transition.') lockTrans = 0 - print('| - Computing lower side. {:>54}'.format('|')) + print('- Lower side,', end = ' ') if iMarker == bNodes[2]: # First wake point self.wakeBC(DFlow) # Wake boundary condition. convergedPoints[iMarker] = 0 - lockTrans = 1 - print('| - Computing wake. {:>60}'.format('|')) - + if lockTrans == 0: + print('no transition.') + lockTrans = 1 + continue # Ignore remaining instructions for the first wake point. # Call Newton solver for the point. @@ -86,8 +89,8 @@ class Solver: convergedPoints[iMarker] = self.integrator.TimeMarching(DFlow, iMarker, displayState) if convergedPoints[iMarker] != 0: - print(ccolors.ANSI_RED + '| Marker {:<4.0f} (x/c={:<1.4f}): PTI terminated with exit code {:<4.0f} {:>17}' - .format(iMarker, DFlow.xGlobal[iMarker], convergedPoints[iMarker], '|'), ccolors.ANSI_RESET) + print(ccolors.ANSI_RED + 'Marker {:<4.0f} (x/c={:<1.4f}): PTI terminated with exit code {:<4.0f}.' + .format(iMarker, DFlow.xGlobal[iMarker], convergedPoints[iMarker]), ccolors.ANSI_RESET) # Check for transition. @@ -97,18 +100,21 @@ class Solver: # Free transition. if DFlow.u[iMarker * DFlow.nVar + 2] >= DFlow.Ncrit: - print('| Transition located near x/c = {:<2.3f}. Marker: {:<4.0f} {:>28s}'.format(DFlow.xGlobal[iMarker],iMarker, '|')) self.__AverageTransition(DFlow, iMarker, displayState) + if iMarker < DFlow.bNodes[1]: + print('free transition x/c = {:<1.5f} {:>4.0f}.'.format(DFlow.xtr[0],iMarker)) + elif iMarker < DFlow.bNodes[2]: + print('free transition x/c = {:<1.5f} {:>4.0f}.'.format(DFlow.xtr[1],iMarker)) + else: + print('error in wake') lockTrans = 1 # Forced transition. elif (DFlow.xtrF[0] is not None and DFlow.xtrF[0] !=0 and DFlow.xtrF[0] != 1) or (DFlow.xtrF[1] is not None and DFlow.xtrF[1] !=0 and DFlow.xtrF[1] != 1): if DFlow.flowRegime[iMarker] == 1 and DFlow.flowRegime[iMarker - 1] == 0: - print('| Forced transition near x/c = {:<2.3f}. Marker: {:<4.0f} {:>28s}'.format(DFlow.xGlobal[iMarker],iMarker, '|')) + print('forced transition near x/c = {:<2.3f} {:>4.0f}'.format(DFlow.xGlobal[iMarker],iMarker)) self.__AverageTransition(DFlow, iMarker, displayState) lockTrans = 1 - """DFlow.extPar[iMarker*DFlow.nExtPar+2] = DFlow.u[iMarker * DFlow.nVar + 3] - DFlow.extPar[iMarker*DFlow.nExtPar+3] = DFlow.blPar[iMarker * DFlow.nBlPar + 9]""" return convergedPoints @@ -154,7 +160,7 @@ class Solver: nTrans = 0 ueTrans = avLam * lamSol[3] + avTurb * var.u[(iMarker)*var.nVar + 3] CtTrans = avTurb * var.u[(iMarker)*var.nVar + 4] - #CtTrans = max(CtTrans, var.u[(iMarkerPrev)*var.nVar + 4]) + var.u[(iMarker)*var.nVar : (iMarker+1)*var.nVar] = [thetaTrans, HTrans, nTrans, ueTrans, CtTrans] # Recompute closures. -- GitLab