Skip to content

Commit

Permalink
Merge pull request #192 from timryanb/tacs-meld-api-update
Browse files Browse the repository at this point in the history
Tacs meld api update
  • Loading branch information
timryanb authored Dec 17, 2024
2 parents 8cab854 + 9dc6d97 commit e65f67f
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 43 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/unit_tests_and_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
echo "=============================================================";
echo "Install optional dependencies";
echo "=============================================================";
mamba install -c "smdogroup/label/complex" -c smdogroup -c conda-forge "tacs>=3.6.0" funtofem -q -y;
mamba install -c "smdogroup/label/complex" -c smdogroup -c conda-forge "tacs>=3.8.0" "funtofem>=0.3.8" -q -y;
pip install openaerostruct;
echo "=============================================================";
echo "List installed packages/versions";
Expand All @@ -72,14 +72,14 @@ jobs:
echo "=============================================================";
cd tests/unit_tests
testflo
#echo "=============================================================";
#echo "Running integration tests";
#echo "=============================================================";
#cd ../input_files
#chmod +x get-input-files.sh
#./get-input-files.sh
#cd ../integration_tests
#testflo test_tacs_* test_meld_* test_oas_*
echo "=============================================================";
echo "Running integration tests";
echo "=============================================================";
cd ../input_files
chmod +x get-input-files.sh
./get-input-files.sh
cd ../integration_tests
testflo test_tacs_* test_meld_* #test_oas_*
echo "=============================================================";
echo "Making docs";
echo "=============================================================";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def setup(self):

# TACS setup
struct_builder = TacsBuilder(mesh_file="wingbox_Y_Z_flip.bdf", element_callback=tacs_setup.element_callback,
problem_setup=tacs_setup.problem_setup, coupled=True)
problem_setup=tacs_setup.problem_setup,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC])
struct_builder.initialize(self.comm)
ndv_struct = struct_builder.get_ndv()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def setup(self):

# TACS setup
struct_builder = TacsBuilder(mesh_file='wingbox_Y_Z_flip.bdf', element_callback=tacs_setup.element_callback,
problem_setup=tacs_setup.problem_setup, coupled=True)
problem_setup=tacs_setup.problem_setup,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC])

# MELD
isym = 1
Expand Down
19 changes: 12 additions & 7 deletions examples/aerostructural/oas_tacs_wing/run_oas_tacs_wing.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def setup(self):
re = 1e6

dvs = self.add_subsystem('dvs', om.IndepVarComp(), promotes=['*'])
dvs.add_output('aoa', val=aoa, units='deg')
dvs.add_output('yaw', val=yaw, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, val=aoa, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE, val=yaw, units='deg')
dvs.add_output('rho', val=rho, units='kg/m**3')
dvs.add_output('mach', mach)
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER, mach)
dvs.add_output('v', vel, units='m/s')
dvs.add_output('reynolds', re, units="1/m")
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER, re, units="1/m")

# OpenAeroStruct
aero_builder = AeroBuilder(surfaces)
Expand All @@ -70,7 +70,8 @@ def setup(self):
# TACS setup
struct_builder = TacsBuilder(mesh_file=bdf_file, element_callback=tacs_setup.element_callback,
problem_setup=tacs_setup.problem_setup,
constraint_setup=tacs_setup.constraint_setup, coupled=True)
constraint_setup=tacs_setup.constraint_setup,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC])

struct_builder.initialize(self.comm)
ndv_struct = struct_builder.get_ndv()
Expand All @@ -92,7 +93,11 @@ def setup(self):
self.connect(f'mesh_struct.{MPhysVariables.Structures.Mesh.COORDINATES}',
f'maneuver.{MPhysVariables.Structures.COORDINATES}')

for dv in ['aoa', 'yaw', 'rho', 'mach', 'v', 'reynolds']:
for dv in [MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK,
MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE,
MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER,
MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER,
'rho', 'v']:
self.connect(dv, f'maneuver.{dv}')
self.connect('dv_struct', 'maneuver.dv_struct')

Expand All @@ -103,7 +108,7 @@ def setup(self):

# Add wingbox panel thicknesses and angle of attack as design variables
model.add_design_var('dv_struct', lower=0.002, upper=0.2, scaler=1000.0)
model.add_design_var('aoa', lower=-10, upper=10.0, scaler=0.1)
model.add_design_var(MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, lower=-10, upper=10.0, scaler=0.1)
# Structural mass of half wing
model.add_objective('maneuver.mass', scaler=1.0/1000.0)
# Max stress constraint
Expand Down
2 changes: 1 addition & 1 deletion examples/struct_only/crm9/run_tacs_mphys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Top(Multipoint):
def setup(self):
struct_builder = TacsBuilder(mesh_file='CRM_box_2nd.bdf', element_callback=tacs_setup.element_callback,
problem_setup=tacs_setup.problem_setup,
constraint_setup=tacs_setup.constraint_setup, coupled=False)
constraint_setup=tacs_setup.constraint_setup)
struct_builder.initialize(self.comm)
dv_array = struct_builder.get_initial_dvs()

Expand Down
11 changes: 7 additions & 4 deletions tests/integration_tests/test_oas_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def setup(self):
re = 1e6

dvs = self.add_subsystem("dvs", om.IndepVarComp(), promotes=["*"])
dvs.add_output("aoa", val=aoa, units="deg")
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, val=aoa, units="deg")
dvs.add_output("rho", val=rho, units="kg/m**3")
dvs.add_output("mach", mach)
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER, mach)
dvs.add_output("v", vel, units="m/s")
dvs.add_output("reynolds", re, units="1/m")
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER, re, units="1/m")

aero_builder = AeroBuilder([surface], options={"write_solution": False})
aero_builder.initialize(self.comm)
Expand All @@ -62,7 +62,10 @@ def setup(self):
self.connect(f'mesh.{MPhysVariables.Aerodynamics.Surface.Mesh.COORDINATES}',
f'cruise.{MPhysVariables.Aerodynamics.Surface.COORDINATES}')

for dv in ['aoa', 'mach', 'rho', 'v', 'reynolds']:
for dv in [MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK,
MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER,
MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER,
'rho', 'v']:
self.connect(dv, f'cruise.{dv}')

class TestOAS(unittest.TestCase):
Expand Down
17 changes: 11 additions & 6 deletions tests/integration_tests/test_oas_tacs_meld_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def setup(self):
re = 1e6

dvs = self.add_subsystem('dvs', om.IndepVarComp(), promotes=['*'])
dvs.add_output('aoa', val=aoa, units='deg')
dvs.add_output('yaw', val=beta, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, val=aoa, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE, val=beta, units='deg')
dvs.add_output('rho', val=rho, units='kg/m**3')
dvs.add_output('mach', mach)
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER, mach)
dvs.add_output('v', vel, units='m/s')
dvs.add_output('reynolds', re, units="1/m")
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER, re, units="1/m")

aero_builder = AeroBuilder([surface], options={"write_solution": False})
aero_builder.initialize(self.comm)
Expand All @@ -115,7 +115,8 @@ def setup(self):

# TACS setup
struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup, check_partials=True, coupled=True,
problem_setup=problem_setup, check_partials=True,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC],
write_solution=False)

struct_builder.initialize(self.comm)
Expand Down Expand Up @@ -144,7 +145,11 @@ def setup(self):
self.connect(f'mesh_struct.{MPhysVariables.Structures.Mesh.COORDINATES}',
f'cruise.{MPhysVariables.Structures.COORDINATES}')

for dv in ['aoa', 'yaw', 'rho', 'mach', 'v', 'reynolds']:
for dv in [MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK,
MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE,
MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER,
MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER,
'rho', 'v']:
self.connect(dv, f'cruise.{dv}')
self.connect('dv_struct', 'cruise.dv_struct')

Expand Down
20 changes: 13 additions & 7 deletions tests/integration_tests/test_oas_tacs_meld_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def setup(self):
re = 1e6

dvs = self.add_subsystem('dvs', om.IndepVarComp(), promotes=['*'])
dvs.add_output('aoa', val=aoa, units='deg')
dvs.add_output('yaw', val=yaw, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, val=aoa, units='deg')
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE, val=yaw, units='deg')
dvs.add_output('rho', val=rho, units='kg/m**3')
dvs.add_output('mach', mach)
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER, mach)
dvs.add_output('v', vel, units='m/s')
dvs.add_output('reynolds', re, units="1/m")
dvs.add_output(MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER, re, units="1/m")

aero_builder = AeroBuilder([surface], options={"write_solution": False})
aero_builder.initialize(self.comm)
Expand All @@ -112,7 +112,8 @@ def setup(self):

# TACS setup
struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup, check_partials=True, coupled=True,
problem_setup=problem_setup, check_partials=True,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC],
write_solution=False)

struct_builder.initialize(self.comm)
Expand Down Expand Up @@ -141,7 +142,11 @@ def setup(self):
self.connect(f'mesh_struct.{MPhysVariables.Structures.Mesh.COORDINATES}',
f'cruise.{MPhysVariables.Structures.COORDINATES}')

for dv in ['aoa', 'yaw', 'rho', 'mach', 'v', 'reynolds']:
for dv in [MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK,
MPhysVariables.Aerodynamics.FlowConditions.YAW_ANGLE,
MPhysVariables.Aerodynamics.FlowConditions.MACH_NUMBER,
MPhysVariables.Aerodynamics.FlowConditions.REYNOLDS_NUMBER,
'rho', 'v']:
self.connect(dv, f'cruise.{dv}')
self.connect('dv_struct', 'cruise.dv_struct')

Expand All @@ -161,7 +166,8 @@ def test_derivatives(self):
self.prob.run_model()
print('----------------starting check totals--------------')
data = self.prob.check_totals(of=['cruise.wing.CL', 'cruise.ks_vmfailure', 'cruise.mass'],
wrt=['aoa', 'dv_struct'], method='fd', form='central',
wrt=[MPhysVariables.Aerodynamics.FlowConditions.ANGLE_OF_ATTACK, 'dv_struct'],
method='fd', form='central',
step=1e-5, step_calc='rel')
assert_check_totals(data, atol=1e99, rtol=1e-6)

Expand Down
8 changes: 5 additions & 3 deletions tests/integration_tests/test_tacs_derivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class Top(Multipoint):
def setup(self):
tacs_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup,
check_partials=True, coupled=True, write_solution=False)
check_partials=True,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC],
write_solution=False)
tacs_builder.initialize(self.comm)
ndv_struct = tacs_builder.get_ndv()

Expand All @@ -85,7 +87,7 @@ def setup(self):
self.connect(f'mesh.{MPhysVariables.Structures.Mesh.COORDINATES}',
f'analysis.{MPhysVariables.Structures.COORDINATES}')
self.connect('dv_struct', 'analysis.dv_struct')
self.connect('f_struct', f'analysis.{MPhysVariables.Structures.LOADS_FROM_AERODYNAMICS}')
self.connect('f_struct', f'analysis.{MPhysVariables.Structures.Loads.AERODYNAMIC}')


class TestTACS(unittest.TestCase):
Expand All @@ -105,7 +107,7 @@ def test_derivatives(self):
self.prob.run_model()
print('----------------starting check totals--------------')
data = self.prob.check_totals(of=['analysis.ks_vmfailure', 'analysis.mass'],
wrt='mesh.fea_mesh.x_struct0', method='cs',
wrt=f'mesh.fea_mesh.{MPhysVariables.Structures.Mesh.COORDINATES}', method='cs',
step=1e-50, step_calc='rel')
assert_check_totals(data, atol=1e99, rtol=1e-7)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_tacs_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Top(Multipoint):

def setup(self):
tacs_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup, check_partials=True, coupled=False,
problem_setup=problem_setup, check_partials=True,
write_solution=False)
tacs_builder.initialize(self.comm)
ndv_struct = tacs_builder.get_ndv()
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/vlm_tacs_meld_check_partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def setup(self):
#struct_assembler = ModalStructAssembler(tacs_options)
else:
struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup, check_partials=True, coupled=True,
problem_setup=problem_setup, check_partials=True,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC],
write_solution=False)

struct_builder.initialize(self.comm)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/vlm_tacs_meld_check_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def setup(self):
#struct_assembler = ModalStructAssembler(tacs_options)
else:
struct_builder = TacsBuilder(mesh_file='../input_files/debug.bdf', element_callback=element_callback,
problem_setup=problem_setup, check_partials=True, coupled=True,
problem_setup=problem_setup, check_partials=True,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC],
write_solution=False)

struct_builder.initialize(self.comm)
Expand Down
3 changes: 2 additions & 1 deletion tests/regression_tests/test_aerostruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def setup(self):
# TACS setup
################################################################################
struct_builder = TacsBuilder(mesh_file='../input_files/wingbox.bdf', element_callback=element_callback,
problem_setup=problem_setup, coupled=True)
problem_setup=problem_setup,
coupling_loads=[MPhysVariables.Structures.Loads.AERODYNAMIC])
struct_builder.initialize(self.comm)

self.add_subsystem("mesh_struct", struct_builder.get_mesh_coordinate_subsystem())
Expand Down

0 comments on commit e65f67f

Please sign in to comment.