Skip to content

Commit 186b23c

Browse files
Squash Blade Stiffened TACS commits (#8)
* stupid simple wing prototype (#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 (#275) * Update esp/caps download (#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 (#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 (#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 (#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 (#295) * Fix opt manager nan exit (#284) * fix bug in optimization manager * Update optimization_manager.py * Create a generalized mesh AIM. (#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 (#289) * working unsteady aero loads files * black reformat * FUN3D v14.0.2 interface stable release for thermal cases (#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 (#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 (#296) * Fix opt manager nan exit (#284) * fix bug in optimization manager * Update optimization_manager.py * Create a generalized mesh AIM. (#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 (#289) * working unsteady aero loads files * black reformat * FUN3D v14.0.2 interface stable release for thermal cases (#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 (#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 (#297) * Formatting (#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 * working blade stiffeners with TACS + FUNtoFEM * update the blade callback file --------- Co-authored-by: Burke, Brian <[email protected]> Co-authored-by: Brian Burke <[email protected]>
1 parent 2ef23b5 commit 186b23c

File tree

6 files changed

+606
-84
lines changed

6 files changed

+606
-84
lines changed

examples/framework/tacs_oneway_naca_wing/1_tacs_sizing_opt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
model=f2f_model,
133133
comm=comm,
134134
nprocs=1,
135-
bdf_file=tacs_aim.dat_file_path,
136-
prefix=tacs_aim.analysis_dir,
135+
bdf_file=tacs_aim.root_dat_file_path,
136+
prefix=tacs_aim.root_analysis_dir,
137137
)
138138
solvers.flow.copy_struct_mesh()
139139
null_driver = NullDriver(solvers, model=f2f_model, transfer_settings=None)

examples/framework/tacs_oneway_naca_wing/2_tacs_sizing_and_shape_opt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
model=f2f_model,
144144
comm=comm,
145145
nprocs=1,
146-
bdf_file=tacs_aim.dat_file_path,
147-
prefix=tacs_aim.analysis_dir,
146+
bdf_file=tacs_aim.root_dat_file_path,
147+
prefix=tacs_aim.root_analysis_dir,
148148
)
149149
solvers.flow.copy_struct_mesh()
150150
null_driver = NullDriver(solvers, model=f2f_model, transfer_settings=None)

examples/framework/tacs_oneway_naca_wing/3_tacs_sizing_opt_stringer.py examples/framework/tacs_oneway_naca_wing/3_tacs_blade_stiffened.py

+23-79
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import openmdao.api as om
1010
from mpi4py import MPI
1111

12+
from _blade_callback import blade_elemCallBack
13+
1214
# --------------------------------------------------------------#
1315
# Setup CAPS Problem and FUNtoFEM model - NOTE: not complete, needs stringer PR
1416
# --------------------------------------------------------------#
@@ -31,50 +33,32 @@
3133
)
3234
tacs_aim = tacs_model.tacs_aim
3335

34-
aluminum = caps2tacs.Isotropic.aluminum()
35-
aluminum_stringer = caps2tacs.Orthotropic.smeared_stringer(
36-
aluminum, area_ratio=0.5
37-
).register_to(tacs_model)
38-
3936
# setup the thickness design variables + automatic shell properties
4037
# using Composite functions, this part has to go after all funtofem variables are defined...
4138
nribs = int(tacs_model.get_config_parameter("nribs"))
4239
nspars = int(tacs_model.get_config_parameter("nspars"))
4340
nOML = int(tacs_aim.get_output_parameter("nOML"))
4441

42+
null_material = caps2tacs.Orthotropic.null().register_to(tacs_model)
43+
4544
init_thickness = 0.08
4645
for irib in range(1, nribs + 1):
4746
name = f"rib{irib}"
48-
caps2tacs.CompositeProperty.one_ply(
49-
caps_group=name,
50-
material=aluminum_stringer,
51-
thickness=init_thickness,
52-
ply_angle=0,
53-
).register_to(tacs_model)
47+
caps2tacs.CompositeProperty.null(name, null_material).register_to(tacs_model)
5448
Variable.structural(name, value=init_thickness).set_bounds(
5549
lower=0.01, upper=0.2, scale=100.0
5650
).register_to(wing)
5751

5852
for ispar in range(1, nspars + 1):
5953
name = f"spar{ispar}"
60-
caps2tacs.CompositeProperty.one_ply(
61-
caps_group=name,
62-
material=aluminum_stringer,
63-
thickness=init_thickness,
64-
ply_angle=0,
65-
).register_to(tacs_model)
54+
caps2tacs.CompositeProperty.null(name, null_material).register_to(tacs_model)
6655
Variable.structural(name, value=init_thickness).set_bounds(
6756
lower=0.01, upper=0.2, scale=100.0
6857
).register_to(wing)
6958

7059
for iOML in range(1, nOML + 1):
7160
name = f"OML{iOML}"
72-
caps2tacs.CompositeProperty.one_ply(
73-
caps_group=name,
74-
material=aluminum_stringer,
75-
thickness=init_thickness,
76-
ply_angle=0,
77-
).register_to(tacs_model)
61+
caps2tacs.CompositeProperty.null(name, null_material).register_to(tacs_model)
7862
Variable.structural(name, value=init_thickness).set_bounds(
7963
lower=0.01, upper=0.2, scale=100.0
8064
).register_to(wing)
@@ -91,51 +75,52 @@
9175

9276
# make the scenario(s)
9377
tacs_scenario = Scenario.steady("tacs", steps=100)
94-
Function.mass().optimize(scale=1.0e-2, objective=True, plot=True).register_to(
95-
tacs_scenario
96-
)
9778
Function.ksfailure(ks_weight=10.0).optimize(
9879
scale=30.0, upper=0.267, objective=False, plot=True
9980
).register_to(tacs_scenario)
81+
Function.mass().optimize(scale=1.0e-2, objective=True, plot=True).register_to(
82+
tacs_scenario
83+
)
10084
tacs_scenario.register_to(f2f_model)
10185

10286
# make the composite functions for adjacency constraints
10387
variables = f2f_model.get_variables()
104-
adjacency_ratio = 2.0
88+
adj_value = 0.002
10589
adjacency_scale = 10.0
10690
for irib in range(
10791
1, nribs
10892
): # not (1, nribs+1) bc we want to do one less since we're doing nribs-1 pairs
10993
left_rib = f2f_model.get_variables(names=f"rib{irib}")
11094
right_rib = f2f_model.get_variables(names=f"rib{irib+1}")
11195
# make a composite function for relative diff in rib thicknesses
112-
adjacency_rib_constr = (left_rib - right_rib) / left_rib
96+
adjacency_rib_constr = left_rib - right_rib
11397
adjacency_rib_constr.set_name(f"rib{irib}-{irib+1}").optimize(
114-
lower=-adjacency_ratio, upper=adjacency_ratio, scale=1.0, objective=False
98+
lower=-adj_value, upper=adj_value, scale=1.0, objective=False
11599
).register_to(f2f_model)
116100

117101
for ispar in range(1, nspars):
118102
left_spar = f2f_model.get_variables(names=f"spar{ispar}")
119103
right_spar = f2f_model.get_variables(names=f"spar{ispar+1}")
120104
# make a composite function for relative diff in spar thicknesses
121-
adjacency_spar_constr = (left_spar - right_spar) / left_spar
105+
adjacency_spar_constr = left_spar - right_spar
122106
adjacency_spar_constr.set_name(f"spar{ispar}-{ispar+1}").optimize(
123-
lower=-adjacency_ratio, upper=adjacency_ratio, scale=1.0, objective=False
107+
lower=-adj_value, upper=adj_value, scale=1.0, objective=False
124108
).register_to(f2f_model)
125109

126110
for iOML in range(1, nOML):
127111
left_OML = f2f_model.get_variables(names=f"OML{iOML}")
128112
right_OML = f2f_model.get_variables(names=f"OML{iOML+1}")
129113
# make a composite function for relative diff in OML thicknesses
130-
adj_OML_constr = (left_OML - right_OML) / left_OML
114+
adj_OML_constr = left_OML - right_OML
131115
adj_OML_constr.set_name(f"OML{iOML}-{iOML+1}").optimize(
132-
lower=-adjacency_ratio, upper=adjacency_ratio, scale=1.0, objective=False
116+
lower=-adj_value, upper=adj_value, scale=1.0, objective=False
133117
).register_to(f2f_model)
134118

135119
# make the BDF and DAT file for TACS structural analysis
136120
tacs_aim.setup_aim()
137121
tacs_aim.pre_analysis()
138122

123+
139124
# build the solver manager, no tacs interface since built for each new shape
140125
# in the tacs driver
141126
solvers = SolverManager(comm)
@@ -144,56 +129,15 @@
144129
model=f2f_model,
145130
comm=comm,
146131
nprocs=1,
147-
bdf_file=tacs_aim.dat_file_path,
148-
prefix=tacs_aim.analysis_dir,
132+
bdf_file=tacs_aim.root_dat_file,
133+
prefix=tacs_aim.root_analysis_dir,
134+
callback=blade_elemCallBack,
149135
)
150136
solvers.flow.copy_struct_mesh()
151137
null_driver = NullDriver(solvers, model=f2f_model, transfer_settings=None)
152138

153139
# build the tacs oneway driver
154140
tacs_driver = OnewayStructDriver.prime_loads(driver=null_driver)
155141

156-
# --------------------------------------------------------------------------#
157-
# Setup OpenMDAO Problem and Perform Sizing Optimization on the Wing
158-
# --------------------------------------------------------------------------#
159-
160-
# setup the OpenMDAO Problem object
161-
prob = om.Problem()
162-
163-
# Create the OpenMDAO component using the built-in Funtofem component
164-
design_out_file = "design-test.txt"
165-
f2f_subsystem = FuntofemComponent(
166-
driver=tacs_driver, write_dir=tacs_aim.analysis_dir, design_out_file=design_out_file
167-
)
168-
prob.model.add_subsystem("f2fSystem", f2f_subsystem)
169-
f2f_subsystem.register_to_model(prob.model, "f2fSystem")
170-
171-
# setup the optimizer settings # COBYLA for auto-FDing
172-
optimizer = "scipy"
173-
if optimizer == "scipy":
174-
prob.driver = om.ScipyOptimizeDriver(optimizer="SLSQP", tol=1.0e-9, disp=True)
175-
elif optimizer == "pyoptsparse":
176-
prob.driver = om.pyOptSparseDriver(optimizer="SNOPT")
177-
# prob.driver.opt_settings['Major feasibility tolerance'] = 1e-5 # lower tolerance to prevent tight oscillations
178-
179-
# Start the optimization
180-
print("\n==> Starting optimization...")
181-
prob.setup()
182-
183-
debug = False
184-
if debug:
185-
print("Checking partials...", flush=True)
186-
prob.check_partials(compact_print=True)
187-
188-
else:
189-
prob.run_driver()
190-
191-
# report the final optimal design
192-
design_hdl = f2f_subsystem._design_hdl
193-
for var in f2f_model.get_variables():
194-
opt_value = prob.get_val(f"f2fSystem.{var.name}")
195-
design_hdl.write(f"\t{var.name} = {opt_value}")
196-
197-
prob.cleanup()
198-
# close the design hdl file
199-
f2f_subsystem.cleanup()
142+
tacs_driver.solve_forward()
143+
# tacs_driver.solve_adjoint()

0 commit comments

Comments
 (0)