Skip to content

Commit

Permalink
Merge branch 'rem_tacs_component' of github.com:sean-engelstad/tacs i…
Browse files Browse the repository at this point in the history
…nto rem_tacs_component
  • Loading branch information
sean-engelstad committed Sep 3, 2024
2 parents a2fd142 + 2d51038 commit 216fee1
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 44 deletions.
1 change: 1 addition & 0 deletions examples/beam/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
6 noded beam model 1 meter long in x direction.
We apply a tip load in the z direction and clamp it at the root.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/beam/ibeam_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
The tip deflection of the model is given by the following formula
v_tip = V * L^3 / (3 * E * I) = 1.4285714285714286
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/buckling_plate/1_run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Sean Engelstad, Feb 2024
GT SMDO Lab
"""

from _flat_plate_analysis import FlatPlateAnalysis
from mpi4py import MPI

Expand Down
7 changes: 4 additions & 3 deletions examples/buckling_plate/2_verification_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Sean Engelstad, Feb 2024
GT SMDO Lab
"""

from _flat_plate_analysis import FlatPlateAnalysis
import numpy as np
import unittest
Expand Down Expand Up @@ -43,7 +44,7 @@ def test_uniaxial_compression(self):

# flat_plate.run_static_analysis(write_soln=True)

tacs_eigvals,_ = self.flat_plate.run_buckling_analysis(
tacs_eigvals, _ = self.flat_plate.run_buckling_analysis(
sigma=30.0, num_eig=12, write_soln=True
)

Expand Down Expand Up @@ -75,7 +76,7 @@ def test_pure_shear_clamped(self):

# flat_plate.run_static_analysis(write_soln=True)

tacs_eigvals,_ = self.flat_plate.run_buckling_analysis(
tacs_eigvals, _ = self.flat_plate.run_buckling_analysis(
sigma=30.0, num_eig=12, write_soln=True
)

Expand Down Expand Up @@ -110,7 +111,7 @@ def test_combined_axial_shear_clamped(self):

# flat_plate.run_static_analysis(write_soln=True)

tacs_eigvals,_ = self.flat_plate.run_buckling_analysis(
tacs_eigvals, _ = self.flat_plate.run_buckling_analysis(
sigma=30.0, num_eig=12, write_soln=True
)

Expand Down
24 changes: 16 additions & 8 deletions examples/buckling_plate/_flat_plate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def exp_kernel1(xp, xq, sigma_f, L):
# xp, xq are Nx1, Nx1 vectors
return sigma_f**2 * np.exp(-0.5 * (xp - xq).T @ (xp - xq) / L**2)


class CompositeMaterialUtility:
"""
utility class for computing composite material properties at an orientation
Expand Down Expand Up @@ -70,6 +71,7 @@ def __str__(self):
f"E11 = {self.E11}, E22 = {self.E22}, nu12 = {self.nu12}, G12 = {self.G12}"
)


class FlatPlateAnalysis:
def __init__(
self,
Expand Down Expand Up @@ -204,13 +206,13 @@ def get_materials(cls):
cls.hexcelIM7,
cls.victrexAE,
]

@classmethod
def get_material_from_str(cls, mat_name:str):
def get_material_from_str(cls, mat_name: str):
method_names = [_.__qualname__ for _ in cls.get_materials()]
materials = cls.get_materials()
_method = None
for i,method_name in enumerate(method_names):
for i, method_name in enumerate(method_names):
if mat_name in method_name:
_method = materials[i]
assert _method is not None
Expand Down Expand Up @@ -408,9 +410,7 @@ def affine_exx(self):
get the exx so that lambda = kx_0 the affine buckling coefficient for pure axial load
out of the buckling analysis!
"""
exx_T = (
np.pi**2 * np.sqrt(self.D11 * self.D22) / self.b**2 / self.h / self.E11
)
exx_T = np.pi**2 * np.sqrt(self.D11 * self.D22) / self.b**2 / self.h / self.E11
return exx_T

@property
Expand All @@ -427,7 +427,14 @@ def affine_exy(self):
option = 2
# option 1 - based on self derivation (but didn't match data well)
if option == 1:
exy_T = np.pi**2 * (self.D11 * self.D22)**0.5 / self.a / self.b / self.h / self.G12
exy_T = (
np.pi**2
* (self.D11 * self.D22) ** 0.5
/ self.a
/ self.b
/ self.h
/ self.G12
)
# option 2 - based on NASA non-dimensional buckling parameter derivation (much better)
elif option == 2:
exy_T = (
Expand Down Expand Up @@ -780,6 +787,7 @@ def elemCallBack(
# Add scale for thickness dv
scale = [100.0]
return elemList, scale

return elemCallBack

def run_static_analysis(self, base_path=None, write_soln=False):
Expand Down Expand Up @@ -832,7 +840,7 @@ def run_buckling_analysis(
FEAAssembler.initialize(self._elemCallBack())

# set complex step Gmatrix into all elements through assembler
#FEAAssembler.assembler.setComplexStepGmatrix(True)
# FEAAssembler.assembler.setComplexStepGmatrix(True)

# Setup buckling problem
bucklingProb = FEAAssembler.createBucklingProblem(
Expand Down
1 change: 1 addition & 0 deletions examples/crm/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and computes sensitivities with respect to wingbox thicknesses and node xyz locations.
The sensitivities are then verified against finite-difference or complex step approximations.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/fuselage/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The fuselage is subjected to a cabin pressure of 1 atm and 1G gravity load.
User can run this example using aluminum or composite material properties.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
10 changes: 6 additions & 4 deletions examples/nonlinear_annulus/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg
outerRadius = np.max(nodeRadius)
totalForce = PMax * (outerRadius - innerRadius)
loadPointFactors = [
1.0
if nodeRadius[ii - 1] <= (innerRadius + 1e-4)
or nodeRadius[ii - 1] >= (outerRadius - 1e-4)
else 2.0
(
1.0
if nodeRadius[ii - 1] <= (innerRadius + 1e-4)
or nodeRadius[ii - 1] >= (outerRadius - 1e-4)
else 2.0
)
for ii in loadPointNodeIDs
]
factorSum = np.sum(loadPointFactors)
Expand Down
1 change: 1 addition & 0 deletions examples/nonlinear_cantilever/ValidationPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# External Python modules
# ==============================================================================
import numpy as np

# import niceplots
import matplotlib.pyplot as plt

Expand Down
1 change: 1 addition & 0 deletions examples/plate/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
L = 1.0 m
3. A modal problem where the dynamic eigenmodes are solved for the plate structure
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
12 changes: 3 additions & 9 deletions examples/plate/optimize_composite_plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@


# Callback function used to setup TACS element objects and DVs
def element_callback(
dvNum, compID, compDescript, elemDescripts, specialDVs, **kwargs
):
def element_callback(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwargs):
# Create ply object
ortho_prop = constitutive.MaterialProperties(
rho=rho,
Expand Down Expand Up @@ -135,15 +133,11 @@ def setup(self):
dvs = self.add_subsystem("dvs", om.IndepVarComp(), promotes=["*"])
dvs.add_output("dv_struct", dv_array)

self.add_subsystem(
"mesh", struct_builder.get_mesh_coordinate_subsystem()
)
self.add_subsystem("mesh", struct_builder.get_mesh_coordinate_subsystem())
self.mphys_add_scenario(
"pressure_load", ScenarioStructural(struct_builder=struct_builder)
)
self.mphys_connect_scenario_coordinate_source(
"mesh", "pressure_load", "struct"
)
self.mphys_connect_scenario_coordinate_source("mesh", "pressure_load", "struct")

self.connect("dv_struct", "pressure_load.dv_struct")

Expand Down
1 change: 1 addition & 0 deletions examples/plate/plate_buckle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/plate/rotating_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
t = 1 mm
omega = 100 rev/s
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/plot_JD_history/plot_JD_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This script plots the printout file that contains the convergence history
of the Jacobi-Davidson eigenvalue solver
"""

import enum
from matplotlib.colors import LinearSegmentedColormap
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions examples/rbe2/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
RBE2 example where an RBE2 is used to connect two separate cantilevered plate sections.
A load is applied at the centroid of the RBE2.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/rbe3/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Cylindrical beam constructed from shell elements. The beam is cantilevered at
one end and loaded at the other using an RBE3.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/slot_3d/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The slot is constrained at its bolt holes and a set of point
forces are applied at the top of the slot.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/spring_mass/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
fx = fy = fz = 1.0 N
mx = my = mz = 1.0 N * m
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/spring_mass/harmonic_oscillation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
the model's first natural frequency. We then plot the respone of both
the baseline and resonating transient problem.
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions examples/thermal_plate/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. A transient problem where the bc's are applied time t=0
2. A static problem that represents the steady state solution of the above at t=infinty
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ['setuptools>=45.0', 'wheel', 'cython>=3.0.0', 'numpy>=1.25,<2.0.0',
requires = ['setuptools>=45.0,<72.0', 'wheel', 'cython>=3.0.0', 'numpy>=1.25,<2.0.0',
# Build against an old version (3.1.1) of mpi4py for forward compatibility
"mpi4py==3.1.1; python_version<'3.11'",
# Python 3.11 requires 3.1.4+
Expand Down
4 changes: 1 addition & 3 deletions tacs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ def get_libraries():
from . import problems
from . import constraints

__all__.extend(
["caps2tacs", "pytacs", "pyTACS", "problems", "constraints"]
)
__all__.extend(["caps2tacs", "pytacs", "pyTACS", "problems", "constraints"])
2 changes: 1 addition & 1 deletion tacs/caps2tacs/tacs_aim.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def set_config_parameter(self, param_name: str, value: float):
@root_broadcast
def get_config_parameter(self, param_name: str):
return self.geometry.cfgpmtr[param_name].value

@parallel
def set_design_parameter(self, param_name: str, value: float):
self.geometry.despmtr[param_name].value = value
Expand Down
12 changes: 6 additions & 6 deletions tacs/constraints/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ def _initializeAdjacencyList(self):
# will be inconsistent
for i, iComp in enumerate(edgeToFace[edgeKey][:-1]):
for jComp in edgeToFace[edgeKey][i + 1 :]:
self.adjacentOrientationMatch[iComp][
jComp
] = self.adjacentOrientationMatch[jComp][iComp] = False
self.adjacentOrientationMatch[iComp][jComp] = (
self.adjacentOrientationMatch[jComp][iComp]
) = False
# If this component shares an edge with another component
# but the edge ordering is reversed, the normal orientations
# will be consistent
flippedEdgeKey = (edgeKey[1], edgeKey[0])
if flippedEdgeKey in edgeToFace:
for iComp in edgeToFace[edgeKey]:
for jComp in edgeToFace[flippedEdgeKey]:
self.adjacentOrientationMatch[iComp][
jComp
] = self.adjacentOrientationMatch[jComp][iComp] = True
self.adjacentOrientationMatch[iComp][jComp] = (
self.adjacentOrientationMatch[jComp][iComp]
) = True

else:
self.adjacentOrientationMatch = None
Expand Down
2 changes: 1 addition & 1 deletion tacs/problems/buckling.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def getVariables(self, index, states=None):
elif isinstance(states, np.ndarray):
states[:] = eigVector.getArray()
return eigVal, eigVector.getArray()

def getModalError(self, index):
"""
Return the error associated with a particular mode
Expand Down
6 changes: 3 additions & 3 deletions tacs/pymeshloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def scanBdfFile(self, bdf):
self.elemConnectivity[tacsElementID] = self.idMap(
conn, self.nastranToTACSNodeIDDict
)
self.elemConnectivityPointer[
tacsElementID + 1
] = self.elemConnectivityPointer[tacsElementID] + len(element.nodes)
self.elemConnectivityPointer[tacsElementID + 1] = (
self.elemConnectivityPointer[tacsElementID] + len(element.nodes)
)

# Allocate list for user-specified tacs element objects
self.elemObjects = [None] * elementObjectCounter
Expand Down
4 changes: 1 addition & 3 deletions tacs/pytacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,7 @@ def matCallBack(matInfo):
Yc = matInfo.Yc
S12 = matInfo.S

if (
S12 == 0 or Xt == 0 or Xc == 0 or Yt == 0 or Yc == 0
):
if S12 == 0 or Xt == 0 or Xc == 0 or Yt == 0 or Yc == 0:
self._TACSWarning(
f"MAT8 card {matInfo.mid} has a zero strength, check Xc, Xt, Yc, Yt, and S12."
"Otherwise Tsai-Wu Failure criterion is undefined or infinity."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def get_con(self, ply):
self.panelPlyFracNums,
self.stiffenerHeightNum,
self.stiffenerThicknessNum,
self.stiffenerPlyFracNums
self.stiffenerPlyFracNums,
)
# Set the KS weight really low so that all failure modes make a
# significant contribution to the failure function derivatives
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_mphys_struct_buckling.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def buckling_setup(scenario_name, fea_assembler):
Helper function to add fixed forces and eval functions
to structural problems used in tacs builder
"""
bucklingOptions = {"writeSolution":False}
bucklingOptions = {"writeSolution": False}
problem = fea_assembler.createBucklingProblem(
"buckling", sigma=1e0, numEigs=2, options=bucklingOptions
)
Expand Down

0 comments on commit 216fee1

Please sign in to comment.