Skip to content

Commit d920409

Browse files
Mass no adjoint SSW case 4 merge into SSW Turbulent example (#6)
* stupid simple wing prototype (smdogroup#268) * Define aero problem and conditions. * Wing structural model ESP/CAPS * Update .gitignore * SSW structural model Rename wing.udc to wingStuct.udc for clarity. Completed structural model of SSW in ESP/CAPS. * SSW aerodynamic model * Full SSW ESP/CAPS model * Completed meshing scripts for SSW * Update 1_panel_thickness.py * Initial CFD run * Working oneway sizing optimization * Update 1_panel_thickness.py * Update 1_panel_thickness.py * Initial version of 2_aero_aoa * Update 2_aero_aoa.py * Update sizing.txt * Update ssw-sizing_history.png * Update _mesh_fun3d.py * Update 3_geom_twist.py * Update fun3d.nml * Update design file naming conventions * Update 3_geom_twist.py * Update 4_oml_shape.py * Formatting * Update 2_aero_aoa.py * Update 4_oml_shape.py * Update SSW branch (smdogroup#275) * Update esp/caps download (smdogroup#271) * Update esp/caps download * Update tar command in unit-test workflow * Fix ESP124 folder name * FUN3D clean up: fix logic in shape driver and remove build_morph method in fun3d_model (smdogroup#272) * Update funtofem_shape_driver.py * Update fun3d_model.py Delete redundant build_morph method and add documentation to build method. * Print out a summary of the driver instance for inspection (smdogroup#273) * Clean up the model summary Added methods to print out a summary of the driver set up, including details on the solvers, shape change, mesh change, transfer settings, and comm manager. Cleaned up the model summary to print more neatly using standard spacings rather than arbitrary tabs. Small bug fix in `funtofem_shape_driver.py` associated with trying to delete the structural model at the end of the adjoint. Originally implemented to free up memory, but the implementation was attempting to delete an attribute which leads to an Attribute Error. * Create driver summary methods * Move print_transfer to _funtofem_driver Move _print_transfer method to _funtofem_driver so that all drivers can inherit the method. Also changed the generic driver summary in _funtofem_driver. * Formatting * Make transfer_settings an attribute of base driver Add attribute to the base driver class for the transfer_settings, including a check for None. Remove attribution in the shape driver. * Typo in base driver * Formatting * Read in inactive variables from design files (smdogroup#274) * Root proc check on _setDictOptions for AFLR AIM * Add ability to read inactive variables from previous designs --------- Co-authored-by: Sean Engelstad <[email protected]> * Redefine geometry Set all twists to default to zero. Use blend instead of rule. * Create _2_cfd_only.py * Update _oneway_sizing to use SNOPT * Update oneway_aero_driver.py * Delete naca_wing.csm * Delete ssw-sizing_history.png * Update cases to match hpc files * Add Pointwise meshes * Update _oneway_sizing.py * Formatting * commit ssw 14.0 example * egads aero mesh example * prototype ssw finite difference test * remove reload design file * update cfl in namelist * fix steps in namelist * update panel thickness script * add FD test for the derivatives * fix early stopping multi analysis bug * update ssw 14 fun3d nml * new aero loads for ssw case * oneway sizing opt * updated aerodynamic function fun3d check * black reformat * SSW 14.0 Modifications for SNOPT (smdogroup#295) * Fix opt manager nan exit (smdogroup#284) * fix bug in optimization manager * Update optimization_manager.py * Create a generalized mesh AIM. (smdogroup#286) * Generalized mesh AIM * New notation in meshAIM * Update egads_aim.py * Update aflr_aim.py * Formatting * Update egads_aim.py * FUNtoFEM read and write unsteady aero loads files (smdogroup#289) * working unsteady aero loads files * black reformat * FUN3D v14.0.2 interface stable release for thermal cases (smdogroup#288) * fun3d 14.0 fun3d interface changes * add separate fun3d 14 and 13.0 interfaces * Update fun3d_14_interface.py name to Fun3d14Interface * update fun3d 14 interface unittests * update fun3d model * black reformat * update fun3d 14.0 thermal changes * update fun3d 14 interface with debug statements * new thermal fun3d test * add new fun3d thermal interface test * fun3d 14 thermal interface test complete * update the fun3d 14 thermal interface test * update the import statements * black reformat * black reformat with psf/black-stable * Apply suggestions from code review * undo debug changes * black reformat * Rollback test_fun3d_tacs.py to FUN3D 13.6 test * Update test_fun3d_tacs.py to add fun3d_project_name back in * black reformat --------- Co-authored-by: Brian Burke <[email protected]> * FUN3D 14.0 Coupling Frequency for Coupled Adjoint speedup + Early Stopping Fix (smdogroup#291) * huge speedup in funtofem fully coupled adjoint solve * turn hanim off in turbulent beta nml * working adjoint derivatives and change adjoint_steps * working early stopping criterion in FUN3D 14.0.2 * add error check for first aero function w early stopping * input funtofem loose coupling frequency through the fun3d interface (no longer namelist input) * update nml for turbulent beta * black reformat + throw error if FUN3D 13.6 uses loose coupling frequency * Update funtofem/interface/fun3d_interface.py --------- Co-authored-by: Brian Burke <[email protected]> * commit ssw 14.0 example * egads aero mesh example * prototype ssw finite difference test * remove reload design file * update cfl in namelist * fix steps in namelist * update panel thickness script * add FD test for the derivatives * fix early stopping multi analysis bug * update ssw 14 fun3d nml * new aero loads for ssw case * oneway sizing opt * updated aerodynamic function fun3d check * black reformat --------- Co-authored-by: Brian Burke <[email protected]> * fix any aerodynamic again * fix any aerodynamic again * Fix any aerodynamic function check again (smdogroup#296) * Fix opt manager nan exit (smdogroup#284) * fix bug in optimization manager * Update optimization_manager.py * Create a generalized mesh AIM. (smdogroup#286) * Generalized mesh AIM * New notation in meshAIM * Update egads_aim.py * Update aflr_aim.py * Formatting * Update egads_aim.py * FUNtoFEM read and write unsteady aero loads files (smdogroup#289) * working unsteady aero loads files * black reformat * FUN3D v14.0.2 interface stable release for thermal cases (smdogroup#288) * fun3d 14.0 fun3d interface changes * add separate fun3d 14 and 13.0 interfaces * Update fun3d_14_interface.py name to Fun3d14Interface * update fun3d 14 interface unittests * update fun3d model * black reformat * update fun3d 14.0 thermal changes * update fun3d 14 interface with debug statements * new thermal fun3d test * add new fun3d thermal interface test * fun3d 14 thermal interface test complete * update the fun3d 14 thermal interface test * update the import statements * black reformat * black reformat with psf/black-stable * Apply suggestions from code review * undo debug changes * black reformat * Rollback test_fun3d_tacs.py to FUN3D 13.6 test * Update test_fun3d_tacs.py to add fun3d_project_name back in * black reformat --------- Co-authored-by: Brian Burke <[email protected]> * FUN3D 14.0 Coupling Frequency for Coupled Adjoint speedup + Early Stopping Fix (smdogroup#291) * huge speedup in funtofem fully coupled adjoint solve * turn hanim off in turbulent beta nml * working adjoint derivatives and change adjoint_steps * working early stopping criterion in FUN3D 14.0.2 * add error check for first aero function w early stopping * input funtofem loose coupling frequency through the fun3d interface (no longer namelist input) * update nml for turbulent beta * black reformat + throw error if FUN3D 13.6 uses loose coupling frequency * Update funtofem/interface/fun3d_interface.py --------- Co-authored-by: Brian Burke <[email protected]> * commit ssw 14.0 example * egads aero mesh example * prototype ssw finite difference test * remove reload design file * update cfl in namelist * fix steps in namelist * update panel thickness script * add FD test for the derivatives * fix early stopping multi analysis bug * update ssw 14 fun3d nml * new aero loads for ssw case * oneway sizing opt * updated aerodynamic function fun3d check * black reformat * fix any aerodynamic again * fix any aerodynamic again --------- Co-authored-by: Brian Burke <[email protected]> * Updated SSW meshes (smdogroup#297) * Formatting (smdogroup#299) * update tolerances * merge ssw geometries * update aero surf mesh * update * geomtry orig * working mass, adjoint False * working mass function with no adjoint * remove ssw-14 folder * update unittest * fix unittests? * fix shape driver * fix tacs interface unsteady with non adjoint functions * add fix for case 2 ssw testing * update case 3 ssw testing * update example 3 * udpate case 3 _ssw-testing * change scenario fun3d_project_name back * update optimal designs * ssw case 4 * update get variables routine for case 4 * remove TODO statements * fix snoptimizer syntax * update the ssw case 4 inviscid * add test struct shape example --------- Co-authored-by: Burke, Brian <[email protected]> Co-authored-by: Brian Burke <[email protected]>
1 parent 19ba3d4 commit d920409

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import unittest, importlib, numpy as np, os, sys
2+
from funtofem import *
3+
from mpi4py import MPI
4+
5+
np.random.seed(1234567)
6+
comm = MPI.COMM_WORLD
7+
8+
tacs_loader = importlib.util.find_spec("tacs")
9+
caps_loader = importlib.util.find_spec("pyCAPS")
10+
11+
base_dir = os.path.dirname(os.path.abspath(__file__))
12+
csm_path = os.path.join(base_dir, "geometry", "ssw.csm")
13+
results_folder, _ = make_test_directories(comm, base_dir)
14+
15+
if tacs_loader is not None and caps_loader is not None:
16+
from tacs import caps2tacs
17+
18+
# check if we're in github to run only online vs offline tests
19+
in_github_workflow = bool(os.getenv("GITHUB_ACTIONS"))
20+
# in_github_workflow = True
21+
optional = True # whether to run optional tests
22+
23+
24+
@unittest.skipIf(
25+
tacs_loader is None or caps_loader is None,
26+
"skipping test using caps2tacs if caps or tacs are unavailable",
27+
)
28+
class TestTacsSteadyShapeDriver(unittest.TestCase):
29+
N_PROCS = 2
30+
FILENAME = "tacs_steady_shape_driver.txt"
31+
FILEPATH = os.path.join(results_folder, FILENAME)
32+
33+
@unittest.skipIf(in_github_workflow, "only run this test offline")
34+
def test_shape_steady_aeroelastic(self):
35+
# make the funtofem and tacs model
36+
f2f_model = FUNtoFEMmodel("wing")
37+
tacs_model = caps2tacs.TacsModel.build(csm_file=csm_path, comm=comm)
38+
tacs_model.mesh_aim.set_mesh( # need a refined-enough mesh for the derivative test to pass
39+
edge_pt_min=5,
40+
edge_pt_max=10,
41+
global_mesh_size=0.1,
42+
max_surf_offset=0.01,
43+
max_dihedral_angle=5,
44+
).register_to(
45+
tacs_model
46+
)
47+
f2f_model.structural = tacs_model
48+
49+
# build a body which we will register variables to
50+
wing = Body.aeroelastic("wing")
51+
52+
# setup the material and shell properties
53+
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)
54+
55+
nribs = int(tacs_model.get_config_parameter("nribs"))
56+
nspars = int(tacs_model.get_config_parameter("nspars"))
57+
nOML = nribs - 1
58+
59+
for irib in range(1, nribs + 1):
60+
caps2tacs.ShellProperty(
61+
caps_group=f"rib{irib}", material=aluminum, membrane_thickness=0.05
62+
).register_to(tacs_model)
63+
for ispar in range(1, nspars + 1):
64+
caps2tacs.ShellProperty(
65+
caps_group=f"spar{ispar}", material=aluminum, membrane_thickness=0.05
66+
).register_to(tacs_model)
67+
for iOML in range(1, nOML + 1):
68+
caps2tacs.ShellProperty(
69+
caps_group=f"OML{iOML}", material=aluminum, membrane_thickness=0.03
70+
).register_to(tacs_model)
71+
for prefix in ["LE", "TE"]:
72+
caps2tacs.ShellProperty(
73+
caps_group=f"{prefix}spar", material=aluminum, membrane_thickness=0.03
74+
).register_to(tacs_model)
75+
76+
# register any shape variables to the wing which are auto-registered to tacs model
77+
for itc in range(2, 4):
78+
Variable.shape(name=f"tc{itc}").set_bounds(
79+
lower=0.4, value=0.2, upper=1.6
80+
).register_to(wing)
81+
82+
# register the wing body to the model
83+
wing.register_to(f2f_model)
84+
85+
# add remaining information to tacs model
86+
caps2tacs.PinConstraint("root").register_to(tacs_model)
87+
88+
# make a funtofem scenario
89+
test_scenario = Scenario.steady("test", steps=10)
90+
Function.ksfailure().register_to(test_scenario)
91+
Function.mass().register_to(test_scenario)
92+
test_scenario.register_to(f2f_model)
93+
94+
solvers = SolverManager(comm)
95+
solvers.flow = TestAerodynamicSolver(comm, f2f_model)
96+
aero_driver = TestAeroOnewayDriver(solvers, f2f_model)
97+
transfer_settings = TransferSettings(npts=200, beta=0.5)
98+
99+
# setup the tacs model
100+
tacs_model.setup()
101+
102+
tacs_driver = OnewayStructDriver.prime_loads(
103+
aero_driver, transfer_settings=transfer_settings, nprocs=2
104+
)
105+
106+
max_rel_error = TestResult.derivative_test(
107+
"testaero=>tacs_shape_steady-aeroelastic",
108+
f2f_model,
109+
tacs_driver,
110+
TestTacsSteadyShapeDriver.FILEPATH,
111+
complex_mode=False,
112+
epsilon=1e-4,
113+
)
114+
rtol = 1e-4
115+
self.assertTrue(max_rel_error < rtol)
116+
return
117+
118+
119+
if __name__ == "__main__":
120+
if tacs_loader is not None and caps_loader is not None:
121+
if comm.rank == 0:
122+
open(TestTacsSteadyShapeDriver.FILEPATH, "w").close()
123+
124+
unittest.main()

0 commit comments

Comments
 (0)