I have been trying to find the frequency of a 2d truss on PyAnsys. I did code it up but have not been able to get the desired answer. Below I have attached the truss that i want to solve using the PyAnsys.
Below is the Code that I used to get the frequency of the truss.
import ansys.mapdl.core as pymapdl
import numpy as np
# Start MAPDL
mapdl = pymapdl.launch_mapdl()
# Clear any existing data
mapdl.clear()
# Set up the model
mapdl.prep7()
# Define material properties
mapdl.mp('EX', 1, 68.95e9) # Young's modulus in Pascals
mapdl.mp('DENS', 1, 2767.05) # Density in kg/m^3 for modal analysis
# Define element type for 2D truss elements (LINK1)
mapdl.et(1, "LINK1")
# Define real constant (cross-sectional area)
area = 0.00007161 # Cross-sectional area in m^2
mapdl.r(1, area)
# Define nodal coordinates
nodes = [
(1, 0, 0), # Node 1
(2, 3.048, 0), # Node 2
(3, 6.096, 0), # Node 3
(4, 9.144, 0), # Node 4
(5, 9.144, 3.048), # Node 5
(6, 6.096, 3.048), # Node 6
(7, 3.048, 3.048), # Node 7
(8, 0, 3.048) # Node 8
]
# Create nodes
for node in nodes:
mapdl.n(*node)
# Define elements
mapdl.type(1) # Set element type to LINK1
mapdl.mat(1) # Set material number to 1
mapdl.real(1) # Set real constant set number to 1
elements = [
(1, 2), (2, 3), (3, 4),
(5, 6), (6, 7), (7, 8),
(2, 7), (3, 6), (4, 5),
(1, 7), (2, 8), (2, 6),
(3, 7), (3, 5), (4, 6)
]
for start_node, end_node in elements:
mapdl.e(start_node, end_node)
# Apply boundary conditions
mapdl.d(1, 'UX', 0) # Fix UX at Node 1
mapdl.d(1, 'UY', 0) # Fix UY at Node 1
mapdl.d(8, 'UX', 0) # Fix UX at Node 8
mapdl.d(8, 'UY', 0) # Fix UY at Node 8
# Apply loads for static analysis
load_magnitude = -44482.2 # Load in Newtons
mapdl.f(4, 'FY', load_magnitude) # Apply load at node 4
# Solve modal analysis
mapdl.finish()
mapdl.run('/SOLU')
mapdl.antype('MODAL')
mapdl.modopt('LANPCG', 10)
mapdl.solve()
mapdl.finish()
# Post-processing to extract natural frequencies
mapdl.post1()
frequencies = mapdl.post_processing.frequency_values
# Check and print frequencies
if frequencies.size > 0:
for mode, frequency in enumerate(frequencies, start=1):
print(f"Mode {mode} - Natural Frequency: {frequency:.2f} Hz")
else:
print("No natural frequencies were computed. Check constraints and setup.")
# Stop MAPDL
mapdl.exit()
How ever I am not getting the result I want. I have attached the modes that i got from SAP2000 and Ansys.