Commit f274e901 authored by Amira Abdel-Rahman's avatar Amira Abdel-Rahman
Browse files

wrist

parent 69a31706
Pipeline #15885 passed with stage
in 23 seconds
This diff is collapsed.
This diff is collapsed.
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2021
######################### 1. Voxel Design ###########################
setup = Dict()
### 1.b Draw Lattice
rhino=true
voxelSize=75
latticeSizeX=8
latticeSizeY=1
latticeSizeZ=8
gridSize=10
setup["gridSize"]=gridSize
setup["rhino"]=rhino
setup["rhinoFileName"]="../julia/examples/CAD_Rhino/chiral.3dm";
setup["useMaterialList"]=false;
setup["layerIndex"]="1";
# setup["layerIndex"]="2";
setup["useVoxelList"]=false
setup["latticeSizeX"]=1
setup["latticeSizeY"]=1
setup["latticeSizeZ"]=1
######################### 2. Boundary Conditions #########################
######################### 2.a. Global Settings #########################
#scaling params
setup["voxelSize"]=voxelSize; #voxel size
setup["scale"]=0.5; #scale for visualization
setup["hierarchical"]=false; #hierachical simualtion
#simulation params
setup["numTimeSteps"]=10000; #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)
#0.05
#visualization params
setup["maxNumFiles"]=50; #num of saved timesteps for visualization, make sure it's smaller than numTimeSteps
######################### 2.b. Materials #########################
#default material
material1= Dict()
material1["area"]=2.38*2.38*7*7
material1["density"]=0.028
material1["stiffness"]=2000.0
material1["poissonRatio"]=0.0
material1["cTE"]=0.0 #coefficient of thermal expansion
#large bounding box for default material
boundingBoxMaterial1=Dict()
boundingBoxMaterial1["min"]=Dict()
boundingBoxMaterial1["max"]=Dict()
boundingBoxMaterial1["min"]["x"]=-voxelSize*gridSize;
boundingBoxMaterial1["min"]["y"]=-voxelSize*gridSize;
boundingBoxMaterial1["min"]["z"]=-voxelSize*gridSize;
boundingBoxMaterial1["max"]["x"]= voxelSize*gridSize;
boundingBoxMaterial1["max"]["y"]= voxelSize*gridSize;
boundingBoxMaterial1["max"]["z"]= voxelSize*gridSize;
setup["materials"]=[
[boundingBoxMaterial1,material1]
];
######################### 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"]=-voxelSize/2.0;
boundingBoxSupport1["min"]["y"]=-voxelSize/2.0;
boundingBoxSupport1["min"]["z"]=-voxelSize/2.0;
boundingBoxSupport1["max"]["x"]= voxelSize*(latticeSizeX)+voxelSize/2.0;
boundingBoxSupport1["max"]["y"]= voxelSize/8;
boundingBoxSupport1["max"]["z"]= voxelSize*(latticeSizeZ)+voxelSize/2.0;
setup["supports"]=[
[boundingBoxSupport1,dof]
];
######################### 2.d. Loads #########################
#### 2.d.1 Static Loads
load1=Dict()
load1["x"]=0.0
load1["y"]=-2e4
load1["z"]=0.0
boundingBoxLoad1=Dict()
boundingBoxLoad1["min"]=Dict()
boundingBoxLoad1["max"]=Dict()
boundingBoxLoad1["min"]["x"]=-voxelSize/2.0;
boundingBoxLoad1["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
boundingBoxLoad1["min"]["z"]=-voxelSize/2.0;
boundingBoxLoad1["max"]["x"]=voxelSize*(latticeSizeX)+voxelSize/2.0;
boundingBoxLoad1["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
boundingBoxLoad1["max"]["z"]=voxelSize*(latticeSizeZ)+voxelSize/2.0;
# boundingBoxLoad2=Dict()
# boundingBoxLoad2["min"]=Dict()
# boundingBoxLoad2["max"]=Dict()
# boundingBoxLoad2["min"]["x"]=-voxelSize/8.0;
# boundingBoxLoad2["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
# boundingBoxLoad2["min"]["z"]=voxelSize/2.0-voxelSize/8.0;
# boundingBoxLoad2["max"]["x"]=voxelSize/8.0;
# boundingBoxLoad2["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
# boundingBoxLoad2["max"]["z"]=voxelSize/2.0+voxelSize/8.0;
# boundingBoxLoad3=Dict()
# boundingBoxLoad3["min"]=Dict()
# boundingBoxLoad3["max"]=Dict()
# boundingBoxLoad3["min"]["x"]=voxelSize/2.0-voxelSize/8.0;
# boundingBoxLoad3["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
# boundingBoxLoad3["min"]["z"]=-voxelSize/8.0;
# boundingBoxLoad3["max"]["x"]=voxelSize/2.0+voxelSize/8.0;
# boundingBoxLoad3["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
# boundingBoxLoad3["max"]["z"]=+voxelSize/8.0;
# boundingBoxLoad4=Dict()
# boundingBoxLoad4["min"]=Dict()
# boundingBoxLoad4["max"]=Dict()
# boundingBoxLoad4["min"]["x"]=voxelSize-voxelSize/8.0;
# boundingBoxLoad4["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
# boundingBoxLoad4["min"]["z"]=voxelSize/2.0-voxelSize/8.0;
# boundingBoxLoad4["max"]["x"]=voxelSize+voxelSize/8.0;
# boundingBoxLoad4["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
# boundingBoxLoad4["max"]["z"]=voxelSize/2.0+voxelSize/8.0;
# boundingBoxLoad5=Dict()
# boundingBoxLoad5["min"]=Dict()
# boundingBoxLoad5["max"]=Dict()
# boundingBoxLoad5["min"]["x"]=voxelSize/2.0-voxelSize/8.0;
# boundingBoxLoad5["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
# boundingBoxLoad5["min"]["z"]=voxelSize-voxelSize/8.0;
# boundingBoxLoad5["max"]["x"]=voxelSize/2.0+voxelSize/8.0;
# boundingBoxLoad5["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
# boundingBoxLoad5["max"]["z"]=voxelSize+voxelSize/8.0;
# boundingBoxLoad6=Dict()
# boundingBoxLoad6["min"]=Dict()
# boundingBoxLoad6["max"]=Dict()
# boundingBoxLoad6["min"]["x"]=voxelSize+voxelSize/2.0;
# boundingBoxLoad6["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
# boundingBoxLoad6["min"]["z"]=-voxelSize/2.0;
# boundingBoxLoad6["max"]["x"]=voxelSize*(latticeSizeX)+voxelSize/2.0;
# boundingBoxLoad6["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
# boundingBoxLoad6["max"]["z"]=voxelSize*(latticeSizeZ)+voxelSize/2.0;
setup["loads"]=[
[boundingBoxLoad1,load1],
# [boundingBoxLoad2,load1],
# [boundingBoxLoad3,load1],
# [boundingBoxLoad4,load1],
# [boundingBoxLoad5,load1],
# [boundingBoxLoad6,load1],
];
#### 2.d.2 Fixed Displacements
dis1=Dict()
dis1["x"]=0.0
dis1["y"]=-5e-3
dis1["z"]=0.0
boundingBoxDis1=Dict()
boundingBoxDis1["min"]=Dict()
boundingBoxDis1["max"]=Dict()
boundingBoxDis1["min"]["x"]=-voxelSize/2.0;
boundingBoxDis1["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/8;
boundingBoxDis1["min"]["z"]=-voxelSize/2.0;
boundingBoxDis1["max"]["x"]=voxelSize*(latticeSizeX)+voxelSize/2.0;
boundingBoxDis1["max"]["y"]=voxelSize*(latticeSizeY)+voxelSize/2.0;
boundingBoxDis1["max"]["z"]=voxelSize*(latticeSizeZ)+voxelSize/2.0;
setup["fixedDisplacements"]=[
# [boundingBoxDis1,dis1]
];
#### 2.d.3 Dynamic Loads
function floorEnabled()
return false
end
function gravityEnabled()
return false
end
function externalDisplacement(currentTimeStep,N_position,N_fixedDisplacement)
return N_fixedDisplacement
end
function externalForce(currentTimeStep,N_position,N_currentPosition,N_force)
return N_force
end
function updateTemperature(currentRestLength,currentTimeStep,mat)
# @cuprintln("currentRestLength $currentRestLength")
return currentRestLength
end
###########################################################################
\ No newline at end of file
......@@ -34,7 +34,7 @@ setup["latticeSizeZ"]=1
#scaling params
setup["voxelSize"]=voxelSize; #voxel size
setup["scale"]=0.1; #scale for visualization
setup["scale"]=0.5; #scale for visualization
setup["hierarchical"]=false; #hierachical simualtion
......
......@@ -8,7 +8,7 @@ setup = Dict()
rhino=true
name="auxetic_v"
name="ch"
voxelSize=75
latticeSizeX=1
latticeSizeY=1
......@@ -20,7 +20,7 @@ setup["gridSize"]=gridSize
setup["rhino"]=rhino
setup["rhinoFileName"]="../julia/examples/CAD_Rhino/trial.3dm";
setup["layerIndex"]="12";
setup["layerIndex"]="13";
setup["useVoxelList"]=false
......
......@@ -468,3 +468,53 @@ function plot2D(name)
end
function plotTop(name,thresholdMin,thresholdMax=1000,num=1)
for ii=1:num
setupViz=getSetup1("$(name)/0")
maxNumFiles=setupViz["maxNumFiles"]
ts=Int(floor(ii/num*maxNumFiles))
setupVizLast=getSetup1("$(name)/$(Int(ts-1))");
nodes=setupVizLast["nodes"]
edges=setupVizLast["edges"]
disX=[];disY=[];disZ=[]
posX=[]; posY=[];posZ=[]
IDs=[]
i=1
for node in nodes
if node["position"]["y"]>thresholdMin && node["position"]["y"]<thresholdMax
append!(disX,[node["displacement"]["x"]])
append!(disY,[node["displacement"]["y"]])
append!(disZ,[node["displacement"]["z"]])
append!(posX,[node["position"]["x"]])
append!(posY,[node["position"]["y"]])
append!(posZ,[node["position"]["z"]])
#append!(IDs,[parse(Int64,node["id"][2:end])])
append!(IDs,[i])
end
i+=1
end
if ii==1
Plots.scatter(posX,posZ,title="Top",label="",ylabel="x",xlabel="z", aspect_ratio=:equal,color=:cyan)
end
Plots.scatter!(posX.+disX,posZ.+disZ,title="Top",label="",ylabel="x",xlabel="z", aspect_ratio=:equal,color=RGB(-(ii-num)/num,-(ii-num)/num,-(ii-num)/num))
# display(Plots.scatter(posZ,posX,title="f",label="",ylabel="d",xlabel="d", aspect_ratio=:equal))
for edge in edges
if in(IDs).(edge["source"]+1) && in(IDs).(edge["target"]+1)
s=edge["source"]+1;t=edge["target"]+1;
if ii==1
Plots.plot!([nodes[s]["position"]["x"],nodes[t]["position"]["x"]],[nodes[s]["position"]["z"],nodes[t]["position"]["z"]],legend=false,color=:cyan)
end
Plots.plot!([nodes[s]["position"]["x"]+nodes[s]["displacement"]["x"],
nodes[t]["position"]["x"]+nodes[t]["displacement"]["x"]],
[nodes[s]["position"]["z"]+nodes[s]["displacement"]["z"],
nodes[t]["position"]["z"]+nodes[t]["displacement"]["z"]]
,legend=false,color=RGB(-(ii-num)/num,-(ii-num)/num,-(ii-num)/num),linestyle=:dash)
end
end
end
display(Plots.plot!())
end
This diff is collapsed.
This diff is collapsed.
{
"name": "metavoxels-code",
"version": "1.0.0",
"description": "Code for the design, simulation and optimization of MetaVoxels.",
"main": "app.js",
"directories": {
"lib": "lib"
},
"dependencies": {
"edit-json-file": "^1.5.0",
"finalhandler": "^1.1.2",
"http": "^0.0.1-security",
"rhino3dm": "^0.13.0",
"serve-static": "^1.14.1",
"three": "^0.123.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "ssh://git@gitlab.cba.mit.edu:846/amiraa/metavoxels-code.git"
},
"author": "Amira Abdel-Rahman",
"license": "ISC"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment