diff --git a/examples/beam/analysis.py b/examples/beam/analysis.py index 9ca6c5d30..daa61d944 100755 --- a/examples/beam/analysis.py +++ b/examples/beam/analysis.py @@ -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 # ============================================================================== diff --git a/examples/beam/ibeam_example.py b/examples/beam/ibeam_example.py index 6dd1b38f0..b3c48cc62 100755 --- a/examples/beam/ibeam_example.py +++ b/examples/beam/ibeam_example.py @@ -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 # ============================================================================== diff --git a/examples/buckling_plate/1_run_analysis.py b/examples/buckling_plate/1_run_analysis.py index e2ea5b362..652452560 100644 --- a/examples/buckling_plate/1_run_analysis.py +++ b/examples/buckling_plate/1_run_analysis.py @@ -2,6 +2,7 @@ Sean Engelstad, Feb 2024 GT SMDO Lab """ + from _flat_plate_analysis import FlatPlateAnalysis from mpi4py import MPI diff --git a/examples/buckling_plate/2_verification_cases.py b/examples/buckling_plate/2_verification_cases.py index f7ce15e0d..af6be9cfc 100644 --- a/examples/buckling_plate/2_verification_cases.py +++ b/examples/buckling_plate/2_verification_cases.py @@ -2,6 +2,7 @@ Sean Engelstad, Feb 2024 GT SMDO Lab """ + from _flat_plate_analysis import FlatPlateAnalysis import numpy as np import unittest @@ -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 ) @@ -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 ) @@ -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 ) diff --git a/examples/buckling_plate/_flat_plate_analysis.py b/examples/buckling_plate/_flat_plate_analysis.py index 20cca2d70..e065e8062 100644 --- a/examples/buckling_plate/_flat_plate_analysis.py +++ b/examples/buckling_plate/_flat_plate_analysis.py @@ -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 @@ -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, @@ -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 @@ -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 @@ -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 = ( @@ -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): @@ -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( diff --git a/examples/crm/analysis.py b/examples/crm/analysis.py index 1dcae8297..97211ec30 100755 --- a/examples/crm/analysis.py +++ b/examples/crm/analysis.py @@ -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 # ============================================================================== diff --git a/examples/fuselage/analysis.py b/examples/fuselage/analysis.py index 246c7a528..81bab44fd 100644 --- a/examples/fuselage/analysis.py +++ b/examples/fuselage/analysis.py @@ -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 # ============================================================================== diff --git a/examples/nonlinear_annulus/analysis.py b/examples/nonlinear_annulus/analysis.py index bc8421fba..414e00ab5 100644 --- a/examples/nonlinear_annulus/analysis.py +++ b/examples/nonlinear_annulus/analysis.py @@ -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) diff --git a/examples/nonlinear_cantilever/ValidationPlots.py b/examples/nonlinear_cantilever/ValidationPlots.py index e05a85605..7a27d38e1 100644 --- a/examples/nonlinear_cantilever/ValidationPlots.py +++ b/examples/nonlinear_cantilever/ValidationPlots.py @@ -17,6 +17,7 @@ # External Python modules # ============================================================================== import numpy as np + # import niceplots import matplotlib.pyplot as plt diff --git a/examples/plate/analysis.py b/examples/plate/analysis.py index c3ff4368c..889266dc2 100755 --- a/examples/plate/analysis.py +++ b/examples/plate/analysis.py @@ -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 # ============================================================================== diff --git a/examples/plate/optimize_composite_plate.py b/examples/plate/optimize_composite_plate.py index 171425309..9373d4e1c 100644 --- a/examples/plate/optimize_composite_plate.py +++ b/examples/plate/optimize_composite_plate.py @@ -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, @@ -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") diff --git a/examples/plate/plate_buckle.py b/examples/plate/plate_buckle.py index a326b8ab9..061be9a2a 100755 --- a/examples/plate/plate_buckle.py +++ b/examples/plate/plate_buckle.py @@ -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 # ============================================================================== diff --git a/examples/plate/rotating_disk.py b/examples/plate/rotating_disk.py index 501dba524..e91759b56 100755 --- a/examples/plate/rotating_disk.py +++ b/examples/plate/rotating_disk.py @@ -9,6 +9,7 @@ t = 1 mm omega = 100 rev/s """ + # ============================================================================== # Standard Python modules # ============================================================================== diff --git a/examples/plot_JD_history/plot_JD_history.py b/examples/plot_JD_history/plot_JD_history.py index 961ca1e03..31f474d01 100644 --- a/examples/plot_JD_history/plot_JD_history.py +++ b/examples/plot_JD_history/plot_JD_history.py @@ -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 diff --git a/examples/rbe2/analysis.py b/examples/rbe2/analysis.py index 21b8e918d..ee429ea05 100755 --- a/examples/rbe2/analysis.py +++ b/examples/rbe2/analysis.py @@ -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 # ============================================================================== diff --git a/examples/rbe3/analysis.py b/examples/rbe3/analysis.py index 198b5655c..5442f7cce 100755 --- a/examples/rbe3/analysis.py +++ b/examples/rbe3/analysis.py @@ -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 # ============================================================================== diff --git a/examples/slot_3d/analysis.py b/examples/slot_3d/analysis.py index a4f63d285..0df995379 100755 --- a/examples/slot_3d/analysis.py +++ b/examples/slot_3d/analysis.py @@ -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 # ============================================================================== diff --git a/examples/spring_mass/analysis.py b/examples/spring_mass/analysis.py index c32154807..a76653b43 100755 --- a/examples/spring_mass/analysis.py +++ b/examples/spring_mass/analysis.py @@ -19,6 +19,7 @@ fx = fy = fz = 1.0 N mx = my = mz = 1.0 N * m """ + # ============================================================================== # Standard Python modules # ============================================================================== diff --git a/examples/spring_mass/harmonic_oscillation.py b/examples/spring_mass/harmonic_oscillation.py index 420ff07f2..401f77caf 100755 --- a/examples/spring_mass/harmonic_oscillation.py +++ b/examples/spring_mass/harmonic_oscillation.py @@ -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 # ============================================================================== diff --git a/examples/thermal_plate/analysis.py b/examples/thermal_plate/analysis.py index 7f0e951c1..f525e6358 100755 --- a/examples/thermal_plate/analysis.py +++ b/examples/thermal_plate/analysis.py @@ -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 # ============================================================================== diff --git a/pyproject.toml b/pyproject.toml index d13d55ba6..53e454e6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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+ diff --git a/tacs/__init__.py b/tacs/__init__.py index 8c6e07206..c44452c13 100644 --- a/tacs/__init__.py +++ b/tacs/__init__.py @@ -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"]) diff --git a/tacs/caps2tacs/tacs_aim.py b/tacs/caps2tacs/tacs_aim.py index a933f9057..b0985c6a9 100644 --- a/tacs/caps2tacs/tacs_aim.py +++ b/tacs/caps2tacs/tacs_aim.py @@ -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 diff --git a/tacs/constraints/volume.py b/tacs/constraints/volume.py index 0e036ca93..e2cc24910 100644 --- a/tacs/constraints/volume.py +++ b/tacs/constraints/volume.py @@ -132,9 +132,9 @@ 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 @@ -142,9 +142,9 @@ def _initializeAdjacencyList(self): 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 diff --git a/tacs/problems/buckling.py b/tacs/problems/buckling.py index 46175e438..f5b6ca03f 100644 --- a/tacs/problems/buckling.py +++ b/tacs/problems/buckling.py @@ -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 diff --git a/tacs/pymeshloader.py b/tacs/pymeshloader.py index 312612ce9..0a558db3e 100644 --- a/tacs/pymeshloader.py +++ b/tacs/pymeshloader.py @@ -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 diff --git a/tacs/pytacs.py b/tacs/pytacs.py index 074be8804..1b5c6ea32 100755 --- a/tacs/pytacs.py +++ b/tacs/pytacs.py @@ -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." diff --git a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py index 4f1d11b93..07e202502 100644 --- a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py +++ b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py @@ -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 diff --git a/tests/integration_tests/test_mphys_struct_buckling.py b/tests/integration_tests/test_mphys_struct_buckling.py index 3fd75f812..0dd4612a7 100644 --- a/tests/integration_tests/test_mphys_struct_buckling.py +++ b/tests/integration_tests/test_mphys_struct_buckling.py @@ -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 )