Skip to content

Commit 15d3890

Browse files
Add design_svg
1 parent f999f1c commit 15d3890

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"# Design files: Quads design (3dp pla + blue shims) for switching between focusing and protection\n"
9+
]
10+
},
11+
{
12+
"attachments": {},
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"## Imports"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stderr",
26+
"output_type": "stream",
27+
"text": [
28+
"No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)\n"
29+
]
30+
}
31+
],
32+
"source": [
33+
"from difflexmm.utils import load_data\n",
34+
"from scripts.fabrication import generate_clamped_sample_continuous_bond_drawing\n",
35+
"from problems.quads_focusing import OptimizationProblem\n",
36+
"from pathlib import Path\n",
37+
"\n",
38+
"import jax.numpy as jnp\n"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {},
44+
"source": [
45+
"## Paths"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": 2,
51+
"metadata": {},
52+
"outputs": [],
53+
"source": [
54+
"# Where to load/save data\n",
55+
"data_folder = Path(\"../../data/quads_focusing_3dp_pla_shims\")\n"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"metadata": {},
61+
"source": [
62+
"## Problem info"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"NOTE: Either define the problem info here or load it from an optimization file."
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": 3,
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"# NOTE: Units are mm, N, s\n",
79+
"\n",
80+
"# Retrieve design info from optimization data\n",
81+
"optimization_filename = f\"opt_with_angle_30_and_length_3_constraints_quads_24x16_excited_blocks_2_amplitude_7.50_loading_rate_30.00_input_shift_0_initial_angle_25.0_target_size_2x2_target_shift_4x5\"\n",
82+
"optimization = OptimizationProblem.from_dict(\n",
83+
" load_data(\n",
84+
" f\"{data_folder}/{optimization_filename}.pkl\",\n",
85+
" )\n",
86+
")\n",
87+
"problem = optimization.forward_problem\n",
88+
"# Set up the forward problem to get the geometry\n",
89+
"problem.setup()\n",
90+
"geometry = problem.geometry\n",
91+
"\n",
92+
"# Select the best design\n",
93+
"design_values = optimization.design_values[-1]\n"
94+
]
95+
},
96+
{
97+
"cell_type": "markdown",
98+
"metadata": {},
99+
"source": [
100+
"## Drawings"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": 4,
106+
"metadata": {},
107+
"outputs": [
108+
{
109+
"name": "stdout",
110+
"output_type": "stream",
111+
"text": [
112+
"Design size is 370.60x243.60 mm\n",
113+
"Saved at ../../data/quads_focusing_3dp_pla_shims/opt_with_angle_30_and_length_3_constraints_quads_24x16_excited_blocks_2_amplitude_7.50_loading_rate_30.00_input_shift_0_initial_angle_25.0_target_size_2x2_target_shift_4x5/svgs/opt_with_angle_30_and_length_3_constraints_quads_24x16_excited_blocks_2_amplitude_7.50_loading_rate_30.00_input_shift_0_initial_angle_25.0_target_size_2x2_target_shift_4x5.svg\n"
114+
]
115+
}
116+
],
117+
"source": [
118+
"generate_clamped_sample_continuous_bond_drawing(\n",
119+
" geometry=geometry,\n",
120+
" block_centroids=geometry.block_centroids(*design_values),\n",
121+
" centroid_node_vectors=geometry.centroid_node_vectors(*design_values),\n",
122+
" bond_connectivity=geometry.bond_connectivity(),\n",
123+
" reference_bond_vectors=geometry.reference_bond_vectors(),\n",
124+
" n_blocks_clamped_corners=2,\n",
125+
" attachment_size=(15, 15),\n",
126+
" attachment_hole_size=4.2,\n",
127+
" offset_type=\"constant\", # [\"ratio\", \"constant\"]\n",
128+
" offset_size=3,\n",
129+
" path_orientation=\"column\",\n",
130+
" out_file=f\"{data_folder}/{optimization_filename}/svgs/{optimization_filename}.svg\",\n",
131+
")\n"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": null,
137+
"metadata": {},
138+
"outputs": [],
139+
"source": []
140+
}
141+
],
142+
"metadata": {
143+
"kernelspec": {
144+
"display_name": "blockymetamaterials-fbuxbt7l-py3.9",
145+
"language": "python",
146+
"name": "python3"
147+
},
148+
"language_info": {
149+
"codemirror_mode": {
150+
"name": "ipython",
151+
"version": 3
152+
},
153+
"file_extension": ".py",
154+
"mimetype": "text/x-python",
155+
"name": "python",
156+
"nbconvert_exporter": "python",
157+
"pygments_lexer": "ipython3",
158+
"version": "3.9.16"
159+
},
160+
"orig_nbformat": 4
161+
},
162+
"nbformat": 4,
163+
"nbformat_minor": 2
164+
}

0 commit comments

Comments
 (0)