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
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2020
######################### 1. Voxel Design ###########################
setup = Dict()
### 1.b Draw Lattice
rhino=false
voxelSize=0.001
latticeSizeX=1
latticeSizeY=1
latticeSizeZ=1
setup["latticeSizeX"]=latticeSizeX
setup["latticeSizeY"]=latticeSizeY
setup["latticeSizeZ"]=latticeSizeZ
gridSize=10
setup["gridSize"]=gridSize
setup["rhino"]=false;
setup["useVoxelList"]=true;
######################### 2. Boundary Conditions #########################
######################### 2.a. Global Settings #########################
#scaling params
setup["voxelSize"]=voxelSize; #voxel size
setup["scale"]=1e4; #scale for visualization
setup["hierarchical"]=true; #hierachical simualtion
#simulation params
setup["numTimeSteps"]=20000; #num of saved timesteps for simulation
setup["poisson"]=false; # account for poisson ration (only for hierarchical)
setup["linear"]=true; # linear vs non-linear
setup["thermal"]=false; #if there is change in temperature
setup["globalDamping"]=0.2; # (usually from 0.1 to 0.4)
#visualization params
setup["maxNumFiles"]=200; #num of saved timesteps for visualization
######################### 2.b. Materials #########################
#default material
material1= Dict()
material1["area"]=voxelSize*voxelSize
material1["density"]=1e3
material1["stiffness"]=1e6
material1["poissonRatio"]=0.0
material1["cTE"]=0.0 #coefficient of thermal expansion
#second material
material2= Dict()
material2["area"]=voxelSize*voxelSize
material2["density"]=1e3
material2["stiffness"]=1e6
material2["poissonRatio"]=0.0
material2["cTE"]=0.0 #coefficient of thermal expansion
#//allowed x, yand z are from -gridSize to +gridSize (floor is at 0)
setup["voxelList"]=[
[[0,1,0],material1],#spine
[[0,1,1],material1],#spine
[[0,1,2],material1],#spine
[[0,1,3],material1],#spine
[[0,1,4],material1],#spine
[[-1,1,0],material2],#leg1
[[-2,1,0],material2],#leg1
[[-3,1,0],material2],#leg1
[[1,1,0],material2],#leg2
[[2,1,0],material2],#leg2
[[3,1,0],material2],#leg2
[[-1,1,4],material2],#leg3
[[-2,1,4],material2],#leg3
[[-3,1,4],material2],#leg3
[[1,1,4],material2],#leg4
[[2,1,4],material2],#leg4
[[3,1,4],material1] #leg4
];
###############################################################
setup["materials"]=[
# [boundingBoxMaterial1,material1],
# [boundingBoxMaterial2,material2]
];
######################### 2.c. Supports #########################
#x,y,z,rx,ry,rz (default is pinned joing i.e [false,false,false,true,true,true])
dof=[true,true,true,true,true,true]
# boundingBoxSupport1=Dict()
# boundingBoxSupport1["min"]=Dict()
# boundingBoxSupport1["max"]=Dict()
# boundingBoxSupport1["min"]["x"]= 0;
# boundingBoxSupport1["min"]["y"]= 0;
# boundingBoxSupport1["min"]["z"]= 0;
# boundingBoxSupport1["max"]["x"]= voxelSize;
# boundingBoxSupport1["max"]["y"]= voxelSize*(latticeSizeY);
# boundingBoxSupport1["max"]["z"]= voxelSize*(latticeSizeZ);
setup["supports"]=[
# [boundingBoxSupport1,dof]
];
######################### 2.d. Loads #########################
#### 2.d.1 Static Loads
load1=Dict()
load1["x"]=0.0
load1["y"]=0.0
load1["z"]=1.0
load2=Dict()
load2["x"]=0.0
load2["y"]=0.0
load2["z"]=2.0
boundingBoxLoad1=Dict()
boundingBoxLoad1["min"]=Dict()
boundingBoxLoad1["max"]=Dict()
boundingBoxLoad1["min"]["x"]=voxelSize;
boundingBoxLoad1["min"]["y"]=voxelSize;
boundingBoxLoad1["min"]["z"]=-voxelSize/2;
boundingBoxLoad1["max"]["x"]=voxelSize*2.0;
boundingBoxLoad1["max"]["y"]=2*voxelSize;
boundingBoxLoad1["max"]["z"]=voxelSize/2+voxelSize*5.0;
boundingBoxLoad2=Dict()
boundingBoxLoad2["min"]=Dict()
boundingBoxLoad2["max"]=Dict()
boundingBoxLoad2["min"]["x"]=-voxelSize
boundingBoxLoad2["min"]["y"]=voxelSize;
boundingBoxLoad2["min"]["z"]=-voxelSize/2;
boundingBoxLoad2["max"]["x"]=0;
boundingBoxLoad2["max"]["y"]=2*voxelSize;
boundingBoxLoad2["max"]["z"]=voxelSize/2+voxelSize*5.0;
setup["loads"]=[
[boundingBoxLoad1,load1],
[boundingBoxLoad2,load2],
];
setup["fixedDisplacements"]=[
];
#### 2.d.2 Dynamic Loads
function floorEnabled()
return true
end
function gravityEnabled()
return true
end
function externalDisplacement(currentTimeStep,N_position,N_fixedDisplacement)
return N_fixedDisplacement
end
function externalForce(currentTimeStep,N_position,N_force)
return Vector3(0,0,0);
return N_force
end
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
function externalForce(currentTimeStep,N_position,N_force)
if(convert(Float64,N_force.z)>0.0)
pi=3.14159265359
a0=0.1;
f=5.0/10000.0;
t=currentTimeStep;
ampZ=0.0;
z= a0* CUDAnative.cos(2.0*3.14159265359*(f*t+ampZ))
ampY=0.25;
y= a0* CUDAnative.sin(2.0*3.14159265359*(f*t+ampY))
if(convert(Float64,N_force.z)>1.5)
z=-z
y=-y
end
return Vector3(0.0,y,z)
else
return Vector3(0.0,0.0,0.0)
end
end
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
function externalForce(currentTimeStep,N_position,N_force)
if(convert(Float64,N_force.z)>0.0)
pi=3.14159265359
Bx=convert(Float64,N_position.x)
By=convert(Float64,N_position.y)
voxelSize=5.0*15.0
d=0.000000001 #magnitude
Ax= ( Bx ÷ voxelSize)*voxelSize
Ay= ( By ÷ voxelSize)*voxelSize
# Ay=0.0
x=Bx+d*(Ay-By)/CUDAnative.sqrt((Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By))
y=By-d*(Ax-Bx)/CUDAnative.sqrt((Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By))
a0=0.1;
l=1.0 ;
f=5.0;
amp=0.25;
amp=0.0;
max=10000.0;
t=currentTimeStep/max;
z= a0* CUDAnative.cos(2.0*3.14159265359*(f*t+amp))
amp=0.25;
y= a0* CUDAnative.sin(2.0*3.14159265359*(f*t+amp))
if(convert(Float64,N_force.z)>1.5)
z=-z
y=-y
end
return Vector3(0.0,y,z)
else
return Vector3(0.0,0.0,0.0)
end
end
function updateTemperature(currentRestLength,currentTimeStep,mat)
return currentRestLength
end