Skip to content

Commit 47279cd

Browse files
committed
clean ricardo analysis
1 parent 5659188 commit 47279cd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

commands/TNA_analysis.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# venv: brg-csd
33
# r: compas_masonry
44

5-
import rhinoscriptsyntax as rs # type: ignore
65
import ast
7-
from numpy import zeros
8-
from numpy import array
6+
7+
import numpy as np
8+
import rhinoscriptsyntax as rs # type: ignore
99

1010
from compas_masonry.scene import RhinoFormDiagramObject
1111
from compas_masonry.session import MasonrySession as Session
@@ -63,11 +63,11 @@ def RunCommand():
6363

6464
elif objective == "MaximumLoad":
6565
n = formobject.diagram.number_of_vertices()
66-
load_direction = zeros((n, 1))
66+
load_direction = np.zeros((n, 1))
6767
index_vertex = formobject.diagram.index_vertex()
6868

6969
while True:
70-
formobject.show_vertices = list(formobject.diagram.vertices())
70+
formobject.show_vertices = list(formobject.diagram.vertices()) # type: ignore
7171
vertices = formobject.select_vertices()
7272
formobject.redraw()
7373

@@ -80,6 +80,7 @@ def RunCommand():
8080

8181
for vertex in vertices:
8282
load_direction[index_vertex[vertex]] = force
83+
8384
# Here we should add a vector to the Scene showing the load case that we are maximizing.
8485

8586
add_loads = rs.GetString(message="Apply Loads on additional vertices?", strings=["Yes", "No"])
@@ -95,7 +96,7 @@ def RunCommand():
9596
elif objective == "SupportDisplacement":
9697
supports = list(formobject.diagram.supports())
9798
nb = len(supports)
98-
displacement_array = zeros((nb, 3))
99+
displacement_array = np.zeros((nb, 3))
99100

100101
while True:
101102
formobject.show_vertices = supports
@@ -110,14 +111,14 @@ def RunCommand():
110111
if not displ:
111112
break
112113

114+
displ_list = ast.literal_eval(displ)
113115
if len(displ_list) != 3:
114116
print("provide a 3x1 vector as shown as the example")
115117
break
116-
117-
displ_list = ast.literal_eval(displ)
118118

119119
for vertex in vertices:
120-
displacement_array[supports.index(vertex)] = array(displ_list)
120+
displacement_array[supports.index(vertex)] = np.array(displ_list)
121+
121122
# Here we should add a vector to the Scene showing the displacement that we are maximizing.
122123

123124
add_vector = rs.GetString(message="Define additional displacement vectors?", strings=["Yes", "No"])
@@ -127,7 +128,7 @@ def RunCommand():
127128
pass
128129
else:
129130
break
130-
131+
131132
analysis = Analysis.create_compl_energy_analysis(formdiagram, envelope, solver="SLSQP", support_displacement=displacement_array)
132133

133134
elif objective == "Bestfit":

0 commit comments

Comments
 (0)