Creation of nodes with an automatized process

Good morning,

So for a project , I need to create a structure with different nodes, but to implement as much nodes as I want, I need to automatize the process. Do you have any idea on how you can do it? This is the script where the nodes are implemented manually : import numpy as np
#Import matplotlib.pyplot library with the name plt. From now on you can reference it as plt
import matplotlib.pyplot as plt
#To perform modal analysis we will need the following package:
from scipy.sparse.linalg import eigs, eigsh

%matplotlib inline

Material properties

E = 4e10 # Young modulus [Pa]
rho = 4500 # Density [kg/m^3]

Cross-section properties

A1, I1 = 102e-3, 980e-6
A2, I2 = 93e-3, 720e-6
A3, I3 = 140e-3, 2430e-6

Node coordinates (10 nodes)

nodes = np.array([
# Nœuds principaux (gauche puis droite, du bas vers le haut)
[0, 0], # 0
[12, 0], # 1
[0, 3], # 2
[12, 3], # 3
[0, 6], # 4
[12, 6], # 5
[0, 9], # 6
[12, 9], # 7
[0, 12], # 8
[12, 12], # 9

# Nœuds intermédiaires verticaux
[0, 1.5],   # 10
[12, 1.5],  # 11
[0, 4.5],   # 12
[12, 4.5],  # 13
[0, 7.5],   # 14
[12, 7.5],  # 15
[0, 10.5],  # 16
[12, 10.5], # 17

# Nœuds intermédiaires horizontaux (centres des poutres)
[6, 3],     # 18
[6, 6],     # 19
[6, 9],     # 20
[6, 12],    # 21

])

numberOfDofs = nodes.shape[0]*3 #.shape[0] returns the number of rows

Connectivity matrix (12 elements)

connectivity = np.array([
# Colonnes gauche (avec intermédiaires)
[0, 10], [10, 2],
[2, 12], [12, 4],
[4, 14], [14, 6],
[6, 16], [16, 8],

# Colonnes droite (avec intermédiaires)
[1, 11], [11, 3],
[3, 13], [13, 5],
[5, 15], [15, 7],
[7, 17], [17, 9],

# Poutres horizontales (niveau 1 à 4, gauche -> centre -> droite)
[2, 18], [18, 3],
[4, 19], [19, 5],
[6, 20], [20, 7],
[8, 21], [21, 9],

])

Element types: 0 for column, 1 for beam

crossSections = np.array([
[0], [0], [0], [0], [0], [0], [0], [0], # colonnes gauche
[0], [0], [0], [0], [0], [0], [0], [0], # colonnes droite
[1], [1], [1], [1], [1], [1], [1], [1], # poutres
])

crossSectionProperties = np.array([
[A1, I1],
[A2, I2],
[A3, I3]
])

Boundary Conditions (fixed nodes 0 and 1)

BCs = np.array([
[0, 1, 2],
[3, 4, 5]
])

Local stiffness and mass functions

Are these nodes for numerical analysis, e.g. FEM or FD?

There are lots of libraries available to automatically generate meshes (nodes and edges lists).

Could you edit your code using the </> button so that it appears more readable? We’re having difficulty understanding what the code does.

yes they are modal analysis nodes FEM