From 4b59e627d93417f27ac7386f96899292b0dc9ce1 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Wed, 25 Oct 2023 10:01:30 -0400 Subject: [PATCH] Fix nonlinear examples (#263) * Fix annulus example * Remove niceplots code from cantilever example * Fix nonlinear hemisphere benchmark * Alter solver options in skin buckle example * Fixing more benchmarks --------- Co-authored-by: Tim Brooks <41971846+timryanb@users.noreply.github.com> --- .../benchmark/benchmark_mach_tutorial.py | 12 ++++++------ examples/nonlinear_annulus/analysis.py | 6 +++--- .../benchmark/benchmark_annulus.py | 6 +++--- .../nonlinear_cantilever/ValidationPlots.py | 3 --- examples/nonlinear_hemisphere/analysis.py | 7 +++---- .../benchmark/benchmark_hemisphere.py | 10 +++++----- examples/nonlinear_skin_buckle/analysis.py | 17 ++++++++++------- 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/examples/mach_tutorial_wing/benchmark/benchmark_mach_tutorial.py b/examples/mach_tutorial_wing/benchmark/benchmark_mach_tutorial.py index 2a92f3cb6..09c8c32b8 100644 --- a/examples/mach_tutorial_wing/benchmark/benchmark_mach_tutorial.py +++ b/examples/mach_tutorial_wing/benchmark/benchmark_mach_tutorial.py @@ -13,15 +13,15 @@ # Reference values for eval functions FUNC_REF = { - "StructAnalysis_compliance": 155457.77449517886, - "StructAnalysis_l_skin_ksFailure": 0.6688990169113461, + "StructAnalysis_compliance": 155444.88138037617, + "StructAnalysis_l_skin_ksFailure": 0.6688691183266002, "StructAnalysis_l_skin_mass": 1056.704174594214, "StructAnalysis_mass": 3196.8719514874, - "StructAnalysis_rib_ksFailure": 0.25352002232016596, + "StructAnalysis_rib_ksFailure": 0.25350286472639316, "StructAnalysis_rib_mass": 686.2303380471093, - "StructAnalysis_spar_ksFailure": 0.6336362974489301, - "StructAnalysis_spar_mass": 400.0665693788245, - "StructAnalysis_u_skin_ksFailure": 0.46504728373719834, + "StructAnalysis_spar_ksFailure": 0.6336086764475523, + "StructAnalysis_spar_mass": 400.06656937882445, + "StructAnalysis_u_skin_ksFailure": 0.46502733574612126, "StructAnalysis_u_skin_mass": 1053.8708694672512, "AdjCon_L_SKIN_panelThicknessAdj": np.zeros(21), "AdjCon_L_SKIN_stiffenerHeightAdj": np.zeros(21), diff --git a/examples/nonlinear_annulus/analysis.py b/examples/nonlinear_annulus/analysis.py index 3a0c204ad..bc8421fba 100644 --- a/examples/nonlinear_annulus/analysis.py +++ b/examples/nonlinear_annulus/analysis.py @@ -91,8 +91,7 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg "printLevel": 1, } newtonOptions = { - "MaxIter": 50, - "MaxLinIters": 5, + "MaxLinIters": 10, "UseEW": True, } continuationOptions = { @@ -100,7 +99,8 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg "TargetIter": 6, "RelTol": 1e-7, "UsePredictor": True, - "NumPredictorStates": 8, + "NumPredictorStates": 6, + "MaxIter": 60, } problem = FEAAssembler.createStaticProblem("Annulus", options=probOptions) problem.nonlinearSolver.setOptions(continuationOptions) diff --git a/examples/nonlinear_annulus/benchmark/benchmark_annulus.py b/examples/nonlinear_annulus/benchmark/benchmark_annulus.py index d45439e1c..3bf5ec649 100644 --- a/examples/nonlinear_annulus/benchmark/benchmark_annulus.py +++ b/examples/nonlinear_annulus/benchmark/benchmark_annulus.py @@ -13,9 +13,9 @@ # Reference values for eval functions FUNC_REF = { - "Annulus_Compliance": 19.00178466211241, - "Annulus_KSFailure": 0.10786534506897062, - "Annulus_MaxZDisp": 12.519062474962869, + "Annulus_Compliance": 19.001784662112364, + "Annulus_KSFailure": 48164.44513056076, + "Annulus_MaxZDisp": 12.519062474962878, } diff --git a/examples/nonlinear_cantilever/ValidationPlots.py b/examples/nonlinear_cantilever/ValidationPlots.py index 233eff647..e05a85605 100644 --- a/examples/nonlinear_cantilever/ValidationPlots.py +++ b/examples/nonlinear_cantilever/ValidationPlots.py @@ -28,9 +28,6 @@ LENGTH = 10.0 -# plt.style.use(niceplots.get_style()) -# colours = niceplots.get_colors() - alphaTest = np.arange(0.05, 1.01, 0.05) * 4 alphaPlot = np.linspace(0.0, 1.0, 101) * 4 diff --git a/examples/nonlinear_hemisphere/analysis.py b/examples/nonlinear_hemisphere/analysis.py index 7a28fe2de..a517ba53a 100644 --- a/examples/nonlinear_hemisphere/analysis.py +++ b/examples/nonlinear_hemisphere/analysis.py @@ -94,9 +94,9 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg "InitialStep": 1.0, } newtonOptions = { - "newtonSolverMaxIter": 50, - "newtonSolverUseEW": True, - "newtonSolverMaxLinIters": 10, + "MaxIter": 50, + "UseEW": True, + "MaxLinIters": 10, } problem = FEAAssembler.createStaticProblem("RadialForces", options=probOptions) @@ -168,4 +168,3 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg if COMM.rank == 0: pprint(funcs) - pprint(funcsSens) diff --git a/examples/nonlinear_hemisphere/benchmark/benchmark_hemisphere.py b/examples/nonlinear_hemisphere/benchmark/benchmark_hemisphere.py index f20f606ee..9dc2e999e 100644 --- a/examples/nonlinear_hemisphere/benchmark/benchmark_hemisphere.py +++ b/examples/nonlinear_hemisphere/benchmark/benchmark_hemisphere.py @@ -12,11 +12,11 @@ sys.path.append(example_path) # Reference values for eval functions -FUNC_REFS = { - "RadialForces_Compliance": 121.37975434927841, - "RadialForces_KSFailure": 0.09375588756570011, - "RadialForces_MaxYDisp": 0.23012106687058378, - "RadialForces_MaxZDisp": 2.3202346529634763, +FUNC_REF = { + "RadialForces_Compliance": 121.37975434928234, + "RadialForces_KSFailure": 312113.1779703558, + "RadialForces_MaxYDisp": 0.2301210668705867, + "RadialForces_MaxZDisp": 2.3202346529635003, } diff --git a/examples/nonlinear_skin_buckle/analysis.py b/examples/nonlinear_skin_buckle/analysis.py index c5546af62..e6d7e71ba 100644 --- a/examples/nonlinear_skin_buckle/analysis.py +++ b/examples/nonlinear_skin_buckle/analysis.py @@ -86,18 +86,21 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg FEAAssembler.initialize(elemCallBack) probOptions = { - "printTiming": True, "nRestarts": 3, "subSpaceSize": 20, "printLevel": 1, } -continuationOptions = { - "InitialStep": 0.25, -} newtonOptions = { - "MaxLinIters": 0, - "SkipFirstNLineSearch": 0, - "MaxIter": 100, + "MaxLinIters": 10, + "UseEW": True, +} +continuationOptions = { + "InitialStep": 0.05, + "TargetIter": 6, + "RelTol": 1e-7, + "UsePredictor": True, + "NumPredictorStates": 4, + "MaxIter": 60, } problem = FEAAssembler.createStaticProblem("TipForce", options=probOptions)