Skip to content

Commit

Permalink
Adding buckling eigenvalue solver (#213)
Browse files Browse the repository at this point in the history
* Adding geometric stiffness to shell elements

* Adding TACSBuckling API to cython wrapper

* Adding BucklingProblem class

* Adding buckling integration test

* clang format fixes

* loosening up shell test tol

* Adding buckling solver to mphys wrapper

* Minor mphys refactor

* Clang format fixes

* Reducing mesh size for mphys buckling test

* Increasing testflo CI timelimit

* Updating sigma value in eigenvalue test

* Adding rtol setting to ModalProblem setup

* Adding buckling example and benchmark

* Reducing N_PROCS to 1 for mphys buckling test
  • Loading branch information
timryanb authored Jun 3, 2023
1 parent f3ddea0 commit e5e98c7
Show file tree
Hide file tree
Showing 22 changed files with 4,863 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
if [[ ${{ matrix.NAME }} == 'Real' ]]; then
source ${TACS_DIR}/extern/ESP122/ESPenv.sh
fi
testflo --timeout 120 .;
testflo --timeout 240 .;
- name: Build docs
run: |
cd $TACS_DIR/docs;
Expand Down
19 changes: 19 additions & 0 deletions docs/source/pytacs/buckling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BucklingProblem
------------
.. automodule:: tacs.problems.buckling

Options
^^^^^^^
Options can be set for :class:`~tacs.problems.BucklingProblem` at time of creation for the class in the
:meth:`pyTACS.createBucklingProblem <tacs.pytacs.pyTACS.createBucklingProblem>` method or using the
:meth:`BucklingProblem.setOption <tacs.problems.BucklingProblem.setOption>` method. Current option values for a class
instance can be printed out using the :meth:`BucklingProblem.printOption <tacs.problems.BucklingProblem.printOptions>` method.
The following options, their default values and descriptions are listed below:

.. program-output:: python -c "from tacs.problems import BucklingProblem; BucklingProblem.printDefaultOptions()"

API Reference
^^^^^^^^^^^^^
.. autoclass:: tacs.problems.BucklingProblem
:members:
:inherited-members:
3 changes: 2 additions & 1 deletion docs/source/pytacs/problems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Problem classes

static
transient
modal
modal
buckling
44 changes: 44 additions & 0 deletions examples/plate/benchmark/benchmark_buckle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
This script is used to regression test the example against historical values.
"""

import numpy as np
import unittest
import sys
import os

# Set the path to the example script we're testing
example_path = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(example_path)

# Reference values for eval functions
FUNC_REF = {
"buckle_eigsb.0": 20.082400947865022,
"buckle_eigsb.1": 43.01440496545738,
"buckle_eigsb.2": 80.31233170890538,
"buckle_eigsb.3": 84.69751385025641,
"buckle_eigsb.4": 86.82024838978569,
}


class ExampleBenchmark(unittest.TestCase):
N_PROCS = 8 # this is how many MPI processes to use for this TestCase.

def setUp(self):
# Import the example to automatically run the script
import plate_buckle

self.example = plate_buckle

def benchmark_funcs(self):
"""
Test the example eval functions against reference values
"""
func_dict = self.example.funcs

# Test functions values against historical values
for func_name in func_dict:
with self.subTest(function=func_name):
np.testing.assert_allclose(
func_dict[func_name], FUNC_REF[func_name], rtol=1e-6, atol=1e-6
)
50 changes: 50 additions & 0 deletions examples/plate/plate_buckle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
This problem performs a buckling analysis on a 4m x 3m flat plate.
The perimeter of the plate is pinned and loaded in compression (20kN/m) on its horizontal edges.
We use TACS buckling eigenvalue solver through the pyTACS BucklingProblem interface.
"""
# ==============================================================================
# Standard Python modules
# ==============================================================================
from __future__ import print_function
import os

# ==============================================================================
# External Python modules
# ==============================================================================
from pprint import pprint

import numpy as np
from mpi4py import MPI

# ==============================================================================
# Extension modules
# ==============================================================================
from tacs import pyTACS

comm = MPI.COMM_WORLD

# Instantiate FEAAssembler
bdfFile = os.path.join(os.path.dirname(__file__), "ss_plate_buckle.bdf")
FEAAssembler = pyTACS(bdfFile, comm=comm)
# Set up constitutive objects and elements
FEAAssembler.initialize()

# Setup static problem
bucklingProb = FEAAssembler.createBucklingProblem(name="buckle", sigma=10.0, numEigs=5)
bucklingProb.setOption("printLevel", 2)
# Add Loads
bucklingProb.addLoadFromBDF(loadID=1)

# solve and evaluate functions/sensitivities
funcs = {}
funcsSens = {}
bucklingProb.solve()
bucklingProb.evalFunctions(funcs)
bucklingProb.evalFunctionsSens(funcsSens)
bucklingProb.writeSolution(outputDir=os.path.dirname(__file__))


if comm.rank == 0:
pprint(funcs)
pprint(funcsSens)
Loading

0 comments on commit e5e98c7

Please sign in to comment.