Skip to content

Commit

Permalink
Added summary table in report and more conistent typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccomb committed Dec 17, 2023
1 parent 6dbe7e6 commit d3160dc
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
22 changes: 11 additions & 11 deletions trussme/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
TrussInfo = TypedDict(
"TrussInfo",
{
"coordinates": numpy.ndarray,
"connections": numpy.ndarray,
"loads": numpy.ndarray,
"reactions": numpy.ndarray,
"area": numpy.ndarray,
"elastic_modulus": numpy.ndarray,
"coordinates": NDArray[float],
"connections": NDArray[float],
"loads": NDArray[float],
"reactions": NDArray[float],
"area": NDArray[float],
"elastic_modulus": NDArray[float],
},
)


def the_forces(
truss_info: TrussInfo,
) -> tuple[NDArray[float], NDArray[float], NDArray[float], float]:
tj: numpy.ndarray = numpy.zeros([3, numpy.size(truss_info["connections"], axis=1)])
w: numpy.ndarray = numpy.array(
tj: NDArray[float] = numpy.zeros([3, numpy.size(truss_info["connections"], axis=1)])
w: NDArray[float] = numpy.array(
[
numpy.size(truss_info["reactions"], axis=0),
numpy.size(truss_info["reactions"], axis=1),
]
)
dof: numpy.ndarray = numpy.zeros([3 * w[1], 3 * w[1]])
deflections: numpy.ndarray = numpy.ones(w)
dof: NDArray[float] = numpy.zeros([3 * w[1], 3 * w[1]])
deflections: NDArray[float] = numpy.ones(w)
deflections -= truss_info["reactions"]

# This identifies joints that can be loaded
ff: numpy.ndarray = numpy.where(deflections.T.flat == 1)[0]
ff: NDArray[float] = numpy.where(deflections.T.flat == 1)[0]

# Build the global stiffness matrix
for i in range(numpy.size(truss_info["connections"], axis=1)):
Expand Down
53 changes: 53 additions & 0 deletions trussme/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,59 @@ def generate_summary(the_truss) -> str:
summary += st + ","
summary += "and " + str(failure_string[-1]) + " were not satisfied.\n"

data = []
rows = [
"Minimum Total FOS",
"Minimum FOS for Buckling",
"Minimum FOS for Yielding",
"Maximum Mass",
"Maximum Deflection",
]
data.append(
[
the_truss.minimum_fos_total,
the_truss.fos_total,
"Yes" if the_truss.fos_total > the_truss.minimum_fos_total else "No",
]
)
data.append(
[
the_truss.minimum_fos_buckling,
the_truss.fos_buckling,
"Yes" if the_truss.fos_buckling > the_truss.minimum_fos_buckling else "No",
]
)
data.append(
[
the_truss.minimum_fos_yielding,
the_truss.fos_yielding,
"Yes" if the_truss.fos_yielding > the_truss.minimum_fos_yielding else "No",
]
)
data.append(
[
the_truss.maximum_mass,
the_truss.mass,
"Yes" if the_truss.mass < the_truss.maximum_mass else "No",
]
)
data.append(
[
the_truss.maximum_deflection,
the_truss.deflection,
"Yes" if the_truss.deflection < the_truss.maximum_deflection else "No",
]
)

summary += (
"\n"
+ pandas.DataFrame(
data,
index=rows,
columns=["Target", "Actual", "Ok?"],
).to_markdown()
)

return summary


Expand Down

0 comments on commit d3160dc

Please sign in to comment.