Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Voxel Designer - Frame"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"using Plots\n",
"using LinearAlgebra\n",
"using NLopt\n",
"import JSON\n",
"using SparseArrays\n",
"using StaticArrays, BenchmarkTools\n",
"using Statistics"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"simulateAndExport (generic function with 1 method)"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"include(\"./julia/FEM_frame.jl\")\n",
"include(\"./julia/compliant_mechanisms_frame.jl\")"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"complianMechanismOptimization (generic function with 6 methods)"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function complianMechanismOptimization(fileName,scale,dmax,amax,maxeval=500,SIMP=false,threshold=0.25,exageration=100.0,save=true)\n",
" \n",
" setup = getSetup(\"json/$(fileName)\")\n",
" E,f,g,idb,ien,ndf,nel,nen,nnp,nsd,xn,len,Ke,Te,Ls=getDataFromSetup3D(setup,scale);\n",
" problem=E,f,g,idb,ien,ndf,nel,nen,nnp,nsd,xn,len,Ke,Te;\n",
" \n",
" ##todo change based on hinge\n",
" free=map(node ->map(deg -> !deg, node[\"restrained_degrees_of_freedom\"]), setup[\"nodes\"])\n",
" free=reshape(collect(Iterators.flatten(free)),size(Ls[1]))\n",
"\n",
" nel=length(setup[\"edges\"])\n",
" X=ones(nel)\n",
" K,F,d,stress,dcomp,g=FEM_frame(problem,X);\n",
" display(\"Original Domain:\")\n",
" display(plotFrame3D(problem,X,1.0))\n",
" display(\"Optimization Details:\")\n",
" \n",
" X=optimizeCompliantMechanism(problem,Ls,free,dmax,amax,maxeval,SIMP)\n",
" display(plotFrame3D(problem,X,1.0))\n",
" display(\"Final Design:\")\n",
" display(\"max:$(maximum(X)), min:$(minimum(X))\")\n",
" display(plotFrameDeformed3D(problem,copy(X),scale,threshold,exageration))\n",
" \n",
" if(save)\n",
" K,F,d,stress,dcomp,g=FEM_frame(problem,X);\n",
" simulateAndExport(setup,X,dcomp,\"json/result_frame_$(fileName)\",threshold)\n",
" end\n",
"\n",
" return X\n",
" \n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"Original Domain:\""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n",
"<defs>\n",
" <clipPath id=\"clip3100\">\n",
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<path clip-path=\"url(#clip3100)\" d=\"\n",
"M0 1600 L2400 1600 L2400 0 L0 0 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip3101\">\n",
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<defs>\n",
" <clipPath id=\"clip3102\">\n",
" <rect x=\"86\" y=\"47\" width=\"2267\" height=\"1475\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<path clip-path=\"url(#clip3102)\" d=\"\n",
"M86.9921 1433.95 L86.9921 308.423 L916.319 47.2441 L2352.76 134.304 L2352.76 1259.83 L1523.43 1521.01 L86.9921 1433.95 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip3100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 86.9921,1433.95 1523.43,1521.01 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 1523.43,1521.01 2352.76,1259.83 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 86.9921,1433.95 86.9921,308.423 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3800c6; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 387.961,1146.07 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3000ce; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 828.682,1438.23 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3300cb; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 828.682,1172.78 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3000ce; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 779.153,1288.32 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3200cc; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 779.153,1022.87 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3700c7; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 1219.87,1315.03 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#2e00d0; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1411.52 1219.87,1049.58 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3900c5; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 779.153,1022.87 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3200cc; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1219.87,1315.03 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3500c9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1219.87,1049.58 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3800c6; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1170.34,1165.13 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#2100dd; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1170.34,899.671 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3800c6; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1611.07,1191.84 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#2f00cf; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 779.153,1288.32 1611.07,926.382 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#ec0012; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 1170.34,1165.13 1170.34,899.671 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3a00c4; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 1170.34,1165.13 1611.07,1191.84 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#9c0062; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 1170.34,1165.13 1611.07,926.382 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#4100bd; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1146.07 387.961,880.612 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip3102)\" style=\"stroke:#3500c9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
" 387.961,1146.07 828.682,1172.78 \n",
Loading
Loading full blame...