Space Truss Span
Source: examples/grammar/space_truss_span.py
Introduction
Build and optionally evaluate a simple 3D space-truss state.
Technical Implementation
This page is generated from the top-of-file module docstring and the example source code. The full script is included below for direct inspection.
1from __future__ import annotations
2
3import warnings
4
5import design_research_problems as derp
6
7
8def main() -> None:
9 """Build a simple bridge-like space truss and evaluate it when ``trussme`` is installed."""
10 problem = derp.get_problem("space_truss_span")
11 state = problem.initial_state()
12 state = problem.add_member(state, start_joint_id=0, end_joint_id=4)
13 state = problem.add_member(state, start_joint_id=1, end_joint_id=4)
14 state = problem.add_member(state, start_joint_id=2, end_joint_id=4)
15 state = problem.add_member(state, start_joint_id=3, end_joint_id=4)
16 state = problem.add_member(state, start_joint_id=0, end_joint_id=1)
17 state = problem.add_member(state, start_joint_id=2, end_joint_id=3)
18 state = problem.add_member(state, start_joint_id=0, end_joint_id=2)
19 state = problem.add_member(state, start_joint_id=1, end_joint_id=3)
20 state = problem.add_member(state, start_joint_id=0, end_joint_id=3)
21 state = problem.add_member(state, start_joint_id=1, end_joint_id=2)
22 print(problem.metadata.problem_id)
23 try:
24 with warnings.catch_warnings():
25 warnings.filterwarnings("ignore", category=RuntimeWarning, module=r"trussme\\.components")
26 evaluation = problem.evaluate(state)
27 except derp.MissingOptionalDependencyError as exc:
28 print(exc)
29 return
30 print("mass", round(evaluation.mass, 3))
31 print("fos", round(evaluation.fos, 3))
32 print("deflection", round(evaluation.deflection, 3))
33
34
35if __name__ == "__main__":
36 main()
Expected Results
Run Command
PYTHONPATH=src python3 examples/grammar/space_truss_span.py
Run the command shown below from repository root. Output should summarize the problem setup, a baseline solution, or diagnostic values relevant to this example.