Commit 6771053e authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

also add residual force caused by above voxel

parent 114d9dea
......@@ -37,7 +37,7 @@ contours = clean_contour.(contour.(JSON.parse(open(obj_add * "contours.json"))))
contours = [c for c in contours if c!=nothing]
cdata = contourdata(contours, 20, 5) # contour data
@time vd = voxdata(obj_add * "_voxels.csv", cdata)
stress_multiplier!(vd.voxels,0)
stress_multiplier!(vd.voxels,10)
println("Constructing Cost function...")
construct_cost(cdata, vd, ABS, td, f_name)
construct_cost_hist(cdata, vd, ABS, td)
......@@ -96,7 +96,7 @@ plot(rl_g, cdata)
plot(rl_l, cdata)
# plot rollout animated
@time plot_animate(rl_g, cdata, rate=1)
@time plot_animate(rl_l, cdata, rate=1)
# plot results
plot(results)
......
......@@ -47,6 +47,7 @@ struct voxdata
voxels::DataFrame
maps::Vector{voxmap}
below::Vector{Int}
above::Vector{Int}
width::Number
end
......@@ -377,8 +378,10 @@ function voxdata(fname::String, cdata::contourdata)
vpos = [[v.x, v.y, v.z] for v in eachrow(voxels)]
voxms = [voxmap(v, w, cdata) for v in vpos]
below = indexin([v - [0,0,cdata.layer_height] for v in vpos], vpos)
above = indexin([v + [0,0,cdata.layer_height] for v in vpos], vpos)
replace!(below, nothing=>0)
return voxdata(voxels, voxms, below, w)
replace!(above, nothing=>0)
return voxdata(voxels, voxms, below, above, w)
end
......@@ -677,11 +680,13 @@ function construct_cost(cdata::contourdata, vd::voxdata, mat::material, td::temp
# considered voxels
not_empty_voxels = length.([m.seglen for m in vd.maps]) .>0
valid_voxels = (1:length(vd.below))[(vd.below.!=0) .& not_empty_voxels]
valid_voxels = (1:length(vd.below))[(vd.below.!=0) .& not_empty_voxels .& (vd.above.!=0)]
valid_voxels = valid_voxels[not_empty_voxels[vd.below[valid_voxels]]]
valid_voxels = valid_voxels[not_empty_voxels[vd.above[valid_voxels]]]
considered_voxels = valid_voxels
relbelows = vd.below[valid_voxels]
relaboves = vd.above[valid_voxels]
rel_voxels = vd.voxels[considered_voxels,:]
relmaps = vd.maps
vox_area_scaling = min.(abs.(1 ./ rel_voxels.AreaRatio),1)
......@@ -711,18 +716,22 @@ function construct_cost(cdata::contourdata, vd::voxdata, mat::material, td::temp
voxtimes = sum($vox_seglen .* timestart[$vox_contour_id], dims=2) .+ $vox_c
# voxel temps
Δt = voxtimes[$considered_voxels] - voxtimes[$relbelows]
ΔT = $(mat.T_cutoff.-td.ambient) .- $(td.extrusion-td.ambient).*.^(-$td.decay_rate.*Δt)
replace!(x-> x<0 ? 0 : x, ΔT)
Δt_below = voxtimes[$considered_voxels] - voxtimes[$relbelows]
ΔT_b = $(mat.T_cutoff.-td.ambient) .- $(td.extrusion-td.ambient).*.^(-$td.decay_rate.*Δt_below)
replace!(x-> x<0 ? 0 : x, ΔT_b)
Δt_above = voxtimes[$considered_voxels] - voxtimes[$relaboves]
ΔT_a = $(mat.T_cutoff.-td.ambient) .- $(td.extrusion-td.ambient).*.^(-$td.decay_rate.*-Δt_above)
replace!(x-> x<0 ? 0 : x, ΔT_a)
#println(ΔT_b - ΔT_a)
# voxel stresses
rel_v= $rel_voxels
σ11 = rel_v.Sx + $(mat.E*mat.α)*ΔT
σ22 = rel_v.Sy + $(mat.E*mat.α)*ΔT
σ11 = rel_v.Sx + $(mat.E*mat.α)*(ΔT_b-ΔT_a)
σ22 = rel_v.Sy + $(mat.E*mat.α)*(ΔT_b-ΔT_a)
σ33 = rel_v.Sz
σ12 = rel_v.Txy
σ23 = rel_v.Tyz + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
σ31 = rel_v.Txy + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
σ23 = rel_v.Tyz + $((cdata.layer_height/vd.width)*mat.E*mat.α)*(ΔT_b-ΔT_a)
σ31 = rel_v.Txy + $((cdata.layer_height/vd.width)*mat.E*mat.α)*(ΔT_b-ΔT_a)
return sum(($vox_area_scaling .* ($F * (σ11 - σ22).^2 +
$G * ((σ33 - σ11).^2 + (σ33 - σ22).^2) +
$(2 * L) * (σ12).^2 +
......
Markdown is supported
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